cleanup
[jalview.git] / forester / java / src / org / forester / sdi / SDI.java
index b21b9b5..d7bf01b 100644 (file)
@@ -7,7 +7,7 @@
 // Copyright (C) 2000-2001 Washington University School of Medicine
 // and Howard Hughes Medical Institute
 // All rights reserved
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
@@ -17,7 +17,7 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 // Lesser General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
@@ -131,7 +131,6 @@ public abstract class SDI {
         boolean all_have_id = true;
         boolean all_have_code = true;
         boolean all_have_sn = true;
-        boolean all_have_cn = true;
         for( final PhylogenyNodeIterator iter = _species_tree.iteratorExternalForward(); iter.hasNext(); ) {
             final PhylogenyNode n = iter.next();
             if ( n.getNodeData().isHasTaxonomy() ) {
@@ -145,9 +144,6 @@ public abstract class SDI {
                 if ( ForesterUtil.isEmpty( tax.getScientificName() ) ) {
                     all_have_sn = false;
                 }
-                if ( ForesterUtil.isEmpty( tax.getCommonName() ) ) {
-                    all_have_cn = false;
-                }
             }
             else {
                 throw new IllegalArgumentException( "species tree node [" + n + "] has no taxonomic data" );
@@ -166,9 +162,6 @@ public abstract class SDI {
                 if ( ForesterUtil.isEmpty( tax.getScientificName() ) ) {
                     all_have_sn = false;
                 }
-                if ( ForesterUtil.isEmpty( tax.getCommonName() ) ) {
-                    all_have_cn = false;
-                }
             }
             else {
                 throw new IllegalArgumentException( "gene tree node [" + n + "] has no taxonomic data" );
@@ -183,9 +176,6 @@ public abstract class SDI {
         else if ( all_have_sn ) {
             base = TaxonomyComparisonBase.SCIENTIFIC_NAME;
         }
-        else if ( all_have_cn ) {
-            base = TaxonomyComparisonBase.COMMON_NAME;
-        }
         else {
             throw new IllegalArgumentException( "gene tree and species tree have incomparable taxonomies" );
         }
@@ -224,8 +214,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<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.
@@ -296,7 +287,7 @@ public abstract class SDI {
         return sb.toString();
     }
 
-    private static String taxonomyToString( final PhylogenyNode n, final TaxonomyComparisonBase base ) {
+    static String taxonomyToString( final PhylogenyNode n, final TaxonomyComparisonBase base ) {
         final Taxonomy tax = n.getNodeData().getTaxonomy();
         switch ( base ) {
             case ID:
@@ -305,14 +296,12 @@ public abstract class SDI {
                 return tax.getTaxonomyCode();
             case SCIENTIFIC_NAME:
                 return tax.getScientificName();
-            case COMMON_NAME:
-                return tax.getCommonName();
             default:
                 throw new IllegalArgumentException( "unknown comparison base for taxonomies: " + base );
         }
     }
 
-    enum TaxonomyComparisonBase {
-        ID, CODE, SCIENTIFIC_NAME, COMMON_NAME;
+    public enum TaxonomyComparisonBase {
+        ID, CODE, SCIENTIFIC_NAME
     }
 }