Search in sources :

Example 11 with MappedChain

use of algorithms.isomorphism.chains.MappedChain in project Smiles2Monomers by yoann-dufresne.

the class Isomorphism method searchAChainRecur.

/**/
/**
 * Search a bloc in a chemical object
 * @param chain Searched bloc
 * @param co Chemical object
 * @return All mappings of bloc on co.
 */
public static List<MappedChain> searchAChainRecur(Chain chain, ChemicalObject co, MatchingType type) {
    if (Isomorphism.mappings.containsKey(chain))
        return Isomorphism.mappings.get(chain);
    List<MappedChain> mbs;
    List<MappedChain> newMbs = new ArrayList<>();
    if (chain.getSize() == 1) {
        mbs = new ArrayList<>();
        mbs.add(new MappedChain(co));
    } else {
        mbs = searchAChainRecur(chain.getSubBlc(), co, type);
    }
    for (MappedChain mb : mbs) {
        List<MappedChain> newMbsFromOne = searchFromPreviousMapping(mb, chain.getExt(), chain.getPosition1(), chain.getPosition2(), type);
        // Filter equals mappings
        for (MappedChain mc : newMbsFromOne) if (!newMbs.contains(mc))
            newMbs.add(mc);
    }
    if (Isomorphism.storeMappings)
        Isomorphism.mappings.put(chain, newMbs);
    return newMbs;
}
Also used : MappedChain(algorithms.isomorphism.chains.MappedChain) ArrayList(java.util.ArrayList)

Aggregations

MappedChain (algorithms.isomorphism.chains.MappedChain)11 Test (org.junit.Test)5 IAtom (org.openscience.cdk.interfaces.IAtom)5 Chain (algorithms.isomorphism.chains.Chain)4 ArrayList (java.util.ArrayList)4 Polymer (model.Polymer)4 IMolecule (org.openscience.cdk.interfaces.IMolecule)4 HashMap (java.util.HashMap)3 IBond (org.openscience.cdk.interfaces.IBond)3 BondMapping (algorithms.isomorphism.chains.Extension.BondMapping)2 Residue (model.Residue)2 ChainAdd (algorithms.isomorphism.chains.ChainAdd)1 Extension (algorithms.isomorphism.chains.Extension)1 FamilyChainsDB (algorithms.isomorphism.chains.FamilyChainsDB)1 Coverage (algorithms.utils.Coverage)1 Match (algorithms.utils.Match)1 ChemicalObject (model.ChemicalObject)1 Monomer (model.Monomer)1 Rule (model.Rule)1 Before (org.junit.Before)1