⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hydrogenadder.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    	IAtomContainer intermediateContainer= null;    	for (int k = 0; k < moleculeSet.getAtomContainerCount(); k++) {    		IMolecule molPart = moleculeSet.getMolecule(k);    		java.util.Iterator atoms = molPart.atoms();    		while (atoms.hasNext()) {    			intermediateContainer = addHydrogensToSatisfyValency(molPart, (IAtom)atoms.next(), molecule);    			changedAtomsAndBonds.add(intermediateContainer);    		}    	}    	logger.debug("End of addExplicitHydrogensToSatisfyValency");    	return changedAtomsAndBonds;    }    /**     * Method that saturates an atom in a molecule by adding explicit hydrogens.     * In order to get coordinates for these Hydrogens, you need to      * remember the average bondlength of you molecule (coordinates for      * all atoms should be available) by using     * double bondLength = GeometryTools.getBondLengthAverage(atomContainer);     * and then use this method here and then use     * org.openscience.cdk.HydrogenPlacer(atomContainer, bondLength);     *     * @param  atom      Atom to saturate     * @param  container AtomContainer containing the atom     * @param  totalContainer In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure     *     * @cdk.keyword          hydrogen, adding     * @cdk.keyword          explicit hydrogen     *     * @deprecated     */    public IAtomContainer addHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, IAtomContainer totalContainer)         throws IOException, ClassNotFoundException, CDKException    {	logger.debug("Start of addHydrogensToSatisfyValency(AtomContainer container, Atom atom)");    IAtomContainer changedAtomsAndBonds = addExplicitHydrogensToSatisfyValency(container, atom, totalContainer);	logger.debug("End of addHydrogensToSatisfyValency(AtomContainer container, Atom atom)");    return changedAtomsAndBonds;    }    /**     * Method that saturates an atom in a molecule by adding explicit hydrogens.     * In order to get coordinates for these Hydrogens, you need to     * remember the average bondlength of you molecule (coordinates for     * all atoms should be available) by using     * double bondLength = GeometryTools.getBondLengthAverage(atomContainer);     * and then use this method here and then use     * org.openscience.cdk.HydrogenPlacer(atomContainer, bondLength);     *     * @param  atom      Atom to saturate     * @param  container AtomContainer containing the atom     *     * @cdk.keyword hydrogen, adding     * @cdk.keyword explicit hydrogen     */    public IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom)            throws IOException, ClassNotFoundException, CDKException {        // set number of implicit hydrogens to zero        // add explicit hydrogens        logger.debug("Start of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)");        int missingHydrogens = calculateNumberOfImplicitHydrogens(container, atom);        logger.debug("According to valencyChecker, " + missingHydrogens + " are missing");        IAtomContainer changedAtomsAndBonds = addExplicitHydrogensToSatisfyValency(container, atom, missingHydrogens, container);        logger.debug("End of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)");        return changedAtomsAndBonds;    }    /**     * Method that saturates an atom in a molecule by adding explicit hydrogens.     * In order to get coordinates for these Hydrogens, you need to      * remember the average bondlength of you molecule (coordinates for      * all atoms should be available) by using     * double bondLength = GeometryTools.getBondLengthAverage(atomContainer);     * and then use this method here and then use     * org.openscience.cdk.HydrogenPlacer(atomContainer, bondLength);     *     * @param  atom      Atom to saturate     * @param  container AtomContainer containing the atom     * @param  totalContainer In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure     *     * @cdk.keyword          hydrogen, adding     * @cdk.keyword          explicit hydrogen     */    public IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, IAtomContainer totalContainer)         throws IOException, ClassNotFoundException, CDKException    {        // set number of implicit hydrogens to zero        // add explicit hydrogens	logger.debug("Start of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)");        int missingHydrogens = calculateNumberOfImplicitHydrogens(container, atom);  logger.debug("According to valencyChecker, " + missingHydrogens + " are missing");        IAtomContainer changedAtomsAndBonds = addExplicitHydrogensToSatisfyValency(container, atom, missingHydrogens, totalContainer);	logger.debug("End of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)");    return changedAtomsAndBonds;    }        /**     * Method that saturates an atom in a molecule by adding explicit hydrogens.     *     * @param  atom      Atom to saturate     * @param  container AtomContainer containing the atom     * @param  count     Number of hydrogens to add     * @param  totalContainer In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure     *     * @cdk.keyword          hydrogen, adding     * @cdk.keyword          explicit hydrogen     */    public IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, int count, IAtomContainer totalContainer)         throws IOException, ClassNotFoundException    {        //boolean create2DCoordinates = GeometryTools.has2DCoordinates(container);                IIsotope isotope = IsotopeFactory.getInstance(container.getBuilder()).getMajorIsotope("H");        atom.setHydrogenCount(0);        IAtomContainer changedAtomsAndBonds = container.getBuilder().newAtomContainer();        for (int i = 1; i <= count; i++) {            IAtom hydrogen = container.getBuilder().newAtom("H");            IsotopeFactory.getInstance(container.getBuilder()).configure(hydrogen, isotope);            totalContainer.addAtom(hydrogen);            IBond newBond = container.getBuilder().newBond((IAtom)atom, hydrogen, 1.0);            totalContainer.addBond(newBond);            changedAtomsAndBonds.addAtom(hydrogen);            changedAtomsAndBonds.addBond(newBond);        }        return changedAtomsAndBonds;    }        /**     * Method that saturates a molecule by adding implicit hydrogens.     *     *@param  container  Molecule to saturate     *@cdk.keyword          hydrogen, adding     *@cdk.keyword          implicit hydrogen     */    public HashMap addImplicitHydrogensToSatisfyValency(IAtomContainer container) throws CDKException {      IMoleculeSet moleculeSet = ConnectivityChecker.partitionIntoMolecules(container);      HashMap hydrogenAtomMap = new HashMap();      for (int k = 0; k < moleculeSet.getAtomContainerCount(); k++) {    	IMolecule molPart = moleculeSet.getMolecule(k);        java.util.Iterator atoms = molPart.atoms();        while (atoms.hasNext()) {        	IAtom atom = (IAtom)atoms.next();            int[] hydrogens = addImplicitHydrogensToSatisfyValency(molPart, atom);            hydrogenAtomMap.put(atom, hydrogens);        }      }      return hydrogenAtomMap;    }        /**     * Method that saturates an atom in a molecule by adding implicit hydrogens.     *     * @param  container  Molecule to saturate     * @param  atom      Atom to satureate.     * @cdk.keyword          hydrogen, adding     * @cdk.keyword          implicit hydrogen     */    public int[] addImplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom) throws CDKException    {        int formerHydrogens = atom.getHydrogenCount();        int missingHydrogens = calculateNumberOfImplicitHydrogens(container, atom);        atom.setHydrogenCount(missingHydrogens);        int[] hydrogens = new int[2];        hydrogens[0] = formerHydrogens;        hydrogens[1] = missingHydrogens;        return hydrogens;    }    private int calculateNumberOfImplicitHydrogens(IAtomContainer container, IAtom atom) throws CDKException {    	return valencyChecker.calculateNumberOfImplicitHydrogens(atom, container);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -