// 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;

/*******************************************************************************
 * Copyright C 2012, The Pistoia Alliance
 * 
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ******************************************************************************/
package org.helm.notation.tools;




/**
 * This class provides methods that handle chemical structures
 * 
 * @author zhangtianhong
 */
public class StructureParser {

	public static final String SMILES_EXTENSION_SEPARATOR_REGEX = "\\|";
	public static final String SMILES_EXTENSION_SEPARATOR_SYMBOL = "|";
	public static final String EXTENSION_COMPONENT_SEPARATOR_REGEX = "\\$";
	public static final String EXTENSION_COMPONENT_SEPARATOR_SYMBOL = "$";
	public static final String SMILES_MIXTURE_DELIMITER_REGEX = "\\.";
	public static final String ATOM_POSITION_DELIMITER_REGEX = "\\$|;";
	public static final String ATOM_POSITION_DELIMITER_SYMBOL = ";";
	public static final String WHITE_SPACE_REGEX = "\\s";
	// 2014-05-13 -e :do not include enhanced stereochemistry features
	public static final String CHEMAXON_EXTENDEND_SMILES_FORMAT = "cxsmiles:u-e";
	public static final String UNIQUE_SMILES_FORMAT = "smiles:u";
	public static final String SMILES_FORMAT = "smiles";
	private static final int CANONICALIZATION_ROUND = 3;


// 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;

/*******************************************************************************
 * Copyright C 2012, The Pistoia Alliance
 * 
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ******************************************************************************/
package org.helm.notation.tools;




/**
 * This class provides methods that handle chemical structures
 * 
 * @author zhangtianhong
 */
public class StructureParser {

	public static final String SMILES_EXTENSION_SEPARATOR_REGEX = "\\|";
	public static final String SMILES_EXTENSION_SEPARATOR_SYMBOL = "|";
	public static final String EXTENSION_COMPONENT_SEPARATOR_REGEX = "\\$";
	public static final String EXTENSION_COMPONENT_SEPARATOR_SYMBOL = "$";
	public static final String SMILES_MIXTURE_DELIMITER_REGEX = "\\.";
	public static final String ATOM_POSITION_DELIMITER_REGEX = "\\$|;";
	public static final String ATOM_POSITION_DELIMITER_SYMBOL = ";";
	public static final String WHITE_SPACE_REGEX = "\\s";
	// 2014-05-13 -e :do not include enhanced stereochemistry features
	public static final String CHEMAXON_EXTENDEND_SMILES_FORMAT = "cxsmiles:u-e";
	public static final String UNIQUE_SMILES_FORMAT = "smiles:u";
	public static final String SMILES_FORMAT = "smiles";
	private static final int CANONICALIZATION_ROUND = 3;


	public static MoleculeInfo getMoleculeInfo(String smiles)
