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;
}
Aggregations