This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) throws CDKException, IOException { | |
String smi = "C1[C@H]([C@@H](OC2=CC(=CC(=C21)O)O)*)O |$;;;;;;;;;;;;_AP1$|"; | |
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); | |
IAtomContainer mol = smipar.parseSmiles(smi); | |
// atom indexes to highlight | |
int[] idxs = new int[]{3,4,5,9}; | |
boolean outgoing = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static IAtomContainer getChains(IAtomContainer mol) { | |
IAtomContainer result = mol.getBuilder().newInstance(IAtomContainer.class); | |
for (IAtom atom : mol.atoms()) | |
atom.setFlag(CDKConstants.VISITED, false); | |
for (IBond bond : mol.bonds()) { | |
if (!bond.isInRing()) { | |
IAtom beg = bond.getAtom(0); | |
IAtom end = bond.getAtom(1); | |
if (!beg.getFlag(CDKConstants.VISITED)) { | |
result.addAtom(beg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String smi = "[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>[Al+3].[Cl-].[Cl-].[Cl-].C(Cl)Cl>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]"; | |
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
SmilesParser smipar = new SmilesParser(bldr); | |
IReaction rxn = smipar.parseReactionSmiles(smi); | |
new DepictionGenerator().withAtomMapHighlight(new Color[]{new Color(0xAAC0FF), | |
new Color(0x8BFFB9)}) | |
.withOuterGlowHighlight() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MDLV2000Reader mdlr = ...; | |
IAtomContainer mol; | |
while ((mol = mdlr.read(new AtomContainer(0,0,0,0)) != null) { | |
// do something with mol | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
SmilesParser smipar = new SmilesParser(bldr); | |
Pattern ptrn = SmartsPattern.create("O=[C,N]aa[N,O;!H0]", null); | |
try (Reader frdr = new FileReader(fname); | |
BufferedReader brdr = new BufferedReader(frdr)) { | |
String line; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new DepictionGenerator().withSize(256, 256) | |
.depict(mol) | |
.writeTo("molecule.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StructureDiagramGenerator sdg = new StructureDiagramGenerator(); | |
sdg.setMolecule(mol, false); | |
sdg.generateCoordinates(); | |
AtomContainerRenderer renderer = | |
new AtomContainerRenderer(Arrays.asList(new BasicSceneGenerator(), | |
new BasicBondGenerator(), | |
new ExtendedAtomGenerator()), | |
new AWTFontManager()); | |
BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_4BYTE_ABGR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
SmilesParser smipar = new SmilesParser(bldr); | |
final String fname = "/data/nci_aug00.smi"; | |
SMARTSQueryTool sqt = new SMARTSQueryTool("O=[C,N]aa[N,O;!H0]"); | |
int num_hits = 0; | |
try (BufferedReader brdr = new BufferedReader(new FileReader(fname))) { | |
String line; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openscience.cdk.exception.CDKException; | |
import org.openscience.cdk.interfaces.IAtom; | |
import org.openscience.cdk.interfaces.IAtomContainer; | |
import org.openscience.cdk.interfaces.IBond; | |
import org.openscience.cdk.interfaces.IChemObjectBuilder; | |
import org.openscience.cdk.isomorphism.Pattern; | |
import org.openscience.cdk.silent.SilentChemObjectBuilder; | |
import org.openscience.cdk.smiles.SmilesGenerator; | |
import org.openscience.cdk.smiles.SmilesParser; | |
import org.openscience.cdk.smiles.smarts.SmartsPattern; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ICountFingerprint fp; | |
int numBins = fp.numOfPopulatedbins(); | |
for (int i = 0; i < numBins; i++) { | |
int hash = fp.getHash(i); | |
int freq = fp.getCount(i); | |
} |