public class Abbreviations extends Object implements Iterable<String>
Basic usage:
 Abbreviations abrv = new Abbreviations();
 // add some abbreviations, when overlapping (e.g. Me,Et,tBu) first one wins
 abrv.add("[Na+].[H-] NaH");
 abrv.add("*c1ccccc1 Ph");
 abrv.add("*C(C)(C)C tBu");
 abrv.add("*CC Et");
 abrv.add("*C Me");
 // maybe we don't want 'Me' in the depiction
 abrv.setEnabled("Me", false);
 // assign abbreviations with some filters
 int numAdded = abrv.apply(mol);
 // generate all but don't assign, need to be added manually
 // set/update the CDKConstants.CTAB_SGROUPS property of mol
 List<Sgroup> sgroups = abrv.generate(mol);
 
 Predefined sets of abbreviations can be loaded, the following are on the classpath.
 // https://www.github.com/openbabel/superatoms
 abrv.loadFromFile("obabel_superatoms.smi");
 CDKConstants.CTAB_SGROUPS, 
Sgroup| Constructor and Description | 
|---|
Abbreviations()  | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
add(IAtomContainer mol,
   String label)
Add an abbreviation to the factory. 
 | 
boolean | 
add(String line)
Convenience method to add an abbreviation from a SMILES string. 
 | 
int | 
apply(IAtomContainer mol)
Generates and assigns abbreviations to a molecule. 
 | 
List<Sgroup> | 
generate(IAtomContainer mol)
Find all enabled abbreviations in the provided molecule. 
 | 
boolean | 
isEnabled(String label)
Check whether an abbreviation is enabled. 
 | 
Iterator<String> | 
iterator()
Iterate over loaded abbreviations. 
 | 
int | 
loadFromFile(String path)
Load a set of abbreviations from a classpath resource or file in SMILES format. 
 | 
void | 
setContractOnHetero(boolean val)
Set whether abbreviations should be further contracted when they are connected
 to a heteroatom, for example -NH-Boc becomes -NHBoc. 
 | 
void | 
setContractToSingleLabel(boolean val)  | 
boolean | 
setEnabled(String label,
          boolean enabled)
Set whether an abbreviation is enabled or disabled. 
 | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic Iterator<String> iterator()
public boolean isEnabled(String label)
label - is enabledpublic boolean setEnabled(String label, boolean enabled)
label - the label (e.g. Ph, Et, Me, OAc, etc.)enabled - flag the label as enabled or disabledpublic void setContractOnHetero(boolean val)
val - on/offpublic void setContractToSingleLabel(boolean val)
public List<Sgroup> generate(IAtomContainer mol)
mol - moleculepublic int apply(IAtomContainer mol)
generate(org.openscience.cdk.interfaces.IAtomContainer) and the filtered based on
 the coverage. Currently only abbreviations that cover 100%, or < 40% of the
 atoms are assigned.mol - moleculegenerate(IAtomContainer)public boolean add(String line) throws InvalidSmilesException
line - the smiles to add with a title (the label)InvalidSmilesException - the SMILES was not validpublic boolean add(IAtomContainer mol, String label)
Detached - zero attachments, the abbreviation covers the whole structure (e.g. THF) Terminal - one attachment, covers substituents (e.g. Ph for Phenyl) Linker - [NOT SUPPORTED YET] two attachments, covers long repeated chains (e.g. PEG4)
Attachment points (if present) must be specified with zero element atoms.
*c1ccccc1 Ph *OC(=O)C OAc
mol - the fragment to abbreviatelabel - the label of the fragmentpublic int loadFromFile(String path) throws IOException
*c1ccccc1 Ph *c1ccccc1 OAc
Available:
https://www.github.com/openbabel/superatomspath - classpath or filesystem path to a SMILES fileIOExceptionCopyright © 2021. All rights reserved.