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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations