org.gersteinlab.act.io
Class DataFilesReader

java.lang.Object
  extended by org.gersteinlab.act.io.DataFilesReader
Direct Known Subclasses:
BedFilesReader, GtfFilesReader, NarrowPeakFilesReader, WigFilesReader

public abstract class DataFilesReader
extends java.lang.Object

        This class defines a reader of data files.
        


Field Summary
protected  java.io.BufferedReader br
          The input reader.
 
Constructor Summary
DataFilesReader(java.io.Reader rIn)
          Create a new reader with source data from an input reader.
 
Method Summary
 void close()
          Close the reader.
 int countIntervals()
          Get the total number of intervals.
static DataFilesReader getReader(Config config, java.io.File dataFile)
          Get a data file reader for a data file.
abstract  Interval readInterval()
          Read the next interval from the reader.
 void readIntervals(java.util.Collection<Interval> output)
          Read all intervals into a collection.
 void readIntervals(java.util.Collection<Interval> output, double value)
          Read the intervals that contain a given value into a collection.
 void reset()
          Reset the reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

br

protected java.io.BufferedReader br
The input reader.

Constructor Detail

DataFilesReader

public DataFilesReader(java.io.Reader rIn)
Create a new reader with source data from an input reader.

Parameters:
rIn - The input reader
Method Detail

getReader

public static DataFilesReader getReader(Config config,
                                        java.io.File dataFile)
                                 throws java.lang.ClassNotFoundException,
                                        java.io.FileNotFoundException,
                                        java.lang.IllegalAccessException,
                                        java.lang.InstantiationException,
                                        java.lang.reflect.InvocationTargetException,
                                        java.lang.NoSuchMethodException
Get a data file reader for a data file. This method tries to identify the file format based on the file extension.

Parameters:
config - Configurations
dataFile - The data file
Returns:
The data file reader
Throws:
java.lang.ClassNotFoundException
java.io.FileNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException

reset

public void reset()
           throws java.io.IOException
Reset the reader.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the reader.

Throws:
java.io.IOException

readInterval

public abstract Interval readInterval()
                               throws java.io.IOException
Read the next interval from the reader.

Returns:
The next interval
null if not more
Throws:
java.io.IOException

readIntervals

public void readIntervals(java.util.Collection<Interval> output)
                   throws java.io.IOException
Read all intervals into a collection.

Parameters:
output - Collection for storing the intervals
Throws:
java.io.IOException

readIntervals

public void readIntervals(java.util.Collection<Interval> output,
                          double value)
                   throws java.io.IOException
Read the intervals that contain a given value into a collection.

Parameters:
output - Collection for storing the intervals
value - The value
Throws:
java.io.IOException

countIntervals

public int countIntervals()
                   throws java.io.IOException
Get the total number of intervals.

Returns:
The total number
Throws:
java.io.IOException