import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Identifier;
import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.util.ForesterUtil;
* links (sets the field "link" of PhylogenyNode) each external
* PhylogenyNode of gene_tree to the external PhylogenyNode of species_tree
* which has the same species name.
+ * @throws SDIException
*/
- void linkNodesOfG() {
+ void linkNodesOfG() throws SDIException {
final Map<String, PhylogenyNode> speciestree_ext_nodes = new HashMap<String, PhylogenyNode>();
final TaxonomyComparisonBase tax_comp_base = determineTaxonomyComparisonBase();
// Put references to all external nodes of the species tree into a map.
}
static String taxonomyToString( final PhylogenyNode n, final TaxonomyComparisonBase base ) {
- final Taxonomy tax = n.getNodeData().getTaxonomy();
switch ( base ) {
case ID:
- return tax.getIdentifier().getValue();
+ final Identifier id = n.getNodeData().getTaxonomy().getIdentifier();
+ if ( id == null ) {
+ return null;
+ }
+ return id.getValuePlusProvider();
case CODE:
- return tax.getTaxonomyCode();
+ return n.getNodeData().getTaxonomy().getTaxonomyCode();
case SCIENTIFIC_NAME:
- return tax.getScientificName();
+ return n.getNodeData().getTaxonomy().getScientificName();
default:
throw new IllegalArgumentException( "unknown comparison base for taxonomies: " + base );
}
}
public enum TaxonomyComparisonBase {
- ID, CODE, SCIENTIFIC_NAME
+ ID {
+
+ @Override
+ public String toString() {
+ return "taxonomy id";
+ }
+ },
+ CODE {
+
+ @Override
+ public String toString() {
+ return "taxonomy code/mnemonic";
+ }
+ },
+ SCIENTIFIC_NAME {
+
+ @Override
+ public String toString() {
+ return "scientific name";
+ }
+ }
}
}