Search in sources :

Example 11 with Family

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

the class FamilyDB method addObject.

@Override
public void addObject(String id, Family f) {
    Family prev = null;
    for (Monomer m : f.getMonomers()) if (this.database.containsKey(m.getId())) {
        prev = this.database.get(m.getId());
        break;
    }
    if (prev == null) {
        for (Monomer m : f.getMonomers()) {
            super.addObject(m.getId(), f);
            this.uniqFamilies.add(f);
        }
    } else {
        for (Monomer m : f.getMonomers()) {
            prev.addMonomer(m);
            this.database.put(m.getId(), prev);
        }
        for (Residue res : f.getResidues()) prev.addResidue(res);
        for (Link l : f.getDepandances()) prev.addDependance(l);
    }
}
Also used : Residue(model.Residue) Family(model.Family) Monomer(model.Monomer) Link(model.Family.Link)

Example 12 with Family

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

the class FamilyDB method areInSameFamily.

public boolean areInSameFamily(String mono1, String mono2) {
    Family family1 = null;
    Family family2 = null;
    try {
        family1 = this.getObject(mono1);
        family2 = this.getObject(mono2);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return family1.equals(family2);
}
Also used : Family(model.Family)

Example 13 with Family

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

the class MonomericSpliting method matchAllFamilies.

/**
 * Function to match independently all families onto the polymer.
 * Can easily be parallelized
 * @param matchType Strict/Light
 */
private void matchAllFamilies(MatchingType matchType) {
    for (Family family : this.families.getFamilies()) {
        /*/ Display
			if (verbose) {
				System.out.println("In " + polName);
				System.out.println("  Family " + i++ + "/" + nbFamilies);
			}/**/
        // Time initialization
        // long time = System.currentTimeMillis();
        // Matching
        this.matcher.setAllowLightMatch(matchType);
        Coverage cov = this.matcher.matchFamilly(family);
        if (matchType.equals(MatchingType.LIGHT)) {
            for (Match match : cov.getMatches()) {
                Match transformed = DeepenMatcher.transform(match, this.coverage.getCurrentMaskedMol(), this.coverage.getChemicalObject().getMolecule());
                this.coverage.addMatch(transformed);
            }
        } else
            this.coverage.addMatches(cov);
    /*if (verbose)
				System.out.println("  Search " + matchType.getClass().getCanonicalName() +
						" for family " + family.getName() + " in " + (System.currentTimeMillis()-time) + "\n");/**/
    }
}
Also used : Family(model.Family) Coverage(algorithms.utils.Coverage) Match(algorithms.utils.Match)

Example 14 with Family

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

the class ResidueCreator method createResidues.

/**
 * Create all residues from the argument monomers database according to rules entered in paramaters of the constructor.
 * @param monosDBName A monomers database.
 * @return All possible residues found.
 */
public FamilyDB createResidues(MonomersDB monosDB) {
    FamilyDB famDB = new FamilyDB();
    famDB.init(monosDB);
    for (Family family : famDB.getFamilies()) {
        this.residuesFromMonomers(family);
        for (Residue res : family.getResidues()) {
            IMolecule oldMol = res.getMolecule();
            res.setMol(new Molecule(AtomContainerManipulator.removeHydrogens(res.getMolecule())));
            IMolecule newMol = res.getMolecule();
            Map<IAtom, IAtom> conversion = new HashMap<>();
            int idx = 0;
            for (IAtom a : oldMol.atoms()) {
                if (!"H".equals(a.getSymbol())) {
                    conversion.put(a, newMol.getAtom(idx));
                    idx++;
                }
            }
            Map<IAtom, Rule> oldLinks = new HashMap<>(res.getAtomicLinks());
            res.getAtomicLinks().clear();
            for (IAtom oldA : oldLinks.keySet()) {
                Rule rule = oldLinks.get(oldA);
                res.addLink(conversion.get(oldA), rule);
            }
        }
    }
    return famDB;
}
Also used : Molecule(org.openscience.cdk.Molecule) IMolecule(org.openscience.cdk.interfaces.IMolecule) IMolecule(org.openscience.cdk.interfaces.IMolecule) Residue(model.Residue) HashMap(java.util.HashMap) Family(model.Family) FamilyDB(db.FamilyDB) Rule(model.Rule) IAtom(org.openscience.cdk.interfaces.IAtom)

Aggregations

Family (model.Family)14 Residue (model.Residue)11 Monomer (model.Monomer)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 FamilyDB (db.FamilyDB)3 Rule (model.Rule)3 IAtom (org.openscience.cdk.interfaces.IAtom)3 ResidueJsonLoader (io.loaders.json.ResidueJsonLoader)2 File (java.io.File)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 BondAdd (algorithms.isomorphism.chains.BondAdd)1 Chain (algorithms.isomorphism.chains.Chain)1 ChainAdd (algorithms.isomorphism.chains.ChainAdd)1 Extension (algorithms.isomorphism.chains.Extension)1 FamilyChainsDB (algorithms.isomorphism.chains.FamilyChainsDB)1 HydrogenAdd (algorithms.isomorphism.chains.HydrogenAdd)1 Coverage (algorithms.utils.Coverage)1 Match (algorithms.utils.Match)1