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
Reader reader = new BufferedReader(new FileReader(new File("ChEBI_lite.sdf")), | |
2048); | |
// instantiate the iterating reader with skip=true in the constructor | |
IteratingMDLReader sdf = new IteratingMDLReader(reader, | |
SilentChemObjectBuilder.getInstance(), | |
Boolean.TRUE); | |
while (sdf.hasNext()){ | |
IAtomContainer container = sdf.next(); |
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
package demo; | |
import org.openscience.cdk.interfaces.IAtomContainer; | |
import uk.ac.ebi.mdk.domain.identifier.HMDBIdentifier; | |
import uk.ac.ebi.mdk.service.DefaultServiceManager; | |
import uk.ac.ebi.mdk.service.ServiceManager; | |
import uk.ac.ebi.mdk.service.query.data.MolecularFormulaService; | |
import uk.ac.ebi.mdk.service.query.name.IUPACNameService; | |
import uk.ac.ebi.mdk.service.query.name.PreferredNameService; | |
import uk.ac.ebi.mdk.service.query.name.SynonymService; |
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
IAtomContainer container = ... | |
Iterator<IAtom> it = container.atoms(); | |
while(it.hasNext()){ | |
IAtom atom = it.next(); | |
if("H".equals(atom.getSymbol())){ | |
it.remove(); // invokes container.removeBond(IBond); | |
} | |
} |
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 List<IAtom> getAtoms() { | |
return Collections.unmodifiableList(atoms); | |
} |
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 interface AromaticityDetector { | |
public void detect(IAtomContainer container); | |
} |
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 Rectangle2D getTextBounds(String text, double x, double y, | |
Graphics2D graphics) { | |
FontMetrics fontMetrics = graphics.getFontMetrics(); | |
Rectangle2D bounds = fontMetrics.getStringBounds(text, graphics); | |
double widthPad = 3; | |
double heightPad = 1; | |
double width = bounds.getWidth() + widthPad; |
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
TextLayout layout = new TextLayout(text, graphics.getFont(), | |
graphics.getFontRenderContext()); | |
Rectangle2D bounds = layout.getBounds(); |
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
DOMImplementation impl = GenericDOMImplementation.getDOMImplementation(); | |
Document document = impl.createDocument("http://www.w3.org/2000/svg", | |
"svg", | |
null); | |
// SVGGraphics2D implements java.awt.Graphics2D | |
SVGGeneratorContext context = SVGGeneratorContext.createDefault(document) | |
SVGGraphics2D g2 = new SVGGraphics2D(context, | |
true); // convert fonts to SVG Font glyphs | |
// render |
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
double width = bounds.getWidth() + bounds.getHeight() * PADDING_RATIO; | |
double height = bounds.getHeight() + bounds.getHeight() * PADDING_RATIO; |
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
HashGenerator<Integer> generator = new HashGeneratorMaker().withDepth(8) | |
.charged() | |
.chiral() | |
.isotopic() | |
.radicals() | |
.withBondOrderSum() | |
.nullable() | |
.build(); | |
// integer representation | |
Integer hashcode = generator.generate(container); |