Search in sources :

Example 1 with MoleculeStatus

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);
        }
    }
}
Also used : GenericReaction(ambit2.reactions.GenericReaction) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ArrayList(java.util.ArrayList) List(java.util.List) MoleculeStatus(ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 2 with MoleculeStatus

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);
        }
    }
}
Also used : GenericReaction(ambit2.reactions.GenericReaction) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ArrayList(java.util.ArrayList) List(java.util.List) GenericReactionInstance(ambit2.reactions.GenericReactionInstance) MoleculeStatus(ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 3 with MoleculeStatus

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();
}
Also used : GenericReaction(ambit2.reactions.GenericReaction) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ReactionScore(ambit2.reactions.rules.scores.ReactionScore)

Aggregations

GenericReaction (ambit2.reactions.GenericReaction)3 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)3 MoleculeStatus (ambit2.reactions.retrosynth.ReactionSequence.MoleculeStatus)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IAtom (org.openscience.cdk.interfaces.IAtom)2 GenericReactionInstance (ambit2.reactions.GenericReactionInstance)1 ReactionScore (ambit2.reactions.rules.scores.ReactionScore)1