当前位置: 首页>>代码示例>>Java>>正文


Java IAtomContainer.getBondCount方法代码示例

本文整理汇总了Java中org.openscience.cdk.interfaces.IAtomContainer.getBondCount方法的典型用法代码示例。如果您正苦于以下问题:Java IAtomContainer.getBondCount方法的具体用法?Java IAtomContainer.getBondCount怎么用?Java IAtomContainer.getBondCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openscience.cdk.interfaces.IAtomContainer的用法示例。


在下文中一共展示了IAtomContainer.getBondCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValidDoubleBondConfiguration

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
/**
 *  Tells if a certain bond is center of a valid double bond configuration.
 *
 *@param  container  The atomcontainer.
 *@param  bond       The bond.
 *@return            true=is a potential configuration, false=is not.
 */
public boolean isValidDoubleBondConfiguration(IAtomContainer container, IBond bond)
{
	IAtom atom0 = bond.getAtom(0);
	IAtom atom1 = bond.getAtom(1);
	List<IAtom> connectedAtoms = container.getConnectedAtomsList(atom0);
	IAtom from = null;
       for (IAtom connectedAtom : connectedAtoms) {
           if (connectedAtom != atom1) {
               from = connectedAtom;
           }
       }
       boolean[] array = new boolean[container.getBondCount()];
	for (int i = 0; i < array.length; i++)
	{
		array[i] = true;
	}
	if (isStartOfDoubleBond(container, atom0, from, array) && isEndOfDoubleBond(container, atom1, atom0, array) && !bond.getFlag(CDKConstants.ISAROMATIC))
	{
		return (true);
	} else
	{
		return (false);
	}
}
 
开发者ID:yoann-dufresne,项目名称:Smiles2Monomers,代码行数:32,代码来源:SmilesGenerator.java

示例2: generateImage

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
/**
 * draw image and return it as RenderedImage
 * 
 * @param structure
 * @return
 * @throws CDKException
 */
public RenderedImage generateImage(final IAtomContainer structure) {
	Image image = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g2 = (Graphics2D) image.getGraphics();
	g2.setColor(new Color(1.0f, 1.0f, 1.0f, 0.0f));
	g2.fillRect(0, 0, this.imageWidth, this.imageHeight);
	try {
		IAtomContainer moleculeToDraw = AtomContainerManipulator.removeHydrogens(structure);

		Rectangle drawArea = new Rectangle(this.imageWidth, this.imageHeight);

		AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeToDraw);
		for(int i = 0; i < moleculeToDraw.getAtomCount(); i++) 
			moleculeToDraw.getAtom(i).setProperty(StandardGenerator.ANNOTATION_LABEL, i + "");
		for(int i = 0; i < moleculeToDraw.getBondCount(); i++) 
			moleculeToDraw.getBond(i).setProperty(StandardGenerator.ANNOTATION_LABEL, i + "");
		
		StructureDiagramGenerator sdg = new StructureDiagramGenerator();
           sdg.setMolecule(moleculeToDraw);
           sdg.generateCoordinates();
		this.renderer.setup(sdg.getMolecule(), drawArea);
		RendererModel rendererModel = this.renderer.getRenderer2DModel();
		rendererModel.set(StandardGenerator.Visibility.class, SymbolVisibility.iupacRecommendations());
   		rendererModel.set(StandardGenerator.AtomColor.class, new CDK2DAtomColors()); 
   		rendererModel.set(StandardGenerator.AnnotationColor.class, new Color(0x455FFF));
   		rendererModel.set(StandardGenerator.StrokeRatio.class, this.strokeRatio);
		Rectangle2D bounds = new Rectangle2D.Double(0, 0, this.imageWidth, this.imageHeight);
		
		this.renderer.paint(sdg.getMolecule(), new AWTDrawVisitor(g2), bounds, true);

	} catch (Exception e) {
		return (RenderedImage) image;
	}
	return (RenderedImage) image;
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:42,代码来源:AnnotatedStandardSingleStructureImageGenerator.java

示例3: getBondRefs

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
public static BondRef[] getBondRefs(IAtomContainer mol) {

        final int numAtoms = mol.getAtomCount();
        final int numBonds = mol.getBondCount();
        BondRef[] bonds    = new BondRef[numBonds];

        final Map<IAtom, AtomRef> atomCache = new IdentityHashMap<>(mol.getAtomCount());

        for (int i = 0; i < numAtoms; i++) {
            final IAtom atom = mol.getAtom(i);
            final AtomRef atomrf = new AtomRef(i,
                                               atom,
                                               new ArrayList<BondRef>());
            atomCache.put(atomrf.atom, atomrf);
        }
        for (int i = 0; i < numBonds; i++) {
            final IBond   bond    = mol.getBond(i);
            AtomRef       beg     = atomCache.get(bond.getAtom(0));
            AtomRef       end     = atomCache.get(bond.getAtom(1));
            final BondRef bondref = new BondRef(bond, i, beg, end);
            beg.bonds.add(bondref);
            end.bonds.add(bondref);
            bonds[i] = bondref;
        }

        return bonds;
    }
 
开发者ID:johnmay,项目名称:efficient-bits,代码行数:28,代码来源:BondRef.java

示例4: getAtomRefs

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
public static AtomRef[] getAtomRefs(IAtomContainer mol) {

        final int numAtoms = mol.getAtomCount();
        final int numBonds = mol.getBondCount();
        AtomRef[] atoms    = new AtomRef[numAtoms];

        final Map<IAtom, AtomRef> atomCache = new IdentityHashMap<>(mol.getAtomCount());

        for (int i = 0; i < numAtoms; i++) {
            final IAtom atom = mol.getAtom(i);
            final AtomRef atomrf = new AtomRef(i,
                                               atom,
                                               new ArrayList<BondRef>());
            atomCache.put(atomrf.atom, atomrf);
            atoms[i] = atomrf;
        }
        for (int i = 0; i < numBonds; i++) {
            final IBond   bond    = mol.getBond(i);
            AtomRef       beg     = atomCache.get(bond.getAtom(0));
            AtomRef       end     = atomCache.get(bond.getAtom(1));
            final BondRef bondref = new BondRef(bond, i, beg, end);
            beg.bonds.add(bondref);
            end.bonds.add(bondref);
        }

        return atoms;
    }
 
开发者ID:johnmay,项目名称:efficient-bits,代码行数:28,代码来源:AtomRef.java

示例5: setScale

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
private void setScale(IAtomContainer container) {
    if (container.getBondCount() > 0) {
        double bondLength = GeometryUtil.getBondLengthMedian(container);
        if (bondLength < 0.001)
            setScaleForBondLength(0.826);
        else
            setScaleForBondLength(bondLength);
    }
    else {
        setScaleForBondLength(0.826);
    }
}
 
开发者ID:johnmay,项目名称:efficient-bits,代码行数:13,代码来源:DepictionGenerator.java

示例6: main

import org.openscience.cdk.interfaces.IAtomContainer; //导入方法依赖的package包/类
public static void main(String[] args) throws InvalidSmilesException, IOException {
	//SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
	//IAtomContainer m = sp.parseSmiles("CC(C)c1ccc(cc1)S(=O)(=O)O");
	IAtomContainer m = null;
	try {
		m = MoleculeFunctions.getAtomContainerFromInChI("InChI=1S/C10H22N2/c1-9(2)4-8(12)5-10(3,6-9)7-11/h8H,4-7,11-12H2,1-3H3");
		MoleculeFunctions.prepareAtomContainer(m, false);
	} catch (Exception e) {
		e.printStackTrace();
	}
	HighlightSubStructureImageGenerator s = new HighlightSubStructureImageGenerator(new Font("Verdana", Font.BOLD, 18));
	s.setImageHeight(500);
	s.setImageWidth(500);
	s.setStrokeRation(1.5);
	
	BitArray bitArrayAtoms = new BitArray(m.getAtomCount());
	BitArray bitArrayBonds = new BitArray(m.getBondCount());
	bitArrayAtoms.set(0, true);
	bitArrayAtoms.set(1, true);
	bitArrayAtoms.set(2, true);
	bitArrayAtoms.set(3, true);
	bitArrayAtoms.set(4, true);
	bitArrayAtoms.set(5, true);
	bitArrayAtoms.set(6, true);
	bitArrayAtoms.set(7, true);
	bitArrayAtoms.set(8, true);
	bitArrayAtoms.set(9, true);
	
	bitArrayBonds.set(0, true);
	bitArrayBonds.set(1, true);
	bitArrayBonds.set(2, true);
	bitArrayBonds.set(3, true);
	bitArrayBonds.set(4, true);
	bitArrayBonds.set(5, true);
	bitArrayBonds.set(6, true);
	bitArrayBonds.set(7, true);
	bitArrayBonds.set(8, true);
	bitArrayBonds.set(9, true);

	RenderedImage img = s.generateImage(bitArrayAtoms, bitArrayBonds, m);
	ImageIO.write((RenderedImage) img, "PNG", new java.io.File("/tmp/file.png"));
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:43,代码来源:HighlightSubStructureImageGenerator.java


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