Skip to main content

Another molecular string representation

Project description

AMSR

Another Molecular String Representation, inspired by

Installing

pip install amsr

Usage

import amsr

amsr.ToMol("CNcncc5cNcN6C.oC.o") # caffeine

caffine

taxol_smi = "CC1=C2[C@@]([C@]([C@H]([C@@H]3[C@]4([C@H](OC4)C[C@@H]([C@]3(C(=O)[C@@H]2OC(=O)C)C)O)OC(=O)C)OC(=O)c5ccccc5)(C[C@@H]1OC(=O)[C@H](O)[C@@H](NC(=O)c6ccccc6)c7ccccc7)O)(C)C"

amsr.FromSmiles(taxol_smi)
# CccCC(C(C(C)C(OC4.CC)C)6coC(8[OAc].C.O....[OAc].O[Bz].CC(6OcoC(O.C)N[Bz].[Ph]....O.C.C

amsr.FromSmiles(taxol_smi, useGroups=False)
# CccCC(C(C(C)C(OC4.CC)C)6coC(8OcoC..C.O....OcoC..Ococccccc6......CC(6OcoC(O.C)Ncocccccc6......cccccc6.........O.C.C

Description

See documentation for structures accompanying the following examples.

Atoms

Atoms are represented by their symbol enclosed in square brackets, as in SMILES. For a one-letter symbol, brackets may be omitted. Atoms are assumed to have a fixed valence that limits the number of covalently-bonded neighbors. If an atom makes fewer bonds than its valence, hydrogens are assumed.

AMSR molecule
C methane
O water
[Cl] hydrochloric acid

Chains

Each atom in a chain is bonded to the most recently added atom that can still make bonds, according to its valence. Hydrogens may be added explicitly like any other atom. In the first example below, the fluorines are added to the second carbon; the chlorine is then added to the first carbon, since the second can no longer bond. In the second example, after four fluorines are added, the carbon can no longer bond, so a new molecule is formed.

AMSR molecule
CCFFF[Cl] 2-chloro-1,1,1-trifluoroethane
CFFFFCO carbon tetrafluoride and methanol

Branches

Branches are formed automatically when atoms can no longer make bonds. They can also be made by "capping" or "saturating" an atom with hydrogens, using a period . (capping hydrogens are applied to the most recently-added atom that can still make bonds). New atoms will then be bonded to those added earlier, forming a branch.

AMSR molecule
CCC.C isobutane
CC.CC.C.C 2,2-dimethylbutane

Rings

Rings are denoted by a single digit (or two or more digits enclosed in square brackets) giving the size of the ring. A new bond is formed between the two most recently-added atoms that can make bonds and when bonded will form a ring of that size.

AMSR molecule
CCO3 oxirane
CCCCCC6 cyclohexane
CCCCCCCCCCCC[12] cyclododecane

Double bonds (sp2 centers)

Atoms making a double bond are indicated by changing the symbol to lowercase (note that lowercase does not mean "aromatic"; merely, "atom having one fewer neighbor than its valence.") Double bonds are assigned by a matching algorithm. If a perfect matching cannot be found (for instance, in the case of an odd number of contiguous lowercase symbols) a maximal matching is chosen, non-matched atoms remain singly bonded, and hydrogens are added.

AMSR molecule
co formaldehyde
cccccc6 benzene
cco acetaldehyde (only one double bond added)

Note that an oxygen with two neighbors or a nitrogen with three in an aromatic ring is still denoted by a capital (not a lowercase) symbol, although sp2-hybridized, since its coordination number is still equal to its valence.

AMSR molecule
ccccO5 furan
ccccN5 pyrrole

Ring selection

When more than one ring of a given size can be formed, one or more semicolons ; immediately after the digit will make ring-forming bonds with atoms appearing earlier in the string, rather than the most recent.

AMSR molecule
ccOcc5cccc6 benzofuran
ccOcc5cccc6; isobenzofuran

Triple bonds (sp centers)

Atoms with two fewer neighbors than their valence are designated by a trailing colon : can make triple bonds (or more than one double bond).

AMSR molecule
C:N: hydrogen cyanide
oC:o carbon dioxide

Hypervalent atoms

Atoms denoted by their symbol alone are assumed to have their lowest possible valence (for instance, two for sulfur). Higher valences are denoted by one or more exclamation points !.

AMSR molecule
CSC dimethyl sulfide
Cs!oC dimethyl sulfoxide
S!!FFFFFF sulfur hexafluoride

Formal charges, radical electrons, isotopes

Positive/negative formal charges are designated by one or more of +/-. Radical electrons are denoted by one or more asterisks *. An isotopic mass is denoted by a number prefix before the atomic symbol (in which case square brackets must be used even for a one-letter symbol).

AMSR molecule
[Mg++]S!!:ooO-O- magnesium sulfate
CC.C.CCCCC.C.N6O* (2,2,6,6-Tetramethylpiperidin-1-yl)oxyl or TEMPO
[2H]O[2H] heavy water

Tetrahedral stereochemistry

Tetrahedral stereochemistry is denoted by a left parenthesis ( meaning "counterclockwise" or a right parenthesis ) meaning "clockwise," referring to the first three neighbors of a stereocenter atoms as they appear in the string, with the last neighbor (or implicit hydrogen) in back.

AMSR molecule
C(C.FO (1S)-1-fluoroethanol
C)C.FO (1R)-1-fluoroethanol

E/Z stereochemistry

Stereochemistry for a double bond is denoted by an underscore _ meaning "trans" or E, or caret ^ meaning "cis" or Z, between the two atoms making the bond, where the reference neighboring atoms are those that appear earliest in the string.

AMSR molecule
c[Br][Cl]_c[Cl] (E)-1-bromo-1,2-dichloroethene
c[Br][Cl]^c[Cl] (Z)-1-Bromo-1,2-dichloroethene

Groups

The following abbreviations may be used to represent various functional groups:

[Ac], [Bn], [Boc], [Bz], [CCl3], [CF3], [CHO], [CN], [COO-], [COOEt], [COOH], [COOMe], [Cbz], [Et], [Ms], [NHAc], [NHMe], [NMe2], [NO2], [OAc], [OEt], [OMe], [Ph], [Piv], [Tf], [Tol], [Ts], [benzene], [iBu], [iPr], [nBu], [nPr], [sBu], [tBu]
AMSR molecule
N+C)[Bn][COO-] L-phenylalanine
cccccc6[iBu]..CC.[COOH] ibuprofen
C[Ph][Et]coNcoNco6 phenobarbital

Developing

This repo uses pre-commit, so after cloning run pip install -r requirements.txt and pre-commit install prior to committing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amsr-0.1.0.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amsr-0.1.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file amsr-0.1.0.tar.gz.

File metadata

  • Download URL: amsr-0.1.0.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for amsr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb3e4077b95ae8491e17dc6e794e45c57380f612029ff4a9b18b16d7f52d07e3
MD5 fb46d6512fecef7bd22497429023e316
BLAKE2b-256 4865b6f347ccb1885ec08bb0bbc264ebcf76cd37377ab4565eaedc43f61e43b9

See more details on using hashes here.

File details

Details for the file amsr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: amsr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for amsr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60d5f5cf405ef00448f9e4c461bbd68e448cfe91d4d5f15a63d5c46455c992d3
MD5 d8d28ae83fab3860db7697adc1a0675d
BLAKE2b-256 d769e4682a8b1e8dfce0b1145b8ffb7a899c0b78282138c51b0143cacd178f72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page