本文整理汇总了Java中htsjdk.samtools.util.BlockCompressedInputStream.seek方法的典型用法代码示例。如果您正苦于以下问题:Java BlockCompressedInputStream.seek方法的具体用法?Java BlockCompressedInputStream.seek怎么用?Java BlockCompressedInputStream.seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.util.BlockCompressedInputStream
的用法示例。
在下文中一共展示了BlockCompressedInputStream.seek方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canReadFromBlockStart
import htsjdk.samtools.util.BlockCompressedInputStream; //导入方法依赖的package包/类
private void canReadFromBlockStart(long blockStart) throws IOException {
BlockCompressedInputStream blockCompressedInputStream = new
BlockCompressedInputStream(file);
blockCompressedInputStream.setCheckCrcs(true);
blockCompressedInputStream.seek(blockStart << 16);
byte[] b = new byte[100];
blockCompressedInputStream.read(b);
}
示例2: getRecordsAtSplits
import htsjdk.samtools.util.BlockCompressedInputStream; //导入方法依赖的package包/类
private List<SAMRecord> getRecordsAtSplits(File bam, SplittingBAMIndex index) throws IOException {
List<SAMRecord> records = new ArrayList<>();
BAMRecordCodec codec = new BAMRecordCodec(samFileHeader);
BlockCompressedInputStream bci = new BlockCompressedInputStream(bam);
codec.setInputStream(bci);
for (Long offset : index.getVirtualOffsets()) {
bci.seek(offset);
SAMRecord record = codec.decode();
if (record != null) {
records.add(record);
}
}
return records;
}
示例3: initialize
import htsjdk.samtools.util.BlockCompressedInputStream; //导入方法依赖的package包/类
@Override
public void initialize(InputSplit spl, TaskAttemptContext ctx) throws IOException {
// This method should only be called once (see Hadoop API). However,
// there seems to be disagreement between implementations that call
// initialize() and Hadoop-BAM's own code that relies on
// {@link BAMInputFormat} to call initialize() when the reader is
// created. Therefore we add this check for the time being.
if (isInitialized)
close();
isInitialized = true;
final Configuration conf = ContextUtil.getConfiguration(ctx);
final FileVirtualSplit split = (FileVirtualSplit) spl;
final Path file = split.getPath();
final FileSystem fs = file.getFileSystem(conf);
this.stringency = SAMHeaderReader.getValidationStringency(conf);
final FSDataInputStream in = fs.open(file);
codec = new BAMRecordCodec(SAMHeaderReader.readSAMHeaderFrom(in, conf));
in.seek(0);
bci = new BlockCompressedInputStream(
new WrapSeekable<FSDataInputStream>(in, fs.getFileStatus(file).getLen(), file));
final long virtualStart = split.getStartVirtualOffset();
fileStart = virtualStart >>> 16;
virtualEnd = split.getEndVirtualOffset();
bci.seek(virtualStart);
codec.setInputStream(bci);
if (GaeaBamInputFormat.DEBUG_BAM_SPLITTER) {
final long recordStart = virtualStart & 0xffff;
System.err.println(
"XXX inizialized BAMRecordReader byte offset: " + fileStart + " record offset: " + recordStart);
}
}
示例4: guessNextBGZFBlockStart
import htsjdk.samtools.util.BlockCompressedInputStream; //导入方法依赖的package包/类
public long guessNextBGZFBlockStart(long beg, long end)
throws IOException
{
// Buffer what we need to go through. Since the max size of a BGZF block
// is 0xffff (64K), and we might be just one byte off from the start of
// the previous one, we need 0xfffe bytes for the start, and then 0xffff
// for the block we're looking for.
byte[] arr = new byte[2*0xffff - 1];
this.seekableInFile.seek(beg);
int totalRead = 0;
for (int left = Math.min((int)(end - beg), arr.length); left > 0;) {
final int r = inFile.read(arr, totalRead, left);
if (r < 0)
break;
totalRead += r;
left -= r;
}
arr = Arrays.copyOf(arr, totalRead);
this.in = new ByteArraySeekableStream(arr);
final BlockCompressedInputStream bgzf =
new BlockCompressedInputStream(this.in);
bgzf.setCheckCrcs(true);
final int firstBGZFEnd = Math.min((int)(end - beg), 0xffff);
for (int pos = 0;;) {
pos = guessNextBGZFPos(pos, firstBGZFEnd);
if (pos < 0)
return end;
try {
// Seek in order to trigger decompression of the block and a CRC
// check.
bgzf.seek((long)pos << 16);
// This has to catch Throwable, because it's possible to get an
// OutOfMemoryError due to an overly large size.
} catch (Throwable e) {
// Guessed BGZF position incorrectly: try the next guess.
++pos;
continue;
}
return beg + pos;
}
}