// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIdentifier.java
// public interface StructureIdentifier extends Serializable {
// 
// 	/**
// 	 * Get the String form of this identifier.
// 	 *
// 	 * It is recommended that the {@link #toString()} method also return the
// 	 * identifier, for consistency during serialization.
// 	 * @return The String form of this identifier
// 	 */
// 	String getIdentifier();
// 
// 
// 	/**
// 	 * Loads a structure encompassing the structure identified.
// 	 * The Structure returned should be suitable for passing as
// 	 * the input to {@link #reduce(Structure)}.
// 	 *
// 	 * It is recommended that the most complete structure available be returned
// 	 * (e.g. the full PDB) to allow processing of unselected portions where
// 	 * appropriate.
// 	 * @param AtomCache A potential sources of structures
// 	 * @return A Structure containing at least the atoms identified by this,
// 	 *  or null if Structures are not applicable.
// 	 * @throws StructureException For errors loading and parsing the structure
// 	 * @throws IOException Errors reading the structure from disk
// 	 */
// 	Structure loadStructure(AtomCache cache) throws StructureException, IOException;
// 
// 	/**
// 	 * Convert to a canonical SubstructureIdentifier.
// 	 *
// 	 * <p>This allows all domains to be converted to a standard format String.
// 	 * @return A SubstructureIdentifier equivalent to this
// 	 * @throws StructureException Wraps exceptions that may be thrown by individual
// 	 *  implementations. For example, a SCOP identifier may require that the
// 	 *  domain definitions be available for download.
// 	 */
// 	SubstructureIdentifier toCanonical() throws StructureException;
// 
// 	/**
// 	 * Takes a complete structure as input and reduces it to the substructure
// 	 * represented by this StructureIdentifier.
// 	 *
// 	 * <p>The returned structure may be a shallow copy of the input, with shared
// 	 * Chains, Residues, etc.
// 	 * @param input A full structure, e.g. as loaded from the PDB. The structure
// 	 * ID should match that returned by getPdbId(), if applicable.
// 	 * @return
// 	 * @throws StructureException
// 	 * @see StructureTools#getReducedStructure(Structure, String)
// 	 */
// 	Structure reduce(Structure input) throws StructureException;
// 
// }


import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Matrix4d;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.client.StructureName;
import org.biojava.nbio.structure.align.multiple.Block;
import org.biojava.nbio.structure.align.multiple.BlockImpl;
import org.biojava.nbio.structure.align.multiple.BlockSet;
import org.biojava.nbio.structure.align.multiple.BlockSetImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsemble;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsembleImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
import org.biojava.nbio.structure.align.multiple.ScoresCache;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

	private static void parseHeader(Node node,
			MultipleAlignmentEnsemble ensemble) {

		NamedNodeMap atts = node.getAttributes();

		String algo = atts.getNamedItem("Algorithm").getTextContent();
		if (!algo.equals("null")){
			ensemble.setAlgorithmName(algo);
		}

		String version = atts.getNamedItem("Version").getTextContent();
		if (!version.equals("null")){
			ensemble.setVersion(version);
		}

		String ioTime = atts.getNamedItem("IOTime").getTextContent();
		if (!ioTime.equals("null")){
			ensemble.setIoTime(new Long(ioTime));
		}

		String time = atts.getNamedItem("CalculationTime").getTextContent();
		if (!time.equals("null")){
			ensemble.setCalculationTime(new Long(time));
		}
	}

	private static void parseStructures(Node root,
			MultipleAlignmentEnsemble ensemble) {

// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIdentifier.java
// public interface StructureIdentifier extends Serializable {
// 
// 	/**
// 	 * Get the String form of this identifier.
// 	 *
// 	 * It is recommended that the {@link #toString()} method also return the
// 	 * identifier, for consistency during serialization.
// 	 * @return The String form of this identifier
// 	 */
// 	String getIdentifier();
// 
// 
// 	/**
// 	 * Loads a structure encompassing the structure identified.
// 	 * The Structure returned should be suitable for passing as
// 	 * the input to {@link #reduce(Structure)}.
// 	 *
// 	 * It is recommended that the most complete structure available be returned
// 	 * (e.g. the full PDB) to allow processing of unselected portions where
// 	 * appropriate.
// 	 * @param AtomCache A potential sources of structures
// 	 * @return A Structure containing at least the atoms identified by this,
// 	 *  or null if Structures are not applicable.
// 	 * @throws StructureException For errors loading and parsing the structure
// 	 * @throws IOException Errors reading the structure from disk
// 	 */
// 	Structure loadStructure(AtomCache cache) throws StructureException, IOException;
// 
// 	/**
// 	 * Convert to a canonical SubstructureIdentifier.
// 	 *
// 	 * <p>This allows all domains to be converted to a standard format String.
// 	 * @return A SubstructureIdentifier equivalent to this
// 	 * @throws StructureException Wraps exceptions that may be thrown by individual
// 	 *  implementations. For example, a SCOP identifier may require that the
// 	 *  domain definitions be available for download.
// 	 */
// 	SubstructureIdentifier toCanonical() throws StructureException;
// 
// 	/**
// 	 * Takes a complete structure as input and reduces it to the substructure
// 	 * represented by this StructureIdentifier.
// 	 *
// 	 * <p>The returned structure may be a shallow copy of the input, with shared
// 	 * Chains, Residues, etc.
// 	 * @param input A full structure, e.g. as loaded from the PDB. The structure
// 	 * ID should match that returned by getPdbId(), if applicable.
// 	 * @return
// 	 * @throws StructureException
// 	 * @see StructureTools#getReducedStructure(Structure, String)
// 	 */
// 	Structure reduce(Structure input) throws StructureException;
// 
// }


// Path: biojava-structure/src/main/java/org/biojava/nbio/structure/align/xml/MultipleAlignmentXMLParser.java
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Matrix4d;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.biojava.nbio.structure.StructureIdentifier;
import org.biojava.nbio.structure.align.client.StructureName;
import org.biojava.nbio.structure.align.multiple.Block;
import org.biojava.nbio.structure.align.multiple.BlockImpl;
import org.biojava.nbio.structure.align.multiple.BlockSet;
import org.biojava.nbio.structure.align.multiple.BlockSetImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsemble;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentEnsembleImpl;
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
import org.biojava.nbio.structure.align.multiple.ScoresCache;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;


	private static void parseHeader(Node node,
			MultipleAlignmentEnsemble ensemble) {

		NamedNodeMap atts = node.getAttributes();

		String algo = atts.getNamedItem("Algorithm").getTextContent();
		if (!algo.equals("null")){
			ensemble.setAlgorithmName(algo);
		}

		String version = atts.getNamedItem("Version").getTextContent();
		if (!version.equals("null")){
			ensemble.setVersion(version);
		}

		String ioTime = atts.getNamedItem("IOTime").getTextContent();
		if (!ioTime.equals("null")){
			ensemble.setIoTime(new Long(ioTime));
		}

		String time = atts.getNamedItem("CalculationTime").getTextContent();
		if (!time.equals("null")){
			ensemble.setCalculationTime(new Long(time));
		}
	}

	private static void parseStructures(Node root,
			MultipleAlignmentEnsemble ensemble) {

		List<StructureIdentifier> names = new ArrayList<StructureIdentifier>();