use of db.MonomersDB 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 db.MonomersDB in project Smiles2Monomers by yoann-dufresne.
the class ChainLearningTests method setUp.
@Before
public void setUp() throws Exception {
// Loading test monomers
MonomersDB premonos = new MonomersJsonLoader().loadFile("data_tests/monos.json");
// Creation of a subset of monos
this.monos = new MonomersDB();
this.monos.addObject("Dpr", premonos.getObject("Dpr"));
this.monos.addObject("D-Ser", premonos.getObject("D-Ser"));
// Loading test rules
RulesDB rules = RulesJsonLoader.loader.loadFile("data_tests/rules.json");
// Loading test residues
ResidueJsonLoader rjl = new ResidueJsonLoader(rules, this.monos);
this.families = rjl.loadFile("data_tests/res.json");
// Loading test polymers
PolymersJsonLoader pjl = new PolymersJsonLoader(premonos);
PolymersDB base = pjl.loadFile("data_tests/peps.json");
// Creation of learning base with only 1 polymer.
this.learningBase = new PolymersDB();
this.learningBase.addObject("AM-toxin II", base.getObject("306"));
// Construct reference
this.constructReference();
}
use of db.MonomersDB in project Smiles2Monomers by yoann-dufresne.
the class OverlapData method main.
public static void main(String[] args) {
// Norine Loading
MonomersJsonLoader monosLoader = new MonomersJsonLoader();
MonomersDB norMonos = monosLoader.loadFile("data/monomers.json");
PolymersJsonLoader loader = new PolymersJsonLoader(norMonos);
PolymersDB norine = loader.loadFile("data/peptides_clean.json");
// CCD Loading
MonomersDB ccdMonos = monosLoader.loadFile("data/pdbe_monos_min.json");
loader = new PolymersJsonLoader(ccdMonos);
PolymersDB ccd = loader.loadFile("data/pdbe_polys_clean.json");
// Norine smiles generation
HashMap<String, Polymer> polymers = new HashMap<>();
for (Polymer poly : norine.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(poly.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
polymers.put(smiles, poly);
}
// Test overlapping peptides
int overlap = 0;
for (Polymer poly : ccd.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(poly.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
if (polymers.containsKey(smiles)) {
System.out.println(polymers.get(smiles).getName());
overlap++;
}
}
System.out.println("Total peptides overlapping : " + overlap);
// Norine smiles generation
HashMap<String, Monomer> monomers = new HashMap<>();
for (Monomer mono : norMonos.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(mono.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
monomers.put(smiles, mono);
}
// Test overlapping peptides
overlap = 0;
for (Monomer mono : ccdMonos.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(mono.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
if (monomers.containsKey(smiles)) {
System.out.println(monomers.get(smiles).getName());
overlap++;
}
}
System.out.println("Total monomers overlapping : " + overlap + "/" + ccdMonos.size());
}
use of db.MonomersDB in project Smiles2Monomers by yoann-dufresne.
the class PolymersToCanonicalSmiles method modify.
public static void modify(String pepFile) {
// Loading
PolymersJsonLoader pjl = new PolymersJsonLoader(new MonomersDB());
PolymersDB db = pjl.loadFile(pepFile);
// transform all smiles
for (Polymer pep : db.getObjects()) {
IMolecule mol = pep.getMolecule();
String smiles = SmilesConverter.conv.mol2Smiles(mol);
pep.setSmiles(smiles);
}
// Saving
pjl.saveFile(db, pepFile);
}
use of db.MonomersDB in project Smiles2Monomers by yoann-dufresne.
the class ResiduesInfosGeneration method main.
public static void main(String[] args) {
MonomersDB monoDB = new MonomersJsonLoader().loadFile("data/monomers.json");
RulesDB rules = RulesJsonLoader.loader.loadFile("data/rules.json");
ResidueJsonLoader rjl = new ResidueJsonLoader(rules, monoDB);
FamilyDB families = rjl.loadFile("data/residues.json");
StringBuffer sb = new StringBuffer();
for (Family fam : families.getFamilies()) {
sb.append(fam.getName() + "\n");
sb.append("Norine link : http://bioinfo.lifl.fr/norine/res_amino.jsp?code=" + fam.getMonomers().get(0).getCode() + "\n");
sb.append("Num of residues : " + fam.getResidues().size() + "\n");
sb.append("Root residues (with max links) :" + "\n");
for (Residue res : fam.getRoots()) sb.append("\t" + res.getName() + " : " + res.getAtomicLinks().size() + "\n");
sb.append("\n");
}
File out = new File("results/infosMonos.txt");
try {
FileWriter fw = new FileWriter(out);
fw.write(sb.toString());
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations