// Path: source/org/helm/notation/NotationException.java
// public class NotationException extends Exception {
// 
// 	/**
// 	 * Creates a new instance of <code>NotationException</code> without detail
// 	 * message.
// 	 */
// 	public NotationException() {
// 	}
// 
// 	/**
// 	 * Constructs an instance of <code>NotationException</code> with the
// 	 * specified detail message.
// 	 * 
// 	 * @param msg
// 	 *            the detail message.
// 	 */
// 	public NotationException(String msg) {
// 		super(msg);
// 	}
// 
// 	public NotationException(String msg, Throwable err) {
// 		super(msg, err);
// 	}
// }
// 
// Path: source/org/helm/notation/StructureException.java
// public class StructureException extends Exception {
// 
// 	/**
// 	 * Creates a new instance of <code>StructureException</code> without detail
// 	 * message.
// 	 */
// 	public StructureException() {
// 	}
// 
// 	/**
// 	 * Constructs an instance of <code>StructureException</code> with the
// 	 * specified detail message.
// 	 * 
// 	 * @param msg
// 	 *            the detail message.
// 	 */
// 	public StructureException(String msg) {
// 		super(msg);
// 	}
// 
// 	public StructureException(String msg, Throwable err) {
// 		super(msg, err);
// 	}
// }
// 
// Path: source/org/helm/notation/model/MoleculeInfo.java
// public class MoleculeInfo {
// 	private double molecularWeight;
// 	private String molecularFormula;
// 	private double exactMass;
// 
// 	public double getMolecularWeight() {
// 		return molecularWeight;
// 	}
// 
// 	public void setMolecularWeight(double molecularWeight) {
// 		this.molecularWeight = molecularWeight;
// 	}
// 
// 	public String getMolecularFormula() {
// 		return molecularFormula;
// 	}
// 
// 	public void setMolecularFormula(String molecularFormula) {
// 		this.molecularFormula = molecularFormula;
// 	}
// 
// 	public double getExactMass() {
// 		return exactMass;
// 	}
// 
// 	public void setExactMass(double exactMass) {
// 		this.exactMass = exactMass;
// 	}
// }


import org.helm.notation.model.MoleculeInfo;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import chemaxon.formats.MolImporter;
import chemaxon.marvin.calculations.ElementalAnalyserPlugin;
import chemaxon.marvin.plugin.PluginException;
import chemaxon.struc.MolAtom;
import chemaxon.struc.MolBond;
import chemaxon.struc.Molecule;
import org.helm.notation.NotationException;
import org.helm.notation.StructureException;

		}
		return molecule;
	}

	/**
	 * mol is changed after this step, make sure to clone it if need to preserve
	 * state the first R group with the specifid ID is removed
	 * 
	 * @param mol
	 * @param rGroupId
	 * @return MolAtom this is the atom in the new mol which will be used for
	 *         connection later, could be null
	 * @throws org.helm.notation.StructureException
	 */
	public static MolAtom removeRgroup(Molecule mol, int rGroupId)
			throws StructureException {
		MolAtom atom = null;
		MolAtom[] atoms = mol.getAtomArray();
		for (int i = 0; i < atoms.length; i++) {
			int rId = atoms[i].getRgroup();

			// found first R group
			if (rId == rGroupId) {
				atom = removeRgroup(mol, atoms[i]);
				break;
			}
		}
		if (null != atom) {
			return atom;
		} else {

// Path: source/org/helm/notation/NotationException.java
// public class NotationException extends Exception {
// 
// 	/**
// 	 * Creates a new instance of <code>NotationException</code> without detail
// 	 * message.
// 	 */
// 	public NotationException() {
// 	}
// 
// 	/**
// 	 * Constructs an instance of <code>NotationException</code> with the
// 	 * specified detail message.
// 	 * 
// 	 * @param msg
// 	 *            the detail message.
// 	 */
// 	public NotationException(String msg) {
// 		super(msg);
// 	}
// 
// 	public NotationException(String msg, Throwable err) {
// 		super(msg, err);
// 	}
// }
// 
// Path: source/org/helm/notation/StructureException.java
// public class StructureException extends Exception {
// 
// 	/**
// 	 * Creates a new instance of <code>StructureException</code> without detail
// 	 * message.
// 	 */
// 	public StructureException() {
// 	}
// 
// 	/**
// 	 * Constructs an instance of <code>StructureException</code> with the
// 	 * specified detail message.
// 	 * 
// 	 * @param msg
// 	 *            the detail message.
// 	 */
// 	public StructureException(String msg) {
// 		super(msg);
// 	}
// 
// 	public StructureException(String msg, Throwable err) {
// 		super(msg, err);
// 	}
// }
// 
// Path: source/org/helm/notation/model/MoleculeInfo.java
// public class MoleculeInfo {
// 	private double molecularWeight;
// 	private String molecularFormula;
// 	private double exactMass;
// 
// 	public double getMolecularWeight() {
// 		return molecularWeight;
// 	}
// 
// 	public void setMolecularWeight(double molecularWeight) {
// 		this.molecularWeight = molecularWeight;
// 	}
// 
// 	public String getMolecularFormula() {
// 		return molecularFormula;
// 	}
// 
// 	public void setMolecularFormula(String molecularFormula) {
// 		this.molecularFormula = molecularFormula;
// 	}
// 
// 	public double getExactMass() {
// 		return exactMass;
// 	}
// 
// 	public void setExactMass(double exactMass) {
// 		this.exactMass = exactMass;
// 	}
// }


// Path: source/org/helm/notation/tools/StructureParser.java
import org.helm.notation.model.MoleculeInfo;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import chemaxon.formats.MolImporter;
import chemaxon.marvin.calculations.ElementalAnalyserPlugin;
import chemaxon.marvin.plugin.PluginException;
import chemaxon.struc.MolAtom;
import chemaxon.struc.MolBond;
import chemaxon.struc.Molecule;
import org.helm.notation.NotationException;
import org.helm.notation.StructureException;

		}
		return molecule;
	}

	/**
	 * mol is changed after this step, make sure to clone it if need to preserve
	 * state the first R group with the specifid ID is removed
	 * 
	 * @param mol
	 * @param rGroupId
	 * @return MolAtom this is the atom in the new mol which will be used for
	 *         connection later, could be null
	 * @throws org.helm.notation.StructureException
	 */
	public static MolAtom removeRgroup(Molecule mol, int rGroupId)
			throws StructureException {
		MolAtom atom = null;
		MolAtom[] atoms = mol.getAtomArray();
		for (int i = 0; i < atoms.length; i++) {
			int rId = atoms[i].getRgroup();

			// found first R group
			if (rId == rGroupId) {
				atom = removeRgroup(mol, atoms[i]);
				break;
			}
		}
		if (null != atom) {
			return atom;
		} else {

			throw new StructureException(
