code: public static IReaction reverse(IReaction reaction) {
          IReaction reversedReaction = reaction.getBuilder().newInstance(IReaction.class);
          if (reaction.getDirection() == IReaction.Direction.BIDIRECTIONAL) {
              reversedReaction.setDirection(IReaction.Direction.BIDIRECTIONAL);
          } else if (reaction.getDirection() == IReaction.Direction.FORWARD) {
              reversedReaction.setDirection(IReaction.Direction.BACKWARD);
          } else if (reaction.getDirection() == IReaction.Direction.BACKWARD) {
              reversedReaction.setDirection(IReaction.Direction.FORWARD);
          }
          IAtomContainerSet reactants = reaction.getReactants();
          for (int i = 0; i < reactants.getAtomContainerCount(); i++) {
              double coefficient = reaction.getReactantCoefficient(reactants.getAtomContainer(i));
              reversedReaction.addProduct(reactants.getAtomContainer(i), coefficient);
          }
          IAtomContainerSet products = reaction.getProducts();
          for (int i = 0; i < products.getAtomContainerCount(); i++) {
              double coefficient = reaction.getProductCoefficient(products.getAtomContainer(i));
              reversedReaction.addReactant(products.getAtomContainer(i), coefficient);
          }
          return reversedReaction;
      }
docs: Returns a new Reaction object which is the reverse of the given
  Reaction.
  @param reaction the reaction being considered
  @return the reverse reaction