Class TwoBitParser
java.lang.Object
java.io.InputStream
org.biojava.nbio.genome.parsers.twobit.TwoBitParser
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
Method closes current sequence and it's necessary to invoke it before setting new current sequence.void
Method closes random access file descriptor.long
getFile()
String[]
loadFragment
(long seq_pos, int len) static void
void
void
printFastaSequence
(long len) int
read()
Method reads 1 nucleotide from sequence stream.void
reset()
Method resets current position to the begining of sequence stream.void
setCurrentSequence
(String seq_name) Method open nucleotide stream for sequence with given name.void
setCurrentSequencePosition
(long pos) long
skip
(long n) Method skips n nucleotides in sequence stream.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
DEFAULT_BUFFER_SIZE
public int DEFAULT_BUFFER_SIZE
-
-
Constructor Details
-
TwoBitParser
- Throws:
Exception
-
-
Method Details
-
getSequenceNames
-
setCurrentSequence
Method open nucleotide stream for sequence with given name.- Parameters:
seq_name
- name of sequence (one of returned by getSequenceNames()).- Throws:
Exception
-
reset
Method resets current position to the begining of sequence stream.- Overrides:
reset
in classInputStream
- Throws:
IOException
-
getCurrentSequencePosition
public long getCurrentSequencePosition()- Returns:
- number (starting from 0) of next readable nucleotide in sequence stream.
-
setCurrentSequencePosition
- Throws:
IOException
-
read
Method reads 1 nucleotide from sequence stream. You should set current sequence before use it.- Specified by:
read
in classInputStream
- Throws:
IOException
-
skip
Method skips n nucleotides in sequence stream. You should set current sequence before use it.- Overrides:
skip
in classInputStream
- Throws:
IOException
-
close
Method closes current sequence and it's necessary to invoke it before setting new current sequence.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
closeParser
Method closes random access file descriptor. You can't use any reading methods after it.- Throws:
Exception
-
getFile
-
loadFragment
- Throws:
IOException
-
printFastaSequence
- Throws:
IOException
-
printFastaSequence
- Throws:
IOException
-
main
- Throws:
Exception
-