Package org.biojava.bio.seq.db.emblcd
Class EmblCDROMRandomAccess
java.lang.Object
org.biojava.bio.seq.db.emblcd.EmblCDROMRandomAccess
- Direct Known Subclasses:
EntryNamRandomAccess
EmblCDROMRandomAccess is an abstract class whose
concrete subclasses can perform fast lookups in EMBL CD-ROM format
index files. As the format of the records varies between file
types, subclasses should implement two methods;
readRecord(), which should parse the record into an
array of objects and getRecordKey() which should
retrieve the the field from the parsed record on which the records
were sorted in the index. This is used during the binary search in
the findRecord() method.
Implementing readRecord() is easy because it simply
means delegating to the supplied RecordParser and
calling the appropriate method on it.
- Since:
- 1.2
- Author:
- Keith James
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RandomAccessFileprotected byte[]protected org.biojava.bio.seq.db.emblcd.RecordParserArecParserfor implementingreadRecord()specific to each concrete subclass. -
Constructor Summary
ConstructorsConstructorDescriptionEmblCDROMRandomAccess(File indexFile, int headerLength, int recordLength, long recordCount) Creates a newEmblCDROMRandomAccessobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()closecloses the underlyingRandomAccessFile.Object[]findRecord(String identifier) findRecordperforms a binary search within the file for a record specified by an identifier String.getFile()getFilereturns theFilewrapped.protected abstract StringgetRecordKey(Object[] record) getRecordKeyreturns the field from the record on which the records were sorted in the index.protected abstract Object[]readRecordreturns an array of objects parsed from a single record.
-
Field Details
-
raIndexFile
-
recParser
ArecParserfor implementingreadRecord()specific to each concrete subclass. -
recBytes
-
-
Constructor Details
-
EmblCDROMRandomAccess
public EmblCDROMRandomAccess(File indexFile, int headerLength, int recordLength, long recordCount) throws FileNotFoundException Creates a newEmblCDROMRandomAccessobject.- Parameters:
indexFile- aFileto wrap.headerLength- anint(normally 300 bytes).recordLength- anintindicating the length of a single record.recordCount- anlongindicating the total number of records.- Throws:
FileNotFoundException- if indexFile cannot be found.
-
-
Method Details
-
getFile
getFilereturns theFilewrapped.- Returns:
- a
File.
-
findRecord
findRecordperforms a binary search within the file for a record specified by an identifier String.- Parameters:
identifier- aStringidentifier (sequence ID or accession number).- Returns:
- an
Object []array containing the record. If there is no such record an empty array is returned. - Throws:
IOException- if an error occurs.
-
close
closecloses the underlyingRandomAccessFile.- Throws:
IOException- if an error occurs.
-
readRecord
readRecordreturns an array of objects parsed from a single record. Its content will depend on the type of index file. Concrete subclasses must provide an implementation of this method.- Returns:
- an
Object []array. - Throws:
IOException- if an error occurs.
-
getRecordKey
getRecordKeyreturns the field from the record on which the records were sorted in the index. (i.e. sequence ID or accession number).- Returns:
- a
String.
-