Search in sources :

Example 46 with IAtom

use of org.openscience.cdk.interfaces.IAtom in project Smiles2Monomers by yoann-dufresne.

the class ResidueCreator method createResidues.

/**
 * Create all residues from the argument monomers database according to rules entered in paramaters of the constructor.
 * @param monosDBName A monomers database.
 * @return All possible residues found.
 */
public FamilyDB createResidues(MonomersDB monosDB) {
    FamilyDB famDB = new FamilyDB();
    famDB.init(monosDB);
    for (Family family : famDB.getFamilies()) {
        this.residuesFromMonomers(family);
        for (Residue res : family.getResidues()) {
            IMolecule oldMol = res.getMolecule();
            res.setMol(new Molecule(AtomContainerManipulator.removeHydrogens(res.getMolecule())));
            IMolecule newMol = res.getMolecule();
            Map<IAtom, IAtom> conversion = new HashMap<>();
            int idx = 0;
            for (IAtom a : oldMol.atoms()) {
                if (!"H".equals(a.getSymbol())) {
                    conversion.put(a, newMol.getAtom(idx));
                    idx++;
                }
            }
            Map<IAtom, Rule> oldLinks = new HashMap<>(res.getAtomicLinks());
            res.getAtomicLinks().clear();
            for (IAtom oldA : oldLinks.keySet()) {
                Rule rule = oldLinks.get(oldA);
                res.addLink(conversion.get(oldA), rule);
            }
        }
    }
    return famDB;
}
Also used : Molecule(org.openscience.cdk.Molecule) IMolecule(org.openscience.cdk.interfaces.IMolecule) IMolecule(org.openscience.cdk.interfaces.IMolecule) Residue(model.Residue) HashMap(java.util.HashMap) Family(model.Family) FamilyDB(db.FamilyDB) Rule(model.Rule) IAtom(org.openscience.cdk.interfaces.IAtom)

Aggregations

IAtom (org.openscience.cdk.interfaces.IAtom)46 IMolecule (org.openscience.cdk.interfaces.IMolecule)16 IBond (org.openscience.cdk.interfaces.IBond)13 ArrayList (java.util.ArrayList)10 Residue (model.Residue)8 Rule (model.Rule)6 Bond (org.openscience.cdk.Bond)6 Molecule (org.openscience.cdk.Molecule)6 MappedChain (algorithms.isomorphism.chains.MappedChain)5 HashMap (java.util.HashMap)5 CDKException (org.openscience.cdk.exception.CDKException)5 Match (algorithms.utils.Match)4 Test (org.junit.Test)4 Chain (algorithms.isomorphism.chains.Chain)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Vector (java.util.Vector)3 Family (model.Family)3 JSONObject (org.json.simple.JSONObject)3 Before (org.junit.Before)3