Package: py2opsin
py2opsinSimple Python interface toOPSIN: Open Parser for Systematic IUPAC nomenclatureInstallationpy2opsincan be installed withpip install py2opsin. It haszeroPython dependencies (OPSIN v2.8.0is included in the PyPI package) and should work inside any environment running modern Python. Java 8+ is required to run OPSIN.Try a demo ofpy2opsinlive on your browser (no installation required!):UsageCommand-line arguments available inOPSINcan be passed through topy2opsin:frompy2opsinimportpy2opsin>>smiles_string=py2opsin(chemical_name="ethane",output_format="SMILES",)smiles_str="CC">>py2opsin(chemical_name:strorlistofstrings,output_format:str="SMILES",allow_acid=False,allow_radicals=True,allow_bad_stereo=False,wildcard_radicals=False,jar_fpath="/path/to/opsin.jar",)The result is returned as a Python string, or False if an unexpected error occurs when calling OPSIN. If a list of IUPAC names is provided, a list is returned. It ishighlyreccomended to usepy2opsinin this manner if you need to resolve any more than a couple names -- the performance cost of runningOPSINfrom Python one name at a time is significant (~5 seconds/molecule individually, milliseconds otherwise).Arguments:chemical_name (str): IUPAC name of chemical as a Python string, or a list of strings.output_format (str, optional): One of "SMILES", "CML", "InChI", "StdInChI", or "StdInChIKey". Defaults to "SMILES".allow_acid (bool, optional): Allow interpretation of acids. Defaults to False.allow_radicals (bool, optional): Enable radical interpretation. Defaults to False.allow_bad_stereo (bool, optional): Allow OPSIN to ignore uninterpreatable stereochem. Defaults to False.wildcard_radicals (bool, optional): Output radicals as wildcards. Defaults to False.jar_fpath (str, optional): Filepath to OPSIN jar file. Defaults to "opsin-cli.jar" which is distributed with py2opsin.Massive speedup frompubchempyfor batch translationspy2opsinruns locally and is smaller in scope in what it provides, which makes itdramaticallyfaster at resolving identifiers. In the code block below, the call topy2opsinwill execute faster than an equivalent call topubchempy:importtimefrompubchempyimportPubChemHTTPError,get_compoundsfrompy2opsinimportpy2opsincompound_list=["pyridine, 2-amino-","pyridine, 3-iodo-",..."aniline, 2,4,6-trinitro-",]forcompoundincompound_list:result=get_compounds(compound,"name")smiles_strings=py2opsin(compound_list)ExamplesJeremy Monat's (@bertiewooster) fantasticblog postusingpy2opsinto help explore the Wiener Index by enabling translation from IUPAC names into molecules directly from the original paper.Online DocumentationClick here to read the documentationCitationPlease checkthe OPSIN repositoryfor the latest citation information, which as of October 2023 suggests citing this paper:Chemical Name to Structure: OPSIN, an Open Source Solution
Daniel M. Lowe, Peter T. Corbett, Peter Murray-Rust, Robert C. Glen
Journal of Chemical Information and Modeling 2011 51 (3), 739-753You may also see fit to mention that you usedpy2opsinto runOPSIN, butpy2opsinitself isn't a significant scholarly effort and thus does not have a DOI.
Providing a link to this GitHub repository along with the version ofpy2opsinused is sufficient.Contributing & Developer NotesPull Requests, Bug Reports, and all Contributions are welcome! Please use the appropriate issue or pull request template when making a contribution.When submitting a PR, please mark your PR with the "PR Ready for Review" label when you are finished making changes so that the GitHub actions bots can work their magic!Developer InstallTo contribute to thepy2opsinsource code, start by cloning the repository (i.e.git clone git@github.com:JacksonBurns/py2opsin.git) and then inside the repository runpip install -e .[dev]. This will set you up with all the required dependencies to runpy2opsinand conform to our formatting standards (blackandisort), which you can configure to run automatically in vscodelike this.Unit and performance tests can then be executed withpytest.Note for Windows Powershell or MacOS Catalina or newer: On these systems the command line will complain about square brackets, so you will need to double quote the install command (i.e.pip install -e ".[dev]").LicenseOPSINandpy2opsinare both distributed under the MIT license.Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.