javagene.io
Class Fasta

java.lang.Object
  extended by javagene.io.Fasta

public class Fasta
extends java.lang.Object

Read and write sequences as Fasta files. A Fasta file has a single header line of the following format:

    >id description
where the > symbol is required, the id is a single word, and the description can be many words, extending to the end of line. The proper interpretation of the id and description fields is not fixed. Data lines immediately follow the header line. Multiple sequences in a single file are separated from one another by a blank line.


Method Summary
static SeqI read(java.lang.String filename, int bufferSize)
          Read a file containing a single sequence.
static SeqBig readBig(java.lang.String filename)
          Read a Fasta file containing a single sequence into a SeqBig object.
static java.util.ArrayList<SeqI> readMany(java.lang.String filename, int bufferSize)
          Read a file containing (possibly) multiple sequences.
static void write(java.util.ArrayList<SeqI> sequences, java.lang.String filename)
          Write an ArrayList of sequences to file.
static void write(SeqI sequence, java.lang.String filename)
          Write a sequence to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public static SeqI read(java.lang.String filename,
                        int bufferSize)
                 throws java.io.IOException
Read a file containing a single sequence.

Parameters:
filename - The path to the file.
bufferSize - An estimate of the size of the sequence (hint: unless you're short on RAM, generously round up. )
Returns:
A SeqMem object.
Throws:
java.io.IOException - Something went wrong -- check exception detail message.

readBig

public static SeqBig readBig(java.lang.String filename)
                      throws java.io.IOException
Read a Fasta file containing a single sequence into a SeqBig object.

Parameters:
filename - The path to the file.
Returns:
The SeqBig object.
Throws:
java.io.IOException - Something went wrong -- check exception detail message.

readMany

public static java.util.ArrayList<SeqI> readMany(java.lang.String filename,
                                                 int bufferSize)
                                          throws java.io.IOException
Read a file containing (possibly) multiple sequences.

Parameters:
filename - The path to the file.
bufferSize - An estimate of the size of the largest sequence (hint: unless you're short on RAM, generously round up. )
Returns:
An ArrayList of SeqMem objects.
Throws:
java.io.IOException - Something went wrong -- check exception detail message.

write

public static void write(java.util.ArrayList<SeqI> sequences,
                         java.lang.String filename)
                  throws java.io.IOException
Write an ArrayList of sequences to file.

Parameters:
sequences - The ArrayList of SeqI sequences.
filename - The path to the file.
Throws:
java.io.IOException - Something went wrong -- check exception detail message.

write

public static void write(SeqI sequence,
                         java.lang.String filename)
                  throws java.io.IOException
Write a sequence to file.

Parameters:
sequence - The SeqI object to write.
filename - The path to the file.
Throws:
java.io.IOException - Something went wrong -- check exception detail message.