package textbender.a.u.chromography; // Copyright 2006-2007, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Textbender Software"), to deal in the Textbender Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Textbender Software, and to permit persons to whom the Textbender Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Textbender Software. THE TEXTBENDER 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 TEXTBENDER SOFTWARE OR THE USE OR OTHER DEALINGS IN THE TEXTBENDER SOFTWARE. import java.io.*; import java.util.*; import org.w3c.dom.*; import textbender.a.r.desk.*; import textbender.d.gene.*; import textbender.g.lang.*; /** A chromographic reference series. */ public @ThreadSafe class ReferenceSeries implements Serializable { private static final long serialVersionUID = 0L; // protected ReferenceSeries( HostServiceRegistry.UniqueID origin ) { this.origin = origin; } /** Constructs a ReferenceSeries. * * @param origin per {@linkplain #origin() origin}() * @param leafGeneArray array of leaf genes defining this series, * in document order * @param gList list of gene meta-data 'g' elements */ public ReferenceSeries( final HostServiceRegistry.UniqueID origin, final Element[] leafGeneArray, final List gList ) { this.origin = origin; LinkedHashMap locusMap = new LinkedHashMap ( /*initial capacity*/(int)((leafGeneArray.length + 1) / 0.75f) + 1 ); for( Element gene : leafGeneArray ) { String locus = gList.get(Gene.gIndexOf(gene)).getAttributeNS( null, "locus" ); locusMap.put( locus, locus ); } leafLocusSetArray = new String[locusMap.size()]; locusMap.values().toArray( leafLocusSetArray ); } // ------------------------------------------------------------------------------------ /** Returns the series as an array of loci, in document order. * If a locus occurs multiple times, it is ordered by its first occurence. * * @return array of loci, each locus being unique */ public String[] leafLocusSetArray() { return leafLocusSetArray; } private final String[] leafLocusSetArray; /** Identifies the origin of the series. */ public final HostServiceRegistry.UniqueID origin() { return origin; } private final HostServiceRegistry.UniqueID origin; }