Search in sources :

Example 6 with Polymer

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());
}
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)

Example 7 with Polymer

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);
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) PolymersDB(db.PolymersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) MonomersDB(db.MonomersDB) Polymer(model.Polymer)

Example 8 with Polymer

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;
}
Also used : Polymer(model.Polymer) Coverage(algorithms.utils.Coverage)

Example 9 with Polymer

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");
    }
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) PolymersDB(db.PolymersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) MonomersDB(db.MonomersDB) SimpleGraph(org._3pq.jgrapht.graph.SimpleGraph) Polymer(model.Polymer) Planarity(algorithms.Planarity) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException)

Example 10 with Polymer

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();
        }
    }
}
Also used : PolymersDB(db.PolymersDB) MolTreeWidth(nl.uu.cs.treewidth.MolTreeWidth) FileWriter(java.io.FileWriter) MonomersDB(db.MonomersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) Polymer(model.Polymer) IOException(java.io.IOException) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Aggregations

Polymer (model.Polymer)12 MonomersDB (db.MonomersDB)5 PolymersDB (db.PolymersDB)5 PolymersJsonLoader (io.loaders.json.PolymersJsonLoader)5 MappedChain (algorithms.isomorphism.chains.MappedChain)4 Test (org.junit.Test)4 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)4 Monomer (model.Monomer)3 MonomersJsonLoader (io.loaders.json.MonomersJsonLoader)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 IMolecule (org.openscience.cdk.interfaces.IMolecule)2 MonomericSpliting (algorithms.MonomericSpliting)1 Planarity (algorithms.Planarity)1 ResidueCreator (algorithms.ResidueCreator)1 Chain (algorithms.isomorphism.chains.Chain)1 ChainLearning (algorithms.isomorphism.chains.ChainLearning)1 ChainsDB (algorithms.isomorphism.chains.ChainsDB)1 Extension (algorithms.isomorphism.chains.Extension)1 Coverage (algorithms.utils.Coverage)1