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

📄 rdfprotondescriptor_g3r.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* $Revision: 7895 $ $Author: egonw $ $Date: 2007-02-07 23:20:44 +0100 (Wed, 07 Feb 2007) $ * * Copyright (C) 2004-2007  Matteo Floris <mfe4@users.sf.net> * Copyright (C) 2006-2007  Federico * * 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.atomic;import org.openscience.cdk.AtomContainerSet;import org.openscience.cdk.CDKConstants;import org.openscience.cdk.Molecule;import org.openscience.cdk.Ring;import org.openscience.cdk.aromaticity.HueckelAromaticityDetector;import org.openscience.cdk.charges.GasteigerMarsiliPartialCharges;import org.openscience.cdk.exception.CDKException;import org.openscience.cdk.graph.invariant.ConjugatedPiSystemsDetector;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.interfaces.IBond;import org.openscience.cdk.interfaces.IRingSet;import org.openscience.cdk.qsar.DescriptorSpecification;import org.openscience.cdk.qsar.DescriptorValue;import org.openscience.cdk.qsar.IAtomicDescriptor;import org.openscience.cdk.qsar.result.DoubleArrayResult;import org.openscience.cdk.ringsearch.AllRingsFinder;import org.openscience.cdk.tools.LoggingTool;import javax.vecmath.Point3d;import javax.vecmath.Vector3d;import java.util.ArrayList;import java.util.Iterator;import java.util.List;/** * This class calculates G3R proton descriptors used in neural networks for H1 * NMR shift. *  * <p> * This descriptor uses these parameters: <table border="1"> * <tr> * <td>Name</td> * <td>Default</td> * <td>Description</td> * </tr> * <tr> * <td>checkAromaticity</td> * <td>false</td> * <td>True is the aromaticity has to be checked</td> * </tr> * </table> *  * @author      Federico * @cdk.created 2006-12-11 * @cdk.module  qsar * @cdk.set     qsar-descriptors * @cdk.dictref qsar-descriptors:rdfProtonCalculatedValues * @cdk.bug     1632419 */public class RDFProtonDescriptor_G3R implements IAtomicDescriptor {	private boolean checkAromaticity = false;	private IAtomContainer acold = null;	private IRingSet varRingSet = null;	private AtomContainerSet varAtomContainerSet = null;	    private final static LoggingTool logger = new LoggingTool(RDFProtonDescriptor_G3R.class);	private static String[] descriptorNames;	/**	 * Constructor for the RDFProtonDescriptor object	 */	public RDFProtonDescriptor_G3R() {	}	/**	 * Gets the specification attribute of the RDFProtonDescriptor_G3R object	 * 	 * @return The specification value	 */	public DescriptorSpecification getSpecification() {		return new DescriptorSpecification(				"http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#rdfProtonCalculatedValues",				this.getClass().getName(),				"$Id: RDFProtonDescriptor.java 7032 2006-09-22 15:26:48 +0000 (ven, 22 set 2006) kaihartmann $",				"The Chemistry Development Kit");	}	/**	 * Sets the parameters attribute of the RDFProtonDescriptor object	 * 	 * @param params	 *            Parameters are the proton position and a boolean (true if you	 *            need to detect aromaticity)	 * @exception CDKException	 *                Possible Exceptions	 */	public void setParameters(Object[] params) throws CDKException {		if (params.length > 1) {			throw new CDKException(					"RDFProtonDescriptor only expects one parameters");		}		if (!(params[0] instanceof Boolean)) {			throw new CDKException(					"The second parameter must be of type Boolean");		}		checkAromaticity = ((Boolean) params[0]).booleanValue();	}	/**	 * Gets the parameters attribute of the RDFProtonDescriptor object	 * 	 * @return The parameters value	 */	public Object[] getParameters() {		// return the parameters as used for the descriptor calculation		Object[] params = new Object[1];		params[0] = Boolean.valueOf(checkAromaticity);		return params;	}	public DescriptorValue calculate(IAtom atom,			IAtomContainer varAtomContainerSet) throws CDKException {		return (calculate(atom, varAtomContainerSet, null));	}	public DescriptorValue calculate(IAtom atom,			IAtomContainer atomContainer, IRingSet precalculatedringset)			throws CDKException {        IAtomContainer varAtomContainer;        try {            varAtomContainer = (IAtomContainer) atomContainer.clone();        } catch (CloneNotSupportedException e) {            throw new CDKException("Error during clone");        }        int atomPosition = atomContainer.getAtomNumber(atom);        IAtom clonedAtom = varAtomContainer.getAtom(atomPosition);		final int g3r_desc_length = 13;		DoubleArrayResult rdfProtonCalculatedValues = new DoubleArrayResult(				g3r_desc_length);		if (!atom.getSymbol().equals("H")) {			throw new CDKException("You tried calculation on a "					+ atom.getSymbol()					+ " atom. This is not allowed! Atom must be a H atom.");		}		// ///////////////////////FIRST SECTION OF MAIN METHOD: DEFINITION OF		// MAIN VARIABLES		// ///////////////////////AND AROMATICITY AND PI-SYSTEM AND RINGS		// DETECTION		Molecule mol = new Molecule(varAtomContainer);		if (varAtomContainer != acold) {			acold = varAtomContainer;			// DETECTION OF pi SYSTEMS			varAtomContainerSet = ConjugatedPiSystemsDetector.detect(mol);			if (precalculatedringset == null)				varRingSet = (new AllRingsFinder())						.findAllRings(varAtomContainer);			else				varRingSet = precalculatedringset;			try {				GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges();				peoe.assignGasteigerMarsiliSigmaPartialCharges(mol, true);			} catch (Exception ex1) {				throw new CDKException(						"Problems with assignGasteigerMarsiliPartialCharges due to "								+ ex1.toString(), ex1);			}		}		if (checkAromaticity) {			HueckelAromaticityDetector.detectAromaticity(varAtomContainer,					varRingSet, true);		}		List rsAtom;		Ring ring;		List ringsWithThisBond;		// SET ISINRING FLAGS FOR BONDS//		org.openscience.cdk.interfaces.IBond[] bondsInContainer = varAtomContainer.getBonds();        Iterator bondsInContainer = varAtomContainer.bonds();        while (bondsInContainer.hasNext()) {            IBond bond = (IBond) bondsInContainer.next();                    			ringsWithThisBond = varRingSet.getRings(bond);			if (ringsWithThisBond.size() > 0) {				bond.setFlag(CDKConstants.ISINRING, true);			}		}		// SET ISINRING FLAGS FOR ATOMS		org.openscience.cdk.interfaces.IRingSet ringsWithThisAtom;		for (int w = 0; w < varAtomContainer.getAtomCount(); w++) {			ringsWithThisAtom = varRingSet					.getRings(varAtomContainer.getAtom(w));			if (ringsWithThisAtom.getAtomContainerCount() > 0) {				varAtomContainer.getAtom(w)						.setFlag(CDKConstants.ISINRING, true);			}		}		IAtomContainer detected = varAtomContainerSet.getAtomContainer(0);		// neighboors[0] is the atom joined to the target proton:		java.util.List neighboors = mol.getConnectedAtomsList(clonedAtom);		IAtom neighbour0 = (IAtom) neighboors.get(0);		// 2', 3', 4', 5', 6', and 7' atoms up to the target are detected:		List atomsInSecondSphere = mol.getConnectedAtomsList(neighbour0);		List atomsInThirdSphere = null;		List atomsInFourthSphere = null;		List atomsInFifthSphere = null;		List atomsInSixthSphere = null;		List atomsInSeventhSphere = null;		// SOME LISTS ARE CREATED FOR STORING OF INTERESTING ATOMS AND BONDS		// DURING DETECTION		ArrayList singles = new ArrayList(); // list of any bond not												// rotatable		ArrayList doubles = new ArrayList(); // list with only double bonds		ArrayList atoms = new ArrayList(); // list with all the atoms in											// spheres		// atoms.add( new Integer( mol.getAtomNumber(neighboors[0]) ) );		ArrayList bondsInCycloex = new ArrayList(); // list for bonds in													// cycloexane-like rings		// 2', 3', 4', 5', 6', and 7' bonds up to the target are detected:		IBond secondBond; // (remember that first bond is proton bond)		IBond thirdBond; //		IBond fourthBond; //		IBond fifthBond; //		IBond sixthBond; //		IBond seventhBond; //		// definition of some variables used in the main FOR loop for detection		// of interesting atoms and bonds:		boolean theBondIsInA6MemberedRing; // this is like a flag for bonds											// which are in cycloexane-like											// rings (rings with more than 4											// at.)		double bondOrder;		int bondNumber;		int sphere;		// THIS MAIN FOR LOOP DETECT RIGID BONDS IN 7 SPHERES:		for (int a = 0; a < atomsInSecondSphere.size(); a++) {			IAtom curAtomSecond = (IAtom) atomsInSecondSphere.get(a);			secondBond = mol.getBond(neighbour0, curAtomSecond);			if (mol.getAtomNumber(curAtomSecond) != atomPosition					&& getIfBondIsNotRotatable(mol, secondBond, detected)) {				sphere = 2;				bondOrder = secondBond.getOrder();				bondNumber = mol.getBondNumber(secondBond);				theBondIsInA6MemberedRing = false;				checkAndStore(bondNumber, bondOrder, singles, doubles,						bondsInCycloex, mol.getAtomNumber(curAtomSecond),						atoms, sphere, theBondIsInA6MemberedRing);				atomsInThirdSphere = mol.getConnectedAtomsList(curAtomSecond);				if (atomsInThirdSphere.size() > 0) {					for (int b = 0; b < atomsInThirdSphere.size(); b++) {						IAtom curAtomThird = (IAtom) atomsInThirdSphere.get(b);						thirdBond = mol.getBond(curAtomThird, curAtomSecond);						// IF THE ATOMS IS IN THE THIRD SPHERE AND IN A						// CYCLOEXANE-LIKE RING, IT IS STORED IN THE PROPER						// LIST:						if (mol.getAtomNumber(curAtomThird) != atomPosition								&& getIfBondIsNotRotatable(mol, thirdBond,										detected)) {							sphere = 3;							bondOrder = thirdBond.getOrder();							bondNumber = mol.getBondNumber(thirdBond);							theBondIsInA6MemberedRing = false;							// if the bond is in a cyclohexane-like ring (a ring							// with 5 or more atoms, not aromatic)							// the boolean "theBondIsInA6MemberedRing" is set to							// true							if (!thirdBond.getFlag(CDKConstants.ISAROMATIC)) {								if (!curAtomThird.equals(neighbour0)) {									rsAtom = varRingSet.getRings(thirdBond);									for (int f = 0; f < rsAtom.size(); f++) {										ring = (Ring) rsAtom.get(f);										if (ring.getRingSize() > 4												&& ring.contains(thirdBond)) {											theBondIsInA6MemberedRing = true;										}									}								}							}							checkAndStore(bondNumber, bondOrder, singles,									doubles, bondsInCycloex, mol											.getAtomNumber(curAtomThird),									atoms, sphere, theBondIsInA6MemberedRing);							theBondIsInA6MemberedRing = false;							atomsInFourthSphere = mol									.getConnectedAtomsList(curAtomThird);							if (atomsInFourthSphere.size() > 0) {								for (int c = 0; c < atomsInFourthSphere.size(); c++) {									IAtom curAtomFourth = (IAtom) atomsInFourthSphere											.get(c);									fourthBond = mol.getBond(curAtomThird,											curAtomFourth);									if (mol.getAtomNumber(curAtomFourth) != atomPosition											&& getIfBondIsNotRotatable(mol,													fourthBond, detected)) {										sphere = 4;										bondOrder = fourthBond.getOrder();										bondNumber = mol												.getBondNumber(fourthBond);										theBondIsInA6MemberedRing = false;										checkAndStore(												bondNumber,												bondOrder,												singles,												doubles,												bondsInCycloex,												mol														.getAtomNumber(curAtomFourth),												atoms, sphere,												theBondIsInA6MemberedRing);										atomsInFifthSphere = mol												.getConnectedAtomsList(curAtomFourth);										if (atomsInFifthSphere.size() > 0) {											for (int d = 0; d < atomsInFifthSphere													.size(); d++) {												IAtom curAtomFifth = (IAtom) atomsInFifthSphere														.get(d);												fifthBond = mol.getBond(														curAtomFifth,														curAtomFourth);												if (mol														.getAtomNumber(curAtomFifth) != atomPosition														&& getIfBondIsNotRotatable(																mol, fifthBond,																detected)) {													sphere = 5;													bondOrder = fifthBond															.getOrder();													bondNumber = mol															.getBondNumber(fifthBond);													theBondIsInA6MemberedRing = false;													checkAndStore(															bondNumber,															bondOrder,

⌨️ 快捷键说明

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