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


Java VariantContextWriter.checkError方法代码示例

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


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

示例1: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
	final String inputName,
	final VcfIterator in,
	final VariantContextWriter delegate)
	{
	final VariantContextWriter  out = this.component.open(delegate);
	final SAMSequenceDictionaryProgress progess=new SAMSequenceDictionaryProgress(in.getHeader()).logger(LOG);
	out.writeHeader(in.getHeader());
	while(in.hasNext() &&  !out.checkError())
		{
		out.add(progess.watch(in.next()));
		}
	progess.finish();
	out.close();
	return 0;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:VcfMoveFiltersToInfo.java

示例2: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(String inputName, VcfIterator r, VariantContextWriter w) {
	try {
		final VCFHeader h2=new VCFHeader(r.getHeader());
		addMetaData(h2);
		final VCFFilterHeaderLine filter = new VCFFilterHeaderLine(
				this.filterName,
				"Filtered with "+getProgramName()+", "+
				(this.inverse?" NOT  ":"")+
				"overlapping "+
				(this.tabixFile==null?this.treeMapFile:this.tabixFile)
				);
		
		
		if(!this.discardFlag) {
			h2.addMetaDataLine(filter);
		}
		
		final SAMSequenceDictionaryProgress progress=new SAMSequenceDictionaryProgress(h2);
		w.writeHeader(h2);
		while(r.hasNext())
			{
			final VariantContext ctx= progress.watch(r.next());
			boolean set_filter=true;
			
			
			if(this.intervalTreeMap!=null) {
				if( this.intervalTreeMap.containsOverlapping(new Interval(ctx.getContig(),ctx.getStart(),ctx.getEnd())))
					{
					set_filter = false;	
					}
				}
			
			else 
				{
				final CloseableIterator<BedLine> iter = this.bedReader.iterator(
						ctx.getContig(),
						ctx.getStart()-1,
						ctx.getEnd()+1
						);
				while(iter.hasNext())
					{
					final BedLine bed = iter.next();
					if(!ctx.getContig().equals(bed.getContig())) continue;
					if(ctx.getStart() > bed.getEnd() ) continue;
					if(ctx.getEnd() < bed.getStart() ) continue;
					set_filter=false;
					break;
					}
				CloserUtil.close(iter);
				}
			
			if(this.inverse) set_filter=!set_filter;
			
			
			
			if(!set_filter)
				{
				w.add(ctx);
				continue;
				}
			
			if(!this.discardFlag)
				{
				final VariantContextBuilder vcb=new VariantContextBuilder(ctx);
				vcb.filter(filter.getID());
				w.add(vcb.make());
				}
			
			if(w.checkError()) break;
			}
		progress.finish();
		return RETURN_OK;
	} catch(Exception err) {
		LOG.error(err);
		return -1;
		}
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:79,代码来源:VCFBedSetFilter.java

示例3: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(String inputName, VcfIterator in, VariantContextWriter out) {
	try {
		//TODO in jdk8 replace with http://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
		VCFHeader header=in.getHeader();
		VCFInfoHeaderLine infoHeader = header.getInfoHeaderLine(this.infoTag);
		if(infoHeader==null)
			{
			LOG.warning("No INFO header line for "+this.infoTag+" in "+inputName);
			}
		else if(!(infoHeader.getCountType()==VCFHeaderLineCount.INTEGER &&
				 infoHeader.getCount()==1 &&
				 infoHeader.getType()==VCFHeaderLineType.String))
			{
			LOG.warning("Bad definition of INFO header line for "+this.infoTag+" in "+inputName+" expected one 'string' got "+infoHeader);
			infoHeader=null;
			}
		
		VCFHeader h2=new VCFHeader(header);
		h2.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName()+"CmdLine",String.valueOf(getProgramCommandLine())));
		h2.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName()+"Version",String.valueOf(getVersion())));
		h2.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName()+"HtsJdkVersion",HtsjdkVersion.getVersion()));
		h2.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName()+"HtsJdkHome",HtsjdkVersion.getHome()));
		SAMSequenceDictionaryProgress progess=new SAMSequenceDictionaryProgress(header.getSequenceDictionary());
		
		out.writeHeader(h2);
		while(in.hasNext() )
			{	
			VariantContext ctx = progess.watch(in.next());
			if(infoHeader==null)//no tag in header
				{
				out.add(ctx);
				continue;
				}
			
			Object o=ctx.getAttribute(this.infoTag);
			if(o==null)
				{
				out.add(ctx);
				continue;
				}
			StringBuilder base64=new StringBuilder(o.toString());
			while(base64.length()%4!=0) base64.append('=');
			ByteArrayInputStream xmlBytes =  new ByteArrayInputStream(Base64.getDecoder().decode(base64.toString()));
			InputSource inputSource=new InputSource(xmlBytes);
			xpathVariableMap.put(new QName("chrom"), ctx.getContig());
			xpathVariableMap.put(new QName("start"), ctx.getStart());
			xpathVariableMap.put(new QName("end"), ctx.getEnd());
			xpathVariableMap.put(new QName("id"), ctx.hasID()?ctx.getID():".");
			boolean accept=(Boolean)xpathExpr.evaluate(inputSource, XPathConstants.BOOLEAN);
			if(accept)
				{
				out.add(ctx);
				}
			if(out.checkError()) break;
			}
		
		progess.finish();
		return 0;
		}
	catch(Exception err)
		{
		LOG.error(err);
		return -1;
		}
	finally
		{
		xpathVariableMap.clear();
		}
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:71,代码来源:VcfFilterXPath.java

示例4: sortvcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
protected int sortvcf(BufferedReader in) throws IOException 
  	{
if(this.refdict!=null) {
	LOG.info("load dict from "+this.refdict);
	this.dict = SAMSequenceDictionaryExtractor.extractDictionary(this.refdict);
	if(this.dict==null) {
		LOG.error("cannot find sam sequence dictionary from "+refdict);
	}
}

final VCFUtils.CodecAndHeader cah =VCFUtils.parseHeader(in);
  	final VCFHeader h2=new  VCFHeader(cah.header);
  	if(this.dict!=null)
  		{
  		h2.setSequenceDictionary(this.dict);
  		}
  	else
  		{
  		this.dict= h2.getSequenceDictionary();
  		if(this.dict==null)
  			{
  			LOG.error("No internal sequence dictionay found in input");
  			return -1;
  			}
  		}
  	
  	addMetaData(h2);

if(this.dict.isEmpty())
	{
	LOG.warn("SEQUENCE DICTIONARY IS EMPTY/NULL");
	}

  	CloseableIterator<ChromPosLine> iter=null;
  	SortingCollection<ChromPosLine> array=null;
  	VariantContextWriter w =null;
  	try {
	array= SortingCollection.newInstance(
			ChromPosLine.class,
			new VariantCodec(),
			new VariantComparator(),
			this.writingSortingCollection.getMaxRecordsInRam(),
			this.writingSortingCollection.getTmpPaths()
			);
	array.setDestructiveIteration(true);
	final SAMSequenceDictionaryProgress progress=new SAMSequenceDictionaryProgress(this.dict);
	String line;
	while((line=in.readLine())!=null)
		{
		final ChromPosLine cpl=new ChromPosLine(line);
		progress.watch(cpl.tid,cpl.pos);
		array.add(cpl);
		}
	array.doneAdding();
	progress.finish();
	
	w = super.openVariantContextWriter(outputFile);
	w.writeHeader(h2);
	
	iter=array.iterator();
	while(iter.hasNext())
		{
		w.add(cah.codec.decode(iter.next().line));
		if(w.checkError()) break;
		}
	return RETURN_OK;
	}
  	catch (Exception e)
  		{
	LOG.error(e);
	return -1;
	}
  	finally
   	{
  		CloserUtil.close(w);
   	CloserUtil.close(iter);
   	if(array!=null) array.cleanup();
   	}
  	
  	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:81,代码来源:SortVcfOnRef2.java

示例5: scanFileSorted

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private int scanFileSorted(
	final VariantContextWriter vcw,
	final String databaseVcfUri,
	final VcfIterator userVcfIn
	)
{
EqualRangeVcfIterator equalRangeDbIter=null;
try
	{
	final VCFHeader header = new VCFHeader(userVcfIn.getHeader());
	final SAMSequenceDictionary userVcfDict = header.getSequenceDictionary();
	/// NO need if(dict1==null)
	if(userVcfDict==null)
		{
		LOG.error("NO SAM sequence Dict in user VCF");
		return -1;
		}
	final Comparator<VariantContext> vcfComparator =
			VCFUtils.createTidPosComparator(userVcfDict)
			;
	equalRangeDbIter = new EqualRangeVcfIterator(
			VCFUtils.createVcfIterator(databaseVcfUri),vcfComparator);

	this.addMetaData(header);
	vcw.writeHeader(header);
	final SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(userVcfDict).logger(LOG);
	
	while(userVcfIn.hasNext())
		{
		final VariantContext ctx = progress.watch(userVcfIn.next());
		//fill both contextes
		final List<VariantContext> dbContexes = new ArrayList<VariantContext>(equalRangeDbIter.next(ctx));
		
		int i=0;
		while(i< dbContexes.size())
			{
			if( dbContexes.get(i).getReference().equals(ctx.getReference()) &&
				allUserAltFoundInDatabase(ctx, dbContexes.get(i)))
				{
				++i;
				}
			else
				{
				dbContexes.remove(i);
				}
			}
		
		final boolean keep=!dbContexes.isEmpty();
		addVariant(vcw,ctx,keep);
		if(vcw.checkError()) break;
		}
	return RETURN_OK;
	}
catch(final Exception err)
	{
	LOG.error(err);
	return -1;
	}
finally
	{
	CloserUtil.close(equalRangeDbIter);
	CloserUtil.close(userVcfIn);
	CloserUtil.close(vcw);
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:66,代码来源:VcfIn.java

示例6: scanUsingTabix

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private int scanUsingTabix(final VariantContextWriter vcw,final String databaseVcfUri,final VcfIterator in2)
{
TabixVcfFileReader tabix=null;
try
	{
	LOG.info("opening "+databaseVcfUri+" as tabix");
	tabix =  new TabixVcfFileReader(databaseVcfUri);
	final VCFHeader header1= new VCFHeader(in2.getHeader());
	this.addMetaData(header1);
	vcw.writeHeader(header1);
	
	final SAMSequenceDictionaryProgress progress=new SAMSequenceDictionaryProgress(header1.getSequenceDictionary()).logger(LOG);
	
	while(in2.hasNext() && !vcw.checkError())
		{
		final VariantContext userCtx= progress.watch(in2.next());
		
		final Iterator<VariantContext> iter= tabix.iterator(userCtx.getContig(),
				Math.max(1,userCtx.getStart()-1),
				userCtx.getEnd()+1);
		boolean keep=false;
		while(iter.hasNext())
			{
			final VariantContext dbctx= iter.next();
			if(! dbctx.getContig().equals(userCtx.getContig())) continue;
			if(dbctx.getStart()!=userCtx.getStart()) continue;
			if(! dbctx.getReference().equals(userCtx.getReference())) continue;
			if(!allUserAltFoundInDatabase(userCtx, dbctx)) continue;
			keep=true;
			break;
			}
		
		addVariant(vcw,userCtx,keep);
		if(vcw.checkError()) break;
		}
	progress.finish();
	return RETURN_OK;
	}
catch(final Exception err)
	{
	LOG.error(err);
	return -1;
	}
finally
	{
	CloserUtil.close(tabix);
	CloserUtil.close(in2);
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:50,代码来源:VcfIn.java


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