use of org.openscience.cdk.interfaces.IReaction 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;
}
use of org.openscience.cdk.interfaces.IReaction 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;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class ReactionSetManipulator method getAllChemObjects.
public static List<IChemObject> getAllChemObjects(IReactionSet set) {
ArrayList<IChemObject> list = new ArrayList<>();
list.add(set);
for (IReaction reaction : set.reactions()) {
list.addAll(ReactionManipulator.getAllChemObjects(reaction));
}
return list;
}
use of org.openscience.cdk.interfaces.IReaction 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;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class ChemFileManipulator method getAllReactions.
/**
* Get a list of all IReaction inside an IChemFile.
*
* @param file The IChemFile object.
* @return The List of IReaction objects inside.
*/
public static List<IReaction> getAllReactions(IChemFile file) {
List<IReaction> reactonList = new ArrayList<>();
List<IChemModel> chemModel = getAllChemModels(file);
for (IChemModel iChemModel : chemModel) {
for (IReaction reaction : iChemModel.getReactionSet().reactions()) {
reactonList.add(reaction);
}
}
return reactonList;
}
Aggregations