use of ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus in project ambit-mirror by ideaconsult.
the class ReactionSequence method iterateLevelMoleculesRandomly.
public void iterateLevelMoleculesRandomly(ReactionSequenceLevel level) throws Exception {
for (int i = 0; i < level.molecules.size(); i++) {
IAtomContainer mol = level.molecules.get(i);
MoleculeStatus status = getMoleculeStatus(mol);
if (status == MoleculeStatus.ADDED_TO_LEVEL) {
// check for starting material is performed on product generation
Map<GenericReaction, List<List<IAtom>>> allInstances = generateAllReactionInstances(mol);
if (allInstances.isEmpty()) {
setMoleculeStatus(mol, MoleculeStatus.UNRESOLVED);
continue;
}
Object[] obj = SyntheticStrategy.getRandomSelection(allInstances);
GenericReaction gr = (GenericReaction) obj[0];
List<IAtom> inst = (List<IAtom>) obj[1];
generateSequenceStepForReactionInstance(level, i, gr, inst);
setMoleculeStatus(mol, MoleculeStatus.RESOLVED);
}
}
}
use of ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus in project ambit-mirror by ideaconsult.
the class ReactionSequence method iterateLevelMolecules.
public void iterateLevelMolecules(ReactionSequenceLevel level) throws Exception {
for (int i = 0; i < level.molecules.size(); i++) {
IAtomContainer mol = level.molecules.get(i);
MoleculeStatus status = getMoleculeStatus(mol);
if (status == MoleculeStatus.ADDED_TO_LEVEL) {
// check for starting material is performed on product generation
Map<GenericReaction, List<List<IAtom>>> allInstances = generateAllReactionInstances(mol);
if (allInstances.isEmpty()) {
setMoleculeStatus(mol, MoleculeStatus.UNRESOLVED);
continue;
}
List<GenericReactionInstance> griList = handleReactionInstances(allInstances, mol);
GenericReactionInstance bestInst = getBestInstance(griList);
generateSequenceStepForReactionInstance(level, i, bestInst);
setMoleculeStatus(mol, MoleculeStatus.RESOLVED);
}
}
}
use of ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus in project ambit-mirror by ideaconsult.
the class ReactionSequenceLevel method toString.
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Level " + levelIndex + "\n");
for (int i = 0; i < molecules.size(); i++) {
String smi = null;
try {
IAtomContainer mol = molecules.get(i).clone();
MoleculeTools.convertExplicitHAtomsToImplicit(mol);
smi = SmartsHelper.moleculeToSMILES(mol, true);
} catch (Exception x) {
}
;
sb.append("" + smi);
sb.append(" " + MoleculeStatus.getShortString((MoleculeStatus) molecules.get(i).getProperty(ReactionSequence.MoleculeStatusProperty)));
// sb.append(" " + molecules.get(i).getProperty(ReactionSequence.MoleculeInChIKeyProperty));
Object[] obj = getGenerationInfo(i);
if (obj != null) {
GenericReaction genReaction = (GenericReaction) obj[0];
sb.append(" <R" + genReaction.getExternId() + ",M" + ((Integer) obj[1] + 1));
if (obj[2] != null) {
ReactionScore rscore = (ReactionScore) obj[2];
sb.append(",S" + ((Double) rscore.totalScore).intValue());
sb.append(">");
sb.append(" " + rscore.toStringLine());
} else
sb.append(">");
}
/*
ReactionSequenceStep step = steps.get(i);
if (step != null)
{
//TODO
}
*/
sb.append("\n");
}
return sb.toString();
}
Aggregations