use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class HoseCodeCreator method getHoseCodesFromDiaID.
public static String[] getHoseCodesFromDiaID(String diastereotopicID, int maxSphereSize, int type) {
// We need atom coordinates to properly determine stereo features of fragments later
StereoMolecule molecule = new IDCodeParser(true).getCompactMolecule(diastereotopicID);
// One of the atom has to be marked !
int atomID = -1;
for (int i = 0; i < molecule.getAllAtoms(); i++) {
// we need to find the marked atom
String atomCustomLabel = molecule.getAtomCustomLabel(i);
if (atomCustomLabel != null && atomCustomLabel.endsWith("*"))
;
atomID = i;
break;
}
if (atomID >= 0) {
return HoseCodeCreator.getHoseCodesForAtom(molecule, atomID, maxSphereSize, type);
}
return new String[0];
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class DruglikenessPredictor method getDruglikenessString.
public String getDruglikenessString(StereoMolecule testMolecule) {
if (!sInitialized)
return "Druglikeness predictor not properly initialized.";
double incrementSum = 0.0;
int fragmentCount = 0;
SSSearcher sss = new SSSearcher(SSSearcher.cMatchAtomCharge);
StereoMolecule fragment = new StereoMolecule();
for (int i = 0; i < sIncrementTable.getSize(); i++) {
new IDCodeParser(false).parse(fragment, sIncrementTable.getFragment(i));
sss.setMol(fragment, testMolecule);
if (sss.isFragmentInMolecule()) {
incrementSum += sIncrementTable.getIncrement(i);
fragmentCount++;
}
}
double druglikeness = (fragmentCount == 0) ? -1 : incrementSum / Math.sqrt(fragmentCount);
return druglikeness + "\t" + fragmentCount + "\t" + testMolecule.getAtoms();
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class ToxicityPredictor method assessRisk.
public int assessRisk(StereoMolecule testMolecule, int riskType, ThreadMaster threadMaster) {
if (!sInitialized)
return cUnknownRisk;
if (sRiskMolecules[riskType].contains(new Canonizer(testMolecule).getIDCode()))
return cHighRisk;
SSSearcher sss = new SSSearcher(SSSearcher.cMatchAtomCharge);
StereoMolecule fragment = new StereoMolecule();
for (int i = 0; i < sHighRiskFragments[riskType].size(); i++) {
if (threadMaster != null && threadMaster.threadMustDie())
return cUnknownRisk;
Thread.yield();
new IDCodeParser(false).parse(fragment, sHighRiskFragments[riskType].get(i));
sss.setMol(fragment, testMolecule);
if (sss.isFragmentInMolecule())
return cHighRisk;
}
for (int i = 0; i < sLowRiskFragments[riskType].size(); i++) {
if (threadMaster != null && threadMaster.threadMustDie())
return cUnknownRisk;
Thread.yield();
new IDCodeParser(false).parse(fragment, sLowRiskFragments[riskType].get(i));
sss.setMol(fragment, testMolecule);
if (sss.isFragmentInMolecule())
return cLowRisk;
}
return cNoRisk;
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class DescriptorHandlerHashedCFp method createDescriptor.
/**
* This descriptor requires proper up/down bonds, because it encodes stereo parities.
* If a passed molecule is generated from idcode parsing, make sure that coordinates
* and up/down/bonds are available, i.e. that the IDCodeParser was instantiated with
* the respective option.
*/
public int[] createDescriptor(StereoMolecule mol) {
if (mol == null)
return null;
mol.ensureHelperArrays(Molecule.cHelperRings);
StereoMolecule fragment = new StereoMolecule(mol.getAtoms(), mol.getBonds());
// byte[] descriptor = new byte[DESCRIPTOR_SIZE];
int len = DESCRIPTOR_SIZE / Integer.SIZE;
IntVec iv = new IntVec(len);
int[] atomList = new int[mol.getAtoms()];
boolean[] atomMask = new boolean[mol.getAtoms()];
for (int rootAtom = 0; rootAtom < mol.getAtoms(); rootAtom++) {
if (rootAtom != 0)
Arrays.fill(atomMask, false);
int min = 0;
int max = 0;
for (int sphere = 0; sphere < SPHERE_COUNT && max < mol.getAtoms(); sphere++) {
if (max == 0) {
atomList[0] = rootAtom;
atomMask[rootAtom] = true;
max = 1;
} else {
int newMax = max;
for (int i = min; i < max; i++) {
int atom = atomList[i];
for (int j = 0; j < mol.getConnAtoms(atom); j++) {
int connAtom = mol.getConnAtom(atom, j);
if (!atomMask[connAtom]) {
atomMask[connAtom] = true;
atomList[newMax++] = connAtom;
}
}
}
min = max;
max = newMax;
}
mol.copyMoleculeByAtoms(fragment, atomMask, true, null);
// take fragment as it is
String idcode = new Canonizer(fragment).getIDCode();
int h = BurtleHasher.hashlittle(idcode, HASH_INIT);
h = (h & BurtleHasher.hashmask(HASH_BITS));
iv.setBit(h);
// System.out.println("atom:"+rootAtom+"\tsphere:"+sphere+"\thash:"+h+"\t"+idcode);
}
}
return iv.get();
}
use of com.actelion.research.chem.StereoMolecule in project openchemlib by Actelion.
the class CompoundFileParser method updateIDCodeAndCoords.
private void updateIDCodeAndCoords() {
if (!mIDCodeUpToDate) {
try {
StereoMolecule mol = new StereoMolecule(getMolecule());
mol.normalizeAmbiguousBonds();
mol.canonizeCharge(true);
Canonizer canonizer = new Canonizer(mol);
mIDCode = canonizer.getIDCode();
mCoords = canonizer.getEncodedCoordinates();
} catch (Exception e) {
mIDCode = null;
mCoords = null;
}
mIDCodeUpToDate = true;
}
}
Aggregations