Class ABIFParser
- java.lang.Object
-
- org.biojava.bio.program.abi.ABIFParser
-
- Direct Known Subclasses:
ABIFChromatogram.Parser
public class ABIFParser extends Object
A general base parser for files produced by ABI software. This includes chromatograms derived from ABI sequencers and potentially other data files as well. The format was described by Clark Tibbetts in his paper "Raw Data File Formats, and the Digital and Analog Raw Data Streams of the ABI PRISM 377 DNA Sequencer." Available online http://www-2.cs.cmu.edu/afs/cs/project/genome/WWW/Papers/clark.htmlBriefly, the format consists of a set of named fixed-length "tagged data records" which may contain data themselves, or pointers to data elsewhere in the file. This class reads these records and exposes them to subclasses through the
getDataRecord(java.lang.String, int)
method. The attributes of the records as described in Tibbets' paper are exposed through public (final) fields ofABIFParser.TaggedDataRecord
instances.If a record only contains a pointer to the desired data (see
ABIFParser.TaggedDataRecord.hasOffsetData
, subclasses may get at the raw data by usingABIFParser.TaggedDataRecord.offsetData
:This parser provides methods and classes for dealing with the files as streams or local files (local files being more memory-efficient).
- Author:
- Rhett Sutphin (UI CBCB), Richard Holland
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ABIFParser.DataAccess
static class
ABIFParser.TaggedDataRecord
An aggregate immutable type for an ABIF tagged data record.
-
Constructor Summary
Constructors Constructor Description ABIFParser(File f)
Creates a new ABIFParser for a file.ABIFParser(InputStream in)
Creates a new ABIFParser for an input stream.ABIFParser(ABIFParser.DataAccess toParse)
Creates a new ABIFParser for the specifiedABIFParser.DataAccess
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Symbol
decodeDNAToken(char token)
Decodes a character into aSymbol
in the DNA alphabet.Map
getAllDataRecords()
Obtain all data records.ABIFParser.DataAccess
getDataAccess()
Returns the accessor for the raw data being parsed by this parser.ABIFParser.TaggedDataRecord
getDataRecord(String tagName, int tagNumber)
Get the entry from the file TOC with the given name and tag number.
-
-
-
Constructor Detail
-
ABIFParser
public ABIFParser(File f) throws IOException
Creates a new ABIFParser for a file.- Throws:
IOException
-
ABIFParser
public ABIFParser(InputStream in) throws IOException
Creates a new ABIFParser for an input stream. Note that the stream will be wrapped in aCachingInputStream
if it isn't one already. If it is, it will be seeked to 0.- Throws:
IOException
-
ABIFParser
public ABIFParser(ABIFParser.DataAccess toParse) throws IOException
Creates a new ABIFParser for the specifiedABIFParser.DataAccess
object. If you need to read from something other than a file or a stream, you'll have to implement aABIFParser.DataAccess
-implementing class wrapping your source and then pass an instance to this constructor.- Throws:
IOException
-
-
Method Detail
-
getDataAccess
public final ABIFParser.DataAccess getDataAccess()
Returns the accessor for the raw data being parsed by this parser.
-
decodeDNAToken
public static Symbol decodeDNAToken(char token) throws IllegalSymbolException
Decodes a character into aSymbol
in the DNA alphabet. Uses a definition of characters that is compatible with the ABI format.- Parameters:
token
- the character to decode- Throws:
IllegalSymbolException
- when token isn't in{ a, A, c, C, g, G, t, T, n, N, - }
-
getDataRecord
public ABIFParser.TaggedDataRecord getDataRecord(String tagName, int tagNumber) throws IllegalArgumentException, IllegalStateException
Get the entry from the file TOC with the given name and tag number.- Parameters:
tagName
- the four-character string name of the desired data recordtagNumber
- which one of the tags with this name to return (must be positive)- Returns:
- the requested data record, or null if no such record exists
- Throws:
IllegalArgumentException
- if tagName is the wrong length or tagNumber is 0 or negativeIllegalStateException
- if the initial parsing is not complete
-
getAllDataRecords
public Map getAllDataRecords()
Obtain all data records. Keys of the map are strings consisting of tag names with tag numbers concatenated immediately afterwards. Values are TaggedDataRecord objects. The map has no particular order and so cannot be relied on to iterate over records in the same order they were read from the file.- Returns:
- the map of all data records.
-
-