com.actelion.research.chem.prediction.GlobularityCalculator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.prediction;
import com.actelion.research.calc.SingularValueDecomposition;
import com.actelion.research.chem.Coordinates;
import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.conf.Conformer;
import com.actelion.research.chem.conf.ConformerSet;
import com.actelion.research.chem.conf.ConformerSetGenerator;
import org.openmolecules.chem.conf.gen.ConformerGenerator;
import java.util.Arrays;
public class GlobularityCalculator {
private static final boolean MINIMIZE = false;
/**
* Generates conformers from a 2D- or 3D-molecule and then calculates the globularity
* (flat=0, round=1) from the conformer's atom coordinates.
* @param mol molecule used to generate conformers
* @param maxConformerCount maximum number of conformers to generate
* @return globularity (flat=0, round=1)
*/
public static double assessGlobularity(StereoMolecule mol, int maxConformerCount) {
ConformerSet cs = new ConformerSetGenerator(maxConformerCount, ConformerGenerator.STRATEGY_LIKELY_RANDOM, MINIMIZE,0).generateConformerSet(mol);
return assessGlobularity(cs);
}
/**
* Generates conformers from a 2D- or 3D-molecule and then calculates the globularity
* (flat=0, round=1) from the conformer's atom coordinates.
* @param cs conformer set from which to calculate and average the globularity
* @return globularity (flat=0, round=1)
*/
public static double assessGlobularity(ConformerSet cs) {
if (cs == null || cs.size() == 0)
return Double.NaN;
double globularity = 0.0;
for (Conformer conf:cs)
globularity += assessGlobularityFromSVD(conf);
return globularity / cs.size();
}
/**
* Calculates the globularity of a conformer (flat=0, round=1) from 3D coordinates
* @param conf
* @return
*/
public static double assessGlobularityFromSVD(Conformer conf) {
int atomCount = conf.getSize();
Coordinates cog = new Coordinates(); // center of gravity
for (int i=0; i c.x)
xmin = c.x;
if (xmax < c.x)
xmax = c.x;
if (ymin > c.y)
ymin = c.y;
if (ymax < c.y)
ymax = c.y;
if (zmin > c.z)
zmin = c.z;
if (zmax < c.z)
zmax = c.z;
}
double dx = xmax - xmin;
double dy = ymax - ymin;
double dz = zmax - zmin;
return dx == 0.0 ? Double.NaN : dz / dx;
}
}