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);
}
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;
}
Aggregations