edu.upenn.crimson.io
Class FileIO

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

public class FileIO
extends java.lang.Object

Import and export utilities.

Version:
$Id: FileIO.java,v 1.22 2009/07/16 16:19:52 fisher Exp $

Constructor Summary
FileIO()
           
 
Method Summary
static java.lang.String exportQuery(java.lang.String id)
          Export the Query to a file based on it's ID.
static java.lang.String exportQuery(java.lang.String id, java.lang.String filename, boolean overwrite)
          Export the Query to a python file.
static void loadPython(java.lang.String filename)
           
static void printPositions(java.util.TreeSet positions)
          This will print the list of positions to the output file ('positions.list'), one position per line.
static void printSpecies(java.util.Collection species, boolean onlyLeaves)
          This will print the list of species to the output file ('species.list'), one species ID per line.
static void writeString(java.lang.String filename, boolean append, java.lang.String out)
          Write string to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileIO

public FileIO()
Method Detail

loadPython

public static void loadPython(java.lang.String filename)

writeString

public static void writeString(java.lang.String filename,
                               boolean append,
                               java.lang.String out)
Write string to file. If append is true then the string will be appended to the end of the file. Nothing will be done if an empty string is provided.


exportQuery

public static java.lang.String exportQuery(java.lang.String id)
Export the Query to a file based on it's ID. This will overwrite any existing file.


exportQuery

public static java.lang.String exportQuery(java.lang.String id,
                                           java.lang.String filename,
                                           boolean overwrite)
Export the Query to a python file. This will append ".py" to the filename, if necessary. The python file created can be imported into jython to re-create the query object. If no filename is given, then the output will be returned as a string.


printSpecies

public static void printSpecies(java.util.Collection species,
                                boolean onlyLeaves)
This will print the list of species to the output file ('species.list'), one species ID per line. If 'onlyLeaves' is true then the output file will be 'leaf.list' and only leaves will be included.


printPositions

public static void printPositions(java.util.TreeSet positions)
This will print the list of positions to the output file ('positions.list'), one position per line. Note that the position values in the file go from 1 to N, not from 0 to N-1. This routine requires a TreeSet because we want the positions sorted for testing.




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