3
* $Date: 2006-07-31 11:23:24 +0200 (Mon, 31 Jul 2006) $
6
* Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project
8
* Contact: cdk-devel@lists.sourceforge.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
14
* All we ask is that proper credit is given for our work, which includes
15
* - but is not limited to - adding the above copyright notice to the beginning
16
* of your source code files, and to any copyright notice that you may distribute
17
* with programs based on this work.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28
package org.openscience.cdk.tools.manipulator;
30
import java.util.ArrayList;
31
import java.util.List;
33
import org.openscience.cdk.interfaces.IAtom;
34
import org.openscience.cdk.interfaces.IAtomContainer;
35
import org.openscience.cdk.interfaces.IBond;
36
import org.openscience.cdk.interfaces.IElectronContainer;
37
import org.openscience.cdk.interfaces.IMoleculeSet;
38
import org.openscience.cdk.interfaces.IReaction;
39
import org.openscience.cdk.interfaces.IReactionSet;
42
* @cdk.module standard
44
* @see ChemModelManipulator
46
public class ReactionSetManipulator {
48
public static int getAtomCount(IReactionSet set) {
50
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
51
count += ReactionManipulator.getAtomCount((IReaction)iter.next());
56
public static int getBondCount(IReactionSet set) {
58
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
59
count += ReactionManipulator.getBondCount((IReaction)iter.next());
64
public static void removeAtomAndConnectedElectronContainers(IReactionSet set, IAtom atom) {
65
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
66
IReaction reaction = (IReaction)iter.next();
67
ReactionManipulator.removeAtomAndConnectedElectronContainers(reaction, atom);
71
public static void removeElectronContainer(IReactionSet set, IElectronContainer electrons) {
72
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
73
IReaction reaction = (IReaction)iter.next();
74
ReactionManipulator.removeElectronContainer(reaction, electrons);
78
public static IMoleculeSet getAllMolecules(IReactionSet set) {
79
IMoleculeSet moleculeSet = set.getBuilder().newMoleculeSet();
80
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
81
IReaction reaction = (IReaction)iter.next();
82
moleculeSet.add(ReactionManipulator.getAllMolecules(reaction));
87
public static List getAllIDs(IReactionSet set) {
88
List IDlist = new ArrayList();
89
if (set.getID() != null) IDlist.add(set.getID());
90
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
91
IReaction reaction = (IReaction)iter.next();
92
IDlist.addAll(ReactionManipulator.getAllIDs(reaction));
98
* Returns all the AtomContainer's of a Reaction.
100
public static List getAllAtomContainers(IReactionSet set) {
102
return MoleculeSetManipulator.getAllAtomContainers(
107
public static IReaction getRelevantReaction(IReactionSet set, IAtom atom) {
108
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
109
IReaction reaction = (IReaction)iter.next();
110
IAtomContainer container = ReactionManipulator.getRelevantAtomContainer(reaction, atom);
111
if (container != null) { // a match!
118
public static IReaction getRelevantReaction(IReactionSet set, IBond bond) {
119
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
120
IReaction reaction = (IReaction)iter.next();
121
IAtomContainer container = ReactionManipulator.getRelevantAtomContainer(reaction, bond);
122
if (container != null) { // a match!
129
public static IAtomContainer getRelevantAtomContainer(IReactionSet set, IAtom atom) {
130
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
131
IReaction reaction = (IReaction)iter.next();
132
IAtomContainer container = ReactionManipulator.getRelevantAtomContainer(reaction, atom);
133
if (container != null) { // a match!
140
public static IAtomContainer getRelevantAtomContainer(IReactionSet set, IBond bond) {
141
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
142
IReaction reaction = (IReaction)iter.next();
143
IAtomContainer container = ReactionManipulator.getRelevantAtomContainer(reaction, bond);
144
if (container != null) { // a match!
151
public static void setAtomProperties(IReactionSet set, Object propKey, Object propVal) {
152
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
153
IReaction reaction = (IReaction)iter.next();
154
ReactionManipulator.setAtomProperties(reaction, propKey, propVal);
158
public static List getAllChemObjects(IReactionSet set) {
159
ArrayList list = new ArrayList();
161
for (java.util.Iterator iter = set.reactions(); iter.hasNext();) {
162
IReaction reaction = (IReaction)iter.next();
163
list.addAll(ReactionManipulator.getAllChemObjects(reaction));