Class TwoBitParser
- java.lang.Object
-
- java.io.InputStream
-
- org.biojava.nbio.genome.parsers.twobit.TwoBitParser
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class TwoBitParser extends InputStream
downloaded from http://storage.bioinf.fbb.msu.ru/~roman/TwoBitParser.java Class is a parser of UCSC Genome Browser file format .2bit used to store nucleotide sequence information. This class extends InputStream and can be used as it after choosing one of names of containing sequences. This parser can be used to do some work like UCSC tool named twoBitToFa. For it just run this class with input file path as single parameter and set stdout stream into output file. If you have any problems or ideas don't hesitate to contact me through email: rsutormin[at]gmail.com.- Author:
- Roman Sutormin
-
-
Field Summary
Fields Modifier and Type Field Description intDEFAULT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description TwoBitParser(File f)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()Method closes current sequence and it's necessary to invoke it before setting new current sequence.voidcloseParser()Method closes random access file descriptor.longgetCurrentSequencePosition()FilegetFile()String[]getSequenceNames()StringloadFragment(long seq_pos, int len)static voidmain(String[] args)voidprintFastaSequence()voidprintFastaSequence(long len)intread()Method reads 1 nucleotide from sequence stream.voidreset()Method resets current position to the begining of sequence stream.voidsetCurrentSequence(String seq_name)Method open nucleotide stream for sequence with given name.voidsetCurrentSequencePosition(long pos)longskip(long n)Method skips n nucleotides in sequence stream.-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public int DEFAULT_BUFFER_SIZE
-
-
Constructor Detail
-
TwoBitParser
public TwoBitParser(File f) throws Exception
- Throws:
Exception
-
-
Method Detail
-
getSequenceNames
public String[] getSequenceNames()
-
setCurrentSequence
public void setCurrentSequence(String seq_name) throws Exception
Method open nucleotide stream for sequence with given name.- Parameters:
seq_name- name of sequence (one of returned by getSequenceNames()).- Throws:
Exception
-
reset
public void reset() throws IOException
Method resets current position to the begining of sequence stream.- Overrides:
resetin classInputStream- Throws:
IOException
-
getCurrentSequencePosition
public long getCurrentSequencePosition()
- Returns:
- number (starting from 0) of next readable nucleotide in sequence stream.
-
setCurrentSequencePosition
public void setCurrentSequencePosition(long pos) throws IOException
- Throws:
IOException
-
read
public int read() throws IOException
Method reads 1 nucleotide from sequence stream. You should set current sequence before use it.- Specified by:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException
Method skips n nucleotides in sequence stream. You should set current sequence before use it.- Overrides:
skipin classInputStream- Throws:
IOException
-
close
public void close() throws IOException
Method closes current sequence and it's necessary to invoke it before setting new current sequence.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
availablein classInputStream- Throws:
IOException
-
closeParser
public void closeParser() throws Exception
Method closes random access file descriptor. You can't use any reading methods after it.- Throws:
Exception
-
loadFragment
public String loadFragment(long seq_pos, int len) throws IOException
- Throws:
IOException
-
printFastaSequence
public void printFastaSequence() throws IOException
- Throws:
IOException
-
printFastaSequence
public void printFastaSequence(long len) throws IOException
- Throws:
IOException
-
-