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

📄 rdfprotondescriptor_gsr.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                        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, singles, doubles, bondsInCycloex, mol.getAtomNumber(curAtomFifth), atoms, sphere, theBondIsInA6MemberedRing);                                                    atomsInSixthSphere = mol.getConnectedAtomsList(curAtomFifth);                                                    if (atomsInSixthSphere.size() > 0) {                                                        for (int e = 0; e < atomsInSixthSphere.size(); e++) {                                                            IAtom curAtomSixth = (IAtom) atomsInSixthSphere.get(e);                                                            sixthBond = mol.getBond(curAtomFifth, curAtomSixth);                                                            if (mol.getAtomNumber(curAtomSixth) != atomPosition && getIfBondIsNotRotatable(mol, sixthBond, detected))                                                            {                                                                sphere = 6;                                                                bondOrder = sixthBond.getOrder();                                                                bondNumber = mol.getBondNumber(sixthBond);                                                                theBondIsInA6MemberedRing = false;                                                                checkAndStore(bondNumber, bondOrder, singles, doubles, bondsInCycloex, mol.getAtomNumber(curAtomSixth), atoms, sphere, theBondIsInA6MemberedRing);                                                                atomsInSeventhSphere = mol.getConnectedAtomsList(curAtomSixth);                                                                if (atomsInSeventhSphere.size() > 0) {                                                                    for (int f = 0; f < atomsInSeventhSphere.size(); f++)                                                                    {                                                                        IAtom curAtomSeventh = (IAtom) atomsInSeventhSphere.get(f);                                                                        seventhBond = mol.getBond(curAtomSeventh, curAtomSixth);                                                                        if (mol.getAtomNumber(curAtomSeventh) != atomPosition && getIfBondIsNotRotatable(mol, seventhBond, detected))                                                                        {                                                                            sphere = 7;                                                                            bondOrder = seventhBond.getOrder();                                                                            bondNumber = mol.getBondNumber(seventhBond);                                                                            theBondIsInA6MemberedRing = false;                                                                            checkAndStore(bondNumber, bondOrder, singles, doubles, bondsInCycloex, mol.getAtomNumber(curAtomSeventh), atoms, sphere, theBondIsInA6MemberedRing);                                                                        }                                                                    }                                                                }                                                            }                                                        }                                                    }                                                }                                            }                                        }                                    }                                }                            }                        }                    }                }            }        }        //Variables        double[] values; // for storage of results of other methods        double distance;        double sum;        double smooth = -20;        double partial;        int position;        double limitInf;        double limitSup;        double step;////////////////////////THE FOUTH DESCRIPTOR IS gS(r), WHICH TAKES INTO ACCOUNT SINGLE BONDS IN RIGID SYSTEMS				Vector3d a_a = new Vector3d();	Vector3d a_b = new Vector3d();	Vector3d b_a = new Vector3d();	Vector3d b_b = new Vector3d();	Point3d middlePoint = new Point3d();	double angle = 0;				if(singles.size() > 0) {		double dist0;		double dist1;		IAtom singleBondAtom0;		IAtom singleBondAtom1;		distance = 0;		position = 0;		org.openscience.cdk.interfaces.IBond theSingleBond = null;		limitInf = 0;		limitSup = Math.PI / 2;		step = (limitSup - limitInf)/7;		smooth = -1.15;		for(double ghs = 0; ghs < limitSup; ghs = ghs + step) {			sum = 0;			for( int sing = 0; sing < singles.size(); sing++ ) {				angle = 0;				partial = 0;				Integer thisSingleBond = (Integer)singles.get(sing);				position = thisSingleBond.intValue();				theSingleBond = mol.getBond(position);				middlePoint = theSingleBond.get3DCenter();				singleBondAtom0 = theSingleBond.getAtom(0);				singleBondAtom1 = theSingleBond.getAtom(1);				dist0 = calculateDistanceBetweenTwoAtoms(singleBondAtom0, atom);				dist1 = calculateDistanceBetweenTwoAtoms(singleBondAtom1, atom);									a_a.set(middlePoint.x, middlePoint.y, middlePoint.z);				if(dist1 > dist0) a_b.set(singleBondAtom0.getPoint3d().x, singleBondAtom0.getPoint3d().y, singleBondAtom0.getPoint3d().z);				else a_b.set(singleBondAtom1.getPoint3d().x, singleBondAtom1.getPoint3d().y, singleBondAtom1.getPoint3d().z);				b_a.set(middlePoint.x, middlePoint.y, middlePoint.z);				b_b.set(atom.getPoint3d().x, atom.getPoint3d().y, atom.getPoint3d().z);								values = calculateDistanceBetweenAtomAndBond(atom, theSingleBond );								angle = calculateAngleBetweenTwoLines(a_a, a_b, b_a, b_b);					//System.out.println("ANGLe: "+angle+ " "+ mol.getAtomNumber(atomsInSingleBond[0]) +" " +mol.getAtomNumber(atomsInSingleBond[1]));									partial = (1 / (Math.pow( values[0], 2 ))) * Math.exp( smooth * (Math.pow( (ghs - angle) , 2)));				sum += partial;			}			//gSr_function.add(new Double(sum));			rdfProtonCalculatedValues.add(sum);			logger.debug("RDF gSr prob.: " + sum +  " at distance " + ghs);		}	}	else {		for (int i=0; i<gsr_desc_length; i++) rdfProtonCalculatedValues.add(Double.NaN);	}	return new DescriptorValue(		getSpecification(), getParameterNames(), 		getParameters(), rdfProtonCalculatedValues,		descriptorNames	);	}	//Others definitions    private boolean getIfBondIsNotRotatable(Molecule mol, org.openscience.cdk.interfaces.IBond bond, IAtomContainer detected) {        boolean isBondNotRotatable = false;        int counter = 0;        IAtom atom0 = bond.getAtom(0);        IAtom atom1 = bond.getAtom(1);        if (detected != null) {            if (detected.contains(bond)) counter += 1;        }        if (atom0.getFlag(CDKConstants.ISINRING)) {            if (atom1.getFlag(CDKConstants.ISINRING)) {                counter += 1;            } else {                if (atom1.getSymbol().equals("H")) counter += 1;                else counter += 0;            }        }        if (atom0.getSymbol().equals("N") && atom1.getSymbol().equals("C")) {            if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom1)) counter += 1;        }        if (atom0.getSymbol().equals("C") && atom1.getSymbol().equals("N")) {            if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom0)) counter += 1;        }        if (counter > 0) isBondNotRotatable = true;        return isBondNotRotatable;    }    private boolean getIfACarbonIsDoubleBondedToAnOxygen(Molecule mol, IAtom carbonAtom) {        boolean isDoubleBondedToOxygen = false;        java.util.List neighToCarbon = mol.getConnectedAtomsList(carbonAtom);        org.openscience.cdk.interfaces.IBond tmpBond;        int counter = 0;        for (int nei = 0; nei < neighToCarbon.size(); nei++) {            IAtom neighbour = (IAtom) neighToCarbon.get(nei);            if (neighbour.getSymbol().equals("O")) {                tmpBond = mol.getBond(neighbour, carbonAtom);                if (tmpBond.getOrder() == 2.0) counter += 1;            }        }        if (counter > 0) isDoubleBondedToOxygen = true;        return isDoubleBondedToOxygen;    }    // this method calculates the angle between two bonds given coordinates of their atoms    public double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) {        Vector3d firstLine = new Vector3d();        firstLine.sub(a, b);        Vector3d secondLine = new Vector3d();        secondLine.sub(c, d);        Vector3d firstVec = new Vector3d(firstLine);        Vector3d secondVec = new Vector3d(secondLine);        return firstVec.angle(secondVec);    }    // this method store atoms and bonds in proper lists:    private void checkAndStore(int bondToStore, double bondOrder,                               ArrayList singleVec, ArrayList doubleVec,                               ArrayList cycloexVec, int a1,                               ArrayList atomVec, int sphere, boolean isBondInCycloex) {        if (!atomVec.contains(new Integer(a1))) {            if (sphere < 6) atomVec.add(new Integer(a1));        }        if (!cycloexVec.contains(new Integer(bondToStore))) {            if (isBondInCycloex) {                cycloexVec.add(new Integer(bondToStore));            }        }        if (bondOrder == 2.0) {            if (!doubleVec.contains(new Integer(bondToStore))) doubleVec.add(new Integer(bondToStore));        }        if (bondOrder == 1.0) {            if (!singleVec.contains(new Integer(bondToStore))) singleVec.add(new Integer(bondToStore));        }    }    // generic method for calculation of distance btw 2 atoms    private double calculateDistanceBetweenTwoAtoms(IAtom atom1, IAtom atom2) {        double distance;        Point3d firstPoint = atom1.getPoint3d();        Point3d secondPoint = atom2.getPoint3d();        distance = firstPoint.distance(secondPoint);        return distance;    }    // given a double bond    // this method returns a bond bonded to this double bond    private int getNearestBondtoAGivenAtom(Molecule mol, IAtom atom, org.openscience.cdk.interfaces.IBond bond) {        int nearestBond = 0;        double[] values;        double distance = 0;        IAtom atom0 = bond.getAtom(0);        List bondsAtLeft = mol.getConnectedBondsList(atom0);        int partial;        for (int i = 0; i < bondsAtLeft.size(); i++) {            IBond curBond = (IBond) bondsAtLeft.get(i);            values = calculateDistanceBetweenAtomAndBond(atom, curBond);            partial = mol.getBondNumber(curBond);            if (i == 0) {                nearestBond = mol.getBondNumber(curBond);                distance = values[0];            } else {                if (values[0] < distance) {                    nearestBond = partial;                }                /* XXX commented this out, because is has no effect                     *                     else {                        nearestBond = nearestBond;                    }*/            }        }        return nearestBond;    }    // method which calculated distance btw an atom and the middle point of a bond    // and returns distance and coordinates of middle point    private double[] calculateDistanceBetweenAtomAndBond(IAtom proton, org.openscience.cdk.interfaces.IBond theBond) {        Point3d middlePoint = theBond.get3DCenter();        Point3d protonPoint = proton.getPoint3d();        double[] values = new double[4];        values[0] = middlePoint.distance(protonPoint);        values[1] = middlePoint.x;        values[2] = middlePoint.y;        values[3] = middlePoint.z;        return values;    }    /**     * Gets the parameterNames attribute of the RDFProtonDescriptor     * object     *     * @return The parameterNames value     */    public String[] getParameterNames() {        String[] params = new String[2];        params[0] = "atomPosition";        params[1] = "checkAromaticity";        return params;    }    /**     * Gets the parameterType attribute of the RDFProtonDescriptor     * object     *     * @param name Description of the Parameter     * @return The parameterType value     */    public Object getParameterType(String name) {        if (name.equals("atomPosition")) return new Integer(0);        return Boolean.TRUE;    }}

⌨️ 快捷键说明

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