This file contains 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
// compute labelling (others are available) | |
final long[] labels = Canon.label(m, GraphUtil.toAdjList(m)); | |
IAtom[] atoms = AtomContainerManipulator.getAtomArray(m); | |
IBond[] bonds = AtomContainerManipulator.getBondArray(m); | |
// atoms don't know their index | |
for (int i = 0; i < labels.length; i++) | |
atoms[i].setProperty("rank", labels); | |
This file contains 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 Exception { | |
while(System.out.getClass() | |
.getMethod("println", String.class) | |
.invoke(System.out, "Hello world!") != null) { | |
} | |
} | |
} |
This file contains 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
// imports can be inlined but excluded for readability | |
// import javax.script.SimpleScriptContext; | |
// import java.io.PrintWriter; | |
public class Main { | |
public static void main(String[] args) { | |
new SimpleScriptContext() {{ | |
new PrintWriter(writer) {{ | |
println("Hello World!"); | |
flush(); |
This file contains 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
Map<AtomPair,IBond> bondMap = new HashMap<>(); | |
for (IBond bond : container.bonds()) | |
bondMap.put(new AtomPair(bond.getAtom(0), bond.getAtom(1)), | |
bond); | |
class AtomPair { | |
IAtom a, b; | |
AtomPair(IAtom a, IAtom b) { | |
this.a = a, this.b = b; |
This file contains 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); | |
SmilesGenerator smigen = SmilesGenerator.unique(); | |
System.out.println(smigen.create(smipar.parseSmiles("c1cc2c(cc1)cccc2"))); | |
System.out.println(smigen.create(smipar.parseSmiles("C1=CC2=C(C=C1)C=CC=C2"))); | |
System.out.println(smigen.create(smipar.parseSmiles("C=1C=C2C(=CC=1)C=CC=C2"))); | |
System.out.println(smigen.create(smipar.parseSmiles("C1=CC=2C(C=C1)=CC=CC=2"))); |
This file contains 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
static IAtomContainer mykekule(IAtomContainer org) throws Exception { | |
final IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
final SmilesParser smipar = new SmilesParser(bldr); | |
final SmilesGenerator smigen = SmilesGenerator.unique(); | |
final int n = org.getAtomCount(); | |
int[] ordering = new int[n]; | |
// generate a kekule assignment via SMILES and store the output order (a permutation of |
This file contains 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); | |
SmilesGenerator smigen = SmilesGenerator.generic(); | |
System.out.println(smigen.create(mykekule(smipar.parseSmiles("c1cc2c(cc1)cccc2")))); | |
System.out.println(smigen.create(mykekule(smipar.parseSmiles("C1=CC2=C(C=C1)C=CC=C2")))); | |
System.out.println(smigen.create(mykekule(smipar.parseSmiles("C=1C=C2C(=CC=1)C=CC=C2")))); | |
System.out.println(smigen.create(mykekule(smipar.parseSmiles("C1=CC=2C(C=C1)=CC=CC=2")))); |
This file contains 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
BufferedReader brdr = ...; | |
// create once and reuse | |
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); | |
Aromaticity arom = new Aromaticity(ElectronDonation.daylight(), | |
Cycles.or(Cycles.all(), Cycles.all(6))); | |
// SMILES, implicit h already present | |
SmilesParser smipar = new SmilesParser(bldr); | |
String line; |
This file contains 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
if (GeometryTools.has2DCoordinates(container)) { | |
renderer.paint(container, new AWTDrawVisitor(g2), bounds, true); | |
} else { | |
// can log or invoke g2.drawString() to display "no coordinates" | |
} |
This file contains 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
static int aromStatus(IAtomContainer mol) { | |
int res = 0; | |
for (IAtom atom : mol.atoms()) { | |
if (atom.getImplicitHydrogenCount() == null && atom.getFlag(CDKConstants.ISAROMATIC)) { | |
// N and P are ambiguous | |
if (atom.getAtomicNumber() == 7 || atom.getAtomicNumber() == 15) | |
res = 2; | |
else if (res < 2) | |
res = 1; | |
} |
OlderNewer