Search in sources :

Example 1 with StereoMolecule

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];
}
Also used : IDCodeParser(com.actelion.research.chem.IDCodeParser) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 2 with StereoMolecule

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();
}
Also used : IDCodeParser(com.actelion.research.chem.IDCodeParser) SSSearcher(com.actelion.research.chem.SSSearcher) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 3 with StereoMolecule

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;
}
Also used : IDCodeParser(com.actelion.research.chem.IDCodeParser) SSSearcher(com.actelion.research.chem.SSSearcher) StereoMolecule(com.actelion.research.chem.StereoMolecule) Canonizer(com.actelion.research.chem.Canonizer)

Example 4 with StereoMolecule

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();
}
Also used : IntVec(com.actelion.research.util.datamodel.IntVec) StereoMolecule(com.actelion.research.chem.StereoMolecule) Canonizer(com.actelion.research.chem.Canonizer)

Example 5 with StereoMolecule

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;
    }
}
Also used : StereoMolecule(com.actelion.research.chem.StereoMolecule) IOException(java.io.IOException) Canonizer(com.actelion.research.chem.Canonizer)

Aggregations

StereoMolecule (com.actelion.research.chem.StereoMolecule)62 Point2D (java.awt.geom.Point2D)11 Canonizer (com.actelion.research.chem.Canonizer)8 IDCodeParser (com.actelion.research.chem.IDCodeParser)8 GeomFactory (com.actelion.research.share.gui.editor.geom.GeomFactory)7 SSSearcher (com.actelion.research.chem.SSSearcher)4 Rectangle2D (java.awt.geom.Rectangle2D)3 IDrawingObject (com.actelion.research.share.gui.editor.chem.IDrawingObject)2 IOException (java.io.IOException)2 Depictor2D (com.actelion.research.chem.Depictor2D)1 DrawingObjectList (com.actelion.research.chem.DrawingObjectList)1 CoordinateInventor (com.actelion.research.chem.coords.CoordinateInventor)1 IAtomPropertiesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomPropertiesDialog)1 IAtomQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomQueryFeaturesDialog)1 IBondQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IBondQueryFeaturesDialog)1 LittleEndianDataOutputStream (com.actelion.research.util.LittleEndianDataOutputStream)1 IntVec (com.actelion.research.util.datamodel.IntVec)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1