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


Java BlockCompressedInputStream类代码示例

本文整理汇总了Java中htsjdk.samtools.util.BlockCompressedInputStream的典型用法代码示例。如果您正苦于以下问题:Java BlockCompressedInputStream类的具体用法?Java BlockCompressedInputStream怎么用?Java BlockCompressedInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makeTabixCompressedIndex

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
private void makeTabixCompressedIndex(final File sourceFile, final File indexFile, final AsciiFeatureCodec codec,
                                      final TabixFormat format) throws IOException {
    TabixIndexCreator indexCreator = new TabixIndexCreator(format);

    try (
        BlockCompressedInputStream inputStream = new BlockCompressedInputStream(
            new FileInputStream(sourceFile));
        LittleEndianOutputStream outputStream = new LittleEndianOutputStream(
            new BlockCompressedOutputStream(indexFile))
    ) {
        long p = 0;
        String line = inputStream.readLine();

        while (line != null) {
            //add the feature to the index
            Feature decode = codec.decode(line);
            if (decode != null) {
                indexCreator.addFeature(decode, p);
            }
            // read the next line if available
            p = inputStream.getFilePointer();
            line = inputStream.readLine();
        }

        // write the index to a file
        Index index = indexCreator.finalizeIndex(p);
        // VERY important! either use write based on input file or pass the little endian a BGZF stream
        index.write(outputStream);
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:31,代码来源:FileManager.java

示例2: initStream

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public void initStream(final File plusFile) {
	if(plusFile.exists()) {
		try {
			 final ISeekableStreamFactory ssf = SeekableStreamFactory.getInstance();
	         final SeekableStream seekableStream =
	                    ssf.getBufferedStream(ssf.getStreamFor(plusFile.getAbsolutePath()));
	         BlockCompressedInputStream is = new BlockCompressedInputStream(seekableStream);
	         writeIndex(is);
	     	 is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} else {
		throw new IllegalArgumentException("plus file in location:" + path +" is needed to write a plus index.");
	}
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:17,代码来源:BinIndexWriter.java

示例3: makeIndex

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public void makeIndex(final String plusFile, final String path) {
	try {
		final File tempFile = new File(plusFile + BinIndexWriter.TEMP);
		BlockCompressedInputStream reader = BasicUtils.checkStream(new File(path));
		LittleEndianOutputStream los = new LittleEndianOutputStream(new BlockCompressedOutputStream(tempFile));
		
		readBGZInputstream(reader, los);
		los.writeShort(BinIndexWriter.PLUS_FILE_END);
		writeOthers(los);
		los.close();
		boolean success = tempFile.renameTo(new File(plusFile));
		if (!success) {
		   System.err.println("Make index has completed. But rename from '" + tempFile.getAbsolutePath() + "' to '" + plusFile + "' with error. ");
		   System.exit(1);
		} 
	} catch (IOException e) {
		e.printStackTrace();
	} 
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:20,代码来源:AppendixFileWriter.java

示例4: makeIndex

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public void makeIndex() {
	try {
		final String outputPath = path + IntervalIndex.PLUS_EXTENSION;
		final File outputFile = new File(outputPath + IntervalIndex.TEMP);
			
		BlockCompressedInputStream reader = checkStream(new File(path));
		LittleEndianOutputStream los = new LittleEndianOutputStream(new BlockCompressedOutputStream(outputFile));
		readBGZInputstream(reader, los);
			
		los.writeInt(IntervalIndex.PLUS_FILE_END);
		writeOthers(los);
		los.close();
		
		boolean success = outputFile.renameTo(new File(outputPath));
		if (!success) {
		   System.err.println("Make index has completed. But rename from '" + outputFile.getAbsolutePath() + "' to '" + outputPath + "' with error. ");
		} else {
			throw new IllegalArgumentException("We currently support bgz file format. please use bgzip to compress your file!");
		} 
	} catch (IOException e) {
		e.printStackTrace();
	} 
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:24,代码来源:CollectionFileWriter.java

示例5: initStream

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public void initStream() {
	File inputFile = new File(path);
	if(inputFile.exists() && inputFile.getName().toLowerCase().endsWith(IntervalIndex.PLUS_EXTENSION)) {
		try {
			 final ISeekableStreamFactory ssf = SeekableStreamFactory.getInstance();
	         final SeekableStream seekableStream =
	                    ssf.getBufferedStream(ssf.getStreamFor(inputFile.getAbsolutePath()));
	         BlockCompressedInputStream is = new BlockCompressedInputStream(seekableStream);
	         writeIndex(is);
	     	 is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} else {
		throw new IllegalArgumentException("plus file is needed to write a plus index.");
	}
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:18,代码来源:BinIndexWriter.java

示例6: readFormat

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public void readFormat(BlockCompressedInputStream is) throws IOException {
        mChr2tid = new HashMap<String, Integer>();
        mTid2chr = new HashMap<Integer, String>();
        mPreset = readInt(is);
        mSc = readInt(is);
        mBc = readInt(is);
        mEc = readInt(is);
        mMeta = readInt(is);
        mSkip = readInt(is);  //read skip
        
        format = new TabixFormat(this.mPreset, this.mSc, this.mBc, this.mEc, (char)this.mMeta, this.mSkip);
//        if((mPreset & 0xffff) == 2) {
//			this.formatWithRef = FormatWithRef.VCF;
//    	} else {
//    		if(mBc == mEc) {
//    			formatWithRef = new FormatWithRef(this.format, readInt(is), readInt(is), readInt(is), readInt(is));
//    		} else {
//    			
//    		}
//    	}
        formatWithRef = new FormatWithRef(this.format, readInt(is), readInt(is), readInt(is), readInt(is));
        
        mSeq = new String[readInt(is)]; // # sequences    
	}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:25,代码来源:BinIndexV1.java

示例7: readSeq

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
protected void readSeq(BlockCompressedInputStream is) throws IOException {
	byte[] buf = new byte[4];
	int i, j, k, l = readInt(is);
	buf = new byte[l];
	is.read(buf);
	for (i = j = k = 0; i < buf.length; ++i) {
		if (buf[i] == 0) {
			byte[] b = new byte[i - j];
			System.arraycopy(buf, j, b, 0, b.length);
			String s = new String(b);
			mChr2tid.put(s, k);
			if (s.toLowerCase().startsWith("chr")) {
				mChr2tid.put(s.substring(3), k);
			} else {
				mChr2tid.put("chr" + s, k);
				mChr2tid.put("Chr" + s, k);
				mChr2tid.put("CHR" + s, k);
			}
			mTid2chr.put(k, s);
			mSeq[k++] = s;
			j = i + 1;
		}
	}
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:25,代码来源:Index.java

示例8: createStream

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
private InputStream createStream(final FileInputStream fileStream) throws IOException {
    // if this looks like a block compressed file and it in fact is, we will use it
    // otherwise we will use the file as is
    if (!AbstractFeatureReader.hasBlockCompressedExtension(inputFile)) {
        return fileStream;
    }

    // make a buffered stream to test that this is in fact a valid block compressed file
    final int bufferSize = Math.max(Defaults.BUFFER_SIZE,
            BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE);
    final BufferedInputStream bufferedStream = new BufferedInputStream(fileStream, bufferSize);

    if (!BlockCompressedInputStream.isValidFile(bufferedStream)) {
        throw new TribbleException.MalformedFeatureFile(
                "Input file is not in valid block compressed format.", inputFile.getAbsolutePath());
    }

    final ISeekableStreamFactory ssf = SeekableStreamFactory.getInstance();
    // if we got here, the file is valid, make a SeekableStream for the BlockCompressedInputStream
    // to read from
    final SeekableStream seekableStream =
            ssf.getBufferedStream(ssf.getStreamFor(inputFile.getAbsolutePath()));
    return new BlockCompressedInputStream(seekableStream);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:25,代码来源:FeatureIterator.java

示例9: setInputStream

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
void setInputStream() {
	try {
	if(this.tabixfile.endsWith(".gz")) {
		this.inputStream = new BlockCompressedInputStream(new File(this.tabixfile));
	}
	else {
		this.vcfreader= new BufferedReader(new FileReader(this.tabixfile));
	}
	}
	catch(Exception e) {
		
		this.inputStream =null;
		e.printStackTrace();
		JOptionPane.showMessageDialog(Main.chromDraw, e.getMessage() , "Error", JOptionPane.ERROR_MESSAGE);
		
	}
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:18,代码来源:Sample.java

示例10: tryBGZIP

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
private static InputStream tryBGZIP(InputStream in) throws IOException
{
byte buffer[]=new byte[2048];

PushbackInputStream push_back=new PushbackInputStream(in,buffer.length+10);
int nReads=push_back.read(buffer);
push_back.unread(buffer, 0, nReads);

try
	{
	BlockCompressedInputStream bgz=new BlockCompressedInputStream(new ByteArrayInputStream(buffer, 0, nReads));
	bgz.read();
	bgz.close();
	return new BlockCompressedInputStream(push_back);
	}
catch(Exception err)
	{
	return new GZIPInputStream(push_back);
	}
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:21,代码来源:IOUtils.java

示例11: seek

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public int seek(final List<File> files, final TileIndex tileIndex, final int currentTile) {
    int count = 0;
    int numClustersInTile = 0;
    for (final InputStream inputStream : streams) {
        final TileIndex.TileIndexRecord tileIndexRecord = tileIndex.findTile(currentTile);
        final BclIndexReader bclIndexReader = new BclIndexReader(files.get(count));
        final long virtualFilePointer = bclIndexReader.get(tileIndexRecord.getZeroBasedTileNumber());
        if (!(inputStream instanceof BlockCompressedInputStream)) {
            throw new UnsupportedOperationException("Seeking only allowed on bzgf");
        } else {
            try {
                if (tileIndex.getNumTiles() != bclIndexReader.getNumTiles()) {
                    throw new PicardException(String.format("%s.getNumTiles(%d) != %s.getNumTiles(%d)",
                            tileIndex.getFile().getAbsolutePath(), tileIndex.getNumTiles(), bclIndexReader.getBciFile().getAbsolutePath(), bclIndexReader.getNumTiles()));
                }
                ((BlockCompressedInputStream) inputStream).seek(virtualFilePointer);
                numClustersInTile = tileIndexRecord.getNumClustersInTile();
            } catch (final IOException e) {
                throw new PicardException("Problem seeking to " + virtualFilePointer, e);
            }
        }
        count++;
    }
    return numClustersInTile;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:26,代码来源:BclReader.java

示例12: doWork

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
@Override protected int doWork() {
    IOUtil.assertFileIsReadable(INPUT);
    try {
        final FileTermination term = BlockCompressedInputStream.checkTermination(INPUT);
        System.err.println(term.name());
        if (term == FileTermination.DEFECTIVE) {
            return 100;
        }
        else {
            return 0;
        }
    }
    catch (IOException ioe) {
        throw new PicardException("Exception reading terminator block of file: " + INPUT.getAbsolutePath());
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:17,代码来源:CheckTerminatorBlock.java

示例13: BGZF_ReferenceSequenceFile

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public BGZF_ReferenceSequenceFile(File file) throws FileNotFoundException {
	if (!file.canRead())
		throw new RuntimeException("Cannot find or read fasta file: " + file.getAbsolutePath());

	File indexFile = new File(file.getAbsolutePath() + ".fai");
	if (!indexFile.canRead())
		throw new RuntimeException("Cannot find or read fasta index file: " + indexFile.getAbsolutePath());

	Scanner scanner = new Scanner(indexFile);
	int seqID = 0;
	dictionary = new SAMSequenceDictionary();
	while (scanner.hasNextLine()) {
		String line = scanner.nextLine();
		FAIDX_FastaIndexEntry entry = FAIDX_FastaIndexEntry.fromString(seqID++, line);
		index.put(entry.getName(), entry);
		dictionary.addSequence(new SAMSequenceRecord(entry.getName(), entry.getLen()));
	}
	scanner.close();

	if (index.isEmpty())
		log.warn("No entries in the index: " + indexFile.getAbsolutePath());

	is = new BlockCompressedInputStream(new SeekableFileStream(file));
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:25,代码来源:BGZF_ReferenceSequenceFile.java

示例14: main

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	Params params = new Params();
	JCommander jc = new JCommander(params);
	jc.parse(args);

	for (File file : params.files) {
		log.info("Indexing file: " + file.getAbsolutePath());
		BlockCompressedInputStream bcis = new BlockCompressedInputStream(new SeekableFileStream(file));
		bcis.available();
		BGZF_FastaIndexer mli = new BGZF_FastaIndexer(bcis);

		PrintWriter writer = new PrintWriter(file.getAbsolutePath() + ".fai");

		FAIDX_FastaIndexEntry e;
		while (!writer.checkError() && (e = mli.readNext()) != null)
			writer.println(e);

		writer.close();
	}
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:21,代码来源:BGZF_FastaIndexer.java

示例15: main

import htsjdk.samtools.util.BlockCompressedInputStream; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        String inFile = "/psychipc01/disk2/references/1000Genome/release/20130502_v5a/ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz";
        String outFile = "/psychipc01/disk2/references/1000Genome/release/20130502_v5a/ALL.chr1.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes1.vcf.gz";
        BlockCompressedInputStream br = new BlockCompressedInputStream(new File(inFile));
        BlockCompressedOutputStream bw = new BlockCompressedOutputStream(new File(outFile));
        String line = null;
        String[] cells = null;

        int[] orgIndices = new int[]{0, 1, 2, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 33, 34, 35, 36, 37, 38, 39, 40};
        int selectedColNum = orgIndices.length;
        int i, pos;
        String delimiter = "\t";

        while ((line = br.readLine()) != null) {
            line = line.trim();
            if (line.trim().length() == 0) {
                continue;
            }

            bw.write(line.replaceAll("[|]", "/").getBytes());
            bw.write("\n".getBytes());
        }
        bw.close();
        br.close();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:32,代码来源:LocalFile.java


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