|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.bio.seq.io.SeqIOTools
A set of convenience methods for handling common file formats.
Method Summary | |
static void |
biojavaToFile(int fileType,
java.io.OutputStream os,
java.lang.Object biojava)
Converts a Biojava object to the given filetype. |
static void |
biojavaToFile(java.lang.String formatName,
java.lang.String alphabetName,
java.io.OutputStream os,
java.lang.Object biojava)
Writes a Biojava SequenceIterator ,
SequenceDB , Sequence or Aligment
to an OutputStream |
static java.lang.Object |
fileToBiojava(int fileType,
java.io.BufferedReader br)
Reads a file and returns the corresponding Biojava object. |
static java.lang.Object |
fileToBiojava(java.lang.String formatName,
java.lang.String alphabetName,
java.io.BufferedReader br)
Reads a file with the specified format and alphabet |
static SequenceBuilderFactory |
formatToFactory(SequenceFormat format,
Alphabet alpha)
Deprecated. as this essentially duplicates the operation available in the method identifyBuilderFactory . |
static FiniteAlphabet |
getAlphabet(int identifier)
getAlphabet accepts a value which represents a
sequence format and returns the relevant
FiniteAlphabet object. |
static SequenceBuilderFactory |
getBuilderFactory(int identifier)
getBuilderFactory accepts a value which represents
a sequence format and returns the relevant
SequenceBuilderFactory object. |
static SequenceBuilderFactory |
getEmblBuilderFactory()
Get a default SequenceBuilderFactory for handling EMBL files. |
static SequenceBuilderFactory |
getFastaBuilderFactory()
Get a default SequenceBuilderFactory for handling FASTA files. |
static SequenceBuilderFactory |
getGenbankBuilderFactory()
Get a default SequenceBuilderFactory for handling GenBank files. |
static SequenceBuilderFactory |
getGenpeptBuilderFactory()
Get a default SequenceBuilderFactory for handling Genpept files. |
static SequenceFormat |
getSequenceFormat(int identifier)
getSequenceFormat accepts a value which represents
a sequence format and returns the relevant
SequenceFormat object. |
static SequenceBuilderFactory |
getSwissprotBuilderFactory()
Get a default SequenceBuilderFactory for handling Swissprot files. |
static int |
guessFileType(java.io.File seqFile)
Deprecated. because there is no standard file naming convention and guessing by file name is inherantly error prone and bad. |
static int |
identifyFormat(java.lang.String formatName,
java.lang.String alphabetName)
identifyFormat performs a case-insensitive mapping
of a pair of common sequence format name (such as 'embl',
'genbank' or 'fasta') and alphabet name (such as 'dna', 'rna',
'protein', 'aa') to an integer. |
static SequenceIterator |
readEmbl(java.io.BufferedReader br)
Iterate over the sequences in an EMBL-format stream. |
static SequenceIterator |
readEmblNucleotide(java.io.BufferedReader br)
Iterate over the sequences in an EMBL-format stream. |
static SequenceIterator |
readEmblRNA(java.io.BufferedReader br)
Iterate over the sequences in an EMBL-format stream, but for RNA. |
static SequenceDB |
readFasta(java.io.InputStream seqFile,
Alphabet alpha)
Create a sequence database from a fasta file provided as an input stream. |
static SequenceIterator |
readFastaDNA(java.io.BufferedReader br)
Iterate over the sequences in an FASTA-format stream of DNA sequences. |
static SequenceIterator |
readFastaProtein(java.io.BufferedReader br)
Iterate over the sequences in an FASTA-format stream of Protein sequences. |
static SequenceIterator |
readFastaRNA(java.io.BufferedReader br)
Iterate over the sequences in an FASTA-format stream of RNA sequences. |
static SequenceIterator |
readGenbank(java.io.BufferedReader br)
Iterate over the sequences in an GenBank-format stream. |
static SequenceIterator |
readGenpept(java.io.BufferedReader br)
Iterate over the sequences in an Genpept-format stream. |
static SequenceIterator |
readSwissprot(java.io.BufferedReader br)
Iterate over the sequences in an Swissprot-format stream. |
static void |
writeEmbl(java.io.OutputStream os,
Sequence seq)
Writes a single Sequence to an OutputStream in EMBL format. |
static void |
writeEmbl(java.io.OutputStream os,
SequenceIterator in)
Writes a stream of Sequences to an OutputStream in EMBL format. |
static void |
writeFasta(java.io.OutputStream os,
Sequence seq)
Writes a single Sequence to an OutputStream in Fasta format. |
static void |
writeFasta(java.io.OutputStream os,
SequenceDB db)
Write a sequenceDB to an output stream in fasta format. |
static void |
writeFasta(java.io.OutputStream os,
SequenceIterator in)
Writes sequences from a SequenceIterator to an OutputStream in Fasta Format. |
static void |
writeGenbank(java.io.OutputStream os,
Sequence seq)
Writes a single Sequence to an OutputStream in Genbank format. |
static void |
writeGenbank(java.io.OutputStream os,
SequenceIterator in)
Writes a stream of Sequences to an OutputStream in Genbank format. |
static void |
writeGenpept(java.io.OutputStream os,
Sequence seq)
Writes a single Sequence to an OutputStream in Genpept format. |
static void |
writeGenpept(java.io.OutputStream os,
SequenceIterator in)
Writes a stream of Sequences to an OutputStream in Genpept format. |
static void |
writeSwissprot(java.io.OutputStream os,
Sequence seq)
Writes a single Sequence to an OutputStream in SwissProt format. |
static void |
writeSwissprot(java.io.OutputStream os,
SequenceIterator in)
Writes a stream of Sequences to an OutputStream in SwissProt format. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static SequenceBuilderFactory getEmblBuilderFactory()
public static SequenceIterator readEmbl(java.io.BufferedReader br)
public static SequenceIterator readEmblRNA(java.io.BufferedReader br)
public static SequenceIterator readEmblNucleotide(java.io.BufferedReader br)
public static SequenceBuilderFactory getGenbankBuilderFactory()
public static SequenceIterator readGenbank(java.io.BufferedReader br)
public static SequenceBuilderFactory getGenpeptBuilderFactory()
public static SequenceIterator readGenpept(java.io.BufferedReader br)
public static SequenceBuilderFactory getSwissprotBuilderFactory()
public static SequenceIterator readSwissprot(java.io.BufferedReader br)
public static SequenceBuilderFactory getFastaBuilderFactory()
public static SequenceIterator readFastaDNA(java.io.BufferedReader br)
public static SequenceIterator readFastaRNA(java.io.BufferedReader br)
public static SequenceIterator readFastaProtein(java.io.BufferedReader br)
public static SequenceDB readFasta(java.io.InputStream seqFile, Alphabet alpha) throws BioException
BioException
- if problems occur during reading of the
stream.public static void writeFasta(java.io.OutputStream os, SequenceDB db) throws java.io.IOException
java.io.IOException
- if there was an error while writing.public static void writeFasta(java.io.OutputStream os, SequenceIterator in) throws java.io.IOException
java.io.IOException
- if there was an error while writing.public static void writeFasta(java.io.OutputStream os, Sequence seq) throws java.io.IOException
os
- the OutputStream.seq
- the Sequence.
java.io.IOException
- if there was an error while writing.public static void writeEmbl(java.io.OutputStream os, SequenceIterator in) throws java.io.IOException
os
- the OutputStream.in
- a SequenceIterator.
java.io.IOException
- if there was an error while writing.public static void writeEmbl(java.io.OutputStream os, Sequence seq) throws java.io.IOException
os
- the OutputStream.seq
- the Sequence.
java.io.IOException
- if there was an error while writing.public static void writeSwissprot(java.io.OutputStream os, SequenceIterator in) throws java.io.IOException, BioException
os
- the OutputStream.in
- a SequenceIterator.
java.io.IOException
- if there was an error while writing.
BioException
public static void writeSwissprot(java.io.OutputStream os, Sequence seq) throws java.io.IOException, BioException
os
- the OutputStream.seq
- the Sequence.
java.io.IOException
- if there was an error while writing.
BioException
public static void writeGenpept(java.io.OutputStream os, SequenceIterator in) throws java.io.IOException, BioException
os
- the OutputStream.in
- a SequenceIterator.
java.io.IOException
- if there was an error while writing.
BioException
public static void writeGenpept(java.io.OutputStream os, Sequence seq) throws java.io.IOException, BioException
os
- the OutputStream.seq
- the Sequence.
java.io.IOException
- if there was an error while writing.
BioException
public static void writeGenbank(java.io.OutputStream os, SequenceIterator in) throws java.io.IOException
os
- the OutputStream.in
- a SequenceIterator.
java.io.IOException
- if there was an error while writing.public static void writeGenbank(java.io.OutputStream os, Sequence seq) throws java.io.IOException
os
- the OutputStream.seq
- the Sequence.
java.io.IOException
- if there was an error while writing.public static int identifyFormat(java.lang.String formatName, java.lang.String alphabetName)
identifyFormat
performs a case-insensitive mapping
of a pair of common sequence format name (such as 'embl',
'genbank' or 'fasta') and alphabet name (such as 'dna', 'rna',
'protein', 'aa') to an integer. The value returned will be one
of the public static final fields in
SeqIOConstants
, or a bitwise-or combination of
them. The method will reject known illegal combinations of
format and alphabet (such as swissprot + dna) by throwing an
IllegalArgumentException
. It will return the
SeqIOConstants.UNKNOWN
value when either format or
alphabet are unknown.
formatName
- a String
.alphabetName
- a String
.
int
.public static SequenceFormat getSequenceFormat(int identifier) throws BioException
getSequenceFormat
accepts a value which represents
a sequence format and returns the relevant
SequenceFormat
object.
identifier
- an int
which represents a binary
value with bits set according to the scheme described in
SeqIOConstants
.
SequenceFormat
.
BioException
- if an error occurs.public static SequenceBuilderFactory getBuilderFactory(int identifier) throws BioException
getBuilderFactory
accepts a value which represents
a sequence format and returns the relevant
SequenceBuilderFactory
object.
identifier
- an int
which represents a binary
value with bits set according to the scheme described in
SeqIOConstants
.
SequenceBuilderFactory
.
BioException
- if an error occurs.public static FiniteAlphabet getAlphabet(int identifier) throws BioException
getAlphabet
accepts a value which represents a
sequence format and returns the relevant
FiniteAlphabet
object.
identifier
- an int
which represents a binary
value with bits set according to the scheme described in
SeqIOConstants
.
FiniteAlphabet
.
BioException
- if an error occurs.public static int guessFileType(java.io.File seqFile) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public static SequenceBuilderFactory formatToFactory(SequenceFormat format, Alphabet alpha) throws BioException
identifyBuilderFactory
.
SequenceBuilder
object for some combination of
Alphabet
and SequenceFormat
format
- currently supports FastaFormat
,
GenbankFormat
, EmblLikeFormat
alpha
- currently only supports the DNA and Protein
alphabets
SequenceBuilderFactory
BioException
- if the combination of alpha and format is
unrecognized.public static java.lang.Object fileToBiojava(java.lang.String formatName, java.lang.String alphabetName, java.io.BufferedReader br) throws BioException
formatName
- the name of the format eg genbank or
swissprot (case insensitive)alphabetName
- the name of the alphabet eg dna or rna or
protein (case insensitive)br
- a BufferedReader for the input
BioException
- if an error occurs while reading or a
unrecognized format, alphabet combination is used (eg swissprot
and DNA).public static java.lang.Object fileToBiojava(int fileType, java.io.BufferedReader br) throws BioException
BioException
public static void biojavaToFile(java.lang.String formatName, java.lang.String alphabetName, java.io.OutputStream os, java.lang.Object biojava) throws BioException, java.io.IOException, IllegalSymbolException
SequenceIterator
,
SequenceDB
, Sequence
or Aligment
to an OutputStream
formatName
- eg fasta, GenBank (case insensitive)alphabetName
- eg DNA, RNA (case insensititve)os
- where to write tobiojava
- the object to write
BioException
- problems getting data from the biojava object.
java.io.IOException
- if there are IO problems
IllegalSymbolException
- a Symbol cannot be parsedpublic static void biojavaToFile(int fileType, java.io.OutputStream os, java.lang.Object biojava) throws BioException, java.io.IOException, IllegalSymbolException
BioException
java.io.IOException
IllegalSymbolException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |