use of algorithms.ResidueCreator in project Smiles2Monomers by yoann-dufresne.
the class ResidueCreatorTests method setUp.
@Before
public void setUp() throws Exception {
if (this.fam != null)
return;
this.monos = new MonomersDB();
Monomer mono = new Monomer("bOH-Tyr", "bOH-Tyr", "c1cc(ccc1C(C(C(=O)O)N)O)O");
monos.addObject(mono.getId(), mono);
mono = new Monomer("Tyr", "Tyr", "c1cc(ccc1CC(C(=O)O)N)O");
monos.addObject(mono.getId(), mono);
this.rules = RulesJsonLoader.loader.loadFile("data_tests/rules.json");
this.creator = new ResidueCreator(this.rules);
this.families = this.creator.createResidues(this.monos);
this.fam = null;
try {
this.fam = this.families.getObject("Tyr");
} catch (NullPointerException e) {
e.printStackTrace();
}
this.residues = this.fam.getResidues();
}
use of algorithms.ResidueCreator in project Smiles2Monomers by yoann-dufresne.
the class PreComputation method main.
public static void main(String[] args) {
// ----------------- Parameters ---------------------------
String rulesDBName = "data/rules.json";
String monosDBName = "data/monomers.json";
String jsonPolymers = "data/learning.json";
String serialFolder = "data/serials/";
String jsonResidues = "data/residues.json";
String jsonChains = "data/chains.json";
int markovianSize = 3;
// Parsing
for (int idx = 0; idx < args.length; idx++) {
if (args[idx].startsWith("-")) {
switch(args[idx]) {
case "-rul":
rulesDBName = args[idx + 1];
break;
case "-mono":
monosDBName = args[idx + 1];
break;
case "-poly":
jsonPolymers = args[idx + 1];
break;
case "-res":
jsonResidues = args[idx + 1];
break;
case "-cha":
jsonChains = args[idx + 1];
break;
case "-serial":
serialFolder = args[idx + 1];
break;
case "-markovian":
markovianSize = new Integer(args[idx + 1]);
break;
default:
System.err.println("Wrong option " + args[idx]);
System.exit(1);
break;
}
idx++;
} else {
System.err.println("Wrong parameter " + args[idx]);
System.exit(1);
}
}
// File existence
File file = new File(rulesDBName);
if (!file.exists()) {
System.err.println("No file at " + rulesDBName);
System.exit(1);
}
file = new File(monosDBName);
if (!file.exists()) {
System.err.println("No file at " + monosDBName);
System.exit(1);
}
file = new File(jsonPolymers);
if (!file.exists()) {
System.err.println("No file at " + jsonPolymers);
System.exit(1);
}
// ------------------- Loadings ------------------------
System.out.println("--- Loading ---");
RulesDB rules = RulesJsonLoader.loader.loadFile(rulesDBName);
MonomersDB monos = new MonomersJsonLoader(true).loadFile(monosDBName);
PolymersJsonLoader pjl = new PolymersJsonLoader(monos, false);
PolymersDB learningBase = pjl.loadFile(jsonPolymers);
// ----------------- Serializations --------------------
System.out.println("--- Data serialisation ---");
File folder = new File(serialFolder);
if (!folder.exists())
folder.mkdir();
MonomersSerialization ms = new MonomersSerialization();
ms.serialize(monos, serialFolder + "monos.serial");
// ----------------- residues --------------------------
ResidueCreator rc = new ResidueCreator(rules);
rc.setVerbose(false);
System.out.println("--- Residues creation ---");
FamilyDB families = rc.createResidues(monos);
System.out.println("--- Saving residues ---");
ResidueJsonLoader rjl = new ResidueJsonLoader(rules, monos);
rjl.saveFile(families, jsonResidues);
// ----------------- chains ----------------------------
System.out.println("--- Learning chains ---");
// Adapt residue structures
for (Residue res : families.getResidues().getObjects()) res.explicitToImplicitHydrogens();
ChainLearning learning = new ChainLearning(learningBase);
learning.setMarkovianSize(markovianSize);
learning.learn(families);
// --- Save ---
System.out.println("--- Saving chains ---");
FamilyChainIO fcio = new FamilyChainIO(families);
fcio.saveFile(learning.getDb(), jsonChains);
System.out.println("--- Ended ---");
}
use of algorithms.ResidueCreator 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