use of model.Monomer 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 model.Monomer in project Smiles2Monomers by yoann-dufresne.
the class ResidueJsonLoader method objectFromJson.
@Override
protected Family objectFromJson(JSONObject obj) {
Residue res = new Residue((String) obj.get("mono"), (String) obj.get("smarts"), true);
res.setIdx(((Number) obj.get("id")).intValue());
JSONArray array = (JSONArray) obj.get("links");
for (Object o : array) {
JSONObject jso = (JSONObject) o;
String name = (String) jso.get("name");
Rule rule = null;
try {
rule = this.rules.getObject(name);
} catch (NullPointerException e) {
System.err.println("Unknown link " + name);
}
int idx = ((Number) jso.get("atom")).intValue();
IAtom ia = res.getMolecule().getAtom(idx);
res.addLink(ia, rule);
}
// Family construction
Family fam = new Family();
try {
for (String name : ((String) obj.get("family")).split("€")) {
Monomer m = this.monos.getObject(name);
fam.addMonomer(m);
}
} catch (NullPointerException e) {
System.err.println("Unloaded residue " + res.getMonoName());
}
fam.addResidue(res);
for (Object jso : (JSONArray) obj.get("depandances")) {
int idx = ((Number) jso).intValue();
fam.addDependance(idx, new Integer(res.getId()));
}
return fam;
}
use of model.Monomer in project Smiles2Monomers by yoann-dufresne.
the class IsomorphismTests method setUp.
@Before
public void setUp() throws Exception {
// Database
Monomer[] monos = new Monomer[1];
Polymer pepTest = new Polymer(0, "malformin A1", "O=C1NC2C(=O)NC(C(=O)NC(C(=O)NC(C(=O)NC1CSSC2)C(C)CC)CC(C)C)C(C)C", monos);
// Extensions
IAtom a = new Atom("C");
IBond b1 = new Bond(new Atom("S"), a, Order.SINGLE);
this.ext1 = new Extension(b1);
a = new Atom("C");
IAtom a2 = new Atom("C");
IBond b2 = new Bond(a, a2, Order.SINGLE);
this.ext2 = new Extension(b2);
// Mapped blocs
this.mb0 = new MappedChain(pepTest, null, new ArrayList<Integer>(), new ArrayList<Integer>(), new ArrayList<MatchingType>(), new HashMap<Integer, Integer>());
// For blocs Tests
this.bloc = new Chain("S,0,c,0,0,-1,-1;c,0,c,0,0,-1,1");
}
use of model.Monomer in project Smiles2Monomers by yoann-dufresne.
the class LoadersTests method addaTest.
@Test
public void addaTest() {
String smiles = "CC(C=C(C)C=CC(C(C)C(=O)O)N)C(CC1=CC=CC=C1)OC";
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(smiles);
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + smiles);
}
Monomer adda = new Monomer("Adda", "Adda", smiles);
IMolecule mol = adda.getMolecule();
Assert.assertTrue("O=C(O)C(C)C(N)C=CC(=CC(C)C(OC)Cc1ccccc1)C".equals(SmilesConverter.conv.mol2Smiles(mol)));
}
use of model.Monomer 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());
}
Aggregations