use of model.Rule in project Smiles2Monomers by yoann-dufresne.
the class ResidueJsonLoader method fillLinksJSO.
@SuppressWarnings("unchecked")
private String fillLinksJSO(JSONArray links, Residue res) {
IMolecule mol = res.getMolecule();
AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol);
String smiles = SmilesConverter.conv.mol2Smiles(mol, false);
List<IAtom> order = SmilesConverter.conv.getOrder();
for (IAtom a : res.getAtomicLinks().keySet()) {
JSONObject jso = new JSONObject();
Rule rule = res.getAtomicLinks().get(a);
jso.put("name", rule.getName());
jso.put("atom", order.indexOf(a));
links.add(jso);
}
AtomContainerManipulator.removeHydrogens(mol);
return smiles;
}
use of model.Rule in project Smiles2Monomers by yoann-dufresne.
the class ChainsFamilyMatching method addToCoverage.
private void addToCoverage(Family family, MappedChain mc, Residue res) {
Match match = new Match(res);
match.addAtoms(mc.getAtomsMapping());
match.addBonds(mc.getBondsMapping());
match.addHydrogens(mc.getHydrogensMapping());
for (int idx = 0; idx < mc.getMatchings().size(); idx++) {
match.addQuality(mc.getBondsMapping().get(idx), mc.getMatchings().get(idx));
}
// Compute external bonds by aligning chain on residue
// 1- Retrieve the chain on root residue
int current = 200;
List<MappedChain> onResidue = null;
Residue rootMol = null;
for (Residue root : family.getRoots()) {
List<MappedChain> mcs = Isomorphism.searchAChain(mc.getChain(), root, MatchingType.EXACT);
if (mcs.size() > 0 && current > mcs.size()) {
current = mcs.size();
onResidue = mcs;
rootMol = root;
}
}
// 2- Look for atoms of interest
MappedChain resMapping = onResidue.get(0);
for (IAtom ia : rootMol.getAtomicLinks().keySet()) {
Rule r = rootMol.getAtomicLinks().get(ia);
int resMolIdx = rootMol.getMolecule().getAtomNumber(ia);
int chainIdx = resMapping.getAtomsMapping().indexOf(resMolIdx);
match.addExtLink(mc.getAtomsMapping().get(chainIdx), r);
}
// Add the match
if (!this.coverage.getMatches().contains(match))
this.coverage.addMatch(match);
}
use of model.Rule 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