Search in sources :

Example 1 with Monomer

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();
}
Also used : MonomersDB(db.MonomersDB) ResidueCreator(algorithms.ResidueCreator) Monomer(model.Monomer) Before(org.junit.Before)

Example 2 with Monomer

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;
}
Also used : JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) Residue(model.Residue) Family(model.Family) JSONObject(org.json.simple.JSONObject) Rule(model.Rule) Monomer(model.Monomer) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 3 with Monomer

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");
}
Also used : Extension(algorithms.isomorphism.chains.Extension) MappedChain(algorithms.isomorphism.chains.MappedChain) Chain(algorithms.isomorphism.chains.Chain) MappedChain(algorithms.isomorphism.chains.MappedChain) HashMap(java.util.HashMap) IBond(org.openscience.cdk.interfaces.IBond) ArrayList(java.util.ArrayList) Polymer(model.Polymer) Monomer(model.Monomer) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.silent.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Before(org.junit.Before)

Example 4 with Monomer

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)));
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) Monomer(model.Monomer) Test(org.junit.Test)

Example 5 with Monomer

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());
}
Also used : MonomersJsonLoader(io.loaders.json.MonomersJsonLoader) HashMap(java.util.HashMap) PolymersDB(db.PolymersDB) MonomersDB(db.MonomersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) Polymer(model.Polymer) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) Monomer(model.Monomer)

Aggregations

Monomer (model.Monomer)16 Residue (model.Residue)6 ArrayList (java.util.ArrayList)5 Family (model.Family)5 HashMap (java.util.HashMap)4 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Polymer (model.Polymer)3 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)3 MonomersDB (db.MonomersDB)2 Rule (model.Rule)2 MonomerGraph (model.graph.MonomerGraph)2 MonomerLinks (model.graph.MonomerGraph.MonomerLinks)2 Before (org.junit.Before)2 IAtom (org.openscience.cdk.interfaces.IAtom)2 IMolecule (org.openscience.cdk.interfaces.IMolecule)2 ResidueCreator (algorithms.ResidueCreator)1 Chain (algorithms.isomorphism.chains.Chain)1 Extension (algorithms.isomorphism.chains.Extension)1 MappedChain (algorithms.isomorphism.chains.MappedChain)1