use of model.Family in project Smiles2Monomers by yoann-dufresne.
the class FamilyDB method addObject.
@Override
public void addObject(String id, Family f) {
Family prev = null;
for (Monomer m : f.getMonomers()) if (this.database.containsKey(m.getId())) {
prev = this.database.get(m.getId());
break;
}
if (prev == null) {
for (Monomer m : f.getMonomers()) {
super.addObject(m.getId(), f);
this.uniqFamilies.add(f);
}
} else {
for (Monomer m : f.getMonomers()) {
prev.addMonomer(m);
this.database.put(m.getId(), prev);
}
for (Residue res : f.getResidues()) prev.addResidue(res);
for (Link l : f.getDepandances()) prev.addDependance(l);
}
}
use of model.Family in project Smiles2Monomers by yoann-dufresne.
the class FamilyDB method areInSameFamily.
public boolean areInSameFamily(String mono1, String mono2) {
Family family1 = null;
Family family2 = null;
try {
family1 = this.getObject(mono1);
family2 = this.getObject(mono2);
} catch (NullPointerException e) {
e.printStackTrace();
}
return family1.equals(family2);
}
use of model.Family in project Smiles2Monomers by yoann-dufresne.
the class MonomericSpliting method matchAllFamilies.
/**
* Function to match independently all families onto the polymer.
* Can easily be parallelized
* @param matchType Strict/Light
*/
private void matchAllFamilies(MatchingType matchType) {
for (Family family : this.families.getFamilies()) {
/*/ Display
if (verbose) {
System.out.println("In " + polName);
System.out.println(" Family " + i++ + "/" + nbFamilies);
}/**/
// Time initialization
// long time = System.currentTimeMillis();
// Matching
this.matcher.setAllowLightMatch(matchType);
Coverage cov = this.matcher.matchFamilly(family);
if (matchType.equals(MatchingType.LIGHT)) {
for (Match match : cov.getMatches()) {
Match transformed = DeepenMatcher.transform(match, this.coverage.getCurrentMaskedMol(), this.coverage.getChemicalObject().getMolecule());
this.coverage.addMatch(transformed);
}
} else
this.coverage.addMatches(cov);
/*if (verbose)
System.out.println(" Search " + matchType.getClass().getCanonicalName() +
" for family " + family.getName() + " in " + (System.currentTimeMillis()-time) + "\n");/**/
}
}
use of model.Family 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