use of com.actelion.research.chem.IDCodeParser 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.IDCodeParser 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.IDCodeParser 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.IDCodeParser in project openchemlib by Actelion.
the class ReactionEncoder method decodeProducts.
/**
* Generates an array of all products of the encoded reaction string as bytes.
* If the string includes atom coordinates, these are used.
* @param rxnBytes
* @return null or StereoMolecule array with at least one molecule
*/
public static StereoMolecule[] decodeProducts(byte[] rxnBytes) {
if (rxnBytes == null || rxnBytes.length == 0)
return null;
int productIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.PRODUCT_IDENTIFIER);
if (productIndex == 0)
return null;
int productEnd = ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.OBJECT_DELIMITER, productIndex);
if (productEnd == -1)
productEnd = rxnBytes.length;
if (productIndex == productEnd)
return null;
byte[] coords = null;
int coordsIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.OBJECT_DELIMITER, productEnd + 1);
if (coordsIndex != 0) {
int reactantIndex = 0;
while (reactantIndex < productIndex) {
// advance coordinate index one step for every reactant
reactantIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.MOLECULE_DELIMITER, reactantIndex);
coordsIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.MOLECULE_DELIMITER, coordsIndex);
}
coords = rxnBytes;
}
ArrayList<StereoMolecule> productList = new ArrayList<StereoMolecule>();
while (productIndex != -1 && productIndex < productEnd) {
StereoMolecule product = new IDCodeParser().getCompactMolecule(rxnBytes, coords, productIndex, coordsIndex);
if (product.getAllAtoms() != 0)
productList.add(product);
productIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.MOLECULE_DELIMITER, productIndex);
coordsIndex = 1 + ArrayUtils.indexOf(rxnBytes, (byte) ReactionEncoder.MOLECULE_DELIMITER, coordsIndex);
}
return productList.size() == 0 ? null : productList.toArray(new StereoMolecule[0]);
}
use of com.actelion.research.chem.IDCodeParser in project openchemlib by Actelion.
the class DruglikenessPredictor method assessDruglikeness.
public double assessDruglikeness(StereoMolecule testMolecule, ThreadMaster threadMaster) {
ParameterizedStringList detail = new ParameterizedStringList();
if (!sInitialized) {
detail.add("Druglikeness predictor not properly initialized.", ParameterizedStringList.cStringTypeText);
return cDruglikenessUnknown;
}
detail.add("Found sub-structure fragments and their contributions:", ParameterizedStringList.cStringTypeText);
detail.add("(yellow atoms carry at least one more substituent)", ParameterizedStringList.cStringTypeText);
double nastyIncrementSum = 0.0;
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++) {
if (threadMaster != null && threadMaster.threadMustDie())
return cDruglikenessUnknown;
Thread.yield();
new IDCodeParser(false).parse(fragment, sIncrementTable.getFragment(i));
sss.setMol(fragment, testMolecule);
if (sss.isFragmentInMolecule()) {
double increment = sIncrementTable.getIncrement(i);
if (increment < -1)
nastyIncrementSum += increment;
else {
incrementSum += increment;
fragmentCount++;
}
detail.add(sIncrementTable.getFragment(i), ParameterizedStringList.cStringTypeIDCode);
detail.add(Double.toString(increment), ParameterizedStringList.cStringTypeDouble);
}
}
if (fragmentCount == 0)
return -1;
double druglikeness = nastyIncrementSum + incrementSum / Math.sqrt(fragmentCount);
// correct cut-off by also treating molecules
// with more than 50 found fragments as more drug-like
druglikeness = druglikeness + 0.0625 * (fragmentCount - 40);
mDetail = detail;
return druglikeness;
}
Aggregations