Search in sources :

Example 6 with FamilyDB

use of db.FamilyDB in project Smiles2Monomers by yoann-dufresne.

the class ContractedGraphTests method setUp.

@Before
public void setUp() throws Exception {
    MonomersDB monos = new MonomersJsonLoader().loadFile("data_tests/monos.json");
    PolymersDB peps = new PolymersJsonLoader(monos).loadFile("data_tests/peps.json");
    RulesDB rules = RulesJsonLoader.loader.loadFile("data_tests/rules.json");
    ResidueCreator rc = new ResidueCreator(rules);
    FamilyDB families = rc.createResidues(monos);
    ChainLearning cl = new ChainLearning(peps);
    cl.setMarkovianSize(3);
    cl.learn(families);
    ChainsDB chains = cl.getDb();
    MonomericSpliting ms = new MonomericSpliting(families, chains, 2, 2, 3);
    Polymer pol = peps.getObject("633");
    ms.computeCoverage(pol);
    this.coverage = ms.getCoverage();
    this.coverage.calculateGreedyCoverage();
    this.contractedGraph = new ContractedGraph(coverage);
}
Also used : RulesDB(db.RulesDB) MonomericSpliting(algorithms.MonomericSpliting) MonomersJsonLoader(io.loaders.json.MonomersJsonLoader) PolymersDB(db.PolymersDB) MonomersDB(db.MonomersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) ChainsDB(algorithms.isomorphism.chains.ChainsDB) Polymer(model.Polymer) ResidueCreator(algorithms.ResidueCreator) FamilyDB(db.FamilyDB) ChainLearning(algorithms.isomorphism.chains.ChainLearning) Before(org.junit.Before)

Example 7 with FamilyDB

use of db.FamilyDB 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

FamilyDB (db.FamilyDB)7 MonomersDB (db.MonomersDB)5 RulesDB (db.RulesDB)5 MonomersJsonLoader (io.loaders.json.MonomersJsonLoader)5 ResidueJsonLoader (io.loaders.json.ResidueJsonLoader)5 File (java.io.File)5 PolymersDB (db.PolymersDB)4 PolymersJsonLoader (io.loaders.json.PolymersJsonLoader)4 Residue (model.Residue)4 MonomersSerialization (io.loaders.serialization.MonomersSerialization)3 Family (model.Family)3 MonomericSpliting (algorithms.MonomericSpliting)2 ResidueCreator (algorithms.ResidueCreator)2 ChainLearning (algorithms.isomorphism.chains.ChainLearning)2 ChainsDB (algorithms.isomorphism.chains.ChainsDB)2 Coverage (algorithms.utils.Coverage)2 Coverages2HTML (io.html.Coverages2HTML)2 ImagesGeneration (io.imgs.ImagesGeneration)2 ColorsMap (io.imgs.PictureCoverageGenerator.ColorsMap)2 CoveragesJsonLoader (io.loaders.json.CoveragesJsonLoader)2