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


Java VCFFileReader.getFileHeader方法代码示例

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


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

示例1: testGetCalls

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
/**
 * Note: HTSJDK cannot distinguish between PASS filters and
 * unfiltered for variant calls (it can for general filters).
 * As a result, all variant calls which PASS do not have filter
 * information applied.
 */
public void testGetCalls() throws Exception {
  File vcfFile =
      new File(VcfToVariant.class.getClassLoader().getResource(VALID_VCF_4_1).getFile());
  VCFFileReader vcfReader = new VCFFileReader(vcfFile, false);
  VCFHeader vcfHeader = vcfReader.getFileHeader();
  int currVariant = 0;

  for (final VariantContext vc : vcfReader) {
    List<VariantCall> callList = VcfToVariant.getCalls(vc, vcfHeader);
    assertEquals(callList, TRUTH.get(currVariant).getCallsList());
    currVariant++;
  }
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:21,代码来源:VcfToVariantTest.java

示例2: genotypeAsNumericInJS

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void genotypeAsNumericInJS() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, IOException{
	VCFFileReader reader = new VCFFileReader(new File("test_data/info_formats.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	GenomicCoords gc= new GenomicCoords("1:17822074-17822184", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	
	gm.setJsScriptFilter("{GT} == '1/0'");
	String x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample1"));
	assertTrue( ! x.contains("sample2") );
	
	gm.setJsScriptFilter("{GT} == './.'");
	x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue( x.contains("sample1"));
	assertTrue( ! x.contains("sample2") );
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:22,代码来源:GenotypeMatrixTest.java

示例3: invalidJSscripts

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void invalidJSscripts() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, IOException{

	VCFFileReader reader = new VCFFileReader(new File("test_data/info_formats.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	GenomicCoords gc= new GenomicCoords("1:17822074-17822184", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	
	// JS script must return boolean
	gm.setJsScriptFilter("{DP} > 5 && 10 + 3");
	gm.printToScreen(true, linf, 80, vcfHeader);
	assertNull(gm.getJsScriptFilter()); // After faulty script reset to null. 

	// Invalid JS syntax. E.g. when {TAG} does not exist.
	gm.setJsScriptFilter("{FOOBAR} > 10");
	gm.printToScreen(true, linf, 80, vcfHeader);
	assertNull(gm.getJsScriptFilter());
	
	// After exception the invalid filter has been removed
	gm.printToScreen(true, linf, 80, vcfHeader);
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:26,代码来源:GenotypeMatrixTest.java

示例4: canFilterGenotypeWithJS

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void canFilterGenotypeWithJS() throws IOException, ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException{

	VCFFileReader reader = new VCFFileReader(new File("test_data/info_formats.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	GenomicCoords gc= new GenomicCoords("1:17822074-17822184", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	
	// Missing alleles
	gm.setJsScriptFilter("{GT} == './.'");
	String x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample1"));
	assertTrue( ! x.contains("sample2"));
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:GenotypeMatrixTest.java

示例5: overalappingSymbols

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void overalappingSymbols() throws IOException, InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
	
	VCFFileReader reader = new VCFFileReader(new File("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	
	// Same genotype: no ambiguity.
	GenomicCoords gc= new GenomicCoords("1:199882-200100", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);
	List<IntervalFeature> linf = vcf.getIntervalFeatureList();
	
	GenotypeMatrix gm= new GenotypeMatrix();
	String x= gm.printToScreen(false, linf, 80, vcfHeader);
	assertTrue(x.contains("O")); // Two genotype at the same position: Both the same
	assertTrue(x.contains("*")); // Different
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:18,代码来源:GenotypeMatrixTest.java

示例6: canFormatVCFLineStructVar

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void canFormatVCFLineStructVar() throws InvalidGenomicCoordsException, InvalidColourException, IOException, InvalidConfigException{
	
	List<Double> rulerMap= new ArrayList<Double>();
	for(int i= 1; i < 100; i++){
		rulerMap.add((double)i);
	}
	
	// Prepare header
	VCFFileReader reader = new VCFFileReader(new File("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz"));
	VCFHeader vcfHeader= reader.getFileHeader();
	reader.close();
	VCFCodec vcfCodec= new VCFCodec();
	vcfCodec.setVCFHeader(vcfHeader, Utils.getVCFHeaderVersion(vcfHeader));

	String vcfLine= "1 668630 DUP_delly_DUP20532 G <CN2> . PASS AC=64;AF=0.0127795;AFR_AF=0.0015;AMR_AF=0;AN=5008;CIEND=-150,150;CIPOS=-150,150;CS=DUP_delly;EAS_AF=0.0595;END=850204;EUR_AF=0.001;IMPRECISE;NS=2504;SAS_AF=0.001;SITEPOST=1;SVTYPE=DUP GT 0|0 0|0 0|0".replaceAll(" ", "\t");
	IntervalFeature ift= new IntervalFeature(vcfLine, TrackFormat.VCF, vcfCodec);
	ift.mapToScreen(rulerMap);
	assertEquals(850204, ift.getTo());
	assertEquals("|", ift.getIdeogram(true, true).get(0).format(true));
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:22,代码来源:IntervalFeatureTest.java

示例7: createTemporaryIndexedVcfFromInput

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
/**
 * This method makes a copy of the input VCF and creates an index file for it in the same location.
 * This is done so that we don't need to store the index file in the same repo
 * The copy of the input is done so that it and its index are in the same directory which is typically required.
 *
 * @param vcfFile the vcf file to index
 * @return File a vcf file (index file is created in same path).
 */
public static File createTemporaryIndexedVcfFromInput(final File vcfFile, final String tempFilePrefix) throws IOException {
    final String extension;

    if (vcfFile.getAbsolutePath().endsWith(".vcf")) extension = ".vcf";
    else if (vcfFile.getAbsolutePath().endsWith(".vcf.gz")) extension = ".vcf.gz";
    else
        throw new IllegalArgumentException("couldn't find a .vcf or .vcf.gz ending for input file " + vcfFile.getAbsolutePath());

    File output = createTemporaryIndexedVcfFile(tempFilePrefix, extension);

    final VCFFileReader in = new VCFFileReader(vcfFile, false);
    final VCFHeader header = in.getFileHeader();

    final VariantContextWriter out = new VariantContextWriterBuilder().
            setReferenceDictionary(header.getSequenceDictionary()).
            setOptions(EnumSet.of(Options.INDEX_ON_THE_FLY)).
            setOutputFile(output).build();
    out.writeHeader(header);
    for (final VariantContext ctx : in) {
        out.add(ctx);
    }
    out.close();
    in.close();
    return output;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:34,代码来源:VcfTestUtils.java

示例8: forEachVariantData

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
public Stream<VariantData> forEachVariantData(final String vcfFile) throws IOException
{
final File file = new File(vcfFile);
IOUtil.assertFileIsReadable(file);
final VCFFileReader r= new VCFFileReader(file, false);
final VCFHeader header = r.getFileHeader();
this.init(header);
final VcfTools vcfTools = new VcfTools(header);
final CloseableIterator<VariantContext> iter = r.iterator();
final Iterable<VariantContext> iterable = () -> iter;
return StreamSupport.stream(iterable.spliterator(),false).onClose(()->{
	CloserUtil.close(iter);
	CloserUtil.close(r);
	}).map(V->new VariantData(V){
		@Override public  VCFHeader getVcfHeader() {
			return header;
			}
		@Override public  VcfTools getVcfTools(){
			return vcfTools;
			}
	});
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:23,代码来源:KnimeVariantHelper.java

示例9: processVariants

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
private static void processVariants(@NotNull final String filePath, @NotNull final String outputVcf, @NotNull final String outputBed,
        boolean strelka) throws IOException, HartwigException {
    final VCFFileReader vcfReader = new VCFFileReader(new File(filePath), false);
    final VCFHeader outputHeader =
            strelka ? generateOutputHeader(vcfReader.getFileHeader(), StrelkaPostProcess.TUMOR_GENOTYPE) : vcfReader.getFileHeader();
    final BufferedWriter bedWriter = new BufferedWriter(new FileWriter(outputBed, false));
    final VariantContextWriter vcfWriter = new VariantContextWriterBuilder().setOutputFile(outputVcf)
            .setReferenceDictionary(outputHeader.getSequenceDictionary())
            .build();
    vcfWriter.writeHeader(outputHeader);

    Pair<PotentialMNVRegion, Optional<PotentialMNVRegion>> outputPair = ImmutablePair.of(PotentialMNVRegion.empty(), Optional.empty());
    for (final VariantContext rawVariant : vcfReader) {
        final VariantContext variant =
                strelka ? StrelkaPostProcess.simplifyVariant(rawVariant, StrelkaPostProcess.TUMOR_GENOTYPE) : rawVariant;

        final PotentialMNVRegion potentialMNVregion = outputPair.getLeft();
        outputPair = MNVDetector.fitsMNVRegion(potentialMNVregion, variant);
        outputPair.getRight()
                .ifPresent(mnvRegion -> filterMnvRegion(mnvRegion).ifPresent(filteredRegion -> writeMnvRegionToFiles(filteredRegion,
                        vcfWriter,
                        bedWriter,
                        "\n")));
    }
    filterMnvRegion(outputPair.getLeft()).ifPresent(mnvRegion -> writeMnvRegionToFiles(mnvRegion, vcfWriter, bedWriter, ""));
    vcfWriter.close();
    vcfReader.close();
    bedWriter.close();
    LOGGER.info("Written output variants to {}. Written bed regions to {}.", outputVcf, outputBed);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:31,代码来源:MNVDetectorApplication.java

示例10: FastVCFFileReader

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
public FastVCFFileReader(String vcfFilename) throws IOException {

		super(vcfFilename);
		// load header
		VCFFileReader reader = new VCFFileReader(new File(vcfFilename), false);
		VCFHeader header = reader.getFileHeader();
		samples = header.getGenotypeSamples();
		samplesCount = samples.size();
		variantContext = new MinimalVariantContext(samplesCount);
		reader.close();

		parser = new VCFLineParser(samplesCount);

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

示例11: convertVcfToVariant

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
public static List<Variant> convertVcfToVariant(File filepath, boolean checkVersion)
    throws IOException {
  // Check version
  if (checkVersion && !validVersion(filepath)) {
    return null;
  }

  VCFFileReader vcfReader = new VCFFileReader(filepath, false);
  VCFHeader header = vcfReader.getFileHeader();

  return convertContextToVariant(vcfReader, header);
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:13,代码来源:VcfToVariant.java

示例12: testGetInfo

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void testGetInfo() throws Exception {
  File vcfFile =
      new File(VcfToVariant.class.getClassLoader().getResource(VALID_VCF_4_1).getFile());
  VCFFileReader vcfReader = new VCFFileReader(vcfFile, false);
  VCFHeader vcfHeader = vcfReader.getFileHeader();
  int currVariant = 0;

  for (final VariantContext vc : vcfReader) {
    Map<String, ListValue> info = VcfToVariant.getInfo(vc, vcfHeader);
    assertEquals(info, TRUTH.get(currVariant).getInfo());
    currVariant++;
  }
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:15,代码来源:VcfToVariantTest.java

示例13: bigData

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void bigData()throws InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {

	VCFFileReader reader = new VCFFileReader(new File("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	GenomicCoords gc= new GenomicCoords("1:5934301-6000000", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);

	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	gm.setJsScriptFilter("{GT} == 10 || 1>2");
	gm.printToScreen(true, linf, 80, vcfHeader);
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:16,代码来源:GenotypeMatrixTest.java

示例14: genotypeKetwordInJS

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void genotypeKetwordInJS() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, IOException{

	VCFFileReader reader = new VCFFileReader(new File("test_data/info_formats.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	GenomicCoords gc= new GenomicCoords("1:17822074-17822184", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/info_formats.vcf.gz", gc);
	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	
	gm.setJsScriptFilter("{HOM}");
	String x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample2"));
	assertTrue( ! x.contains("sample1") );
	
	gm.setJsScriptFilter("{NO_CALL}");
	x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample1"));
	assertTrue( ! x.contains("sample2") );
	
	gm.setJsScriptFilter("{HET_NON_REF}");
	x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample2"));
	assertTrue( ! x.contains("sample1") );
	
	gm.setJsScriptFilter("{CALLED} && {POS} == 17822094");
	x= gm.printToScreen(true, linf, 80, vcfHeader);
	assertTrue(x.contains("sample2"));
	assertTrue( ! x.contains("sample1") );
	
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:34,代码来源:GenotypeMatrixTest.java

示例15: canInitMatrix

import htsjdk.variant.vcf.VCFFileReader; //导入方法依赖的package包/类
@Test
public void canInitMatrix() throws IOException, InvalidGenomicCoordsException, IOException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidColourException {
	
	VCFFileReader reader = new VCFFileReader(new File("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz"));
	VCFHeader vcfHeader = reader.getFileHeader();
	reader.close();
	
	GenomicCoords gc= new GenomicCoords("1:572807-755079", 80, null, null);
	TrackIntervalFeature vcf= new TrackIntervalFeature("test_data/ALL.wgs.mergedSV.v8.20130502.svs.genotypes.vcf.gz", gc);

	List<IntervalFeature> linf = vcf.getIntervalFeatureList();

	GenotypeMatrix gm= new GenotypeMatrix();
	
	// No feature at all
	assertTrue(gm.printToScreen(true, new ArrayList<IntervalFeature>(), 80, vcfHeader).isEmpty());
	
	String x= gm.printToScreen(true, linf, 80, vcfHeader);
	
	// Check sample name
	assertTrue(x.startsWith("HG00096"));
	
	String[] rows = x.split("\n");
	assertEquals(3, rows.length);
	assertEquals(80, rows[0].length());
	
	// Check genotype coding
	assertTrue(rows[0].contains("?")); // Missing genotype
	assertTrue(rows[0].contains(".")); // HOM ref
	assertTrue(rows[1].contains("E")); // HET
	assertTrue(rows[2].contains("0")); // HOM alt
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:33,代码来源:GenotypeMatrixTest.java


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