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


Java VCFHeaderVersion类代码示例

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


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

示例1: validVersion

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
private static boolean validVersion(File filepath) throws IOException {
  BufferedReader reader = Files.newBufferedReader(filepath.toPath(), UTF_8);

  // The first line must be the header
  String firstLine = reader.readLine();
  reader.close();

  try {
    VCFHeaderVersion version = VCFHeaderVersion.getHeaderVersion(firstLine);

    // If the version is greater than or equal to 4.2, we cannot handle it
    if (version.isAtLeastAsRecentAs(VCFHeaderVersion.VCF4_2)) {
      return false;
    }
  } catch (TribbleException.InvalidHeader msg) {
    throw new IOException(msg);
  }

  return true;
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:21,代码来源:VcfToVariant.java

示例2: getVCFVersion

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
public VCFHeaderVersion getVCFVersion(VCFHeader vcfHeader) {
	String versionLine = null;
	Set<VCFHeaderLine> vcfHeaderLineSet = vcfHeader.getMetaDataInInputOrder();
	for (VCFHeaderLine vcfHeaderLine : vcfHeaderLineSet) {
   		if(VCFHeaderVersion.isFormatString(vcfHeaderLine.getKey())){
   			versionLine = vcfHeaderLine.toString();
   			break;
   		}
	}
	return VCFHeaderVersion.getHeaderVersion("##"+versionLine);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:12,代码来源:SingleVCFHeader.java

示例3: setup

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
@Override
	protected void setup(Context context)
			throws IOException, InterruptedException {
		resultKey = new Text();
		resultValue = new VcfLineWritable();
		conf = context.getConfiguration();
		vcfCodecs = new HashMap<>();

		Path inputPath = new Path(conf.get("inputFilePath"));
		FileSystem fs = inputPath.getFileSystem(conf);
		FileStatus[] files = fs.listStatus(inputPath);
		for(FileStatus file : files) {
			//System.out.println(file.getPath());

			if (file.isFile()) {
				SingleVCFHeader singleVcfHeader = new SingleVCFHeader();
				singleVcfHeader.readHeaderFrom(file.getPath(), fs);
				VCFHeader vcfHeader = singleVcfHeader.getHeader();
				VCFHeaderVersion vcfVersion = singleVcfHeader.getVCFVersion(vcfHeader);
				VCFCodec vcfcodec = new VCFCodec();
				vcfcodec.setVCFHeader(vcfHeader, vcfVersion);
				vcfCodecs.put(file.getPath().getName(), vcfcodec);
			}
		}

//		TODO split vcfLine


	}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:30,代码来源:AnnotationMapper.java

示例4: setup

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
@Before
public void setup() {
    victim = new SomaticVariantFactory();
    codec = new VCFCodec();
    VCFHeader header = new VCFHeader(Sets.newHashSet(), Sets.newHashSet(SAMPLE));
    codec.setVCFHeader(header, VCFHeaderVersion.VCF4_2);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:8,代码来源:SomaticVariantFactoryTest.java

示例5: readActualHeader

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
/**
    * Reads all of the header from the provided iterator, but no reads no further.
    * @param lineIterator the line reader to take header lines from
    * @return The parsed header
    */
   @SuppressWarnings("static-access")
@Override
   public Object readActualHeader(final LineIterator lineIterator) {
       final List<String> headerStrings = new ArrayList<String>();

       String line;
       boolean foundHeaderVersion = false;
       while (lineIterator.hasNext()) {
           line = lineIterator.peek();
           lineNo++;
           if (line.startsWith(VCFHeader.METADATA_INDICATOR)) {
               final String[] lineFields = line.substring(2).split("=");
               if (lineFields.length == 2 && VCFHeaderVersion.isFormatString(lineFields[0]) ) {
                   if ( !VCFHeaderVersion.isVersionString(lineFields[1]) )
                       throw new TribbleException.InvalidHeader(lineFields[1] + " is not a supported version");
                   foundHeaderVersion = true;
                   version = VCFHeaderVersion.toHeaderVersion(lineFields[1]);
                   if ( ! version.isAtLeastAsRecentAs(VCFHeaderVersion.VCF4_0) )
                       throw new TribbleException.InvalidHeader("This codec is strictly for VCFv4; please use the VCF3 codec for " + lineFields[1]);
                   if ( version != VCFHeaderVersion.VCF4_0 && version != VCFHeaderVersion.VCF4_1 && version != VCFHeaderVersion.VCF4_2 )
                       throw new TribbleException.InvalidHeader("This codec is strictly for VCFv4 and does not support " + lineFields[1]);
               }
               headerStrings.add(lineIterator.next());
           }
           else if (line.startsWith(VCFHeader.HEADER_INDICATOR)) {
               if (!foundHeaderVersion) {
                   throw new TribbleException.InvalidHeader("We never saw a header line specifying VCF version");
               }
               headerStrings.add(lineIterator.next());
               super.parseHeaderFromLines(headerStrings, version);
               return this.header;
           }
           else {
               throw new TribbleException.InvalidHeader("We never saw the required CHROM header line (starting with one #) for the input VCF file");
           }

       }
       throw new TribbleException.InvalidHeader("We never saw the required CHROM header line (starting with one #) for the input VCF file");
   }
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:45,代码来源:OwnVCFCodec.java

示例6: getVCFHeaderVersion

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
public static VCFHeaderVersion getVCFHeaderVersion(VCFHeader vcfHeader){
	Iterator<VCFHeaderLine> iter = vcfHeader.getMetaDataInInputOrder().iterator();
	while(iter.hasNext()){
		VCFHeaderLine hl = iter.next();
		if(hl.getKey().equals("fileformat")){
			return VCFHeaderVersion.toHeaderVersion(hl.getValue());
		}
	}
	return null;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:11,代码来源:Utils.java

示例7: setHeader

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
@Override public void setHeader(VCFHeader header) {
	VCFHeaderVersion version = null;

	// Normally AbstractVCFCodec parses the header and thereby sets the
	// version field. It gets used later on so we need to set it.
	for (final VCFHeaderLine line : header.getMetaDataInInputOrder()) {
		if (VCFHeaderVersion.isFormatString(line.getKey())) {
			version = VCFHeaderVersion.toHeaderVersion(line.getValue());
			break;
		}
	}

	codec.setHeaderAndVersion(header, version);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:15,代码来源:LazyVCFGenotypesContext.java

示例8: findCodecFromLines

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
/** find a codec from the lines header. if not found, return default codec */
public static AbstractVCFCodec findCodecFromLines(final List<String> list)
	{
	for(final String line: list)
		{
		String formatString = line;
		if(formatString.startsWith("##"))
			{
			formatString=formatString.substring(2);
			}
		int eq= formatString.indexOf('=');
		if(eq==-1) continue;
		
		if(!VCFHeaderVersion.isFormatString(formatString.substring(0,eq))) continue;
		
		VCFHeaderVersion version=VCFHeaderVersion.getHeaderVersion(line	);
		if(version==null) continue;
		switch(version)
			{
			case VCF3_2: 
			case VCF3_3: return new VCF3Codec();
			case VCF4_0:
			case VCF4_1:
			case VCF4_2: return new VCFCodec();
			}
		}
	return createDefaultVCFCodec();
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:29,代码来源:VCFUtils.java

示例9: reduce

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
@Override
public void reduce(IntWritable key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
   	fileId = key.get();
   	for(Text value : values) {
    	VariantDatumMessenger msg = new VariantDatumMessenger.Builder().
    							buildFrom(value.toString(), genomeLocParser);
    	recal.addData(msg);
   	}
   	recal.recalVCF(fileId, context);
   	
   	VCFHeader header = headers.getVcfHeader(fileId);
   	header = recal.addHeaderLine(header);
   	VCFCodec codec = new VCFCodec();
	codec.setVCFHeader(header, VCFHeaderVersion.VCF4_2);
   	InputStream is = HdfsFileManager.getInputStream(new Path(headers.getFile(fileId)), context.getConfiguration());
	AsciiLineReaderIterator iterator = new AsciiLineReaderIterator(new AsciiLineReader(is));
	while(iterator.hasNext()) {
		VariantContext vc = codec.decode(iterator.next());
		
		if(vc == null)
			continue;
		
		boolean inRegion = false;
		for(int i = vc.getStart() ; i <= vc.getEnd() ; i++){
			if(region != null && region.isPositionInRegion(vc.getContig(), i - 1)) {
                inRegion = true;
                break;
            }
		}
		
		if(region !=null && !inRegion)
			continue;
		
		basicStatics.variantStatic(vc);
		vc = recal.applyRecalibration(vc);
		//statistic(vc);
		if(vc.isNotFiltered()){
			filteredStatics.variantStatic(vc);
		}
		VariantContextWritable vcWritable = new VariantContextWritable();
		vcWritable.set(vc,header);
		context.write(NullWritable.get(), vcWritable);
	}
	iterator.close();
   }
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:46,代码来源:VariantRecalibrationReducer.java

示例10: setup

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
	options = new AnnotatorOptions();
	Configuration conf = context.getConfiguration();
	options.getOptionsFromHadoopConf(conf);

	long setupStart = System.currentTimeMillis();
	long start = System.currentTimeMillis();
	ReferenceShare genomeShare = new ReferenceShare();
	genomeShare.loadChromosomeList(options.getReferenceSequencePath());
	if(options.isDebug())
		System.err.println("genomeShare耗时:" + (System.currentTimeMillis()-start)+"毫秒");

	userConfig = new Config(conf, genomeShare);
	userConfig.setVerbose(options.isVerbose());
	userConfig.setDebug(options.isDebug());

	start = System.currentTimeMillis();
	AnnotatorBuild annoBuild = new AnnotatorBuild(userConfig);
	userConfig.setSnpEffectPredictor(annoBuild.createSnpEffPredictor());
	annoBuild.buildForest();
	if(options.isDebug())
		System.err.println("build SnpEffectPredictor耗时:" + (System.currentTimeMillis()-start)+"毫秒");
	vcfCodecs = new HashMap<>();
	Path inputPath = new Path(options.getInputFilePath());
	FileSystem fs = inputPath.getFileSystem(conf);
	FileStatus[] files = fs.listStatus(inputPath);

	for(FileStatus file : files) {
		if (file.isFile()) {
			SingleVCFHeader singleVcfHeader = new SingleVCFHeader();
			singleVcfHeader.readHeaderFrom(file.getPath(), fs);
			VCFHeader vcfHeader = singleVcfHeader.getHeader();
			VCFHeaderVersion vcfVersion = singleVcfHeader.getVCFVersion(vcfHeader);
			VCFCodec vcfcodec = new VCFCodec();
			vcfcodec.setVCFHeader(vcfHeader, vcfVersion);
			vcfCodecs.put(file.getPath().getName(), vcfcodec);
		}

	}
	if(options.isDebug())
		System.err.println("getVCFHeader耗时:" + (System.currentTimeMillis()-start)+"毫秒");

	annoEngine = new AnnotationEngine(userConfig);

	start = System.currentTimeMillis();
	//用于从数据库中查找信息
	dbAnnotator = new DBAnnotator(userConfig);
	try {
		dbAnnotator.connection();
	} catch (InstantiationException | IllegalAccessException
			| ClassNotFoundException e) {
		e.printStackTrace();
	}
	System.err.println("dbAnnotator.connection耗时:" + (System.currentTimeMillis()-start)+"毫秒");

	// 注释结果header信息
	resultValue.set(userConfig.getHeader());
	context.write(NullWritable.get(), resultValue);
	System.err.println("mapper.setup耗时:" + (System.currentTimeMillis()-setupStart)+"毫秒");
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:62,代码来源:AnnotationReducer.java

示例11: generateHeader

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
private VCFHeader generateHeader(String name, String chromosome) {

		Set<VCFHeaderLine> headerLines = new HashSet<VCFHeaderLine>();
		Set<String> additionalColumns = new HashSet<String>();

		headerLines.add(new VCFHeaderLine(VCFHeaderVersion.VCF4_0.getFormatString(),
				VCFHeaderVersion.VCF4_0.getVersionString()));

		headerLines.add(new VCFFormatHeaderLine(VCFConstants.GENOTYPE_KEY, 1, VCFHeaderLineType.String, "Genotype"));

		additionalColumns.add(name);

		SAMSequenceDictionary sequenceDict = generateSequenceDictionary(chromosome);

		VCFHeader header = new VCFHeader(headerLines, additionalColumns);
		header.setSequenceDictionary(sequenceDict);

		return header;

	}
 
开发者ID:genepi,项目名称:imputationserver,代码行数:21,代码来源:VCFBuilder.java

示例12: warpHeader

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
private static VCFHeader warpHeader(VCFHeader in, Map<String, Long> namesAndLength)
    throws IllegalArgumentException {
  Set<VCFHeaderLine> newLines = new HashSet<>();
  boolean hasSource = false;
  VCFHeaderVersion version = DEFAULT_VCF_VERSION;

  for (VCFHeaderLine line : in.getMetaDataInInputOrder()) {
    if (line.getKey().equals("reference")) {
      newLines.add(new VCFHeaderLine(line.getKey(), ARGS.refTargetFASTA));
    } else if (line.getKey().equals("source")) {
      newLines.add(new VCFHeaderLine(line.getKey(), line.getValue() + "_and_"
          + GENOME_WARP_VERSION));
      hasSource = true;
    } else if (line.getKey().equals("fileformat")) {
      version = VCFHeaderVersion.toHeaderVersion(line.getValue());
      if (version == null) {
        throw new IllegalArgumentException("malformed version: " + line.getValue());
      }
    } else if (line.getKey().equals(VCFConstants.CONTIG_HEADER_KEY)) {
      continue;
    } else {
      newLines.add(line);
    }
  }

  if (!hasSource) {
    newLines.add(new VCFHeaderLine("source", GENOME_WARP_VERSION));
  }

  // Add contigs
  int i = 0;
  for (Map.Entry<String, Long> entry : namesAndLength.entrySet()) {
    String currName = entry.getKey();
    long chrSize = entry.getValue();

    newLines.add(new VCFContigHeaderLine(VCFHeaderLine.toStringEncoding(
        createContigEntry(currName, chrSize, ARGS.targetAssembly, ARGS.species)),
        version, VCFConstants.CONTIG_HEADER_KEY, i++));
  }

  return new VCFHeader(newLines, in.getSampleNamesInOrder());
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:43,代码来源:GenomeWarpSerial.java

示例13: getVcfCodecForSamples

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
private VCFCodec getVcfCodecForSamples(String... sampleNames) {
    VCFCodec vcfCodec = new VCFCodec();
    vcfCodec.setVCFHeader(new VCFHeader(Collections.emptySet(), Arrays.asList(sampleNames)), VCFHeaderVersion.VCF4_2);
    return vcfCodec;
}
 
开发者ID:exomiser,项目名称:Exomiser,代码行数:6,代码来源:TestVcfParser.java

示例14: FailedVariantFilterTest

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
public FailedVariantFilterTest() {
    vcfCodec = new VCFCodec();
    vcfCodec.setVCFHeader(new VCFHeader(), VCFHeaderVersion.VCF4_2);
}
 
开发者ID:exomiser,项目名称:Exomiser,代码行数:5,代码来源:FailedVariantFilterTest.java

示例15: setHeaderAndVersion

import htsjdk.variant.vcf.VCFHeaderVersion; //导入依赖的package包/类
public void setHeaderAndVersion(VCFHeader header, VCFHeaderVersion ver) {
	this.header = header;
	this.version = ver;
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:5,代码来源:LazyVCFGenotypesContext.java


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