use of model.Polymer 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 model.Polymer 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 model.Polymer in project Smiles2Monomers by yoann-dufresne.
the class MonomericSpliting method computeCoverages.
public Coverage[] computeCoverages(PolymersDB polDB) {
Coverage[] covs = new Coverage[polDB.size()];
int idx = 0;
for (Polymer pol : polDB.getObjects()) {
this.computeCoverage(pol);
covs[idx] = this.getCoverage();
idx += 1;
}
return covs;
}
use of model.Polymer in project Smiles2Monomers by yoann-dufresne.
the class PlanarityTest method main.
public static void main(String[] args) {
String pepDBname = "datas/peptides.csv";
// Loading databases
PolymersJsonLoader pcl = new PolymersJsonLoader(new MonomersDB());
PolymersDB pepDB = pcl.loadFile(pepDBname);
// Tools
Planarity pt = new Planarity();
for (Polymer pep : pepDB.getObjects()) {
System.out.println(pep.getName() + " : ");
IMolecule mol = null;
try {
mol = SmilesConverter.conv.transform(pep.getSmiles());
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + pep.getName() + " id:" + pep.getId());
continue;
}
SimpleGraph g = MoleculeGraphs.getMoleculeGraph(mol);
System.out.println("planar : " + pt.isPlanar(g) + "\n");
}
}
use of model.Polymer in project Smiles2Monomers by yoann-dufresne.
the class PolymersTreeWidths method main.
public static void main(String[] args) {
if (args.length < 1) {
System.err.println("Command line : java main.PeptidesTreeWidths <peptidesFile> [outfile]");
System.exit(-1);
}
// Parse arguments
String pepDBname = args[0];
BufferedWriter bw = null;
if (args.length > 1) {
File out = new File(args[1]);
if (out.exists())
out.delete();
try {
bw = new BufferedWriter(new FileWriter(out));
bw.write("peptide;treewidth\n");
} catch (IOException e) {
e.printStackTrace();
}
}
// Loading databases
MonomersDB monoDB = new MonomersDB();
PolymersJsonLoader pcl = new PolymersJsonLoader(monoDB);
PolymersDB pepDB = pcl.loadFile(pepDBname);
// Tools for treewidth
MolTreeWidth mtw = new MolTreeWidth();
for (Polymer pep : pepDB.getObjects()) {
int tw;
try {
tw = mtw.calculateTreeWidth(SmilesConverter.conv.transform(pep.getSmiles()));
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + pep.getName() + " id:" + pep.getId());
continue;
}
if (args.length > 1) {
try {
bw.write(pep.getName() + ";" + tw + "\n");
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println(pep.getName() + " : " + tw);
}
}
if (args.length > 1) {
try {
bw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Aggregations