X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fsdi%2FSDI.java;h=b1258f0820f58c05707179be26936e4045ac8de7;hb=b1a74bd076c917d428002284a53a2c6f390226fb;hp=c783ce095332f7f9a899367dc059d45142518c1f;hpb=4cefcbf8c547e86e56ed503f0a3d1a06e462e60e;p=jalview.git diff --git a/forester/java/src/org/forester/sdi/SDI.java b/forester/java/src/org/forester/sdi/SDI.java index c783ce0..b1258f0 100644 --- a/forester/java/src/org/forester/sdi/SDI.java +++ b/forester/java/src/org/forester/sdi/SDI.java @@ -32,6 +32,7 @@ import java.util.Map; 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; @@ -214,8 +215,9 @@ public abstract class SDI { * 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 speciestree_ext_nodes = new HashMap(); final TaxonomyComparisonBase tax_comp_base = determineTaxonomyComparisonBase(); // Put references to all external nodes of the species tree into a map. @@ -287,20 +289,43 @@ public abstract class SDI { } 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"; + } + } } }