本文整理汇总了Java中htsjdk.samtools.util.BlockCompressedInputStream.setCheckCrcs方法的典型用法代码示例。如果您正苦于以下问题:Java BlockCompressedInputStream.setCheckCrcs方法的具体用法?Java BlockCompressedInputStream.setCheckCrcs怎么用?Java BlockCompressedInputStream.setCheckCrcs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.util.BlockCompressedInputStream
的用法示例。
在下文中一共展示了BlockCompressedInputStream.setCheckCrcs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}