use of algorithms.isomorphism.chains.Extension.BondMapping in project Smiles2Monomers by yoann-dufresne.
the class BonbMatchingTests method lightMatching.
@Test
public void lightMatching() {
Extension ext = new Extension("C,1,N,0,0");
List<BondMapping> matchs = ext.match(this.bond1, MatchingType.LIGHT);
Assert.assertTrue(matchs.size() == 1);
}
use of algorithms.isomorphism.chains.Extension.BondMapping in project Smiles2Monomers by yoann-dufresne.
the class BonbMatchingTests method strongMatching.
@Test
public void strongMatching() {
Extension ext = new Extension("c,1,N,0,1");
List<BondMapping> matchs = ext.match(this.bond1, MatchingType.STRONG);
Assert.assertTrue(matchs.size() == 1);
}
use of algorithms.isomorphism.chains.Extension.BondMapping in project Smiles2Monomers by yoann-dufresne.
the class BonbMatchingTests method noHydrogenMatching.
@Test
public void noHydrogenMatching() {
Extension ext = new Extension("c,1,N,0,0");
List<BondMapping> matchs = ext.match(this.bond1, MatchingType.STRONG);
Assert.assertTrue(matchs.size() == 1);
}
use of algorithms.isomorphism.chains.Extension.BondMapping in project Smiles2Monomers by yoann-dufresne.
the class BonbMatchingTests method aromaticNoMatching.
@Test
public void aromaticNoMatching() {
Extension ext = new Extension("C,1,N,0,1");
List<BondMapping> matchs = ext.match(this.bond1, MatchingType.STRONG);
Assert.assertTrue(matchs.size() == 0);
}
use of algorithms.isomorphism.chains.Extension.BondMapping in project Smiles2Monomers by yoann-dufresne.
the class Isomorphism method searchFromPreviousMapping.
/**/
public static List<MappedChain> searchFromPreviousMapping(MappedChain mc, Extension ext, int idx1, int idx2, MatchingType type) {
IMolecule mol = mc.getChemObject().getMolecule();
int extIdx = idx1 == -1 ? idx2 : idx1;
List<MappedChain> mappings = new ArrayList<>();
// Connected bonds search
List<IBond> connectedBonds = null;
if (extIdx == -1) {
connectedBonds = new ArrayList<>();
for (IBond bond : mol.bonds()) connectedBonds.add(bond);
} else {
IAtom extAtom = mol.getAtom(mc.getAtomsMapping().get(extIdx));
connectedBonds = mol.getConnectedBondsList(extAtom);
}
for (IBond neighbor : connectedBonds) {
// No need to search bonds already present in mapping.
if (mc.getBondsMapping().contains(mol.getBondNumber(neighbor)))
continue;
List<BondMapping> bms = ext.match(neighbor, type);
for (BondMapping bm : bms) {
// Verification of the compatibility with previous matching
if (idx1 != -1 && mol.getAtomNumber(bm.a0) != mc.getAtomsMapping().get(idx1))
continue;
if (idx2 != -1 && mol.getAtomNumber(bm.a1) != mc.getAtomsMapping().get(idx2))
continue;
// Creation of the new mapping
Chain chain = new Chain(mc.getChain(), ext, idx1, idx2);
List<Integer> atoms = new ArrayList<>(mc.getAtomsMapping());
Map<Integer, Integer> hydrogens = new HashMap<>(mc.getHydrogensMapping());
if (idx1 == -1) {
int an = mol.getAtomNumber(bm.a0);
// To avoid cycles where there is no cycle.
if (mc.getAtomsMapping().contains(an))
continue;
atoms.add(an);
hydrogens.put(an, bm.h0);
}
if (idx2 == -1) {
int an = mol.getAtomNumber(bm.a1);
// To avoid cycles where there is no cycle.
if (mc.getAtomsMapping().contains(an))
continue;
atoms.add(an);
hydrogens.put(an, bm.h1);
}
List<Integer> bonds = new ArrayList<>(mc.getBondsMapping());
bonds.add(mol.getBondNumber(neighbor));
List<MatchingType> matchings = new ArrayList<>(mc.getMatchings());
matchings.add(bm.matchingType);
MappedChain newMc = new MappedChain(mc.getChemObject(), chain, atoms, bonds, matchings, hydrogens);
mappings.add(newMc);
}
}
return mappings;
}
Aggregations