• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SmilesParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openscience.cdk.smiles.SmilesParser的典型用法代码示例。如果您正苦于以下问题:Java SmilesParser类的具体用法?Java SmilesParser怎么用?Java SmilesParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SmilesParser类属于org.openscience.cdk.smiles包,在下文中一共展示了SmilesParser类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: PictureGenerator

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
public PictureGenerator() {
	// generators make the image elements
	List<IGenerator<IAtomContainer>> generators = new ArrayList<IGenerator<IAtomContainer>>();
	this.bsg = new BasicSceneGenerator();
	generators.add(this.bsg);
	this.bbg = new BasicBondGenerator();
	generators.add(this.bbg);
	this.atomGenerator = new BasicAtomGenerator();
	generators.add(this.atomGenerator);
	
	this.renderer = new AtomContainerRenderer(generators, new AWTFontManager());
	this.model = renderer.getRenderer2DModel();
	
	// For smiles convertion
	this.sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
	this.sp.setPreservingAromaticity(true);
}
 
开发者ID:yoann-dufresne,项目名称:Smiles2Monomers,代码行数:18,代码来源:PictureGenerator.java


示例2: setUp

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.testFile = new File("data_tests/pictureTest.png");
	if (this.testFile.exists())
		this.testFile.delete();
	
	this.smiles = "c1ccccc1";
	
	SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
	this.imol = null;
	try {
		this.imol = sp.parseSmiles(this.smiles);
	} catch (InvalidSmilesException e) {
		e.printStackTrace();
	}
}
 
开发者ID:yoann-dufresne,项目名称:Smiles2Monomers,代码行数:17,代码来源:CDKMoleculesTests.java


示例3: isIsomorph

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
/**
 * Checks if the given structures are isomorph.
 * 
 * @param candidate1 the candidate1
 * @param candidate2 the candidate2
 * 
 * @return true, if is isomorph
 * 
 * @throws CDKException the CDK exception
 */
public boolean isIsomorph(String candidate1, String candidate2) throws CDKException
{
	IAtomContainer cand1 = null;
	IAtomContainer cand2 = null;
	
	if(hasAtomContainer)
	{
		cand1 = this.candidateToStructure.get(candidate1);
		cand2 = this.candidateToStructure.get(candidate2);
	}
	else
	{
		SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
		cand1 = sp.parseSmiles(candidatesToSmiles.get(candidate1));
		cand2 = sp.parseSmiles(candidatesToSmiles.get(candidate2));
	}
	
	return UniversalIsomorphismTester.isIsomorph(cand1, cand2);
}
 
开发者ID:mgerlich,项目名称:MetFusion,代码行数:30,代码来源:Similarity.java


示例4: getMolFromSmiles

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
/**
 * Gets the mol from smiles.
 * 
 * @param smiles the smiles
 * 
 * @return the mol from smiles
 */
public IAtomContainer getMolFromSmiles(String smiles) {
	if (smiles == null || smiles.isEmpty())
		return null;

	IAtomContainer container = null;
	try {
		SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
		IMolecule m = sp.parseSmiles(smiles);
		container = m;
		
		// hydrogen handling
		container = hydrogenHandling(container);
	} catch (InvalidSmilesException ise) {
		return null;
	}
	return container;
}
 
开发者ID:mgerlich,项目名称:MetFusion,代码行数:25,代码来源:MassBankUtilities.java


示例5: parseSmiles

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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


示例6: parseSmilesImplicitHydrogen

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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


示例7: SmilesConverter

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
private SmilesConverter() {
	IChemObjectBuilder basic = DefaultChemObjectBuilder.getInstance();
	this.sp = new SmilesParser(basic);
	this.sp.setPreservingAromaticity(true);
	this.sg = new SmilesGenerator();
	this.sg.setUseAromaticityFlag(true);
	//this.hrf = new HanserRingFinder();
}
 
开发者ID:yoann-dufresne,项目名称:Smiles2Monomers,代码行数:9,代码来源:SmilesConverter.java


示例8: main

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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


示例9: parseAtomContainer

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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


示例10: createFromSmiles

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
public static ChemicalCompound createFromSmiles(String name, String smilesString)
        throws CDKException
{
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule cdkMolecule = smilesParser.parseSmiles(smilesString);
    return new ChemicalCompound(name, cdkMolecule);
}
 
开发者ID:dhmay,项目名称:msInspect,代码行数:8,代码来源:ChemicalCompound.java


示例11: initSmilesParser

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
public void initSmilesParser() {
	this.sp  = new SmilesParser(SilentChemObjectBuilder.getInstance());
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:4,代码来源:OnlinePubChemDatabaseMicha.java


示例12: AtomContainerToNgraph

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的package包/类
public AtomContainerToNgraph() {
    sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
}
 
开发者ID:yoann-dufresne,项目名称:Smiles2Monomers,代码行数:4,代码来源:AtomContainerToNgraph.java


示例13: main

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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


示例14: main

import org.openscience.cdk.smiles.SmilesParser; //导入依赖的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



注:本文中的org.openscience.cdk.smiles.SmilesParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TimelineState类代码示例发布时间:2022-05-23
下一篇:
Java DatasetReader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap