Search in sources :

Example 1 with OtherChemicalObject

use of model.OtherChemicalObject in project Smiles2Monomers by yoann-dufresne.

the class MonomericSpliting method computeCoverage.

/**
 * Calculate an object Coverage with all matches from families.
 * @param pep Peptide to match
 */
public void computeCoverage(Polymer pep) {
    this.coverage = new Coverage(pep);
    this.matcher.setChemicalObject(pep);
    Isomorphism.setMappingStorage(true);
    // Step 1 : Strict Matching
    if (verbose) {
        System.out.println("+Strict matching");
        System.out.println("++Search residues");
    }
    this.matchAllFamilies(MatchingType.STRONG);
    double ratio = this.coverage.getCoverageRatio();
    if (ratio < 1.0) {
        if (verbose)
            System.out.println("++Modulation");
        this.coverage = this.modulation.modulate(this.coverage);
    }
    Coverage save = this.coverage.clone();
    // conditions to go to light matching
    if (!this.allowLightMatchs || ratio == 1.0) {
        Isomorphism.setMappingStorage(false);
        return;
    }
    // TODO : Why if/else ?
    if (this.condition == null)
        this.condition = new ExtendsNTimes(this.retry);
    else
        this.condition.init();
    this.remover.init();
    // Successive matchings
    int depth = 0;
    while (this.coverage.getCoverageRatio() < 1.0 && this.condition.toContinue(this.coverage)) {
        depth++;
        // Contract the atomic graph to monomeric graph
        ContractedGraph contracted = new ContractedGraph(this.coverage);
        // Remove monomers from the current solution to try with other matching strategy
        this.remover.remove(this.coverage, contracted);
        // Create a masked molecule to only search on free polymer areas
        Molecule mol = DeepenMatcher.mask(this.coverage);
        this.coverage.setCurrentMaskedMol(mol);
        OtherChemicalObject tmp = new OtherChemicalObject(mol);
        this.matcher.setChemicalObject(tmp);
        if (verbose) {
            System.out.println("+Light matching, depth " + depth);
            System.out.println("++Search residues");
        }
        // Compute for all families with ligth matching
        this.matchAllFamilies(MatchingType.LIGHT);
        // Re-compute coverage
        this.coverage.calculateGreedyCoverage();
        if (this.coverage.getCoverageRatio() < 1.0) {
            if (verbose)
                System.out.println("++Modulation");
            this.coverage = this.modulation.modulate(this.coverage);
        }
        if (this.coverage.getCoverageRatio() > save.getCoverageRatio())
            save = this.coverage.clone();
        this.remover.nextLevel();
    }
    Isomorphism.setMappingStorage(false);
    if (save.getCoverageRatio() > this.coverage.getCoverageRatio())
        this.coverage = save;
}
Also used : Molecule(org.openscience.cdk.Molecule) ExtendsNTimes(algorithms.isomorphism.conditions.ExtendsNTimes) ContractedGraph(model.graph.ContractedGraph) Coverage(algorithms.utils.Coverage) OtherChemicalObject(model.OtherChemicalObject)

Aggregations

ExtendsNTimes (algorithms.isomorphism.conditions.ExtendsNTimes)1 Coverage (algorithms.utils.Coverage)1 OtherChemicalObject (model.OtherChemicalObject)1 ContractedGraph (model.graph.ContractedGraph)1 Molecule (org.openscience.cdk.Molecule)1