当前位置: 首页>>代码示例>>Java>>正文


Java BlockCompressedInputStream.setCheckCrcs方法代码示例

本文整理汇总了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);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:9,代码来源:TestBGZFSplitGuesser.java

示例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;
	}
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:50,代码来源:BGZFSplitGuesser.java


注:本文中的htsjdk.samtools.util.BlockCompressedInputStream.setCheckCrcs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。