本文整理汇总了Java中htsjdk.variant.vcf.VCFConstants类的典型用法代码示例。如果您正苦于以下问题:Java VCFConstants类的具体用法?Java VCFConstants怎么用?Java VCFConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VCFConstants类属于htsjdk.variant.vcf包,在下文中一共展示了VCFConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseFilters
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
protected List<String> parseFilters(final String filterString) {
// null for unfiltered
if (filterString.equals(VCFConstants.UNFILTERED))
return null;
if (filterString.equals(VCFConstants.PASSES_FILTERS_v4))
return Collections.emptyList();
// do we have the filter string cached?
if (filterHash.containsKey(filterString))
return filterHash.get(filterString);
// empty set for passes filters
final List<String> fFields = new LinkedList<String>();
// otherwise we have to parse and cache the value
if (!filterString.contains(VCFConstants.FILTER_CODE_SEPARATOR))
fFields.add(filterString);
else
fFields.addAll(Arrays.asList(filterString.split(VCFConstants.FILTER_CODE_SEPARATOR)));
filterHash.put(filterString, Collections.unmodifiableList(fFields));
return fFields;
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:25,代码来源:VcfRecord2VCTransfer.java
示例2: formatVCFField
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
String formatVCFField(final Object val) {
final String result;
if (val == null)
result = VCFConstants.MISSING_VALUE_v4;
else if (val instanceof Double)
result = formatVCFDouble((Double) val);
else if (val instanceof Boolean)
result = (Boolean) val ? "" : null; // empty string for true, null for false
else if (val instanceof List) {
result = formatVCFField(((List) val).toArray());
} else if (val.getClass().isArray()) {
final int length = Array.getLength(val);
if (length == 0)
return formatVCFField(null);
final StringBuilder sb = new StringBuilder(formatVCFField(Array.get(val, 0)));
for (int i = 1; i < length; i++) {
sb.append(",");
sb.append(formatVCFField(Array.get(val, i)));
}
result = sb.toString();
} else
result = val.toString();
return result;
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:26,代码来源:VC2VcfRecordTransfer.java
示例3: writeInfoString
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private void writeInfoString(final Map<String, String> infoFields, final StringBuilder builder) {
if (infoFields.isEmpty()) {
builder.append(VCFConstants.EMPTY_INFO_FIELD);
return;
}
boolean isFirst = true;
for (final Map.Entry<String, String> entry : infoFields.entrySet()) {
if (isFirst) isFirst = false;
else builder.append(VCFConstants.INFO_FIELD_SEPARATOR);
builder.append(entry.getKey());
if (!entry.getValue().equals("")) {
final VCFInfoHeaderLine metaData = this.header.getInfoHeaderLine(entry.getKey());
if (metaData == null || metaData.getCountType() != VCFHeaderLineCount.INTEGER || metaData.getCount() != 0) {
builder.append("=");
builder.append(entry.getValue());
}
}
}
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:23,代码来源:VC2VcfRecordTransfer.java
示例4: blockToVCF
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/**
* Convert a HomRefBlock into a VariantContext
*
* @param block the block to convert
* @return a VariantContext representing the gVCF encoding for this block.
* It will return {@code null} if input {@code block} is {@code null}, indicating that there
* is no variant-context to be output into the VCF.
*/
private VariantContext blockToVCF(final HomRefBlock block) {
if ( block == null ) return null;
final VariantContextBuilder vcb = new VariantContextBuilder(block.getStartingVC());
vcb.attributes(new HashMap<String, Object>(2)); // clear the attributes
vcb.stop(block.getStop());
vcb.attribute(VCFConstants.END_KEY, block.getStop());
// create the single Genotype with GQ and DP annotations
final GenotypeBuilder gb = new GenotypeBuilder(sampleName, GATKVariantContextUtils.homozygousAlleleList(block.getRef(),block.getPloidy()));
gb.noAD().noPL().noAttributes(); // clear all attributes
gb.GQ(block.getMedianGQ());
gb.DP(block.getMedianDP());
gb.attribute(MIN_DP_FORMAT_FIELD, block.getMinDP());
gb.PL(block.getMinPLs());
// This annotation is no longer standard
//gb.attribute(MIN_GQ_FORMAT_FIELD, block.getMinGQ());
return vcb.genotypes(gb.make()).make();
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:30,代码来源:GVCFWriter.java
示例5: annotateRsID
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/**
* Update rsID of vcToAnnotate with rsID match found in vcsAtLoc, if one exists
*
* @param vcsAtLoc a list of variant contexts starting at this location to use as sources for rsID values
* @param vcToAnnotate a variant context to annotate
* @return a VariantContext (may be == to vcToAnnotate) with updated rsID value
*/
public VariantContext annotateRsID(final List<VariantContext> vcsAtLoc, final VariantContext vcToAnnotate ) {
final String rsID = getRsID(vcsAtLoc, vcToAnnotate);
// add the ID if appropriate
if ( rsID != null ) {
final VariantContextBuilder vcb = new VariantContextBuilder(vcToAnnotate);
if ( ! vcToAnnotate.hasID() ) {
return vcb.id(rsID).make();
} else if ( ! vcToAnnotate.getID().contains(rsID) ) {
return vcb.id(vcToAnnotate.getID() + VCFConstants.ID_FIELD_SEPARATOR + rsID).make();
} // falling through to return VC lower down
}
// nothing to do, just return vc
return vcToAnnotate;
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:25,代码来源:VariantOverlapAnnotator.java
示例6: generateFilterString
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
protected String generateFilterString(final double lod) {
String filterString = null;
if (TS_FILTER_LEVEL != null) {
for (int i = tranches.size() - 1; i >= 0; i--) {
final TruthSensitivityTranche tranche = tranches.get(i);
if (lod >= tranche.minVQSLod) {
if (i == tranches.size() - 1) {
filterString = VCFConstants.PASSES_FILTERS_v4;
} else {
filterString = tranche.name;
}
break;
}
}
if (filterString == null) {
filterString = tranches.get(0).name + "+";
}
} else {
filterString = (lod < VQSLOD_CUTOFF ? LOW_VQSLOD_FILTER_NAME : VCFConstants.PASSES_FILTERS_v4);
}
return filterString;
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:25,代码来源:ApplyVQSR.java
示例7: writeOutRecalibrationTable
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
public void writeOutRecalibrationTable(final VariantContextWriter recalWriter,
final SAMSequenceDictionary seqDictionary) {
// we need to sort in coordinate order in order to produce a valid VCF
Collections.sort(data, VariantDatum.getComparator(seqDictionary));
// create dummy alleles to be used
List<Allele> alleles = Arrays.asList(Allele.create("N", true), Allele.create("<VQSR>", false));
for (final VariantDatum datum : data) {
if (VRAC.useASannotations)
alleles = Arrays.asList(datum.referenceAllele, datum.alternateAllele);
VariantContextBuilder builder = new VariantContextBuilder("VQSR", datum.loc.getContig(),
datum.loc.getStart(), datum.loc.getStop(), alleles);
builder.attribute(VCFConstants.END_KEY, datum.loc.getStop());
builder.attribute(GaeaVCFConstants.VQS_LOD_KEY, String.format("%.4f", datum.lod));
builder.attribute(GaeaVCFConstants.CULPRIT_KEY,
(datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"));
if (datum.atTrainingSite)
builder.attribute(GaeaVCFConstants.POSITIVE_LABEL_KEY, true);
if (datum.atAntiTrainingSite)
builder.attribute(GaeaVCFConstants.NEGATIVE_LABEL_KEY, true);
recalWriter.add(builder.make());
}
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:27,代码来源:VariantDataManager.java
示例8: getNumOfReads
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
public int getNumOfReads(final VariantContext vc) {
// don't use the full depth because we don't calculate MQ for reference
// blocks
int numOfReads = 0;
if (vc.hasAttribute(VCFConstants.DEPTH_KEY)) {
numOfReads += Integer.parseInt(vc.getAttributeAsString(VCFConstants.DEPTH_KEY, "-1"));
if (vc.hasGenotypes()) {
for (Genotype gt : vc.getGenotypes()) {
if (gt.isHomRef()) {
// site-level DP contribution will come from MIN_DP for
// gVCF-called reference variants or DP for BP
// resolution
if (gt.hasExtendedAttribute("MIN_DP"))
numOfReads -= Integer.parseInt(gt.getExtendedAttribute("MIN_DP").toString());
else if (gt.hasDP())
numOfReads -= gt.getDP();
}
}
}
return numOfReads;
}
return -1;
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:25,代码来源:RMSAnnotation.java
示例9: getVAttributeValues
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/**
* Pulls out the appropriate values for the INFO field attribute
*
* @param attribute
* INFO field attribute
* @return tokenized attribute values
*/
private static Object[] getVAttributeValues(final Object attribute) {
if (attribute == null)
throw new IllegalArgumentException("the attribute cannot be null");
// break the original attributes into separate tokens
final Object[] tokens;
if (attribute.getClass().isArray())
tokens = (Object[]) attribute;
else if (List.class.isAssignableFrom(attribute.getClass()))
tokens = ((List) attribute).toArray();
else
tokens = attribute.toString().split(VCFConstants.INFO_FIELD_ARRAY_SEPARATOR);
return tokens;
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:24,代码来源:GaeaGvcfVariantContextUtils.java
示例10: updateChromosomeCountsInfo
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/**
* Update the variant context chromosome counts info fields (AC, AN, AF)
*
* @param calledAltAlleles
* number of called alternate alleles for all genotypes
* @param calledAlleles
* number of called alleles for all genotypes
* @param builder
* builder for variant context
* @throws IllegalArgumentException
* if calledAltAlleles or builder are null
*/
public static void updateChromosomeCountsInfo(final Map<Allele, Integer> calledAltAlleles, final int calledAlleles,
final VariantContextBuilder builder) {
if (calledAltAlleles == null)
throw new IllegalArgumentException("Called alternate alleles can not be null");
if (builder == null)
throw new IllegalArgumentException("Variant context builder can not be null");
builder.attribute(VCFConstants.ALLELE_COUNT_KEY, calledAltAlleles.values().toArray())
.attribute(VCFConstants.ALLELE_NUMBER_KEY, calledAlleles);
// Add AF is there are called alleles
if (calledAlleles != 0) {
final Set<Double> alleleFrequency = new LinkedHashSet<Double>(calledAltAlleles.size());
for (final Integer value : calledAltAlleles.values()) {
alleleFrequency.add(value.doubleValue() / calledAlleles);
}
builder.attribute(VCFConstants.ALLELE_FREQUENCY_KEY, alleleFrequency.toArray());
}
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:31,代码来源:GaeaGvcfVariantContextUtils.java
示例11: decodeLine
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private VariantContext decodeLine(final String line, final boolean includeGenotypes) {
// the same line reader is not used for parsing the header and parsing lines, if we see a #, we've seen a header line
if (line.startsWith(VCFHeader.HEADER_INDICATOR)) return null;
// our header cannot be null, we need the genotype sample names and counts
if (header == null) throw new TribbleException("VCF Header cannot be null when decoding a record");
if (parts == null)
parts = new String[Math.min(header.getColumnCount(), NUM_STANDARD_FIELDS+1)];
final int nParts = ParsingUtils.split(line, parts, VCFConstants.FIELD_SEPARATOR_CHAR, true);
// if we have don't have a header, or we have a header with no genotyping data check that we
// have eight columns. Otherwise check that we have nine (normal columns + genotyping data)
if (( (header == null || !header.hasGenotypingData()) && nParts != NUM_STANDARD_FIELDS) ||
(header != null && header.hasGenotypingData() && nParts != (NUM_STANDARD_FIELDS + 1)) )
throw new TribbleException("Line " + lineNo + ": there aren't enough columns for line " + line + " (we expected " + (header == null ? NUM_STANDARD_FIELDS : NUM_STANDARD_FIELDS + 1) +
" tokens, and saw " + nParts + " )");
return parseVCFLine(parts, includeGenotypes);
}
开发者ID:rkataine,项目名称:BasePlayer,代码行数:22,代码来源:OwnVCFCodec.java
示例12: parseInlineGenotypeFields
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private static boolean parseInlineGenotypeFields(String field, VariantCall.Builder vcBuilder,
ListValue.Builder lvBuilder, IntGenotypeFieldAccessors.Accessor accessor, Genotype g) {
final int[] intValues = accessor.getValues(g);
if (intValues == null || intValues.length == 0) {
return false;
}
if (field.equals(VCFConstants.GENOTYPE_PL_KEY)) {
// HTSJDK folds GL's into PL's. We only use PL's to store genotype likelihood.
for (int i = 0; i < intValues.length; i++) {
// We add 0.0 to remove the possiblity of getting -0.0.
vcBuilder.addGenotypeLikelihood(-(double) intValues[i] / 10.0 + 0.0);
}
return false;
}
for (int i = 0; i < intValues.length; i++) {
lvBuilder.addValues(Value.newBuilder().setNumberValue(intValues[i]));
}
return true;
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:23,代码来源:VcfToVariant.java
示例13: calculateAFs
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private void calculateAFs(final Iterable<Genotype> genotypes) {
final int[] truthAC = new int[CopyNumberTriStateAllele.ALL_ALLELES.size()];
final int[] callsAC = new int[CopyNumberTriStateAllele.ALL_ALLELES.size()];
for (final Genotype genotype : genotypes) {
final List<Allele> alleles = genotype.getAlleles();
if (alleles.size() > 1) {
throw new GATKException("unexpected CNV genotype ploidy: " + alleles.size());
} else if (!alleles.isEmpty() && alleles.get(0).isCalled()) {
final int index = CopyNumberTriStateAllele.valueOf(alleles.get(0)).index();
callsAC[index]++;
}
final String truthGT = String.valueOf(genotype.getExtendedAttribute(VariantEvaluationContext.TRUTH_GENOTYPE_KEY, VCFConstants.MISSING_VALUE_v4));
final int truthAlleleIndex = truthGT.equals(VCFConstants.MISSING_VALUE_v4) ? -1 : Integer.parseInt(truthGT);
if (truthAlleleIndex >= 0) {
final List<Allele> contextAlleles = getAlleles();
if (truthAlleleIndex >= contextAlleles.size()) {
throw new GATKException("unexpected CNV truth genotype makes reference to a non-existent allele: " + truthGT);
}
truthAC[CopyNumberTriStateAllele.valueOf(contextAlleles.get(truthAlleleIndex)).index()]++;
}
genotype.getAllele(0);
}
this.truthAC = truthAC;
this.callsAC = callsAC;
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:26,代码来源:VariantEvaluationContextBuilder.java
示例14: addFilterToGenotype
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/** Create an updated genotype string when trying to add a filter value.
*
* @param existingFilterValue filter string (presumably) from a genotype
* @param newFilterToAdd new filter string to append. Cannot be {@code null}.
* @return Properly formatted genotype filter string
*/
public static String addFilterToGenotype(final String existingFilterValue, final String newFilterToAdd) {
Utils.nonNull(newFilterToAdd);
if ((existingFilterValue == null) || (existingFilterValue.trim().length() == 0)
|| (existingFilterValue.equals(VCFConstants.UNFILTERED))
|| (existingFilterValue.equals(VCFConstants.PASSES_FILTERS_v4))) {
return newFilterToAdd;
} else if (existingFilterValue.length() > 0) {
return existingFilterValue + VCFConstants.FILTER_CODE_SEPARATOR + newFilterToAdd;
} else {
final String appendedFilterString = existingFilterValue + VCFConstants.FILTER_CODE_SEPARATOR + newFilterToAdd;
logger.warn("Existing genotype filter could be incorrect: " + existingFilterValue + " ... Proceeding with " + appendedFilterString + " ...");
return appendedFilterString;
}
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:23,代码来源:OrientationBiasUtils.java
示例15: mergeAttributes
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private static Map<String, Object> mergeAttributes(int depth, Map<String, List<Comparable>> annotationMap) {
final Map<String, Object> attributes = new LinkedHashMap<>();
// when combining annotations use the median value from all input vcs which had annotations provided
annotationMap.entrySet().stream()
.filter(p -> !p.getValue().isEmpty())
.forEachOrdered(p -> attributes.put(p.getKey(), combineAnnotationValues(p.getValue()))
);
if ( depth > 0 ) {
attributes.put(VCFConstants.DEPTH_KEY, String.valueOf(depth));
}
// remove stale AC and AF based attributes
removeStaleAttributesAfterMerge(attributes);
return attributes;
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:18,代码来源:ReferenceConfidenceVariantContextMerger.java
示例16: testAnnotateVariantContextWithPreprocessingValues
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
@Test
public void testAnnotateVariantContextWithPreprocessingValues() {
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2Vcf));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
preAdapterQFakeScoreMap.put(Transition.transitionOf('G', 'T'), amGTPreAdapterQ); // preAdapterQ suppression will do nothing.
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
final Genotype genotypeTumor = updatedVariantContext.getGenotype("TUMOR");
final Genotype genotypeNormal = updatedVariantContext.getGenotype("NORMAL");
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.FOB, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
assertArtifact(amGTPreAdapterQ, genotypeTumor, Transition.transitionOf('G', 'T'));
// The NORMAL is always ref/ref in the example file.
assertNormal(genotypeNormal);
}
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:26,代码来源:OrientationBiasFiltererUnitTest.java
示例17: testCalculatePosteriorSamplePlusExternal
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
@Test
public void testCalculatePosteriorSamplePlusExternal() {
final VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0),
makeG("s2",Aref,T,18,0,24),
makeG("s3",Aref,T,22,0,12));
final List<VariantContext> supplTest1 = new ArrayList<>(3);
supplTest1.add(new VariantContextBuilder(makeVC("2", Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,2).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make());
supplTest1.add(new VariantContextBuilder(makeVC("3", Arrays.asList(Aref,T))).attribute(VCFConstants.ALLELE_COUNT_KEY,4).attribute(VCFConstants.ALLELE_NUMBER_KEY,22).make());
supplTest1.add(makeVC("4", Arrays.asList(Aref,T),
makeG("s_1",T,T),
makeG("s_2",Aref,T)));
final VariantContext test1result = PosteriorProbabilitiesUtils.calculatePosteriorProbs(testOverlappingBase,supplTest1,0,0.001,true,false, false);
// the counts here are ref=30, alt=14
final Genotype test1exp1 = makeGwithPLs("t1",T,T,new double[]{-3.370985, -1.415172, -0.01721766});
final Genotype test1exp2 = makeGwithPLs("t2",Aref,T,new double[]{-1.763792, -0.007978791, -3.010024});
final Genotype test1exp3 = makeGwithPLs("t3",Aref,T,new double[]{-2.165587, -0.009773643, -1.811819});
Assert.assertEquals(arraysEq(test1exp1.getPL(),_mleparse((List<Integer>) test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY))), "");
Assert.assertEquals(arraysEq(test1exp2.getPL(),_mleparse((List<Integer>) test1result.getGenotype(1).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY))), "");
Assert.assertEquals(arraysEq(test1exp3.getPL(),_mleparse((List<Integer>) test1result.getGenotype(2).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY))), "");
final VariantContext testNonOverlapping = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,3,1,0));
final List<VariantContext> other = Arrays.asList(makeVC("2", Arrays.asList(Aref,C),makeG("s2",C,C,10,2,0)));
final VariantContext test2result = PosteriorProbabilitiesUtils.calculatePosteriorProbs(testNonOverlapping,other,0,0.001,true,false,false);
final Genotype test2exp1 = makeGwithPLs("SGV",T,T,new double[]{-4.078345, -3.276502, -0.0002661066});
Assert.assertEquals(arraysEq(test2exp1.getPL(),_mleparse((List<Integer>) test2result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY))), "");
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:27,代码来源:PosteriorProbabilitiesUtilsUnitTest.java
示例18: add
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
/**
* Add information from this Genotype to this band.
*
* Treats GQ values > 99 as 99.
*
* @param pos Current genomic position. Must be 1 base after the previous position
* @param genotype A non-null Genotype with GQ and DP attributes
*/
public void add(final int pos, final Genotype genotype) {
Utils.nonNull(genotype, "genotype cannot be null");
if ( ! genotype.hasPL() ) { throw new IllegalArgumentException("genotype must have PL field");}
if ( pos != end + 1 ) { throw new IllegalArgumentException("adding genotype at pos " + pos + " isn't contiguous with previous end " + end); }
if ( genotype.getPloidy() != ploidy) { throw new IllegalArgumentException("cannot add a genotype with a different ploidy: " + genotype.getPloidy() + " != " + ploidy); }
// Make sure the GQ is within the bounds of this band. Treat GQs > 99 as 99.
if ( !withinBounds(Math.min(genotype.getGQ(), VCFConstants.MAX_GENOTYPE_QUAL))) {
throw new IllegalArgumentException("cannot add a genotype with GQ=" + genotype.getGQ() + " because it's not within bounds ["
+ this.getGQLowerBound() + ',' + this.getGQUpperBound() + ')');
}
if( minPLs == null ) {
minPLs = genotype.getPL();
} else { // otherwise take the min with the provided genotype's PLs
final int[] pls = genotype.getPL();
if (pls.length != minPLs.length) {
throw new GATKException("trying to merge different PL array sizes: " + pls.length + " != " + minPLs.length);
}
for (int i = 0; i < pls.length; i++) {
minPLs[i] = Math.min(minPLs[i], pls[i]);
}
}
end = pos;
DPs.add(Math.max(genotype.getDP(), 0)); // DP must be >= 0
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:34,代码来源:HomRefBlock.java
示例19: writeOutRecalibrationTable
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
public void writeOutRecalibrationTable(final VariantContextWriter recalWriter, final SAMSequenceDictionary seqDictionary) {
// we need to sort in coordinate order in order to produce a valid VCF
Collections.sort( data, VariantDatum.getComparator(seqDictionary) );
// create dummy alleles to be used
List<Allele> alleles = Arrays.asList(Allele.create("N", true), Allele.create("<VQSR>", false));
for( final VariantDatum datum : data ) {
if (VRAC.useASannotations)
alleles = Arrays.asList(datum.referenceAllele, datum.alternateAllele); //use the alleles to distinguish between multiallelics in AS mode
VariantContextBuilder builder = new VariantContextBuilder("VQSR", datum.loc.getContig(), datum.loc.getStart(), datum.loc.getEnd(), alleles);
builder.attribute(VCFConstants.END_KEY, datum.loc.getEnd());
builder.attribute(GATKVCFConstants.VQS_LOD_KEY, String.format("%.4f", datum.lod));
builder.attribute(GATKVCFConstants.CULPRIT_KEY, (datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"));
if ( datum.atTrainingSite ) builder.attribute(GATKVCFConstants.POSITIVE_LABEL_KEY, true);
if ( datum.atAntiTrainingSite ) builder.attribute(GATKVCFConstants.NEGATIVE_LABEL_KEY, true);
recalWriter.add(builder.make());
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:VariantDataManager.java
示例20: addGenotypeFieldsToRecords
import htsjdk.variant.vcf.VCFConstants; //导入依赖的package包/类
private void addGenotypeFieldsToRecords(final VariantContext vc, final List<List<String>> records, final boolean errorIfMissingData) {
for ( final String sample : samples ) {
for ( final String gf : genotypeFieldsToTake ) {
if ( vc.hasGenotype(sample) && vc.getGenotype(sample).hasAnyAttribute(gf) ) {
if (VCFConstants.GENOTYPE_KEY.equals(gf)) {
addFieldValue(vc.getGenotype(sample).getGenotypeString(true), records);
} else {
/**
* TODO - If gf == "FT" and the GT record is not filtered, Genotype.getAnyAttribute == null. Genotype.hasAnyAttribute should be changed so it
* returns false for this condition. Presently, it always returns true. Once this is fixed, then only the "addFieldValue" statement will
* remain in the following logic block.
*/
if (vc.getGenotype(sample).getAnyAttribute(gf) != null) {
addFieldValue(vc.getGenotype(sample).getAnyAttribute(gf), records);
} else {
handleMissingData(errorIfMissingData, gf, records, vc);
} }
} else {
handleMissingData(errorIfMissingData, gf, records, vc);
}
}
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:24,代码来源:VariantsToTable.java
注:本文中的htsjdk.variant.vcf.VCFConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论