domain + go output work begins
[jalview.git] / forester / java / src / org / forester / phylogeny / PhylogenyMethods.java
index f7aa56d..459138b 100644 (file)
@@ -133,7 +133,7 @@ public class PhylogenyMethods {
                             if ( !ForesterUtil.isEmpty( stats.get( i ).getDescription() ) ) {\r
                                 if ( !stats.get( i ).getDescription().equalsIgnoreCase( c.getType() ) ) {\r
                                     throw new IllegalArgumentException( "support values in node [" + n.toString()\r
-                                            + "] appear inconsistently ordered" );\r
+                                                                        + "] appear inconsistently ordered" );\r
                                 }\r
                             }\r
                             stats.get( i ).setDescription( c.getType() );\r
@@ -148,8 +148,8 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Calculates the distance between PhylogenyNodes node1 and node2.\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @param node1\r
      * @param node2\r
      * @return distance between node1 and node2\r
@@ -163,8 +163,8 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Returns the LCA of PhylogenyNodes node1 and node2.\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @param node1\r
      * @param node2\r
      * @return LCA of node1 and node2\r
@@ -209,8 +209,8 @@ public class PhylogenyMethods {
     /**\r
      * Returns the LCA of PhylogenyNodes node1 and node2.\r
      * Precondition: ids are in pre-order (or level-order).\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @param node1\r
      * @param node2\r
      * @return LCA of node1 and node2\r
@@ -500,9 +500,9 @@ public class PhylogenyMethods {
     }\r
 \r
     /**\r
-     * \r
+     *\r
      * Convenience method\r
-     * \r
+     *\r
      * @param node\r
      * @return\r
      */\r
@@ -553,9 +553,9 @@ public class PhylogenyMethods {
     }\r
 \r
     /**\r
-     * Returns taxonomy t if all external descendants have \r
+     * Returns taxonomy t if all external descendants have\r
      * the same taxonomy t, null otherwise.\r
-     * \r
+     *\r
      */\r
     public static Taxonomy getExternalDescendantsTaxonomy( final PhylogenyNode node ) {\r
         final List<PhylogenyNode> descs = node.getAllExternalDescendants();\r
@@ -683,7 +683,7 @@ public class PhylogenyMethods {
 \r
     /*\r
      * This is case insensitive.\r
-     * \r
+     *\r
      */\r
     public synchronized static boolean isTaxonomyHasIdentifierOfGivenProvider( final Taxonomy tax,\r
                                                                                final String[] providers ) {\r
@@ -777,7 +777,7 @@ public class PhylogenyMethods {
      * all external nodes of node.\r
      * If at least one of the external nodes has no taxonomy,\r
      * null is returned.\r
-     * \r
+     *\r
      */\r
     public static Map<Taxonomy, Integer> obtainDistinctTaxonomyCounts( final PhylogenyNode node ) {\r
         final List<PhylogenyNode> descs = node.getAllExternalDescendants();\r
@@ -801,10 +801,10 @@ public class PhylogenyMethods {
      * Arranges the order of childern for each node of this Phylogeny in such a\r
      * way that either the branch with more children is on top (right) or on\r
      * bottom (left), dependent on the value of boolean order.\r
-     * \r
+     *\r
      * @param order\r
      *            decides in which direction to order\r
-     * @param pri \r
+     * @param pri\r
      */\r
     public static void orderAppearance( final PhylogenyNode n,\r
                                         final boolean order,\r
@@ -1239,7 +1239,7 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Convenience method.\r
-     * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+     * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
      */\r
     public static void setBootstrapConfidence( final PhylogenyNode node, final double bootstrap_confidence_value ) {\r
         setConfidence( node, bootstrap_confidence_value, "bootstrap" );\r
@@ -1261,7 +1261,7 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Convenience method.\r
-     * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+     * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
      */\r
     public static void setConfidence( final PhylogenyNode node, final double confidence_value ) {\r
         setConfidence( node, confidence_value, "" );\r
@@ -1269,7 +1269,7 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Convenience method.\r
-     * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+     * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
      */\r
     public static void setConfidence( final PhylogenyNode node, final double confidence_value, final String type ) {\r
         Confidence c = null;\r
@@ -1293,11 +1293,11 @@ public class PhylogenyMethods {
 \r
     /**\r
      * Convenience method to set the taxonomy code of a phylogeny node.\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @param node\r
      * @param taxonomy_code\r
-     * @throws PhyloXmlDataFormatException \r
+     * @throws PhyloXmlDataFormatException\r
      */\r
     public static void setTaxonomyCode( final PhylogenyNode node, final String taxonomy_code )\r
             throws PhyloXmlDataFormatException {\r
@@ -1330,7 +1330,7 @@ public class PhylogenyMethods {
     /**\r
      * Removes from Phylogeny to_be_stripped all external Nodes which are\r
      * associated with a species NOT found in Phylogeny reference.\r
-     * \r
+     *\r
      * @param reference\r
      *            a reference Phylogeny\r
      * @param to_be_stripped\r
@@ -1365,7 +1365,7 @@ public class PhylogenyMethods {
             else if ( !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getScientificName() ) )\r
                     && !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getTaxonomyCode() ) )\r
                     && !( ( n.getNodeData().getTaxonomy().getIdentifier() != null ) && ref_ext_taxo.contains( n\r
-                            .getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {\r
+                                                                                                              .getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {\r
                 nodes_to_delete.add( n );\r
             }\r
         }\r
@@ -1502,7 +1502,7 @@ public class PhylogenyMethods {
                             n.setName( "" );\r
                         }\r
                         n.getNodeData().getTaxonomy()\r
-                                .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
+                        .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
                         break;\r
                     }\r
                     case TAXONOMY_ID_UNIPROT_2: {\r
@@ -1518,7 +1518,7 @@ public class PhylogenyMethods {
                             n.setName( "" );\r
                         }\r
                         n.getNodeData().getTaxonomy()\r
-                                .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
+                        .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
                         break;\r
                     }\r
                     case TAXONOMY_ID: {\r
@@ -1617,7 +1617,7 @@ public class PhylogenyMethods {
     /**\r
      * Calculates the distance between PhylogenyNodes n1 and n2.\r
      * PRECONDITION: n1 is a descendant of n2.\r
-     * \r
+     *\r
      * @param n1\r
      *            a descendant of n2\r
      * @param n2\r
@@ -1672,7 +1672,19 @@ public class PhylogenyMethods {
             return my_s.indexOf( my_query ) >= 0;\r
         }\r
         else {\r
-            return Pattern.compile( "(\\b|_)" + Pattern.quote( my_query ) + "(\\b|_)" ).matcher( my_s ).find();\r
+            Pattern p = null;\r
+            try {\r
+                p = Pattern.compile( "(\\b|_)" + Pattern.quote( my_query ) + "(\\b|_)" );\r
+            }\r
+            catch ( final PatternSyntaxException e ) {\r
+                return false;\r
+            }\r
+            if ( p != null ) {\r
+                return p.matcher( my_s ).find();\r
+            }\r
+            else {\r
+                return false;\r
+            }\r
         }\r
     }\r
 \r