use of org.openscience.cdk.interfaces.IAtom 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;
}
Aggregations