本文整理汇总了Java中org.openscience.cdk.silent.SilentChemObjectBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SilentChemObjectBuilder类的具体用法?Java SilentChemObjectBuilder怎么用?Java SilentChemObjectBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SilentChemObjectBuilder类属于org.openscience.cdk.silent包,在下文中一共展示了SilentChemObjectBuilder类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: highlightSmartsPattern
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
private static void highlightSmartsPattern(IAtomContainer container, Color highlightColor, String smarts) {
if (smarts == null)
return;
try {
Pattern ptrn = SmartsPattern.create(smarts,
SilentChemObjectBuilder.getInstance());
Mappings mappings = ptrn.matchAll(container);
int[] p = mappings.first();
for (int x : p) {
container.getAtom(x).setProperty(HIGHLIGHT_COLOR,
highlightColor);
}
for (IBond bond : container.bonds()) {
if (bond.getAtom(0).getProperty(HIGHLIGHT_COLOR) != null && bond.getAtom(1).getProperty(HIGHLIGHT_COLOR) != null)
bond.setProperty(HIGHLIGHT_COLOR,
highlightColor);
}
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
开发者ID:johnmay,项目名称:efficient-bits,代码行数:23,代码来源:Main.java
示例2: parseSmiles
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static IAtomContainer parseSmiles(String smiles) {
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer precursorMolecule = null;
try {
precursorMolecule = sp.parseSmiles(smiles);
} catch (InvalidSmilesException e) {
e.printStackTrace();
}
prepareAtomContainer(precursorMolecule, true);
return precursorMolecule;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:12,代码来源:MoleculeFunctions.java
示例3: parseSmilesImplicitHydrogen
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
/**
*
* @param smiles
* @return
*/
public static IAtomContainer parseSmilesImplicitHydrogen(String smiles) {
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer precursorMolecule = null;
try {
precursorMolecule = sp.parseSmiles(smiles);
} catch (InvalidSmilesException e) {
e.printStackTrace();
}
MoleculeFunctions.prepareAtomContainer(precursorMolecule, true);
MoleculeFunctions.convertExplicitToImplicitHydrogens(precursorMolecule);
return precursorMolecule;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:18,代码来源:MoleculeFunctions.java
示例4: Structure2DComponent
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public Structure2DComponent(String structure) throws CDKException,
IOException {
// Create a silend CDK builder
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
// Create a new molecule instance
molecule = builder.newInstance(IAtomContainer.class);
// Load the structure into the molecule
MDLV2000Reader molReader = new MDLV2000Reader(new StringReader(
structure));
molReader.read(molecule);
molReader.close();
// Suppress the hydrogens
AtomContainerManipulator.suppressHydrogens(molecule);
// If the model has no coordinates, let's generate them
if (!GeometryUtil.has2DCoordinates(molecule)) {
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(molecule, false);
sdg.generateCoordinates();
}
// Generators make the image elements
Font font = new Font("Verdana", Font.PLAIN, 14);
List<IGenerator<IAtomContainer>> generators = new ArrayList<IGenerator<IAtomContainer>>();
generators.add(new BasicSceneGenerator());
generators.add(new StandardGenerator(font));
// Renderer needs to have a toolkit-specific font manager
renderer = new AtomContainerRenderer(generators, new AWTFontManager());
// Set default atom colors for the renderer
RendererModel rendererModel = renderer.getRenderer2DModel();
rendererModel.set(StandardGenerator.AtomColor.class,
new CDK2DAtomColors());
}
开发者ID:mzmine,项目名称:mzmine2,代码行数:41,代码来源:Structure2DComponent.java
示例5: main
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static void main(String[] args) throws CDKException, IOException {
final Font font = new Font("Verdana",
Font.PLAIN,
24);
final DepictionGenerator generator = new DepictionGenerator(Arrays.asList(new BasicSceneGenerator(),
new StandardGenerator(font)));
IAtomContainer container = new SmilesParser(SilentChemObjectBuilder.getInstance()).parseSmiles("[nH]1cccc1.c1ccccc1.[Na+].[Cl-]");
IAtomContainerSet acSet = ConnectivityChecker.partitionIntoMolecules(container);
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setUseTemplates(false);
for (IAtomContainer ac : acSet.atomContainers()) {
sdg.setMolecule(ac, false);
sdg.generateCoordinates();
}
SetDepiction depiction = generator.generate(acSet);
depiction.setLayout(SetDepiction.Layout.Vertical);
FileWriter fw = new FileWriter("/Users/johnmay/Desktop/fragments.svg");
fw.write(depiction.toSvg());
fw.close();
fw = new FileWriter("/Users/johnmay/Desktop/fragments_x2.svg");
fw.write(depiction.toSvg(2));
fw.close();
fw = new FileWriter("/Users/johnmay/Desktop/fragments_x4.svg");
fw.write(depiction.toSvg(4));
fw.close();
ImageIO.write(depiction.toBufferedImage(2), "png", new File("/Users/johnmay/Desktop/fragments_vert.png"));
depiction.setLayout(SetDepiction.Layout.Horizontal);
ImageIO.write(depiction.toBufferedImage(2), "png", new File("/Users/johnmay/Desktop/fragments_horz.png"));
}
开发者ID:johnmay,项目名称:efficient-bits,代码行数:39,代码来源:SetDepictionExample.java
示例6: parseAtomContainer
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
static
public IAtomContainer parseAtomContainer(String structure){
SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
try {
return prepareAtomContainer(parser.parseSmiles(structure));
} catch(CDKException ce){
throw new EvaluationException(ce.toString());
}
}
开发者ID:vruusmann,项目名称:qsar.io,代码行数:11,代码来源:CDKDescriptorFunction.java
示例7: main
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static void main(String[] args) throws IOException, CDKException {
if (args.length < 1 || !args[0].endsWith(".sdf")) {
System.err.println("Expected input SDF as argument.");
return;
}
if (args[0].startsWith("~"))
args[0] = System.getProperty("user.home") + args[0].substring(1);
String sdfInPath = args[0];
String sdfOutPath = sdfInPath.substring(0, sdfInPath.length() - 4) + "-templates.sdf";
System.out.println("Extracting ring templates to '" + sdfOutPath + "'");
System.out.println(" - input SDfile: '" + sdfInPath + "'");
RingTemplateExtractor extractor = new RingTemplateExtractor();
IteratingSDFReader sdfReader = new IteratingSDFReader(new FileReader(sdfInPath),
SilentChemObjectBuilder.getInstance());
SDfile:
while (sdfReader.hasNext()) {
IAtomContainer container = sdfReader.next();
if (container instanceof IQueryAtomContainer)
continue;
for (IAtom atom : container.atoms()) {
if (atom.getImplicitHydrogenCount() == null)
continue SDfile;
if (atom.getPoint2d() == null)
continue SDfile;
}
extractor.add(container);
}
extractor.writeSDfile(new File(sdfOutPath));
}
开发者ID:cdk,项目名称:cdk-build-util,代码行数:41,代码来源:ExtractTemplates.java
示例8: initSmilesParser
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public void initSmilesParser() {
this.sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:4,代码来源:OnlinePubChemDatabaseMicha.java
示例9: run
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
resultWindow = new ResultWindow(
"Searching for " + MZmineCore.getConfiguration().getMZFormat()
.format(searchedMass),
peakListRow, searchedMass, charge, this);
resultWindow.setVisible(true);
logger.finest("Starting search for formulas for " + massRange + " Da");
IsotopePattern detectedPattern = peakListRow.getBestIsotopePattern();
if ((checkIsotopes) && (detectedPattern == null)) {
final String msg = "Cannot calculate isotope pattern scores, because selected"
+ " peak does not have any isotopes. Have you run the isotope peak grouper?";
MZmineCore.getDesktop().displayMessage(resultWindow, msg);
}
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
generator = new MolecularFormulaGenerator(builder,
massRange.lowerEndpoint(), massRange.upperEndpoint(),
elementCounts);
IMolecularFormula cdkFormula;
while ((cdkFormula = generator.getNextFormula()) != null) {
if (isCanceled())
return;
// Mass is ok, so test other constraints
checkConstraints(cdkFormula);
}
if (isCanceled())
return;
logger.finest("Finished formula search for " + massRange
+ " m/z, found " + foundFormulas + " formulas");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
resultWindow.setTitle("Finished searching for "
+ MZmineCore.getConfiguration().getMZFormat()
.format(searchedMass)
+ " amu, " + foundFormulas + " formulas found");
}
});
setStatus(TaskStatus.FINISHED);
}
开发者ID:mzmine,项目名称:mzmine2,代码行数:59,代码来源:SingleRowPredictionTask.java
示例10: main
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InvalidSmilesException {
if (args.length < 1) {
System.err.println("Usage ./smi2fps {input.smi} [{output.smi}]");
return;
}
final String path = args[0];
final BufferedWriter bw = args.length > 1
? new BufferedWriter(new FileWriter(args[1])) :
new BufferedWriter(new OutputStreamWriter(System.out));
final BufferedReader rdr = new BufferedReader(new FileReader(path));
final SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
// TODO choose fingerprint
IFingerprinter fpr = new CircularFingerprinter(CircularFingerprinter.CLASS_ECFP4);
final int len = fpr.getSize();
int cnt = 0;
long t0 = System.nanoTime();
String line;
while ((line = rdr.readLine()) != null) {
try {
final IAtomContainer container = smipar.parseSmiles(line);
final String id = suffixedId(line);
final BitSet bitSet = fpr.getBitFingerprint(container).asBitSet();
StringBuilder sb = new StringBuilder();
FpsFmt.writeHex(sb, len, bitSet.toLongArray());
bw.write(sb.toString());
bw.write("\t");
bw.write(id);
bw.newLine();
if (++cnt % TIME_STAMP_INTERVAL == 0)
System.err.print("\r[RUN] processed " + cnt+ " compounds, elapsed time " + elapsedTime(t0, System.nanoTime()));
} catch (Exception e) {
System.err.println("[INFO] Skipping " + line + " " + e.getMessage());
}
}
long t1 = System.nanoTime();
System.err.println("\r[FINISHED] processed " + cnt+ " compounds, elapsed time " + elapsedTime(t0, t1));
rdr.close();
bw.close();
}
开发者ID:johnmay,项目名称:efficient-bits,代码行数:53,代码来源:SmiToFps.java
示例11: main
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static void main(String[] args) throws IOException, CDKException {
if (args.length < 2) {
System.err.println("usage: ./fpsscan {input.fps} 'SMILES' ['t']");
return;
}
final String fpsPath = args[0];
final String smi = args[1];
final double lim = args.length > 2 ? Double.parseDouble(args[2]) : DEFAULT_THRESHOLD;
final int len = 1024;
final long[] words = new long[len / 64];
// generate query fp (TODO make choosable)
CircularFingerprinter fpr = new CircularFingerprinter(CircularFingerprinter.CLASS_ECFP4);
IAtomContainer container = new SmilesParser(SilentChemObjectBuilder.getInstance()).parseSmiles(smi);
BinaryFingerprint qFp = BinaryFingerprint.valueOf(fpr.getBitFingerprint(container).asBitSet().toLongArray(), len);
int cnt = 0;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
long t0 = System.nanoTime();
FileChannel in = new FileInputStream(fpsPath).getChannel();
ByteBuffer buffer = in.map(FileChannel.MapMode.READ_ONLY, 0, new File(fpsPath).length());
StringBuilder idStrBldr = new StringBuilder();
while (buffer.hasRemaining()) {
// reset
idStrBldr.setLength(0);
FpsFmt.readHex(buffer, len, words); // hex bit set
buffer.get(); // tab
readToEnd(buffer, idStrBldr); // id
BinaryFingerprint dFp = BinaryFingerprint.valueOf(words, len);
double t = qFp.similarity(dFp, Similarity.Tanimoto);
boolean display = t >= lim;
if (display) {
bw.write(idStrBldr.toString());
bw.write(SEPARATOR);
bw.write(String.format("%.2f", t));
bw.newLine();
}
}
long t1 = System.nanoTime();
in.close();
bw.close();
System.err.printf("\rScanned in %.2fs \n", (t1 - t0) / 1e9);
}
开发者ID:johnmay,项目名称:efficient-bits,代码行数:54,代码来源:FpsScan.java
示例12: calculateIsotopePattern
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
public static IsotopePattern calculateIsotopePattern(
String molecularFormula, double minAbundance, int charge,
PolarityType polarity) {
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
IMolecularFormula cdkFormula = MolecularFormulaManipulator
.getMolecularFormula(molecularFormula, builder);
return calculateIsotopePattern(cdkFormula, minAbundance, charge,
polarity);
}
开发者ID:mzmine,项目名称:mzmine2,代码行数:14,代码来源:IsotopePatternCalculator.java
示例13: run
import org.openscience.cdk.silent.SilentChemObjectBuilder; //导入依赖的package包/类
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
totalRows = peakList.getNumberOfRows();
for (PeakListRow row : peakList.getRows()) {
if (row.getPeakIdentities().length > 0) {
continue;
}
this.ResultingFormulas = new ArrayList<ResultFormula>();
this.searchedMass = (row.getAverageMZ() - ionType.getAddedMass())
* charge;
message = "Formula prediction for " + MZmineCore.getConfiguration()
.getMZFormat().format(searchedMass);
massRange = mzTolerance.getToleranceRange(searchedMass);
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
generator = new MolecularFormulaGenerator(builder,
massRange.lowerEndpoint(), massRange.upperEndpoint(),
elementCounts);
IMolecularFormula cdkFormula;
while ((cdkFormula = generator.getNextFormula()) != null) {
// Mass is ok, so test other constraints
checkConstraints(cdkFormula, row);
}
if (isCanceled())
return;
for (ResultFormula f : this.ResultingFormulas) {
SimplePeakIdentity newIdentity = new SimplePeakIdentity(
f.getFormulaAsString());
row.addPeakIdentity(newIdentity, false);
}
finishedRows++;
}
if (isCanceled())
return;
logger.finest("Finished formula search for all the peaks");
setStatus(TaskStatus.FINISHED);
}
开发者ID:mzmine,项目名称:mzmine2,代码行数:59,代码来源:FormulaPredictionPeakListTask.java
注:本文中的org.openscience.cdk.silent.SilentChemObjectBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论