edu.upenn.crimson.io
Class NexusFile

java.lang.Object
  extended by edu.upenn.crimson.io.NexusFile

public class NexusFile
extends java.lang.Object

Functions related to loading NEXUS files.

Version:
$Id: NexusFile.java,v 1.54 2007/06/14 19:48:42 fisher Exp $
Notes:
Should see if can optimize db access by maintaining one Statement that is created every time a database connection is made.

Field Summary
private static java.util.regex.Pattern needsQuotesPattern
          From Mark Holder
private static java.lang.String regexPat
           
private static java.util.regex.Pattern shortStrNeedsQuotePattern
          From Mark Holder
 
Constructor Summary
NexusFile()
           
 
Method Summary
static Tree append(java.lang.String filename, java.lang.String treeID, java.lang.String partitionID)
          Appends a Nexus file into the current database.
static java.lang.String doQuote(java.lang.String text)
          From Mark Holder
private static int findLabelEnd(java.lang.String newick, int start)
          Keep incrementing until we find the end of the number or label.
static Tree load(java.lang.String filename, java.lang.String treeID, java.lang.String partitionID)
          Loads a Nexus file.
static Tree loadNewick(java.lang.String filename)
          Loads a tree structure from a Nexus file into memory.
private static boolean multiCharStringNeedsQuotes(java.lang.String text)
          From Mark Holder
static Tree parseNewick(Tree tree)
          This might be faster if we use char[] instead of String for "newick".
static Tree parseNewick(Tree tree, java.lang.String newick)
          This might be faster if we use char[] instead of String for "newick".
static java.lang.String quote(java.lang.String text)
          From Mark Holder This will properly quote a word that is to be included in a NEXUS file.
static java.lang.String[] quote(java.lang.String[] text)
          From Mark Holder This will properly quote a word that is to be included in a NEXUS file.
private static boolean shortStringNeedsQuotes(java.lang.String text)
          From Mark Holder handles strings of len 1 or 0 only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regexPat

private static final java.lang.String regexPat
See Also:
Constant Field Values

needsQuotesPattern

private static final java.util.regex.Pattern needsQuotesPattern
From Mark Holder


shortStrNeedsQuotePattern

private static final java.util.regex.Pattern shortStrNeedsQuotePattern
From Mark Holder

Constructor Detail

NexusFile

public NexusFile()
Method Detail

loadNewick

public static Tree loadNewick(java.lang.String filename)
Loads a tree structure from a Nexus file into memory. This is meant to be used for debugging.


findLabelEnd

private static int findLabelEnd(java.lang.String newick,
                                int start)
Keep incrementing until we find the end of the number or label.


parseNewick

public static Tree parseNewick(Tree tree)
This might be faster if we use char[] instead of String for "newick". This will break if there are blank spaces (' ') in the tree structure.


parseNewick

public static Tree parseNewick(Tree tree,
                               java.lang.String newick)
This might be faster if we use char[] instead of String for "newick". This will break if there are blank spaces (' ') in the tree structure.


load

public static Tree load(java.lang.String filename,
                        java.lang.String treeID,
                        java.lang.String partitionID)
Loads a Nexus file. This will not load the tree if the tree already exist in the database.


append

public static Tree append(java.lang.String filename,
                          java.lang.String treeID,
                          java.lang.String partitionID)
Appends a Nexus file into the current database. This will not append the tree if the tree don't exist or any of the data files are missing.


doQuote

public static java.lang.String doQuote(java.lang.String text)
From Mark Holder


quote

public static java.lang.String quote(java.lang.String text)
From Mark Holder This will properly quote a word that is to be included in a NEXUS file.


quote

public static java.lang.String[] quote(java.lang.String[] text)
From Mark Holder This will properly quote a word that is to be included in a NEXUS file.


multiCharStringNeedsQuotes

private static boolean multiCharStringNeedsQuotes(java.lang.String text)
From Mark Holder


shortStringNeedsQuotes

private static boolean shortStringNeedsQuotes(java.lang.String text)
From Mark Holder handles strings of len 1 or 0 only. The only single punctuation characters that need quoting are []'_ Note that an empty string and whitespac. must be quoted too.

Parameters:
text -
Returns:
true for "", "[", "



Copyright 2006 Stephen Fisher, Susan Davidson, and Junhyong Kim, University of Pennsylvania.