• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TabixFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: makeTabixCompressedIndex

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的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: readFormat

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的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


示例3: makeBedIndex

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
/**
 * Creates an index for a specified BedFile
 * @param bedFile BedFile to create index for
 */
public void makeBedIndex(final BedFile bedFile) {
    final Map<String, Object> params = new HashMap<>();
    params.put(DIR_ID.name(), bedFile.getId());
    params.put(USER_ID.name(), bedFile.getCreatedBy());

    File file = new File(bedFile.getPath());
    File indexFile = new File(toRealPath(substitute(BED_INDEX, params)));
    NggbBedCodec bedCodec = new NggbBedCodec();

    TabixIndex index = IndexUtils.createTabixIndex(file, bedCodec, TabixFormat.BED);
    index.write(indexFile);

    BiologicalDataItem indexItem = new BiologicalDataItem();
    indexItem.setCreatedDate(new Date());
    indexItem.setPath(indexFile.getAbsolutePath());
    indexItem.setFormat(BiologicalDataItemFormat.BED_INDEX);
    indexItem.setType(BiologicalDataItemResourceType.FILE);
    indexItem.setName("");
    indexItem.setCreatedBy(AuthUtils.getCurrentUserId());

    bedFile.setIndex(indexItem);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:27,代码来源:FileManager.java


示例4: makeMafIndex

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
private void makeMafIndex(final MafFile mafFile, final TabixFormat tabixFormat) throws IOException {
    final Map<String, Object> params = new HashMap<>();
    params.put(DIR_ID.name(), mafFile.getId());
    params.put(USER_ID.name(), mafFile.getCreatedBy());

    File file = new File(mafFile.getPath());
    File indexFile = new File(toRealPath(substitute(MAF_INDEX, params)));
    LOGGER.debug("Writing MAF index at {}", indexFile.getAbsolutePath());

    if (mafFile.getCompressed()) {
        makeTabixCompressedIndex(file, indexFile, new MafCodec(mafFile.getPath()), tabixFormat);
    } else {
        makeTabixIndex(file, indexFile, new MafCodec(mafFile.getPath()), tabixFormat);
    }

    BiologicalDataItem indexItem = new BiologicalDataItem();
    indexItem.setCreatedDate(new Date());
    indexItem.setPath(indexFile.getAbsolutePath());
    indexItem.setFormat(BiologicalDataItemFormat.MAF_INDEX);
    indexItem.setType(BiologicalDataItemResourceType.FILE);
    indexItem.setName("");
    indexItem.setCreatedBy(AuthUtils.getCurrentUserId());

    mafFile.setIndex(indexItem);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:26,代码来源:FileManager.java


示例5: addLineToIndex

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
/** Set vcfHeader and vcfCodec to null if reading non-vcf line.
 * */
private void addLineToIndex(String line, TabixIndexCreator indexCreator, long filePosition, TabixFormat fmt, VCFHeader vcfHeader, VCFCodec vcfCodec) throws InvalidRecordException {

	if(fmt.equals(TabixFormat.BED)){
		
		BedLineCodec bedCodec= new BedLineCodec();
		BedLine bed = bedCodec.decode(line);
		indexCreator.addFeature(bed, filePosition);
	
	} else if(fmt.equals(TabixFormat.GFF)){
		GtfLine gtf= new GtfLine(line.split("\t"));
		indexCreator.addFeature(gtf, filePosition);
	
	} else if(fmt.equals(TabixFormat.VCF)) {

		VariantContext vcf = vcfCodec.decode(line);
		indexCreator.addFeature(vcf, filePosition);
		
	} else {
		System.err.println("Unexpected TabixFormat: " + fmt.sequenceColumn + " " + fmt.startPositionColumn);
		throw new InvalidRecordException();
	}	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:25,代码来源:MakeTabixIndex.java


示例6: trackFormatToTabixFormat

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
public static TabixFormat trackFormatToTabixFormat(TrackFormat fmt){
	
	TabixFormat tbx= null;
	if(fmt.equals(TrackFormat.BAM)){
		tbx= TabixFormat.SAM; 
	} else if (fmt.equals(TrackFormat.BED) || fmt.equals(TrackFormat.BEDGRAPH)){
		tbx= TabixFormat.BED; 
	} else if (fmt.equals(TrackFormat.GFF) || fmt.equals(TrackFormat.GTF)){
		tbx= TabixFormat.GFF;
	} else if (fmt.equals(TrackFormat.VCF)){
		tbx= TabixFormat.VCF;
	} else {
		throw new RuntimeException();
	}
	return tbx;
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:18,代码来源:Utils.java


示例7: canCompressAndIndexHeaderlessVCF

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexHeaderlessVCF() throws ClassNotFoundException, IOException, InvalidRecordException, SQLException{

	String infile= "test_data/noheader.vcf";
	File outfile= new File("test_data/noheader.vcf.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();

	new MakeTabixIndex(infile, outfile, TabixFormat.VCF);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 200);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 100);

	TabixReader tbx = new TabixReader(outfile.getAbsolutePath());
	Iterator x = tbx.query("1", 1, 10000000);
	assertTrue(x.next().startsWith("1"));

}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:23,代码来源:MakeTabixFileTest.java


示例8: testRealFileSizeVCF

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void testRealFileSizeVCF() throws ClassNotFoundException, IOException, InvalidRecordException, SQLException{
	
	// See test_data/README.md for this file. This is fairly large and we want to check it is processed
	// in a reasonable amount of time.
	String infile= "test_data/ALL.wex.union_illumina_wcmc_bcm_bc_bi.20110521.snps.exome.sites.vcf";
	
	File outfile= new File("deleteme.vcf.gz");
	outfile.deleteOnExit();
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	long t0= System.currentTimeMillis();
	new MakeTabixIndex(infile, outfile, TabixFormat.VCF);
	long t1= System.currentTimeMillis();
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 1000);
	assertTrue((t1 - t0) < 20000); // Should be << than 20 sec, ~2 sec

	// Check you can read ok
	this.vcfTester(outfile.getAbsolutePath());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:24,代码来源:MakeTabixFileTest.java


示例9: canCompressAndIndexVCF_CEU

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexVCF_CEU() throws ClassNotFoundException, IOException, InvalidRecordException, SQLException{

	String infile= "test_data/CEU.exon.2010_06.genotypes.vcf";
	
	File outfile= new File("deleteme.vcf.gz");
	outfile.deleteOnExit();
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.VCF);

	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 1000);
	
	// Check you can read ok
	this.vcfTester(outfile.getAbsolutePath());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:MakeTabixFileTest.java


示例10: canHandleEmptyFile

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test 
public void canHandleEmptyFile() throws ClassNotFoundException, IOException, InvalidRecordException, SQLException, InvalidGenomicCoordsException{
	String infile= "test_data/empty.bed";
	File outfile= new File("test_data/empty.tmp.bed.gz");
	outfile.deleteOnExit();
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.BED);

	assertTrue(outfile.exists());
	assertTrue(expectedTbi.exists());
	
	assertEquals(28, outfile.length()); // Checked with `bgzip empty.bed && ls -l empty.bed.gz`
	assertTrue(expectedTbi.length() > 0);

}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:18,代码来源:MakeTabixFileTest.java


示例11: canCompressAndIndexSortedFile

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexSortedFile() throws IOException, InvalidRecordException, ClassNotFoundException, SQLException {
	
	String infile= "test_data/overlapped.bed";
	File outfile= new File("test_data/tmp.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.BED);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 80);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 80);
	
	TabixReader tbx = new TabixReader(outfile.getAbsolutePath());
	Iterator x = tbx.query("chr1", 1, 1000000);
	assertTrue(x.next().startsWith("chr1"));
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:23,代码来源:MakeTabixFileTest.java


示例12: canCompressAndIndexSortedGzipFile

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexSortedGzipFile() throws IOException, InvalidRecordException, ClassNotFoundException, SQLException {
	
	String infile= "test_data/hg19_genes.gtf.gz";
	File outfile= new File("test_data/tmp2.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.GFF);

	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 7000000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 500000);
	
	TabixReader tbx = new TabixReader(outfile.getAbsolutePath());
	Iterator x = tbx.query("chr1", 1, 1000000);
	assertTrue(x.next().startsWith("chr1"));
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:23,代码来源:MakeTabixFileTest.java


示例13: canCompressAndIndexUnsortedFile

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexUnsortedFile() throws IOException, InvalidRecordException, ClassNotFoundException, SQLException {
	
	String infile= "test_data/refSeq.hg19.bed.gz";
	File outfile= new File("test_data/tmp3.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.BED);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 200000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 100000);
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:MakeTabixFileTest.java


示例14: canCompressAndIndexSortedURL

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexSortedURL() throws IOException, InvalidRecordException, ClassNotFoundException, SQLException {
	
	String infile= "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeMapability/wgEncodeDacMapabilityConsensusExcludable.bed.gz";
	File outfile= new File("test_data/tmp4.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.BED);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 1000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 1000);
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:MakeTabixFileTest.java


示例15: canCompressAndIndexUnsortedURL

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexUnsortedURL() throws IOException, InvalidRecordException, ClassNotFoundException, SQLException {
	
	String infile= "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeSydhTfbs/wgEncodeSydhTfbsGm12878P300bStdPk.narrowPeak.gz";
	File outfile= new File("test_data/tmp5.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(infile, outfile, TabixFormat.BED);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 1000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 1000);
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:MakeTabixFileTest.java


示例16: canCompressAndIndexVCF

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void canCompressAndIndexVCF() throws ClassNotFoundException, IOException, InvalidRecordException, SQLException{

	String infile= "test_data/CHD.exon.2010_03.sites.unsorted.vcf";
	File outfile= new File("test_data/tmp6.bed.gz");
	outfile.deleteOnExit();
	
	File expectedTbi= new File(outfile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();

	new MakeTabixIndex(infile, outfile, TabixFormat.VCF);
	
	assertTrue(outfile.exists());
	assertTrue(outfile.length() > 1000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 1000);

	TabixReader tbx = new TabixReader(outfile.getAbsolutePath());
	Iterator x = tbx.query("1", 20000000, 30000000);
	assertTrue(x.next().startsWith("1"));

	// Check you can read ok
	this.vcfTester(outfile.getAbsolutePath());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:25,代码来源:MakeTabixFileTest.java


示例17: blockCompressFileInPlace

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
@Test
public void blockCompressFileInPlace() throws IOException, ClassNotFoundException, InvalidRecordException, SQLException{
	// Test we can compress and index a file and overwrite the original file. 
	
	File testFile= new File("deleteme.bed.gz");
	testFile.deleteOnExit();
	Files.copy(new File("test_data/refSeq.hg19.bed.gz"), testFile);
	
	File expectedTbi= new File(testFile.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION); 
	expectedTbi.deleteOnExit();
	
	new MakeTabixIndex(testFile.getAbsolutePath(), testFile, TabixFormat.BED);
	
	assertTrue(testFile.exists());
	assertTrue(testFile.length() > 200000);
	assertTrue(expectedTbi.exists());
	assertTrue(expectedTbi.length() > 100000);

}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:20,代码来源:MakeTabixFileTest.java


示例18: FormatWithRef

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
public FormatWithRef(final TabixFormat tbiFormat, final int refCol, final int altCol, final int infoCol, final int flag) {
	super();
	this.tbiFormat = tbiFormat;
	this.refCol = refCol;
	this.altCol = altCol;
	this.infoCol = infoCol;
	this.flag = flag;
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:9,代码来源:FormatWithRef.java


示例19: updateFormat

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
public static FormatWithRef updateFormat(final String file, FormatWithRef format, final List<String> cols) {
	
   	Map<String, Integer> map = getHeaderMap();
   	
	for (int j = 0; j < cols.size(); j++) {
		map.put(cols.get(j).trim().toUpperCase(), j + 1);
	}
	
	if(format.tbiFormat == null) {
		format.tbiFormat = new TabixFormat();
		format.tbiFormat.flags = TabixFormat.GENERIC_FLAGS;
	}
	
	format.tbiFormat.sequenceColumn = map.get(HEADER_CHR);
	
	if(map.get(HEADER_POS) != -1) {
		format.tbiFormat.startPositionColumn = map.get(HEADER_POS);
		format.tbiFormat.endPositionColumn = 0;
		format.flag = 3;
	} else if((map.get(HEADER_FROM) != -1) && (map.get(HEADER_TO) != -1)) {
		format.tbiFormat.startPositionColumn = map.get(HEADER_FROM);
		format.tbiFormat.endPositionColumn = map.get(HEADER_TO);
		format.flag = 2;
	} else {
		throw new IllegalArgumentException(ErrorMsg.MISS_POS + ErrorMsg.MISS);
	}
	
	format.refCol = map.get(HEADER_REF);
	format.altCol = map.get(HEADER_ALT);
	format.infoCol = map.get(HEADER_INFO);
	return format;
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:33,代码来源:VannoUtils.java


示例20: main

import htsjdk.tribble.index.tabix.TabixFormat; //导入依赖的package包/类
public static void main(String[] args) {
		String path = "/Users/mulin/Desktop/dbNSFP3.0a.ANN.bgz";
//		String path = "/Users/mulin/Desktop/AF.ANN.bgz";
//		String path = "/Users/mulin/Desktop/clinvar.20160215.sv.ANN.bgz";
		
		CollectionFileWriter write = new CollectionFileWriter(path , TabixFormat.BED);
		write.makeIndex();
	}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:9,代码来源:CollectionFileWriter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Jackson2Annotator类代码示例发布时间:2022-05-23
下一篇:
Java XMLStreamBufferMark类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap