edu.unc.csbio.util
Class BigFaReader

java.lang.Object
  extended by edu.unc.csbio.util.BigFaReader

public class BigFaReader
extends java.lang.Object

this class is for reading data from a fasta file, and reading/generating an index file

Version:
0.1
Author:
Shunping Huang , Jack Wang

Field Summary
private static java.lang.String dataFile
          name of fasta file
private static java.lang.String ENDOFLINE
          end of line character
private static int EXTRA
          length end of line character
private static java.io.FileInputStream fis
          obtains input bytes from given fasta in a file system
private  java.lang.String indexFile
          name of index file
private static java.util.TreeMap<java.lang.String,java.lang.String[]> indexMap
          this maps a chromosome name to its starting offset and line length
 
Constructor Summary
BigFaReader(java.lang.String _dataFile)
          This is the constructor of object BigFaReader.
 
Method Summary
private static void buildIndex(java.lang.String dataFile)
          This method will generate an index file from dataFile.
static java.lang.String getData(java.lang.String chr, int start, int end)
          this method is for getting data given start and end position in one chromosome
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENDOFLINE

private static final java.lang.String ENDOFLINE
end of line character

See Also:
Constant Field Values

EXTRA

private static int EXTRA
length end of line character


dataFile

private static java.lang.String dataFile
name of fasta file


indexFile

private java.lang.String indexFile
name of index file


fis

private static java.io.FileInputStream fis
obtains input bytes from given fasta in a file system


indexMap

private static java.util.TreeMap<java.lang.String,java.lang.String[]> indexMap
this maps a chromosome name to its starting offset and line length

Constructor Detail

BigFaReader

public BigFaReader(java.lang.String _dataFile)
            throws java.io.IOException
This is the constructor of object BigFaReader. It will access given fasta file. If there is a corresponding index file, it will read index data from the file; else, it will generate an index file.

Parameters:
_dataFile - name of fasta file
Throws:
java.io.IOException - if an input or output exception occurred
Method Detail

buildIndex

private static void buildIndex(java.lang.String dataFile)
This method will generate an index file from dataFile. For every chromomsome in the dataFile, the method will append chromomsome's size, starting offset, line length and line length including the new line character.

Parameters:
dataFile - fasta file

getData

public static java.lang.String getData(java.lang.String chr,
                                       int start,
                                       int end)
                                throws java.io.IOException
this method is for getting data given start and end position in one chromosome

Parameters:
chr - chromosome ID
start - start postion
end - end position
Returns:
data within start and end position, represented as a string
Throws:
java.io.IOException - if an input or output exception occurred