get all Molecules object from a set of Reactions.

@param set The set of reaction to inspect
@return    The IAtomContanerSet
325099
public static IAtomContainerSet getAllMolecules(IReactionSet set) {
        IAtomContainerSet moleculeSet = set.getBuilder().newInstance(IAtomContainerSet.class);
        for (IReaction reaction : set.reactions()) {
            IAtomContainerSet molecules = ReactionManipulator.getAllMolecules(reaction);
            for (IAtomContainer ac : molecules.atomContainers()) {
                boolean contain = false;
                for (IAtomContainer atomContainer : moleculeSet.atomContainers()) {
                    if (atomContainer.equals(ac)) {
                        contain = true;
                        break;
                    }
                }
                if (!contain) moleculeSet.addAtomContainer(ac);

            }
        }
        return moleculeSet;
    }
461684
public ExpiringSet<T> buildSet() {
		Set<T> target = (Set<T>) (handleExistEls ? Sets.<T>newHashSet() :
				(elements instanceof Set ? elements : Sets.newHashSet(elements)));
		
		ExpiringSet<T> expiringSet = new ExpirationSet<T>(target, ticker.or(systemTicker()),
				defaultExpireTime.orNull(), defaultExpireUnit.orNull());
		
		if (handleExistEls) {
			expiringSet.addAll(elements);
		}
		
		return expiringSet;
	}
702984
public static IAtomContainerSet getAllProducts(IReaction reaction) {
        IAtomContainerSet moleculeSet = reaction.getBuilder().newInstance(IAtomContainerSet.class);
        IAtomContainerSet products = reaction.getProducts();
        for (int i = 0; i < products.getAtomContainerCount(); i++) {
            moleculeSet.addAtomContainer(products.getAtomContainer(i));
        }
        return moleculeSet;
    }
302204
public static List<IAtomContainer> getAllAtomContainers(IChemModel chemModel) {
        IAtomContainerSet moleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
        if (chemModel.getMoleculeSet() != null) {
            moleculeSet.add(chemModel.getMoleculeSet());
        }
        if (chemModel.getReactionSet() != null) {
            moleculeSet.add(ReactionSetManipulator.getAllMolecules(chemModel.getReactionSet()));
        }
        return MoleculeSetManipulator.getAllAtomContainers(moleculeSet);
    }
370
public SortedSet<T> firstSubset(SortedSet<T> set) {
        if (this.rootNodes.isEmpty() || set == null || set.isEmpty()) {
            return null;
        }
        return firstSubset(set, this.rootNodes);
    }
94620
@Override
    public <O extends Comparable> Set<O> transform(Set<O> set) {
        return checkNotNull(set);
    }
501174
public static <T> Set<T> copy(final Set<T> set) {
		if (set == null) {
			return null;
		}

		TypeEnum elementType = null;
		Set<T> copy = new HashSet<T>();
		for (T element : set) {
			T elementCopy = null;
			if (element != null) {
				if (elementType == null) {
					elementType = TypeEnum.dataTypeOf(element.getClass());
				}
				elementCopy = copy(element, elementType);
			}

			copy.add(elementCopy);
		}

		return copy;
	}
829822
@Override
    public Rectangle calculateDiagramBounds(IChemModel model) {
        IAtomContainerSet moleculeSet = model.getMoleculeSet();
        IReactionSet reactionSet = model.getReactionSet();
        if ((moleculeSet == null && reactionSet == null)) {
            return new Rectangle();
        }

        Rectangle2D moleculeBounds = null;
        Rectangle2D reactionBounds = null;
        if (moleculeSet != null) {
            moleculeBounds = BoundsCalculator.calculateBounds(moleculeSet);
        }
        if (reactionSet != null) {
            reactionBounds = BoundsCalculator.calculateBounds(reactionSet);
        }

        if (moleculeBounds == null) {
            return this.calculateScreenBounds(reactionBounds);
        } else if (reactionBounds == null) {
            return this.calculateScreenBounds(moleculeBounds);
        } else {
            Rectangle2D allbounds = new Rectangle2D.Double();
            Rectangle2D.union(moleculeBounds, reactionBounds, allbounds);
            return this.calculateScreenBounds(allbounds);
        }
    }
649179
public AtomContactSet getAtomContacts() {

		AtomContactSet contacts = new AtomContactSet(cutoff);

		List<Contact> list = getIndicesContacts();

		if (jAtomObjects == null) {
			for (Contact cont : list) {
				contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],iAtomObjects[cont.getJ()]),cont.getDistance()));
			}

		} else {
			for (Contact cont : list) {
				contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],jAtomObjects[cont.getJ()]),cont.getDistance()));
			}
		}

		return contacts;
	}
801415
public static IAtomContainerSet getAllReactants(IReaction reaction) {
        IAtomContainerSet moleculeSet = reaction.getBuilder().newInstance(IAtomContainerSet.class);
        IAtomContainerSet reactants = reaction.getReactants();
        for (int i = 0; i < reactants.getAtomContainerCount(); i++) {
            moleculeSet.addAtomContainer(reactants.getAtomContainer(i));
        }
        return moleculeSet;
    }
915810
public static IReactionSet getRelevantReactionsAsProduct(IReactionSet reactSet, IAtomContainer molecule) {
        IReactionSet newReactSet = reactSet.getBuilder().newInstance(IReactionSet.class);
        for (IReaction reaction : reactSet.reactions()) {
            for (IAtomContainer atomContainer : reaction.getProducts().atomContainers())
                if (atomContainer.equals(molecule)) newReactSet.addReaction(reaction);
        }
        return newReactSet;
    }
73215
public static Set<Node> prepareSingleNodeSetFromSets(Set<Set<BioPAXElement>> sets, Graph graph)
	{
		Set<BioPAXElement> elements = new HashSet<BioPAXElement>();
		for (Set<BioPAXElement> set : sets)
		{
			elements.addAll(set);
		}
		return prepareSingleNodeSet(elements, graph);
	}
653556
public static IReactionScheme createReactionScheme(IReactionSet reactionSet) {
        IReactionScheme reactionScheme = reactionSet.getBuilder().newInstance(IReactionScheme.class);

        // Looking for those reactants which doesn't have any precursor. They are the top.
        ArrayList<IReaction> listTopR = new ArrayList<IReaction>();
        for (IReaction reaction : reactionSet.reactions()) {
            if (extractPrecursorReaction(reaction, reactionSet).getReactionCount() == 0) listTopR.add(reaction);
        }

        for (IReaction reaction : listTopR) {
            reactionScheme.addReaction(reaction);
            IReactionScheme newReactionScheme = setScheme(reaction, reactionSet);
            if (newReactionScheme.getReactionCount() != 0 || newReactionScheme.getReactionSchemeCount() != 0)
                reactionScheme.add(newReactionScheme);
        }
        return reactionScheme;
    }
30396
public static final Atom[] centerAtoms(Atom[] atomSet)
			throws StructureException {

		Atom centroid = getCentroid(atomSet);
		return centerAtoms(atomSet, centroid);
	}
700175
public final Set<K> keySet() {
	return new AbstractSet<K>() {
	    public Iterator<K> iterator() {
		final Iterator<Map.Entry<K,V>> ite = entryIterator();
		return new Iterator<K>() {
		    public boolean hasNext() { return ite.hasNext(); }
		    public void    remove()  { ite.remove(); }
		    public K       next()    { return ite.next().getKey(); }
		};
	    }
	    public int size() {
		return size;
	    }
	};
    }
10460
public IRingSet findEssentialRings() {
        if (atomContainer == null) {
            return null;
        }
        IRingSet ringSet = toRingSet(atomContainer, cycleBasis().essentialCycles());
        //		atomContainer.setProperty(CDKConstants.ESSENTIAL_RINGS, ringSet);
        return ringSet;
    }
726809
private IAtomContainerSet getHyperconjugationInteractions(IAtomContainer ac, IAtomContainerSet iSet)
            throws IOException, ClassNotFoundException, CDKException {
        IAtomContainerSet set = ac.getBuilder().newInstance(IAtomContainerSet.class);
        IReactionProcess type = new HeterolyticCleavageSBReaction();
        cleanFlagReactiveCenter(ac);
        boolean found = false; /* control obtained containers */
        IAtomContainerSet setOfReactants = ac.getBuilder().newInstance(IAtomContainerSet.class);
        /* search of reactive center. */
        out: for (int i = 0; i < ac.getBondCount(); i++) {
            if (ac.getBond(i).getOrder() != IBond.Order.SINGLE) {
                for (int j = 0; j < iSet.getAtomContainerCount(); j++) {
                    IAtomContainer ati = iSet.getAtomContainer(j);
                    if (!ati.equals(ac))
                        for (int k = 0; k < ati.getBondCount(); k++) {
                            IAtom a0 = ati.getBond(k).getBegin();
                            IAtom a1 = ati.getBond(k).getEnd();
                            if (!a0.getSymbol().equals("H") || !a1.getSymbol().equals("H"))
                                if ((a0.getID().equals(ac.getBond(i).getBegin().getID()) && a1.getID().equals(
                                        ac.getBond(i).getEnd().getID()))
                                        || (a1.getID().equals(ac.getBond(i).getBegin().getID()) && a0.getID().equals(
                                                ac.getBond(i).getEnd().getID()))) {
                                    if (a0.getFormalCharge() != 0 || a1.getFormalCharge() != 0) continue out;
                                }
                        }
                }
                ac.getBond(i).getBegin().setFlag(CDKConstants.REACTIVE_CENTER, true);
                ac.getBond(i).getEnd().setFlag(CDKConstants.REACTIVE_CENTER, true);
                ac.getBond(i).setFlag(CDKConstants.REACTIVE_CENTER, true);
                found = true;
            }
        }
        if (!found) return null;

        setOfReactants.addAtomContainer(ac);

        List<IParameterReact> paramList = new ArrayList<IParameterReact>();
        IParameterReact param = new SetReactionCenter();
        param.setParameter(Boolean.TRUE);
        paramList.add(param);
        type.setParameterList(paramList);
        IReactionSet setOfReactions = type.initiate(setOfReactants, null);
        for (int i = 0; i < setOfReactions.getReactionCount(); i++) {
            type = new HyperconjugationReaction();
            IAtomContainerSet setOfM2 = ac.getBuilder().newInstance(IAtomContainerSet.class);
            IAtomContainer mol = setOfReactions.getReaction(i).getProducts().getAtomContainer(0);
            for (int k = 0; k < mol.getBondCount(); k++) {
                mol.getBond(k).setFlag(CDKConstants.REACTIVE_CENTER, false);
                mol.getBond(k).getBegin().setFlag(CDKConstants.REACTIVE_CENTER, false);
                mol.getBond(k).getEnd().setFlag(CDKConstants.REACTIVE_CENTER, false);
            }
            setOfM2.addAtomContainer(mol);
            List<IParameterReact> paramList2 = new ArrayList<IParameterReact>();
            IParameterReact param2 = new SetReactionCenter();
            param2.setParameter(Boolean.FALSE);
            paramList2.add(param);
            type.setParameterList(paramList2);
            IReactionSet setOfReactions2 = type.initiate(setOfM2, null);
            if (setOfReactions2.getReactionCount() > 0) {

                IAtomContainer react = setOfReactions2.getReaction(0).getReactants().getAtomContainer(0);

                set.addAtomContainer(react);
            }
        }

        return set;
    }