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

Java TabixReader类代码示例

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

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



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

示例1: hasTabixIndex

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
/** Return true if fileName has a valid tabix index. 
 * @throws IOException 
 * */
public static boolean hasTabixIndex(String fileName) throws IOException{
	
	if((new UrlValidator()).isValid(fileName) && fileName.startsWith("ftp")){
		// Because of issue #51
		return false;
	}
	
	try{
		TabixReader tabixReader= new TabixReader(fileName);
		tabixReader.readLine();
		tabixReader.close();
		return true;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:20,代码来源:Utils.java


示例2: canCompressAndIndexHeaderlessVCF

import htsjdk.tribble.readers.TabixReader; //导入依赖的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


示例3: canCompressAndIndexSortedFile

import htsjdk.tribble.readers.TabixReader; //导入依赖的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


示例4: canCompressAndIndexSortedGzipFile

import htsjdk.tribble.readers.TabixReader; //导入依赖的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


示例5: canCompressAndIndexVCF

import htsjdk.tribble.readers.TabixReader; //导入依赖的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


示例6: getCaddPathogenicityData

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
private PathogenicityData getCaddPathogenicityData(TabixDataSource tabixDataSource, String chromosome, int start, String ref, String alt) {
    try {
        TabixReader.Iterator results = tabixDataSource.query(chromosome + ":" + start + "-" + start);
        String line;
        //there can be 0 - N results in this format:
        //#Chrom  Pos     Ref     Alt     RawScore        PHRED
        //2       14962   C       CA      -0.138930       1.458
        //2       14962   C       CAA     -0.155009       1.356
        //2       14962   CA      C       0.194173        4.618
        while ((line = results.next()) != null) {
            String[] elements = line.split("\t");
            String caddRef = elements[2];
            String caddAlt = elements[3];
            if (caddRef.equals(ref) && caddAlt.equals(alt)) {
                return makeCaddPathData(elements[5]);
            }
        }
    } catch (IOException e) {
        logger.error("Unable to read from CADD tabix file {}", tabixDataSource.getSource(), e);
    }
    return PathogenicityData.empty();
}
 
开发者ID:exomiser,项目名称:Exomiser,代码行数:23,代码来源:CaddDao.java


示例7: getRemmData

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
private PathogenicityData getRemmData(String chromosome, int start, int end) {
        try {
            float remm = Float.NaN;
            String line;
//            logger.info("Running tabix with " + chromosome + ":" + start + "-" + end);
            TabixReader.Iterator results = remmTabixDataSource.query(chromosome + ":" + start + "-" + end);
            while ((line = results.next()) != null) {
                String[] elements = line.split("\t");
                if (Float.isNaN(remm)) {
                    remm = Float.parseFloat(elements[2]);
                } else {
                    remm = Math.max(remm, Float.parseFloat(elements[2]));
                }
            }
            //logger.info("Final score " + remm);
            if (!Float.isNaN(remm)) {
                return PathogenicityData.of(RemmScore.valueOf(remm));
            }
        } catch (IOException e) {
            logger.error("Unable to read from REMM tabix file {}", remmTabixDataSource.getSource(), e);
        }
        return PathogenicityData.empty();
    }
 
开发者ID:exomiser,项目名称:Exomiser,代码行数:24,代码来源:RemmDao.java


示例8: getPositionFrequencyData

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
private FrequencyData getPositionFrequencyData(String chromosome, int start, String ref, String alt) {
    //Local frequency file defined as tab-delimited lines in 'VCF-lite' format:
    //chr   pos ref alt freq(%)
    //1 12345   A   T   23.0  (an A->T SNP on chr1 at position 12345 with frequency of 23.0%)
    //1 12345   A   TG   0.01  (an A->TG insertion on chr1 at position 12345 with frequency of 0.01%)
    //note in the usual VCF format these would be on a single line
    //1 12345   AT   G   0.02  (an AT->G deletion on chr1 at position 12345 with frequency of 0.02%)
    //1 12345   T   .   0.03  (an T->. monomorphic site (no alt allele) on chr1 at position 12345 with frequency of 0.03%)
    try {
        TabixReader.Iterator results = tabixDataSource.query(chromosome + ":" + start + "-" + start);
        String line;
        while ((line = results.next()) != null) {
            String[] elements = line.split("\t");
            String refField = elements[2];
            String altField = elements[3];
            if (refField.equals(ref) && altField.equals(alt)) {
                return parseLocalFrequency(elements[4]);
            }
        }
    } catch (IOException e) {
        logger.error("Unable to read from local frequency tabix file {}", tabixDataSource.getSource(), e);
    }
    return FrequencyData.empty();
}
 
开发者ID:exomiser,项目名称:Exomiser,代码行数:25,代码来源:LocalFrequencyDao.java


示例9: TabixDataSource

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public TabixDataSource(DataUrl repeat, DataUrl repeatIndex) throws URISyntaxException, IOException {
	//TODO use the provided index instead of guessing
    super(repeat);
    
    URL repeatUrl = repeat.getUrl();
    
    String fileString = null;
    
    if ("http".equals(repeatUrl.getProtocol())) {
    	fileString = repeatUrl.toExternalForm();
    } else {
    	fileString = (new File(repeatUrl.toURI()).getPath()); //Translate '%20' to space character, required in Windows
    }
    
    this.reader = new TabixReader(fileString);       

    // TODO initialize chromosome name unnormaliser (see for example BamDataSource), 
}
 
开发者ID:chipster,项目名称:chipster,代码行数:19,代码来源:TabixDataSource.java


示例10: TrackBookmark

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public TrackBookmark(GenomicCoords gc, String nameForBookmark) throws IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidGenomicCoordsException{
	super(gc);
			
	this.setTrackTag(trackName);
			
	// Prepare bookmark file
	// =====================
    // First write out the current position as plain text. Then gzip and index.
	File bookmarkPlain= Utils.createTempFile(".asciigenome.bookmarks.", ".gff");
	bookmarkPlain.deleteOnExit();
	BufferedWriter wr = new BufferedWriter(new FileWriter(bookmarkPlain));
	wr.write(this.positionToGffLine(gc, nameForBookmark) + "\n"); // gc.getChrom() + "\t" + (gc.getFrom() - 1) + "\t" + gc.getTo() + "\t" + nameForBookmark + "\n");
	wr.close();

	File bookmark= new File(bookmarkPlain + ".gz");
	bookmark.deleteOnExit();
	(new File(bookmark.getAbsolutePath() + ".tbi")).deleteOnExit();
	this.setFilename(bookmark.getAbsolutePath());
	this.setWorkFilename(bookmark.getAbsolutePath());
	
	new MakeTabixIndex(bookmarkPlain.getAbsolutePath(), bookmark, TabixFormat.GFF);
	bookmarkPlain.delete();
	
	this.setTabixReader(new TabixReader(bookmark.getAbsolutePath()));
	this.setTrackFormat(TrackFormat.GTF);
	this.setGc(gc);
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:28,代码来源:TrackBookmark.java


示例11: addBookmark

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
/** Add current genomic position to track.  
 * @throws IOException 
 * @throws SQLException 
 * @throws InvalidRecordException 
 * @throws ClassNotFoundException 
 * @throws InvalidGenomicCoordsException 
 * */
@Override
public void addBookmark(GenomicCoords gc, String nameForBookmark) throws IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidGenomicCoordsException{
	
	// Adding a bookmark means re-preparing the bgzip file again. 
	
	// First write the current position to a new tmp file, then append to this file
	// all the bookmarks previously added. Then bgzip and compress replacing the old bookmark file.
	File plainNew= new File(this.getWorkFilename() + ".add");
	plainNew.deleteOnExit();
	BufferedWriter wr = new BufferedWriter(new FileWriter(plainNew));
	
	InputStream fileStream = new FileInputStream(this.getWorkFilename());
	Reader decoder = new InputStreamReader(new GZIPInputStream(fileStream), "UTF-8");
	BufferedReader br= new BufferedReader(decoder);

	String line;
	while( (line = br.readLine()) != null) {
		if(line.contains("\t__ignore_me__")){ // Hack to circumvent issue #38
			continue;
		}			
		wr.write(line + "\n");
	}
	// Add new bookamrk
	wr.write(this.positionToGffLine(gc, nameForBookmark) + "\n");
	br.close();
	wr.close();

	// Recompress and index replacing the original bgzip file
	new MakeTabixIndex(plainNew.getAbsolutePath(), new File(this.getWorkFilename()), TabixFormat.GFF);
	plainNew.delete();
	this.tabixReader= new TabixReader(this.getWorkFilename());
	// Update track.
	this.update();
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:42,代码来源:TrackBookmark.java


示例12: removeBookmark

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
/** Remove the bookmark matching the exact coordinates of the current position. 
 * Bookmarks partially overlapping are not removed. 
 * @param bookmarkRegion 
 * @throws IOException 
 * @throws SQLException 
 * @throws InvalidRecordException 
 * @throws ClassNotFoundException 
 * @throws InvalidGenomicCoordsException 
 * */
public void removeBookmark(GenomicCoords bookmarkRegion) throws IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidGenomicCoordsException {
	// To remove a bookmark, iterate through the bgzip file writing records to a tmp file.
	// The record(s) matching this position is not written. 
	// 
	File plainNew= new File(this.getWorkFilename() + ".remove");
	plainNew.deleteOnExit();
	BufferedWriter wr = new BufferedWriter(new FileWriter(plainNew));
	
	InputStream fileStream = new FileInputStream(this.getWorkFilename());
	Reader decoder = new InputStreamReader(new GZIPInputStream(fileStream), "UTF-8");
	BufferedReader br= new BufferedReader(decoder);

	String line;
	while( (line = br.readLine()) != null) {
		
		if( ! line.startsWith("#")){ // In case of comment lines
			List<String>pos= Lists.newArrayList(Splitter.on("\t").split(line));
			
			if(bookmarkRegion.getChrom().equals(pos.get(0)) && 
			   bookmarkRegion.getFrom() == Integer.parseInt(pos.get(3)) && 
			   bookmarkRegion.getTo() == Integer.parseInt(pos.get(4))){
				continue;
			}
		}
		wr.write(line + "\n");
	}
	wr.close();
	br.close();
	
	// Recompress and index replacing the original bgzip file
	new MakeTabixIndex(plainNew.getAbsolutePath(), new File(this.getWorkFilename()), TabixFormat.GFF);
	plainNew.delete();
	this.tabixReader= new TabixReader(this.getWorkFilename());
	// Update track.
	this.update();
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:46,代码来源:TrackBookmark.java


示例13: TrackIntervalFeature

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public TrackIntervalFeature(final String filename, GenomicCoords gc) throws IOException, InvalidGenomicCoordsException, ClassNotFoundException, InvalidRecordException, SQLException{
	
	this.setFilename(filename);

	if(Utils.getFileTypeFromName(filename).equals(TrackFormat.BIGBED)){
		
		this.bigBedReader = new BBFileReader(filename);  // or url for remote access.
		if(!this.bigBedReader.getBBFileHeader().isBigBed()){
			throw new RuntimeException("File " + filename + " is not bigBed.");
		}
		
		this.setWorkFilename(filename);
		this.setTrackFormat(TrackFormat.BIGBED);
		
	} else if( ! Utils.hasTabixIndex(filename)){
		// Tabix index not found for this file. Sort and index input to tmp.

		String suffix= new File(filename).getName();
		if( ! suffix.endsWith(".gz")){
			suffix += ".gz";
		}
		String tmpWorkFile= Utils.createTempFile(".asciigenome.", "." + suffix).getAbsolutePath();
		new File(tmpWorkFile).deleteOnExit();
		new File(new File(tmpWorkFile).getAbsolutePath() + ".tbi").deleteOnExit();
		this.setWorkFilename(tmpWorkFile);

		this.setTrackFormat(Utils.getFileTypeFromName(new File(filename).getName()));
		new MakeTabixIndex(filename, new File( this.getWorkFilename() ), Utils.trackFormatToTabixFormat(this.getTrackFormat()));	

		this.setWorkFilename(tmpWorkFile);
		this.tabixReader= new TabixReader(new File(this.getWorkFilename()).getAbsolutePath());
		
	} else { // This means the input is tabix indexed.
		this.setWorkFilename(filename);
		this.setTrackFormat(Utils.getFileTypeFromName(new File(filename).getName()));
		this.tabixReader= new TabixReader(this.getWorkFilename());
	}
	this.setGc(gc);
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:40,代码来源:TrackIntervalFeature.java


示例14: processDataRequest

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
@Override
protected void processDataRequest(DataRequest request) throws InterruptedException {

	// Read the given region
	TabixReader.Iterator iterator = dataSource.getTabixIterator(request);

	try {
		String line;
		List<Feature> resultList = new LinkedList<Feature>();

		if (iterator != null) { //null if there isn't such chromosome in annotations

			while ((line = iterator.next()) != null) {

				parser.setLine(line);
				Region region = parser.getRegion();				
				resultList.add(new Feature(region));
			}
		}

		// Send result			
		super.createDataResult(new DataResult(request.getStatus(), resultList));		
		
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:chipster,项目名称:chipster,代码行数:28,代码来源:BedTabixToRegionConversion.java


示例15: closeIfPossible

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public static void closeIfPossible(TabixReader reader) {
	if (reader != null) {
		try {
			reader.close();
		} catch (Exception e) {
			// Ignore
		}
	}
}
 
开发者ID:chipster,项目名称:chipster,代码行数:10,代码来源:SamBamUtils.java


示例16: GenericTSVVariantContextProvider

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public GenericTSVVariantContextProvider(GenericTSVAnnotationOptions options) {
	this.options = options;
	final String tsvPath = this.options.getTsvFile().toString();
	try {
		this.tabixReader = new TabixReader(tsvPath, tsvPath + ".tbi");
	} catch (IOException e) {
		throw new RuntimeException("Could not open TABIX file " + tsvPath, e);
	}
}
 
开发者ID:charite,项目名称:jannovar,代码行数:10,代码来源:GenericTSVVariantContextProvider.java


示例17: iterator

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
private  Iterator<String> iterator(int parseReg[])
  	{
  	if(isClosed()) return Collections.emptyIterator();
  	if(parseReg==null)
  		{
	return Collections.emptyIterator();
	}
final TabixReader.Iterator titer=this.tabix.query(parseReg[0], parseReg[1],parseReg[2]);
if(titer==null)
	{
	return Collections.emptyIterator();
	}
return new MyIterator(titer);
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:15,代码来源:TabixFileReader.java


示例18: DBBean

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public DBBean(final DBRunConfigBean config, final Printter printter) throws IOException {
	super();
	this.tabixReader = new TabixReader(config.getDbPath(), config.getDbIndex());
	this.printter = printter;
	this.index = new TbiIndex(config.getDbIndex());
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:7,代码来源:DBBean.java


示例19: getTabixReader

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public TabixReader getTabixReader() {
	return tabixReader;
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:4,代码来源:DBBean.java


示例20: changeRef

import htsjdk.tribble.readers.TabixReader; //导入依赖的package包/类
public void changeRef(String dir) {
  writeToConfig("DefaultGenome=" +dir);
 defaultGenome = dir;
 setChromDrop(Main.refDropdown.getSelectedItem().toString()); 		  
 getBands();
 try {
  if(genomehash.get(dir).size() > 0) {
  
    ChromDraw.exonReader = new TabixReader(genomehash.get(dir).get(0).getCanonicalPath());
	String s;
	String[] exonSplit;
	searchTable.clear();
	while((s = ChromDraw.exonReader.readLine()) != null) {
		exonSplit = s.split("\t");
		if(!searchTable.containsKey(exonSplit[3].toUpperCase())) {		
			
			String[] adder = {exonSplit[0], exonSplit[1], exonSplit[2]};
			searchTable.put(exonSplit[3].toUpperCase(), adder);			
			if(exonSplit[6].contains(":")) {
				geneIDMap.put(exonSplit[6].split(":")[1].toUpperCase(), exonSplit[3].toUpperCase());
				}
				else {
					geneIDMap.put(exonSplit[6].toUpperCase(), exonSplit[3].toUpperCase());
				}
			}	
			else {
				
				if(Integer.parseInt(searchTable.get(exonSplit[3].toUpperCase())[1]) > Integer.parseInt(exonSplit[1])) {
					searchTable.get(exonSplit[3].toUpperCase())[1] = exonSplit[1];
				}
				if(Integer.parseInt(searchTable.get(exonSplit[3].toUpperCase())[2]) < Integer.parseInt(exonSplit[2])) {
					searchTable.get(exonSplit[3].toUpperCase())[2] = exonSplit[2];
				}
			}					
		}
	
   }
   }
   catch(Exception e) {
	   e.printStackTrace();
   }
  changeAnnotation(0);
  chromosomeDropdown.setSelectedIndex(0);
  drawCanvas.chrom = chromosomeDropdown.getItemAt(0);
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:46,代码来源:Main.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java FilerImpl类代码示例发布时间:2022-05-23
下一篇:
Java TagValue类代码示例发布时间: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