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

📄 hbondacceptorcountdescriptor.java

📁 化学图形处理软件
💻 JAVA
字号:
/* *  $RCSfile$ *  $Author: egonw $ *  $Date: 2007-10-14 21:39:12 +0200 (Sun, 14 Oct 2007) $ *  $Revision: 9058 $ * *  Copyright (C) 2004-2007  The Chemistry Development Kit (CDK) project * *  Contact: cdk-devel@lists.sourceforge.net * *  This program is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public License *  as published by the Free Software Foundation; either version 2.1 *  of the License, or (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */package org.openscience.cdk.qsar.descriptors.molecular;import org.openscience.cdk.CDKConstants;import org.openscience.cdk.aromaticity.HueckelAromaticityDetector;import org.openscience.cdk.exception.CDKException;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.qsar.DescriptorSpecification;import org.openscience.cdk.qsar.DescriptorValue;import org.openscience.cdk.qsar.IMolecularDescriptor;import org.openscience.cdk.qsar.result.IDescriptorResult;import org.openscience.cdk.qsar.result.IntegerResult;/** * This descriptor calculates the number of hydrogen bond acceptors using a slightly simplified version of the * <a href="http://www.chemie.uni-erlangen.de/model2001/abstracts/rester.html">PHACIR atom types</a>. * The following groups are counted as hydrogen bond acceptors: * <ul> * <li>any oxygen where the formal charge of the oxygen is non-positive (i.e. formal charge <= 0) <b>except</b></li> * <ol> * <li>an aromatic ether oxygen (i.e. an ether oxygen that is adjacent to at least one aromatic carbon)</li> * <li>an oxygen that is adjacent to a nitrogen</li> * </ol> * <li>any nitrogen where the formal charge of the nitrogen is non-positive (i.e. formal charge <= 0) <b>except</b></li> * <ol> * <li>a nitrogen that is adjacent to an oxygen</li> * </ol> * </ul> * * Returns a single value named <i>nHBAcc</i>. * * <p>This descriptor uses these parameters: * <table> *   <tr> *     <td>Name</td> *     <td>Default</td> *     <td>Description</td> *   </tr> *   <tr> *     <td>checkAromaticity</td> *     <td>false</td> *     <td>true if the aromaticity has to be checked</td> *   </tr> * </table> * <p> * This descriptor works properly with AtomContainers whose atoms contain <b>implicit hydrogens</b> or <b>explicit * hydrogens</b>. *  * @author      ulif * @cdk.created 2005-22-07 * @cdk.module  qsar * @cdk.set     qsar-descriptors * @cdk.dictref qsar-descriptors:hBondacceptors */public class HBondAcceptorCountDescriptor implements IMolecularDescriptor {    // only parameter of this descriptor; true if aromaticity has to be checked prior to descriptor calculation, false otherwise    private boolean checkAromaticity = false;  /**     *  Constructor for the HBondAcceptorCountDescriptor object     */    public HBondAcceptorCountDescriptor() { }    /**     * Gets the specification attribute of the HBondAcceptorCountDescriptor object.     *     * @return    The specification value     */    public DescriptorSpecification getSpecification() {        return new DescriptorSpecification(            "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#hBondacceptors",            this.getClass().getName(),            "$Id: HBondAcceptorCountDescriptor.java 9058 2007-10-14 19:39:12Z egonw $",            "The Chemistry Development Kit");    }    /**     * Sets the parameters attribute of the HBondAcceptorCountDescriptor object.     *     * @param  params            a boolean true means that aromaticity has to be checked     * @exception  CDKException  Description of the Exception     */    public void setParameters(Object[] params) throws CDKException {        if (params.length != 1) {            throw new CDKException("HBondAcceptorCountDescriptor expects a single parameter");        }        if (!(params[0] instanceof Boolean)) {            throw new CDKException("The parameter must be of type Boolean");        }        // ok, all should be fine        checkAromaticity = ((Boolean)params[0]).booleanValue();    }    /**     * Gets the parameters attribute of the HBondAcceptorCountDescriptor object.     *     * @return    The parameters value     */    public Object[] getParameters() {        // return the parameters as used for the descriptor calculation        Object[] params = new Object[1];        params[0] = new Boolean(checkAromaticity);        return params;    }    /**     *  Calculates the number of H bond acceptors.     *     * @param  atomContainer             AtomContainer     * @return                   number of H bond acceptors     * @exception  CDKException  Possible Exceptions     */    public DescriptorValue calculate(IAtomContainer atomContainer) throws CDKException {        int hBondAcceptors = 0;        IAtomContainer ac;        try {            ac = (IAtomContainer) atomContainer.clone();        } catch (CloneNotSupportedException e) {            throw new CDKException("Error during clone");        }        // aromaticity is detected prior to descriptor calculation if the respective parameter is set to true        if (checkAromaticity)            HueckelAromaticityDetector.detectAromaticity(ac);        //org.openscience.cdk.interfaces.IAtom[] atoms = ac.getAtoms();    // labelled for loop to allow for labelled continue statements within the loop    atomloop:        for (int atomIndex = 0; atomIndex < ac.getAtomCount(); atomIndex++)    {      // looking for suitable nitrogen atoms      if(ac.getAtom(atomIndex).getSymbol().equals("N") && ac.getAtom(atomIndex).getFormalCharge() <= 0)      {        // excluding nitrogens that are adjacent to an oxygen          java.util.List neighbours = ac.getConnectedAtomsList(ac.getAtom(atomIndex));        for(int neighbourIndex = 0; neighbourIndex < neighbours.size(); neighbourIndex++)          if(((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("O"))            continue atomloop;        hBondAcceptors++;      }      // looking for suitable oxygen atoms      if(ac.getAtom(atomIndex).getSymbol().equals("O") && ac.getAtom(atomIndex).getFormalCharge() <= 0)      {        //excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon          java.util.List neighbours = ac.getConnectedAtomsList(ac.getAtom(atomIndex));        for(int neighbourIndex = 0; neighbourIndex < neighbours.size(); neighbourIndex++)          if(((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("N") ||              (((IAtom)neighbours.get(neighbourIndex)).getSymbol().equals("C") && ((IAtom)neighbours.get(neighbourIndex)).getFlag(CDKConstants.ISAROMATIC)))            continue atomloop;        hBondAcceptors++;      }        }    return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(),            new IntegerResult(hBondAcceptors), new String[] {"nHBAcc"});    }    /**     * Returns the specific type of the DescriptorResult object.     * <p/>     * The return value from this method really indicates what type of result will     * be obtained from the {@link org.openscience.cdk.qsar.DescriptorValue} object. Note that the same result     * can be achieved by interrogating the {@link org.openscience.cdk.qsar.DescriptorValue} object; this method     * allows you to do the same thing, without actually calculating the descriptor.     *     * @return an object that implements the {@link org.openscience.cdk.qsar.result.IDescriptorResult} interface indicating     *         the actual type of values returned by the descriptor in the {@link org.openscience.cdk.qsar.DescriptorValue} object     */    public IDescriptorResult getDescriptorResultType() {        return new IntegerResult(1);    }    /**     * Gets the parameterNames attribute of the HBondAcceptorCountDescriptor object.     *     * @return    The parameterNames value     */    public String[] getParameterNames() {        String[] params = new String[1];        params[0] = "checkAromaticity";        return params;    }    /**     * Gets the parameterType attribute of the HBondAcceptorCountDescriptor object.     *     * @param  name  Description of the Parameter     * @return       The parameterType value     */    public Object getParameterType(String name) {        return Boolean.FALSE;    }}

⌨️ 快捷键说明

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