use of algorithms.isomorphism.chains.ChainLearning in project Smiles2Monomers by yoann-dufresne.
the class ChainLearningTests method generateSize3Test.
@Test
public void generateSize3Test() {
// Computing
ChainLearning learning = new ChainLearning(this.learningBase);
learning.setMarkovianSize(3);
learning.learn(this.families);
FrequencesIndex frequences = learning.getFrequence();
ChainsIndex chains = learning.getAllChains();
// Verification
for (String pattern : chains.keySet()) {
Chain chain = chains.get(pattern);
if (chain.getSize() != 3)
continue;
if (!this.size3Frequencies.containsKey(pattern) || this.size3Frequencies.get(pattern) != frequences.get(pattern) || !this.size3Blocs.get(pattern).equals(chain.getSerial())) {
System.out.println(pattern);
System.out.println(chain.getSerial());
fail(pattern + " : " + frequences.get(pattern) + " -> " + this.size3Blocs.get(pattern));
}
}
Assert.assertTrue(frequences.size() == 19);
}
use of algorithms.isomorphism.chains.ChainLearning in project Smiles2Monomers by yoann-dufresne.
the class ChainLearningTests method loadTest.
/**/
@Test
public void loadTest() {
// Computing
ChainLearning learning = new ChainLearning(this.learningBase);
learning.setMarkovianSize(3);
learning.learn(this.families);
ChainsDB db = learning.getDb();
FamilyChainIO io = new FamilyChainIO(this.families);
io.saveFile(db, "data_tests/chains.json");
ChainsDB loaded = io.loadFile("data_tests/chains.json");
if (loaded.getObjects().size() != db.getObjects().size())
fail("Not the same number of objects");
FamilyChainsDB fc = db.getObjects().get(0);
FamilyChainsDB fcLoaded = loaded.getObjects().get(0);
if (fc.getRootChains().size() != fcLoaded.getRootChains().size())
fail("Root chain number different");
for (Residue res : fc.getFamily().getResidues()) {
if (fc.getAdds(res).size() != fcLoaded.getAdds(res).size())
fail("Adds of " + res.getName() + "are not correctly loaded");
}
Assert.assertTrue(true);
}
use of algorithms.isomorphism.chains.ChainLearning 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);
}
Aggregations