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


Java SeekableStream.close方法代码示例

本文整理汇总了Java中htsjdk.samtools.seekablestream.SeekableStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java SeekableStream.close方法的具体用法?Java SeekableStream.close怎么用?Java SeekableStream.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.samtools.seekablestream.SeekableStream的用法示例。


在下文中一共展示了SeekableStream.close方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readBytes

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
/**
 * Read the bytes between file position posStart and posEnd
 */
private byte[] readBytes(long posStart, long posEnd) throws IOException {

    SeekableStream ss = null;
    try {
        ss = SeekableStreamFactory.getInstance().getStreamFor(path);
        int nBytes = (int) (posEnd - posStart);
        byte[] bytes = new byte[nBytes];
        ss.seek(posStart);
        ss.readFully(bytes);
        return bytes;
    } finally {
        if (ss != null) {
            ss.close();
        }
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:20,代码来源:FastaSequenceFile.java

示例2: streamShouldSkipSmallSeek

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
@Test
public void streamShouldSkipSmallSeek() throws IOException {

    final int seekPosition = 100;

    SeekableStream fakeSeekable = new S3SeekableStream(S3DataLoaderMocker.FAKE_URI,
            client,
            factory);
    assertEquals(0, fakeSeekable.position());
    fakeSeekable.seek(seekPosition);
    assertEquals(seekPosition, fakeSeekable.position());

    final int READ_COUNT = 12;
    for (int i = 0; i < READ_COUNT; i++) {
        assertEquals(seekPosition + i, fakeSeekable.read());
    }
    assertEquals(seekPosition + READ_COUNT, fakeSeekable.position());
    fakeSeekable.close();
}
 
开发者ID:epam,项目名称:htsjdk-s3-plugin,代码行数:20,代码来源:S3SeekableStreamTest.java

示例3: streamShouldSeek

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
@Test
public void streamShouldSeek() throws IOException {

    System.setProperty("samjdk.s3plugin.number_of_connections", "2");
    Configuration.init();
    final int seekPosition = Configuration.getMaxDownloadPartSize() * 2;

    SeekableStream fakeSeekable = new S3SeekableStream(S3DataLoaderMocker.FAKE_URI,
            client,
            factory);
    fakeSeekable.seek(seekPosition);

    final int READ_COUNT = 1024;
    for (int i = 0; i < READ_COUNT; i++) {
        final int expectedByte = (seekPosition + i) & (0xff);
        assertEquals(expectedByte, fakeSeekable.read());
    }
    assertEquals(seekPosition + READ_COUNT, fakeSeekable.position());
    fakeSeekable.close();
}
 
开发者ID:epam,项目名称:htsjdk-s3-plugin,代码行数:21,代码来源:S3SeekableStreamTest.java

示例4: setup

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
	Configuration conf = context.getConfiguration();
	
	Path path = new Path(conf.get(GaeaVCFOutputFormat.OUT_PATH_PROP));
	SeekableStream in = WrapSeekable.openPath(path.getFileSystem(conf), path);
	header = VCFHeaderReader.readHeaderFrom(in);
	in.close();
	
	chrIndexs = new HashMap<String,Integer>();
	List<VCFContigHeaderLine> lines = header.getContigLines();
	for(int i = 0 ; i < lines.size() ; i++){
		VCFContigHeaderLine line = lines.get(i);
		chrIndexs.put(line.getID(), line.getContigIndex());
	}
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:17,代码来源:JointCallingMapper.java

示例5: readBytes

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
/**
 * Read the bytes between file position posStart and posEnd
 *
 * @throws IOException
 */
private byte[] readBytes(long posStart, long posEnd) throws IOException {

    SeekableStream ss = null;
    try {
        ss = IGVSeekableStreamFactory.getInstance().getStreamFor(path);
        int nBytes = (int) (posEnd - posStart);
        byte[] bytes = new byte[nBytes];
        ss.seek(posStart);
        ss.readFully(bytes);
        return bytes;
    } finally {
        if (ss != null) {
            ss.close();
        }
    }
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:22,代码来源:FastaIndexedSequence.java

示例6: testRead

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
@Test
public void testRead() throws IOException {
    SeekableStream fakeSeekable = new S3SeekableStream(S3DataLoaderMocker.FAKE_URI, client, factory);
    assertEquals(0, fakeSeekable.read());

    final int arraySize = 16;
    byte[] loadArray = new byte[arraySize];
    assertEquals(fakeSeekable.read(loadArray), arraySize);

    final int offset = 8;
    assertEquals(offset, fakeSeekable.read(loadArray, offset, offset));

    assertEquals(fakeSeekable.position(), 1 + arraySize + offset);
    fakeSeekable.close();
}
 
开发者ID:epam,项目名称:htsjdk-s3-plugin,代码行数:16,代码来源:S3SeekableStreamTest.java

示例7: getCramHeader

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
public static SAMFileHeader getCramHeader(FileSystem fs, Path path)
		throws IOException {
	SeekableStream sin = WrapSeekable.openPath(fs, path);
	SAMFileHeader header = CramIO.readCramHeader(sin).getSamFileHeader();
	sin.close();
	return header;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:8,代码来源:SamHdfsFileHeader.java

示例8: readHeader

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
public VCFHeader readHeader(Path path,Configuration conf) throws IOException, ClassNotFoundException{
	SeekableStream in = WrapSeekable.openPath(path.getFileSystem(conf), path);
	VCFHeader header = VCFHeaderReader.readHeaderFrom(in);
	in.close();
	
	return header;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:8,代码来源:MultipleVCFHeaderForJointCalling.java

示例9: readHeaderFrom

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
public void readHeaderFrom(Path path, FileSystem fs) throws IOException {
	SeekableStream i = WrapSeekable.openPath(fs, path);
	readHeaderFrom(i);
	i.close();
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:6,代码来源:SingleVCFHeader.java

示例10: addProbabilisticSplits

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
private int addProbabilisticSplits(List<InputSplit> splits, int i,
		List<InputSplit> newSplits, Configuration cfg) throws IOException {
	Path path = ((FileSplit) splits.get(i)).getPath();
	SeekableStream sin = WrapSeekable.openPath(path.getFileSystem(cfg),
			path);

	GaeaBamSplitGuesser guesser = new GaeaBamSplitGuesser(sin,cfg);

	FileVirtualSplit previousSplit = null;

	for (; i < splits.size(); i++) {
		FileSplit fspl = (FileSplit) splits.get(i);
		if (!fspl.getPath().equals(path)) {
			break;
		}
		long beg = fspl.getStart();
		long end = beg + fspl.getLength();

		long alignedBeg = guesser.guessNextBAMRecordStart(beg, end);

		long alignedEnd = end << 16 | 0xFFFF;

		if (alignedBeg == end) {
			if (previousSplit == null) {
				System.err
						.println("'"
								+ path
								+ "': "
								+ "no reads in first split: bad BAM file or tiny split size?");
			} else {
				previousSplit.setEndVirtualOffset(alignedEnd);
			}
		} else
			newSplits.add(previousSplit = new FileVirtualSplit(path,
					alignedBeg, alignedEnd, fspl.getLocations()));

	}

	sin.close();
	return i;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:42,代码来源:GaeaBamInputFormat.java

示例11: setup

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
@Override
protected void setup(Context context) throws IOException {
	Configuration conf = context.getConfiguration();
	contigs = new HashMap<Integer, String>();
	
	Path path = new Path(conf.get(GaeaVCFOutputFormat.OUT_PATH_PROP));
	SeekableStream in = WrapSeekable.openPath(path.getFileSystem(conf), path);
	header = VCFHeaderReader.readHeaderFrom(in);
	in.close();
	
	if(header == null)
		throw new RuntimeException("header is null !!!");
	
	List<VCFContigHeaderLine> lines = header.getContigLines();

	for (int i = 0; i < lines.size(); i++) {
		VCFContigHeaderLine line = lines.get(i);
		contigs.put(line.getContigIndex(), line.getID());
	}

	options = new JointCallingOptions();
	options.getOptionsFromHadoopConf(conf);
	
	windowSize = options.getWindowsSize();
	parser = new GenomeLocationParser(header.getSequenceDictionary());
	headers.readHeaders(conf);
	
	String sampleStr = conf.get(JointCalling.INPUT_ORDER,null);
	if(sampleStr != null)
		engine = new JointCallingEngine(options, parser,header,headers,sampleStr.split(","));
	else
		engine = new JointCallingEngine(options, parser,header,headers,null);
	genomeShare = new ReferenceShare();
	genomeShare.loadChromosomeList(options.getReference());
	dbsnpShare = new DbsnpShare(options.getDBSnp(), options.getReference());
	dbsnpShare.loadChromosomeList(options.getDBSnp() + VcfIndex.INDEX_SUFFIX);
	loader = new VCFLocalLoader(options.getDBSnp());
	filter = new VariantRegionFilter();
	header = engine.getVCFHeader();
	
	if(header == null)
		throw new RuntimeException("header is null!!!");
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:44,代码来源:JointCallingReducer.java

示例12: addProbabilisticSplits

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
private int addProbabilisticSplits(
		List<InputSplit> splits, int i, List<InputSplit> newSplits,
		Configuration cfg)
	throws IOException
{
	final Path path = ((FileSplit)splits.get(i)).getPath();
	final SeekableStream sin =
		WrapSeekable.openPath(path.getFileSystem(cfg), path);

	final BAMSplitGuesser guesser = new BAMSplitGuesser(sin, cfg);

	FileVirtualSplit previousSplit = null;

	for (; i < splits.size(); ++i) {
		FileSplit fspl = (FileSplit)splits.get(i);
		if (!fspl.getPath().equals(path))
			break;

		long beg =       fspl.getStart();
		long end = beg + fspl.getLength();

		long alignedBeg = guesser.guessNextBAMRecordStart(beg, end);

		// As the guesser goes to the next BGZF block before looking for BAM
		// records, the ending BGZF blocks have to always be traversed fully.
		// Hence force the length to be 0xffff, the maximum possible.
		long alignedEnd = end << 16 | 0xffff;

		if (alignedBeg == end) {
			// No records detected in this split: merge it to the previous one.
			// This could legitimately happen e.g. if we have a split that is
			// so small that it only contains the middle part of a BGZF block.
			//
			// Of course, if it's the first split, then this is simply not a
			// valid BAM file.
			//
			// FIXME: In theory, any number of splits could only contain parts
			// of the BAM header before we start to see splits that contain BAM
			// records. For now, we require that the split size is at least as
			// big as the header and don't handle that case.
			if (previousSplit == null)
				throw new IOException("'" + path + "': "+
					"no reads in first split: bad BAM file or tiny split size?");

			previousSplit.setEndVirtualOffset(alignedEnd);
		} else {
			previousSplit = new FileVirtualSplit(
                                       path, alignedBeg, alignedEnd, fspl.getLocations());
			if (logger.isDebugEnabled()) {
				final long byteOffset  = alignedBeg >>> 16;
				final long recordOffset = alignedBeg & 0xffff;
				logger.debug(
					"Split {}: byte offset: {} record offset: {}, virtual offset: {}",
					i, byteOffset, recordOffset, alignedBeg);
			}
			newSplits.add(previousSplit);
		}
	}

	sin.close();
	return i;
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:63,代码来源:BAMInputFormat.java

示例13: addGuessedSplits

import htsjdk.samtools.seekablestream.SeekableStream; //导入方法依赖的package包/类
private int addGuessedSplits(
		List<FileSplit> splits, int i, List<InputSplit> newSplits)
	throws IOException
{
	final Path path = splits.get(i).getPath();
	final SeekableStream sin = WrapSeekable.openPath(conf, path);

	final BCFSplitGuesser guesser = new BCFSplitGuesser(sin);

	final boolean isBGZF = guesser.isBGZF();

	InputSplit prevSplit = null;

	for (; i < splits.size(); ++i) {
		final FileSplit fspl = splits.get(i);
		if (!fspl.getPath().equals(path))
			break;

		final String[] locs = fspl.getLocations();

		final long beg =       fspl.getStart();
		final long end = beg + fspl.getLength();

		final long alignBeg = guesser.guessNextBCFRecordStart(beg, end);

		// As the guesser goes to the next BGZF block before looking for BCF
		// records, the ending BGZF blocks have to always be traversed fully.
		// Hence force the length to be 0xffff, the maximum possible.
		final long alignEnd = isBGZF ? end << 16 | 0xffff : end;

		final long length = alignEnd - alignBeg;

		if (alignBeg == end) {
			// No records detected in this split: merge it to the previous one.
			// This could legitimately happen e.g. if we have a split that is
			// so small that it only contains the middle part of a BGZF block.
			//
			// Of course, if it's the first split, then this is simply not a
			// valid BCF file.
			//
			// FIXME: In theory, any number of splits could only contain parts
			// of the BCF header before we start to see splits that contain BCF
			// records. For now, we require that the split size is at least as
			// big as the header and don't handle that case.
			if (prevSplit == null)
				throw new IOException("'" + path + "': no records in first "+
					"split: bad BCF file or tiny split size?");

			if (isBGZF) {
				((FileVirtualSplit)prevSplit).setEndVirtualOffset(alignEnd);
				continue;
			}
			prevSplit = new FileSplit(path, alignBeg, length, locs);
			newSplits.remove(newSplits.size() - 1);
		} else {
			prevSplit =
				isBGZF ? new FileVirtualSplit(path, alignBeg, alignEnd, locs)
				       : new FileSplit       (path, alignBeg, length,   locs);
		}
		newSplits.add(prevSplit);
	}

	sin.close();
	return i;
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:66,代码来源:VCFInputFormat.java


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