Fixed issue with reading from TreeBase
[jalview.git] / forester / java / src / org / forester / io / parsers / nexus / NexusPhylogeniesParser.java
index 4617a8f..0f51cd7 100644 (file)
@@ -35,7 +35,7 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.forester.archaeopteryx.Constants;
+import org.forester.archaeopteryx.AptxConstants;
 import org.forester.io.parsers.IteratingPhylogenyParser;
 import org.forester.io.parsers.PhylogenyParser;
 import org.forester.io.parsers.nhx.NHXFormatException;
@@ -53,6 +53,8 @@ import org.forester.util.ForesterUtil;
 
 public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, PhylogenyParser {
 
+    final private static boolean DEBUG                               = false;
+    
     final private static String            begin_trees               = NexusConstants.BEGIN_TREES.toLowerCase();
     final private static String            end                       = NexusConstants.END.toLowerCase();
     final private static String            endblock                  = "endblock";
@@ -69,11 +71,11 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P
     final private static Pattern           TRANSLATE_PATTERN         = Pattern.compile( "([0-9A-Za-z]+)\\s+(.+)" );
     final private static Pattern           ALN_PATTERN               = Pattern.compile( "(.+)\\s+([A-Za-z-_\\*\\?]+)" );
     final private static Pattern           DATATYPE_PATTERN          = Pattern.compile( "datatype\\s?.\\s?([a-z]+)" );
-    final private static Pattern           LINK_TAXA_PATTERN         = Pattern.compile( "link\\s+taxa\\s?.\\s?([^;]+)",
-                                                                                        Pattern.CASE_INSENSITIVE );
+    //final private static Pattern           LINK_TAXA_PATTERN         = Pattern.compile( "link\\s+taxa\\s?.\\s?([^;]+)",
+    //                                                                                    Pattern.CASE_INSENSITIVE );
     final private static String            utree                     = NexusConstants.UTREE.toLowerCase();
     private BufferedReader                 _br;
-    private boolean                        _ignore_quotes_in_nh_data = Constants.NH_PARSING_IGNORE_QUOTES_DEFAULT;
+    private boolean                        _ignore_quotes_in_nh_data = AptxConstants.NH_PARSING_IGNORE_QUOTES_DEFAULT;
     private boolean                        _in_taxalabels;
     private boolean                        _in_translate;
     private boolean                        _in_tree;
@@ -246,6 +248,9 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P
         _next = null;
         String line;
         while ( ( line = _br.readLine() ) != null ) {
+            if ( DEBUG ) {
+                System.out.println( line );
+            }
             line = line.trim();
             if ( ( line.length() > 0 ) && !line.startsWith( "#" ) && !line.startsWith( ">" ) ) {
                 line = ForesterUtil.collapseWhiteSpace( line );
@@ -289,11 +294,10 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P
                         }
                     }
                     else if ( line_lc.startsWith( "link" ) ) {
-                        final Matcher link_m = LINK_TAXA_PATTERN.matcher( line );
-                        if ( link_m.lookingAt() ) {
-                            final String link = link_m.group( 1 );
-                            System.out.println( "link taxa:" + link );
-                        }
+                        //final Matcher link_m = LINK_TAXA_PATTERN.matcher( line );
+                        //if ( link_m.lookingAt() ) {
+                            //final String link = link_m.group( 1 );  //TODO why?
+                       // }
                     }
                     else if ( line_lc.startsWith( end ) || line_lc.startsWith( endblock ) ) {
                         _in_trees_block = false;
@@ -395,17 +399,15 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P
                         _datatype = null;
                     }
                     else if ( line_lc.startsWith( "link" ) ) {
-                        final Matcher link_m = LINK_TAXA_PATTERN.matcher( line );
-                        if ( link_m.lookingAt() ) {
-                            final String link = link_m.group( 1 );
-                            System.out.println( "link taxa:" + link );
-                        }
+                     //   final Matcher link_m = LINK_TAXA_PATTERN.matcher( line );
+                     //   if ( link_m.lookingAt() ) {
+                     //       final String link = link_m.group( 1 );
+                     //   }
                     }
                     else {
                         final Matcher datatype_matcher = DATATYPE_PATTERN.matcher( line_lc );
                         if ( datatype_matcher.find() ) {
                             _datatype = datatype_matcher.group( 1 );
-                            System.out.println( _datatype );
                         }
                         else {
                             if ( ( _datatype != null )
@@ -430,7 +432,6 @@ public final class NexusPhylogeniesParser implements IteratingPhylogenyParser, P
                                         s = BasicSequence.createRnaSequence( id, seq );
                                     }
                                     _seqs.put( id, s );
-                                    System.out.println( s );
                                 }
                             }
                         }