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

📄 atomtetrahedralligandplacer3d.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	 *  A is sp2	 *	 *@param  aPoint  central point A (Point3d)	 *@param  bPoint  B (Point3d)	 *@param  cPoint  C (Point3d)	 *@param  length  bond length	 *@param  angle   angle between B(C)-A-X	 *@return         new Points (Point3d [])	 */	public Point3d[] calculate3DCoordinatesSP2_2(Point3d aPoint, Point3d bPoint, Point3d cPoint, double length, double angle) {		//logger.debug("3DCoordinatesSP_2");		Vector3d ca = new Vector3d();		Point3d newPoints[] = new Point3d[2];		Vector3d ba = new Vector3d(bPoint);		ba.sub(aPoint);		if (cPoint != null) {			ca.x = cPoint.x - aPoint.x;			ca.y = cPoint.y - aPoint.y;			ca.z = cPoint.z - aPoint.z;		} else {			ca.x = -1 * ba.x;			ca.y = -1 * ba.y;			ca.z = -1.5 * ba.z;		}		Vector3d crossProduct = new Vector3d();		crossProduct.cross(ba, ca);		Vector3d n1 = rotate(ba, crossProduct, 2 * angle);		n1.normalize();		n1.scale(length);		newPoints[0] = new Point3d(aPoint);		newPoints[0].add(n1);		Vector3d n2 = rotate(n1, ba, Math.PI);		n2.normalize();		n2.scale(length);		newPoints[1] = new Point3d(aPoint);		newPoints[1].add(n2);		n1 = null;		n2 = null;		ba = null;		ca = null;		return newPoints;	}	/**	 *  Gets the nonColinearVector attribute of the AtomLigandPlacer3D class	 *	 *@param  ab  Description of the Parameter	 *@return     The nonColinearVector value	 */	private Vector3d getNonColinearVector(Vector3d ab) {		Vector3d cr = new Vector3d();		cr.cross(ab, XV);		if (cr.length() > 0.00001) {			return XV;		} else {			return YV;		}	}	/**	 *  Rotates a vector around an axis	 *	 *@param  vector  vector to be rotated around axis	 *@param  axis    axis of rotation	 *@param  angle   angle to vector rotate around	 *@return         rotated vector	 *author:         egonw	 */	public static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) {		Matrix3d rotate = new Matrix3d();		rotate.set(new AxisAngle4d(axis.x, axis.y, axis.z, angle));		Vector3d result = new Vector3d();		rotate.transform(vector, result);		return result;	}	/**	 * Gets the distance between two atoms out of the parameter set.	 *	 *@param  id1            id of the paramter set for atom1 (atom1.getAtomTypeName())	 *@param  id2            id of the paramter set for atom2	 *@return                The distanceValue value	 *@exception  Exception  Description of the Exception	 */	private double getDistanceValue(String id1, String id2) throws Exception {		String dkey = "";		if (pSet.containsKey(("bond" + id1 + ";" + id2))) {			dkey = "bond" + id1 + ";" + id2;		} else if (pSet.containsKey(("bond" + id2 + ";" + id1))) {			dkey = "bond" + id2 + ";" + id1;		} else {//			logger.debug("DistanceKEYError:pSet has no key:" + id2 + " ; " + id1 + " take default bond length:" + DEFAULT_BOND_LENGTH_H);			return DEFAULT_BOND_LENGTH_H;		}		return ((Double) (((Vector) pSet.get(dkey)).get(0))).doubleValue();	}	/**	 *  Gets the angleKey attribute of the AtomPlacer3D object	 *	 *@param  id1            Description of the Parameter	 *@param  id2            Description of the Parameter	 *@param  id3            Description of the Parameter	 *@return                The angleKey value	 *@exception  Exception  Description of the Exception	 */	public double getAngleValue(String id1, String id2, String id3) throws Exception {		String akey = "";		if (pSet.containsKey(("angle" + id1 + ";" + id2 + ";" + id3))) {			akey = "angle" + id1 + ";" + id2 + ";" + id3;		} else if (pSet.containsKey(("angle" + id3 + ";" + id2 + ";" + id1))) {			akey = "angle" + id3 + ";" + id2 + ";" + id1;		} else if (pSet.containsKey(("angle" + id2 + ";" + id1 + ";" + id3))) {			akey = "angle" + id2 + ";" + id1 + ";" + id3;		} else if (pSet.containsKey(("angle" + id1 + ";" + id3 + ";" + id2))) {			akey = "angle" + id1 + ";" + id3 + ";" + id2;		} else if (pSet.containsKey(("angle" + id3 + ";" + id1 + ";" + id2))) {			akey = "angle" + id3 + ";" + id1 + ";" + id2;		} else if (pSet.containsKey(("angle" + id2 + ";" + id3 + ";" + id1))) {			akey = "angle" + id2 + ";" + id3 + ";" + id1;		} else {			System.out.println("AngleKEYError:Unknown angle " + id1 + " " + id2 + " " + id3 + " take default angle:" + TETRAHEDRAL_ANGLE);			return TETRAHEDRAL_ANGLE;		}		return ((Double) (((Vector) pSet.get(akey)).get(0))).doubleValue();	}	/**	 *  set Atoms in respect to stereoinformation.	 *	take placed neighbours to stereocenter	 *		create a x b	 *	     if right handed system (spatproduct >0)	 *			if unplaced is not up (relativ to stereocenter)	 *				n=b x a	 *	     Determine angle between n and possible ligand place points	 *	     if angle smaller than 90 degrees take this branch point	 *	 *@param  atomA         placed Atom - stereocenter	 *@param  ax            bond between stereocenter and unplaced atom	 *@param  atomB         neighbour of atomA (in plane created by atomA, atomB and atomC)	 *@param  atomC         neighbour of atomA	 *@param  branchPoints  the two possible placement points for unplaced atom (up and down) 	 *@return               int value of branch point position	 */	public int makeStereocenter(Point3d atomA, IBond ax, Point3d atomB, Point3d atomC, Point3d[] branchPoints) {				Vector3d b = new Vector3d((atomB.x - atomA.x), (atomB.y - atomA.y), (atomB.z - atomA.z));		Vector3d c = new Vector3d((atomC.x - atomA.x), (atomC.y - atomA.y), (atomC.z - atomA.z));		Vector3d n1 = new Vector3d();		Vector3d n2 = null;		n1.cross(b, c);		n1.normalize();		if (getSpatproduct(b, c, n1) >= 0) {			if (ax.getStereo() != CDKConstants.STEREO_BOND_UP_INV) {				n1.cross(c, b);				n1.normalize();			}		}		double dotProduct = 0;		for (int i = 0; i < branchPoints.length; i++) {			n2 = new Vector3d(branchPoints[0].x, branchPoints[0].y, branchPoints[0].z);			dotProduct = n1.dot(n2);			if (Math.acos(dotProduct / (n1.length() * n2.length())) < 1.6) {				return i;			}		}		return -1;	}	/**	 *  Gets the spatproduct of three vectors	 *	 *@param  a  vector a	 *@param  b  vector b	 *@param  c  vector c	 *@return    double value of the spatproduct	 */	public double getSpatproduct(Vector3d a, Vector3d b, Vector3d c) {		return (c.x * (b.y * a.z - b.z * a.y) + c.y * (b.z * a.x - b.x * a.z) + c.z * (b.x * a.y - b.y * a.x));	}	/**	 *  Calculates the torsionAngle of a-b-c-d 	 *	 *@param  a  Point3d	 *@param  b  Point3d	 *@param  c  Point3d	 *@param  d  Point3d	 *@return    The torsionAngle value	 */	public double getTorsionAngle(Point3d a, Point3d b, Point3d c, Point3d d) {		Vector3d ab = new Vector3d(a.x - b.x, a.y - b.y, a.z - b.z);		Vector3d cb = new Vector3d(c.x - b.x, c.y - b.y, c.z - b.z);		Vector3d dc = new Vector3d(d.x - c.x, d.y - c.y, d.z - c.z);		Vector3d bc = new Vector3d(b.x - c.x, b.y - c.y, b.z - c.z);		Vector3d n1 = new Vector3d();		Vector3d n2 = new Vector3d();		n1.cross(ab, cb);		if (getSpatproduct(ab, cb, n1) > 0) {			n1.cross(cb, ab);		}		n1.normalize();		n2.cross(dc, bc);		if (getSpatproduct(dc, bc, n2) < 0) {			n2.cross(bc, dc);		}		n2.normalize();		return n1.dot(n2);	}	/**	 *  Gets all placed neighbouring atoms of a atom	 *	 *@param  atom  central atom (Atom)	 *@param  ac    the molecul	 *@return       all connected and placed atoms to the central atom	 *      ((AtomContainer)	 */	public IAtomContainer getPlacedAtomsInAtomContainer(IAtom atom, IAtomContainer ac) {		java.util.List bonds = ac.getConnectedBondsList(atom);		IAtomContainer connectedAtoms = new org.openscience.cdk.AtomContainer();		IAtom connectedAtom = null;		for (int i = 0; i < bonds.size(); i++) {			connectedAtom = ((IBond)bonds.get(i)).getConnectedAtom(atom);			if (connectedAtom.getFlag(CDKConstants.ISPLACED)) {				connectedAtoms.addAtom(connectedAtom);			}		}		return connectedAtoms;	}	/**	 *  Gets the unsetAtomsInAtomContainer attribute of the	 *  AtomTetrahedralLigandPlacer3D object	 *	 *@param  atom  Description of the Parameter	 *@param  ac    Description of the Parameter	 *@return       The unsetAtomsInAtomContainer value	 */	public IAtomContainer getUnsetAtomsInAtomContainer(IAtom atom, IAtomContainer ac) {		java.util.List atoms = ac.getConnectedAtomsList(atom);		IAtomContainer connectedAtoms = new org.openscience.cdk.AtomContainer();		for (int i = 0; i < atoms.size(); i++) {			IAtom curAtom = (IAtom)atoms.get(i);			if (!curAtom.getFlag(CDKConstants.ISPLACED)){//&& atoms[i].getPoint3d() == null) {				connectedAtoms.addAtom(curAtom);			}		}		return connectedAtoms;	}	public boolean hasUnsetNeighbour(IAtom atom, IAtomContainer ac) {		java.util.List atoms = ac.getConnectedAtomsList(atom);		for (int i = 0; i < atoms.size(); i++) {			IAtom curAtom = (IAtom)atoms.get(i);			if (!curAtom.getFlag(CDKConstants.ISPLACED)) {//&& atoms[i].getPoint3d() == null) {				return true;			}		}		return false;	}	/**	 *  Returns a placed neighbouring atom of a central atom atomA, which is not	 *  atomB	 *	 *@param  atomA  central atom (Atom)	 *@param  atomB  atom connected to atomA (Atom)	 *@param  ac     molecule	 *@return        returns a connected atom (Atom)	 */	public IAtom getPlacedHeavyAtomInAtomContainer(IAtom atomA, IAtom atomB, IAtomContainer ac) {		java.util.List atoms = ac.getConnectedAtomsList(atomA);		IAtom atom=null;		for (int i = 0; i < atoms.size(); i++) {			IAtom curAtom = (IAtom)atoms.get(i);			if (curAtom.getFlag(CDKConstants.ISPLACED) && !curAtom.getSymbol().equals("H")					 && curAtom != atomB) {				return curAtom;			}		}		return atom;	}}

⌨️ 快捷键说明

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