Search in sources :

Example 96 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.

the class ReactionSchemeManipulator method setScheme.

/**
 * Create a IReactionScheme given as a top a IReaction. If it doesn't exist any subsequent reaction
 * return null;
 *
 * @param reaction       The IReaction as a top
 * @param reactionSet    The IReactionSet to extract a IReactionScheme
 * @return               The IReactionScheme
 */
private static IReactionScheme setScheme(IReaction reaction, IReactionSet reactionSet) {
    IReactionScheme reactionScheme = reaction.getBuilder().newInstance(IReactionScheme.class);
    IReactionSet reactConSet = extractSubsequentReaction(reaction, reactionSet);
    if (reactConSet.getReactionCount() != 0) {
        for (IReaction reactionInt : reactConSet.reactions()) {
            reactionScheme.addReaction(reactionInt);
            IReactionScheme newRScheme = setScheme(reactionInt, reactionSet);
            if (newRScheme.getReactionCount() != 0 || newRScheme.getReactionSchemeCount() != 0) {
                reactionScheme.add(newRScheme);
            }
        }
    }
    return reactionScheme;
}
Also used : IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IReactionScheme(org.openscience.cdk.interfaces.IReactionScheme) IReaction(org.openscience.cdk.interfaces.IReaction)

Example 97 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.

the class ReactionSchemeManipulator method extractTopReactions.

/**
 * Extract a set of Reactions which are in top of a IReactionScheme. The top reactions are those
 * which any of their reactants are participating in other reactions as a products.
 *
 * @param reactionScheme  The IReactionScheme
 * @return                The set of top reactions
 */
public static IReactionSet extractTopReactions(IReactionScheme reactionScheme) {
    IReactionSet reactionSet = reactionScheme.getBuilder().newInstance(IReactionSet.class);
    IReactionSet allSet = getAllReactions(reactionScheme);
    for (IReaction reaction : allSet.reactions()) {
        IReactionSet precuSet = extractPrecursorReaction(reaction, allSet);
        if (precuSet.getReactionCount() == 0) {
            boolean found = false;
            for (IReaction reactIn : reactionSet.reactions()) {
                if (reactIn.equals(reaction))
                    found = true;
            }
            if (!found)
                reactionSet.addReaction(reaction);
        }
    }
    return reactionSet;
}
Also used : IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IReaction(org.openscience.cdk.interfaces.IReaction)

Example 98 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.

the class ReactionSetManipulator method getRelevantReactions.

/**
 * Get all Reactions object containing a Molecule from a set of Reactions.
 *
 * @param reactSet The set of reaction to inspect
 * @param molecule The molecule to find
 * @return         The IReactionSet
 */
public static IReactionSet getRelevantReactions(IReactionSet reactSet, IAtomContainer molecule) {
    IReactionSet newReactSet = reactSet.getBuilder().newInstance(IReactionSet.class);
    IReactionSet reactSetProd = getRelevantReactionsAsProduct(reactSet, molecule);
    for (IReaction reaction : reactSetProd.reactions()) newReactSet.addReaction(reaction);
    IReactionSet reactSetReact = getRelevantReactionsAsReactant(reactSet, molecule);
    for (IReaction reaction : reactSetReact.reactions()) newReactSet.addReaction(reaction);
    return newReactSet;
}
Also used : IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IReaction(org.openscience.cdk.interfaces.IReaction)

Example 99 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.

the class ChemModelManipulator method getBondCount.

/**
 * Get the total number of bonds inside an IChemModel.
 *
 * @param chemModel  The IChemModel object.
 * @return           The number of Bond object inside.
 */
public static int getBondCount(IChemModel chemModel) {
    int count = 0;
    ICrystal crystal = chemModel.getCrystal();
    if (crystal != null) {
        count += crystal.getBondCount();
    }
    IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
    if (moleculeSet != null) {
        count += MoleculeSetManipulator.getBondCount(moleculeSet);
    }
    IReactionSet reactionSet = chemModel.getReactionSet();
    if (reactionSet != null) {
        count += ReactionSetManipulator.getBondCount(reactionSet);
    }
    return count;
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet)

Example 100 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.

the class ChemModelManipulator method getAllIDs.

public static List<String> getAllIDs(IChemModel chemModel) {
    ArrayList<String> list = new ArrayList<>();
    if (chemModel.getID() != null)
        list.add(chemModel.getID());
    ICrystal crystal = chemModel.getCrystal();
    if (crystal != null) {
        list.addAll(AtomContainerManipulator.getAllIDs(crystal));
    }
    IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
    if (moleculeSet != null) {
        list.addAll(MoleculeSetManipulator.getAllIDs(moleculeSet));
    }
    IReactionSet reactionSet = chemModel.getReactionSet();
    if (reactionSet != null) {
        list.addAll(ReactionSetManipulator.getAllIDs(reactionSet));
    }
    return list;
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ArrayList(java.util.ArrayList)

Aggregations

IReactionSet (org.openscience.cdk.interfaces.IReactionSet)270 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)222 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)217 Test (org.junit.Test)208 ArrayList (java.util.ArrayList)195 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)192 IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)162 ReactionProcessTest (org.openscience.cdk.reaction.ReactionProcessTest)159 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)159 IAtom (org.openscience.cdk.interfaces.IAtom)132 IReaction (org.openscience.cdk.interfaces.IReaction)84 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)45 CDKException (org.openscience.cdk.exception.CDKException)37 IBond (org.openscience.cdk.interfaces.IBond)37 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)29 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)28 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)17 IChemModel (org.openscience.cdk.interfaces.IChemModel)15 ICrystal (org.openscience.cdk.interfaces.ICrystal)11 IRingSet (org.openscience.cdk.interfaces.IRingSet)10