本文整理汇总了Java中htsjdk.variant.vcf.VCFHeaderLine类的典型用法代码示例。如果您正苦于以下问题:Java VCFHeaderLine类的具体用法?Java VCFHeaderLine怎么用?Java VCFHeaderLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VCFHeaderLine类属于htsjdk.variant.vcf包,在下文中一共展示了VCFHeaderLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
@Override
public void initialize(final AnnotatorCompatible walker, final GenomeLocParser parser, final Set<VCFHeaderLine> headerLines) {
boolean hasSBBSannotation = false;
for (final VCFHeaderLine line : headerLines) {
if (line instanceof VCFFormatHeaderLine) {
final VCFFormatHeaderLine formatline = (VCFFormatHeaderLine) line;
if (formatline.getID().equals(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME)) {
hasSBBSannotation = true;
break;
}
}
}
if (hasSBBSannotation) {
logger.info("StrandBiasBySample annotation exists in input VCF header. Attempting to use StrandBiasBySample " +
"values to calculate strand bias annotation values. If no sample has the SB genotype annotation, annotation may still fail.");
return;
}
}
示例2: onTraversalStart
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
@Override
public void onTraversalStart() {
final VCFHeader inputHeader = getHeaderForVariants();
final Set<VCFHeaderLine> headerLines = new HashSet<>(inputHeader.getMetaDataInSortedOrder());
headerLines.add(new VCFInfoHeaderLine(EXPECTED_ALLELE_FRACTION_NAME, 1, VCFHeaderLineType.Float, "expected allele fraction in pooled bam"));
final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
headerLines.addAll(getDefaultToolVCFHeaderLines());
vcfWriter = createVCFWriter(outputVcf);
vcfWriter.writeHeader(vcfHeader);
final List<MixingFraction> mixingFractionsList = MixingFraction.readMixingFractions(inputMixingFractions);
final Map<String, Double> mixingfractionsMap = mixingFractionsList.stream()
.collect(Collectors.toMap(MixingFraction::getSample, MixingFraction::getMixingFraction));
mixingFractionsInSampleOrder = inputHeader.getSampleNamesInOrder().stream()
.mapToDouble(mixingfractionsMap::get).toArray();
}
示例3: onTraversalStart
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
@Override
public void onTraversalStart() {
final VCFHeader inputHeader = getHeaderForVariants();
final Set<VCFHeaderLine> headerLines = new HashSet<>(inputHeader.getMetaDataInSortedOrder());
Mutect2FilteringEngine.M_2_FILTER_NAMES.stream().map(GATKVCFHeaderLines::getFilterLine).forEach(headerLines::add);
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.ARTIFACT_IN_NORMAL_FILTER_NAME, "artifact_in_normal"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_BASE_QUALITY_DIFFERENCE_FILTER_NAME, "ref - alt median base quality"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_MAPPING_QUALITY_DIFFERENCE_FILTER_NAME, "ref - alt median mapping quality"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_CLIPPING_DIFFERENCE_FILTER_NAME, "ref - alt median clipping"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.MEDIAN_FRAGMENT_LENGTH_DIFFERENCE_FILTER_NAME, "abs(ref - alt) median fragment length"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.READ_POSITION_FILTER_NAME, "median distance of alt variants from end of reads"));
headerLines.add(new VCFFilterHeaderLine(Mutect2FilteringEngine.CONTAMINATION_FILTER_NAME, "contamination"));
headerLines.addAll(getDefaultToolVCFHeaderLines());
final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
vcfWriter = createVCFWriter(new File(outputVcf));
vcfWriter.writeHeader(vcfHeader);
}
示例4: configureHeaders
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
public static void configureHeaders(Configuration conf, Path[] vcfs, String sampleGroup)
throws IOException {
List<VCFHeader> headers = new ArrayList<>();
for (Path vcf : vcfs) {
InputStream inputStream = vcf.getFileSystem(conf).open(vcf);
VcfBlockIterator iterator = new VcfBlockIterator(inputStream, new FullVcfCodec());
VCFHeader header = iterator.getHeader();
header.addMetaDataLine(new VCFHeaderLine(VARIANT_SET_ID, vcf.getName()));
headers.add(header);
}
VCFHeader[] headersArray = headers.toArray(new VCFHeader[headers.size()]);
conf.set(VARIANT_HEADERS,
Base64.encodeBase64String(SerializationUtils.serialize(headersArray)));
if (sampleGroup != null) {
conf.set(SAMPLE_GROUP, sampleGroup);
}
}
示例5: createVCFHeaderLineList
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
/**
* Prepare the VCF header lines
*/
private Set<VCFHeaderLine> createVCFHeaderLineList(Map<String, VCFHeader> vcfHeaders) {
final Set<VCFHeaderLine> headerLines = VCFUtils.smartMergeHeaders(vcfHeaders.values(), true);
headerLines.addAll(getDefaultToolVCFHeaderLines());
// need AC, AN and AF since output if set filtered genotypes to no-call
if (setFilteredGenotypesToNocall) {
GATKVariantContextUtils.addChromosomeCountsToHeader(headerLines);
}
if (keepOriginalChrCounts) {
headerLines.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.ORIGINAL_AC_KEY));
headerLines.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.ORIGINAL_AF_KEY));
headerLines.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.ORIGINAL_AN_KEY));
}
if (keepOriginalDepth) {
headerLines.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.ORIGINAL_DP_KEY));
}
headerLines.addAll(Arrays.asList(ChromosomeCounts.descriptions));
headerLines.add(VCFStandardHeaderLines.getInfoLine(VCFConstants.DEPTH_KEY));
return headerLines;
}
示例6: getVCFWriter
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
private VariantContextWriter getVCFWriter() {
final SortedSet<String> samples = getSamplesForVariants();
final VCFHeader inputVCFHeader = new VCFHeader(getHeaderForVariants().getMetaDataInInputOrder(), samples);
final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputVCFHeader.getMetaDataInInputOrder());
headerLines.addAll(getDefaultToolVCFHeaderLines());
headerLines.addAll(annotationEngine.getVCFAnnotationDescriptions());
// add headers for annotations added by this tool
headerLines.add(VCFStandardHeaderLines.getInfoLine(VCFConstants.DEPTH_KEY)); // needed for gVCFs without DP tags
if ( dbsnp.dbsnp != null ) {
VCFStandardHeaderLines.addStandardInfoLines(headerLines, true, VCFConstants.DBSNP_KEY);
}
VariantContextWriter writer = createVCFWriter(outputFile);
final Set<String> sampleNameSet = new IndexedSampleList(samples).asSetOfSamples();
final VCFHeader vcfHeader = new VCFHeader(headerLines, new TreeSet<>(sampleNameSet));
writer.writeHeader(vcfHeader);
return writer;
}
示例7: onTraversalStart
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
@Override
public void onTraversalStart() {
final VCFHeader inputHeader = getHeaderForVariants();
final Set<VCFHeaderLine> headerLines = inputHeader.getMetaDataInSortedOrder().stream()
.filter(line -> !line.getKey().equals(Mutect2FilteringEngine.FILTERING_STATUS_VCF_KEY)) //remove header line from Mutect2 stating that calls are unfiltered.
.collect(Collectors.toSet());
headerLines.add(new VCFHeaderLine(Mutect2FilteringEngine.FILTERING_STATUS_VCF_KEY, "These calls have been filtered by " + FilterMutectCalls.class.getSimpleName() + " to label false positives with a list of failed filters and true positives with PASS."));
GATKVCFConstants.MUTECT_FILTER_NAMES.stream().map(GATKVCFHeaderLines::getFilterLine).forEach(headerLines::add);
headerLines.addAll(getDefaultToolVCFHeaderLines());
final VCFHeader vcfHeader = new VCFHeader(headerLines, inputHeader.getGenotypeSamples());
vcfWriter = createVCFWriter(new File(outputVcf));
vcfWriter.writeHeader(vcfHeader);
final String tumorSample = getHeaderForVariants().getMetaDataLine(Mutect2Engine.TUMOR_SAMPLE_KEY_IN_VCF_HEADER).getValue();
filteringEngine = new Mutect2FilteringEngine(MTFAC, tumorSample);
}
示例8: testGetDefaultToolVCFHeaderLines
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
@Test
public void testGetDefaultToolVCFHeaderLines() throws IOException {
final TestGATKToolWithFeatures tool = new TestGATKToolWithFeatures();
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/feature_data_source_test_with_bigHeader.vcf");
final String[] args = {"--mask", vcfFile.getCanonicalPath(), "--" + StandardArgumentDefinitions.ADD_OUTPUT_VCF_COMMANDLINE, "true"};
tool.instanceMain(args);
Set<VCFHeaderLine> stdHeaderLines = tool.getDefaultToolVCFHeaderLines();
VCFHeader hdr = new VCFHeader(stdHeaderLines);
VCFHeaderLine sourceLine = hdr.getOtherHeaderLine("source");
Assert.assertEquals(sourceLine.getValue(), tool.getClass().getSimpleName());
VCFIDHeaderLine commandLine = (VCFIDHeaderLine) hdr.getOtherHeaderLine("GATKCommandLine");
Assert.assertEquals(commandLine.getID(), tool.getClass().getSimpleName());
String commandLineString = commandLine.toString();
assertContains(commandLineString,"CommandLine=");
assertContains(commandLineString,"Version=");
assertContains(commandLineString,"Date=");
}
示例9: getMinimalVCFHeader
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
private static VCFHeader getMinimalVCFHeader() {
final Set<VCFHeaderLine> headerlines = new LinkedHashSet<>();
VCFStandardHeaderLines.addStandardFormatLines(headerlines, true,
VCFConstants.GENOTYPE_KEY, VCFConstants.DEPTH_KEY,
VCFConstants.GENOTYPE_QUALITY_KEY, VCFConstants.GENOTYPE_PL_KEY,
VCFConstants.GENOTYPE_ALLELE_DEPTHS);
VCFStandardHeaderLines.addStandardInfoLines(headerlines, true,
VCFConstants.DEPTH_KEY,
VCFConstants.RMS_MAPPING_QUALITY_KEY,
VCFConstants.MAPPING_QUALITY_ZERO_KEY );
Arrays.asList(GATKVCFConstants.BASE_QUAL_RANK_SUM_KEY,
GATKVCFConstants.CLIPPING_RANK_SUM_KEY,
GATKVCFConstants.MLE_ALLELE_COUNT_KEY,
GATKVCFConstants.MLE_ALLELE_FREQUENCY_KEY,
GATKVCFConstants.MAP_QUAL_RANK_SUM_KEY,
GATKVCFConstants.READ_POS_RANK_SUM_KEY)
.forEach( c -> headerlines.add(GATKVCFHeaderLines.getInfoLine(c)));
headerlines.add(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY));
return new VCFHeader(headerlines, Collections.singleton(SAMPLE_NAME));
}
示例10: openVariantContextWriter
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
/**
* Return a new {@link VariantContextWriter} that uses the header from <code>reader</code> but has the header
* extended header through {@link #extendHeaderFields}.
*
* @param header
* the VCF header to use for the construction
* @param fileName
* path to output file
* @param additionalHeaderLines
* additional {@link VCFHeaderLine}s to add
* @param generateIndex
* whether or not to generate an index
* @return A correct writer for variantContexts
*/
public static VariantContextWriter openVariantContextWriter(VCFHeader header, String fileName,
Collection<VCFHeaderLine> additionalHeaderLines, boolean generateIndex) {
VariantContextWriterBuilder builder = makeBuilder(header);
builder.setOutputFile(new File(fileName));
if (!generateIndex)
builder.unsetOption(Options.INDEX_ON_THE_FLY);
// construct VariantContextWriter and write out header
VariantContextWriter out = builder.build();
final VCFHeader updatedHeader = extendHeaderFields(new VCFHeader(header));
for (VCFHeaderLine headerLine : additionalHeaderLines)
updatedHeader.addMetaDataLine(headerLine);
out.writeHeader(updatedHeader);
return out;
}
示例11: open
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
public void open(final VCFHeader src)
{
final File fileout=getFile();
LOG.info("opening VCF file \""+fileout+"\" for writing");
final File parent=fileout.getParentFile();
if(parent!=null) {
parent.mkdirs();
}
this.header= new VCFHeader(src);
this.header.addMetaDataLine(new VCFHeaderLine("ForkVcf.GroupId", String.valueOf(this.groupId)));
try {
this._writer = VCFUtils.createVariantContextWriter(fileout);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
this._writer.writeHeader(this.header);
}
示例12: open
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
public void open(final VCFHeader src)
{
final File fileout=getFile();
LOG.info("opening VCF file \""+fileout+"\" for writing");
final File parent=fileout.getParentFile();
if(parent!=null) {
parent.mkdirs();
}
this.header= new VCFHeader(src);
this.header.addMetaDataLine(new VCFHeaderLine("SplitVcf.GroupName", this.groupName));
try {
this._writer = VCFUtils.createVariantContextWriter(fileout);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
this._writer.writeHeader(this.header);
}
示例13: extractSampleNames
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
/** general utility for program using VCFMulti2One:
* Extract SampleNames
*/
static Set<String> extractSampleNames(final VCFHeader header)
{
final List<String> sample_list =header.getSampleNamesInOrder();
if(sample_list.size()!=1 || !sample_list.get(0).equals(DEFAULT_VCF_SAMPLE_NAME))
{
throw new IllegalArgumentException("Not a VCF produced by VcfMultiToOne");
}
final Set<String> samples = new TreeSet<String>();
for(final VCFHeaderLine h:header.getMetaDataInInputOrder())
{
if(h.getKey().equals(SAMPLE_HEADER_DECLARATION))
{
sample_list.add(h.getValue());
}
}
return samples;
}
示例14: toVCFHeaderLines
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
public Set<VCFHeaderLine> toVCFHeaderLines() {
final Set<VCFHeaderLine> set = new LinkedHashSet<>();
for(final Family f:families.values())
{
for(final Person p:f.getIndividuals()) {
final StringBuilder sb=new StringBuilder();
sb.append("<Family=");
sb.append(f.getId());
sb.append(",ID=");
sb.append(p.getId());
sb.append(",Father=");
sb.append(p.getFather()==null?"0":p.getFather().getId());
sb.append(",Mother=");
sb.append(p.getMother()==null?"0":p.getMother().getId());
sb.append(",Sex=");
sb.append(p.getSex().intValue());
sb.append(",Status=");
sb.append(p.getStatus().intValue());
sb.append(">");
set.add(new VCFHeaderLine(VcfHeaderKey, sb.toString()));
}
}
return set;
}
示例15: getVCFHeaderLines
import htsjdk.variant.vcf.VCFHeaderLine; //导入依赖的package包/类
/**
* Get the VCF header lines to include when emitting reference confidence values via calculateRefConfidence
* @return a non-null set of VCFHeaderLines
*/
public Set<VCFHeaderLine> getVCFHeaderLines() {
final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>();
// TODO - do we need a new kind of VCF Header subclass for specifying arbitrary alternate alleles?
headerLines.add(new VCFSimpleHeaderLine(ALTERNATE_ALLELE_STRING, GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE_NAME, "Represents any possible alternative allele at this location"));
//headerLines.add(new VCFFormatHeaderLine(INDEL_INFORMATIVE_DEPTH, 1, VCFHeaderLineType.Integer, "Number of reads at locus that are informative about an indel of size <= " + indelInformativeDepthIndelSize));
return headerLines;
}