All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.chem.conf.BondAngleSet Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
/*
* Copyright (c) 1997 - 2016
* Actelion Pharmaceuticals Ltd.
* Gewerbestrasse 16
* CH-4123 Allschwil, Switzerland
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the documentation
*    and/or other materials provided with the distribution.
* 3. Neither the name of the the copyright holder nor the
*    names of its contributors may be used to endorse or promote products
*    derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @author Thomas Sander
*/

package com.actelion.research.chem.conf;

import com.actelion.research.chem.Molecule;
import com.actelion.research.chem.RingCollection;
import com.actelion.research.chem.StereoMolecule;

public class BondAngleSet {
	private static float TO_RADIAN = (float)Math.PI/180;

	private final StereoMolecule	mMol;
	private final BondLengthSet		mBondLengthSet;
	private final float[][][]		mBondAngle;
	private final int[]				mDefinedAngleCount,mTinyRingSizeSum;
	private final float[]			mDefinedAngleSum;

	/**
	 * Calculates and caches a list of bond angle estimates for any two neighbours
	 * of any atom of the molecule.
	 * Internally it requires a valid BondLengthSet of this molecule,
	 * which can be passed if there is already one available. Otherwise,
	 * one is created internally.
	 * @param mol
	 * @param set null or a valid BondLengthSet of the molecule
	 */
	public BondAngleSet(final StereoMolecule mol, final BondLengthSet set) {
		// initialize bond angle arrays
		mBondLengthSet = (set == null) ? new BondLengthSet(mol) : set;
		mMol = mol;

		mBondAngle = new float[mMol.getAtoms()][][];
		for (int atom=0; atom 4) {
				for (int i=1; i 0))) {
				if (connAtoms > 2) {
					float angle;
					if (mDefinedAngleCount[atom] == 1) {
						if (mMol.getAtomicNo(atom) <= 14)   // up to Si
							angle = (2f * (float)Math.PI - mDefinedAngleSum[atom]) / 2.0f;
						else
							angle = calculateRemainingTetrahedralAngle(mDefinedAngleSum[atom]);
						}
					else {
						// mDefinedAngleCount==2: we assume two annelated aromatic rings
						// (and not spiro, which theoretically might be possible with e.g. sulphur)
						angle = 2f * (float)Math.PI - mDefinedAngleSum[atom];
						if (connAtoms > 3) {
							// strange case with P,S,Se,etc sharing two/three annelated flat rings and additional substituent(s) sticking out of plane
							if (mDefinedAngleCount[atom] == 2) {  // we need to find the third angle in the plane
								boolean[] isMissingIndex = new boolean[mMol.getAllConnAtoms(atom)];
								for (int i=1; i 10) ? 109.47f * (float)Math.PI/180.0f
							: (mMol.getAtomPi(atom) == 2)   ? (float)Math.PI
				            :  mMol.isFlatNitrogen(atom)    ? 120.00f * (float)Math.PI/180.0f
							: (mMol.getAtomPi(atom) == 0)   ? 109.47f * (float)Math.PI/180.0f
															: 120.00f * (float)Math.PI/180.0f;
				for (int i=1; i Math.abs(maxForce)) {
				    maxForce = force;
					maxForceIndex = i;
					}
				}
			float factor = (float)Math.exp(-5*(float)cycle/cycles);
			direction[maxForceIndex] += factor * maxForce;
			}

		for (int i=0; i 2*Math.PI)
	            angle -= 2*Math.PI;
		    setBondAngle(ringAtom[i], ringBond[im1], ringBond[i], angle);
			}

/*	    double sx = 0.0;
	    double sy = 0.0;
	    System.out.println("------------------");
		for (int i=0; i 2*Math.PI)
	            angle -= 2*Math.PI;

	        System.out.println("optAngle:"+optAngle[i]+"; angle("+i+"):"+com.actelion.research.util.DoubleFormat.toString(angle));
		    sx += mBondLengthSet.getLength(ringBond[i]) * Math.sin(direction[i]);
		    sy += mBondLengthSet.getLength(ringBond[i]) * Math.cos(direction[i]);
			}
		System.out.println("dsx:"+com.actelion.research.util.DoubleFormat.toString(sx));
		System.out.println("dsy:"+com.actelion.research.util.DoubleFormat.toString(sy));
*/		}

	private int getRingStrainClass(int atom) {
		// the ring strain class of an atom is the sorted list
		// of non-zero tinyRingSizeSums of all attached bonds
		boolean[] handled = new boolean[mMol.getConnAtoms(atom)];
		int strainClass = 0;
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy