Search in sources :

Example 1 with MonomersDB

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

Example 2 with MonomersDB

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();
}
Also used : RulesDB(db.RulesDB) MonomersJsonLoader(io.loaders.json.MonomersJsonLoader) PolymersDB(db.PolymersDB) MonomersDB(db.MonomersDB) PolymersJsonLoader(io.loaders.json.PolymersJsonLoader) ResidueJsonLoader(io.loaders.json.ResidueJsonLoader) Before(org.junit.Before)

Example 3 with MonomersDB

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

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

Example 5 with MonomersDB

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();
    }
}
Also used : RulesDB(db.RulesDB) MonomersJsonLoader(io.loaders.json.MonomersJsonLoader) Residue(model.Residue) MonomersDB(db.MonomersDB) FileWriter(java.io.FileWriter) Family(model.Family) FamilyDB(db.FamilyDB) IOException(java.io.IOException) ResidueJsonLoader(io.loaders.json.ResidueJsonLoader) File(java.io.File)

Aggregations

MonomersDB (db.MonomersDB)12 PolymersJsonLoader (io.loaders.json.PolymersJsonLoader)10 PolymersDB (db.PolymersDB)9 MonomersJsonLoader (io.loaders.json.MonomersJsonLoader)7 RulesDB (db.RulesDB)6 FamilyDB (db.FamilyDB)5 ResidueJsonLoader (io.loaders.json.ResidueJsonLoader)5 File (java.io.File)5 Polymer (model.Polymer)5 Before (org.junit.Before)4 ResidueCreator (algorithms.ResidueCreator)3 MonomersSerialization (io.loaders.serialization.MonomersSerialization)3 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)3 MonomericSpliting (algorithms.MonomericSpliting)2 ChainLearning (algorithms.isomorphism.chains.ChainLearning)2 ChainsDB (algorithms.isomorphism.chains.ChainsDB)2 Coverage (algorithms.utils.Coverage)2 Coverages2HTML (io.html.Coverages2HTML)2 ImagesGeneration (io.imgs.ImagesGeneration)2 ColorsMap (io.imgs.PictureCoverageGenerator.ColorsMap)2