本文整理汇总了Java中htsjdk.variant.variantcontext.VariantContextUtils类的典型用法代码示例。如果您正苦于以下问题:Java VariantContextUtils类的具体用法?Java VariantContextUtils怎么用?Java VariantContextUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariantContextUtils类属于htsjdk.variant.variantcontext包,在下文中一共展示了VariantContextUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: splitVariantContextToBiallelics
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
/**
* Split variant context into its biallelic components if there are more than 2 alleles
*
* For VC has A/B/C alleles, returns A/B and A/C contexts.
* Genotypes are all no-calls now (it's not possible to fix them easily)
* Alleles are right trimmed to satisfy VCF conventions
*
* If vc is biallelic or non-variant it is just returned
*
* Chromosome counts are updated (but they are by definition 0)
*
* @param vc a potentially multi-allelic variant context
* @param trimLeft if true, we will also left trim alleles, potentially moving the resulting vcs forward on the genome
* @return a list of bi-allelic (or monomorphic) variant context
*/
public static List<VariantContext> splitVariantContextToBiallelics(final VariantContext vc, final boolean trimLeft, final GenotypeAssignmentMethod genotypeAssignmentMethod) {
if ( ! vc.isVariant() || vc.isBiallelic() )
// non variant or biallelics already satisfy the contract
return Collections.singletonList(vc);
else {
final List<VariantContext> biallelics = new LinkedList<>();
for ( final Allele alt : vc.getAlternateAlleles() ) {
VariantContextBuilder builder = new VariantContextBuilder(vc);
final List<Allele> alleles = Arrays.asList(vc.getReference(), alt);
builder.alleles(alleles);
builder.genotypes(subsetDiploidAlleles(vc, alleles, genotypeAssignmentMethod));
VariantContextUtils.calculateChromosomeCounts(builder, true);
final VariantContext trimmed = trimAlleles(builder.make(), trimLeft, true);
biallelics.add(trimmed);
}
return biallelics;
}
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:36,代码来源:GATKVariantContextUtils.java
示例2: basicStatics
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
private void basicStatics(VariantContext vc, IntArray array, boolean[] conf) {
if (conf[0])
array.incr(VariantEnum.SNPS);
if (conf[1])
array.incr(VariantEnum.MNPS);
if (conf[2]) {
array.incr(VariantEnum.INSERTIONS);
}
if (conf[3]) {
array.incr(VariantEnum.DELETIONS);
}
if (conf[2] || conf[3])
array.incr(VariantEnum.INDELS);
if (conf[0] && vc.isBiallelic() && VariantContextUtils.isTransition(vc)) {
array.incr(VariantEnum.TRANSITIONS);
} else if (conf[0] && vc.isBiallelic())
array.incr(VariantEnum.TRANSVERSIONS);
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:21,代码来源:VariantBasicStatistic.java
示例3: create
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public static Predicate<VariantContext> create(final List<String> exps) {
final List<String> expressions = exps.stream().
filter(S->!StringUtil.isBlank(S)).
collect(Collectors.toList());
if( expressions.isEmpty()) return ACCEPT_ALL;
final List<String> dummyNames = expressions.stream().
map(S->"JEXL"+(++ID_GENERATOR)).
collect(Collectors.toList());
try {
return new JexlVariantPredicate(VariantContextUtils.initializeMatchExps(dummyNames, expressions));
}
catch(final Throwable err) {
LOG.error(err);
throw new RuntimeException("Cannot compile :"+String.join(",", expressions),err);
}
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:JexlVariantPredicate.java
示例4: annotate
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public Map<String, Object> annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,
final ReferenceContext ref,
final Map<String, AlignmentContext> stratifiedContexts,
final VariantContext vc,
final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {
if (!vc.hasGenotypes())
return null;
return VariantContextUtils.calculateChromosomeCounts(vc, new HashMap<String, Object>(), true, founderIds);
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:12,代码来源:ChromosomeCounts.java
示例5: isTransition
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public Builder isTransition() {
if((snpCount != 0) && VariantContextUtils.isTransition(vc))
ti++;
else
tv++;
return this;
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:8,代码来源:ReportDatum.java
示例6: HardFilter
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public HardFilter(String filterName, String snpFilter, String indelFilter) {
if(snpFilter != null)
this.snpFilter = VariantContextUtils.initializeMatchExps(new String[]{filterName+"snp"}, new String[]{snpFilter});
if(indelFilter != null)
this.indelFilter = VariantContextUtils.initializeMatchExps(new String[]{filterName+"indel"}, new String[]{indelFilter});
VariantContextUtils.engine.get().setSilent(true);
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:8,代码来源:HardFilter.java
示例7: setFlagV
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public Builder setFlagV() throws IOException {
if(vc.isSNP() && vc.isBiallelic())
this.flag = (this.flag |= VariantDatumMessenger.isSNP);
if(checkFlag(this.flag, VariantDatumMessenger.isSNP) && VariantContextUtils.isTransition(vc))
this.flag = (this.flag |= VariantDatumMessenger.isTransition);
this.flag = parseTrainingSets(flag, options.isTrustAllPolymorphic());
return this;
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:10,代码来源:VariantDatumMessenger.java
示例8: addDatum
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
private void addDatum(final ExpandingArrayList<VariantDatum> variants, final boolean isInput,
final VariantContext vc, final Allele refAllele, final Allele altAllele) {
final VariantDatum datum = new VariantDatum();
// Populate the datum with lots of fields from the VariantContext,
// unfortunately the VC is too big so we just
// pull in only the things we absolutely need.
datum.referenceAllele = refAllele;
datum.alternateAllele = altAllele;
dataManager.decodeAnnotations(datum, vc, true);
// non-deterministic because order of calls depends on load of machine
datum.loc = (isInput ? parser.createGenomeLocation(vc) : null);
datum.originalQual = vc.getPhredScaledQual();
datum.isSNP = vc.isSNP() && vc.isBiallelic();
datum.isTransition = datum.isSNP && VariantContextUtils.isTransition(vc);
datum.isAggregate = !isInput;
// Loop through the training data sets and if they overlap this locus
// (and allele, if applicable) then update
// the prior and training status appropriately. The locus used to find
// training set variants is retrieved
// by parseTrainingSets from the FeatureContext argument.
dataManager.parseTrainingSets(parser,vc, datum, options.isTrustAllPolymorphic());
final double priorFactor = QualityUtils.qualityToProbability(datum.prior);
datum.prior = Math.log10(priorFactor) - Math.log10(1.0 - priorFactor);
variants.add(datum);
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:31,代码来源:VariantRecalibrator.java
示例9: annotate
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public Map<String, Object> annotate(final VariantDataTracker tracker,
final ChromosomeInformationShare ref,
final Mpileup mpileup,
final VariantContext vc,
final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap ) {
if ( ! vc.hasGenotypes() )
return null;
return VariantContextUtils.calculateChromosomeCounts(vc, new HashMap<String, Object>(), true,founderIds);
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:11,代码来源:ChromosomeCounts.java
示例10: annotate
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public Map<String, Object> annotate(RefMetaDataTracker tracker, ChromosomeInformationShare ref, VariantContext vc) {
if ( ! vc.hasGenotypes() )
return null;
//if none of the "founders" are in the vc samples, assume we uniquified the samples upstream and they are all founders
if (!didUniquifiedSampleNameCheck) {
checkSampleNames(vc);
didUniquifiedSampleNameCheck = true;
}
return VariantContextUtils.calculateChromosomeCounts(vc, new HashMap<String, Object>(), true,founderIds);
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:13,代码来源:ChromosomeCounts.java
示例11: apply
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public void apply(final VariantContext variant,
final ReadsContext readsContext,
final ReferenceContext referenceContext,
final FeatureContext featureContext) {
final Collection<VariantContext> vcs = featureContext.getValues(getDrivingVariantsFeatureInput());
final Collection<VariantContext> otherVCs = featureContext.getValues(supportVariants);
final int missing = supportVariants.size() - otherVCs.size();
for ( final VariantContext vc : vcs ) {
final VariantContext vc_familyPriors;
final VariantContext vc_bothPriors;
//do family priors first (if applicable)
final VariantContextBuilder builder = new VariantContextBuilder(vc);
//only compute family priors for biallelelic sites
if (!skipFamilyPriors && vc.isBiallelic()){
final GenotypesContext gc = famUtils.calculatePosteriorGLs(vc);
builder.genotypes(gc);
}
VariantContextUtils.calculateChromosomeCounts(builder, false);
vc_familyPriors = builder.make();
if (!skipPopulationPriors) {
vc_bothPriors = PosteriorProbabilitiesUtils.calculatePosteriorProbs(vc_familyPriors, otherVCs, missing * numRefIfMissing, globalPrior, !ignoreInputSamples, defaultToAC, useACoff);
} else {
final VariantContextBuilder builder2 = new VariantContextBuilder(vc_familyPriors);
VariantContextUtils.calculateChromosomeCounts(builder, false);
vc_bothPriors = builder2.make();
}
vcfWriter.add(vc_bothPriors);
}
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:36,代码来源:CalculateGenotypePosteriors.java
示例12: annotate
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public Map<String, Object> annotate(final ReferenceContext ref,
final VariantContext vc,
ReadLikelihoods<Allele> likelihoods) {
Utils.nonNull(vc);
if ( ! vc.hasGenotypes() ) {
return Collections.emptyMap();
}
return VariantContextUtils.calculateChromosomeCounts(vc, new LinkedHashMap<>(), true, Collections.emptySet());
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:12,代码来源:ChromosomeCounts.java
示例13: initialize
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public void initialize() {
if(this.window_size<=0) {
throw new UserException("Bad window size.");
}
if(this.window_shift<=0) {
throw new UserException("Bad window shift.");
}
if(this.winName==null || this.winName.isEmpty()) {
throw new UserException("Bad INFO ID windowName");
}
final Map<String,String> exprMap=new HashMap<>();
for(final String expStr:this.selectExpressions) {
exprMap.put("expr"+(1+exprMap.size()), expStr);
}
this.jexls = VariantContextUtils.initializeMatchExps(exprMap);
final VCFHeader header= new VCFHeader(super.getVcfHeader());
if(header.getInfoHeaderLine(this.winName)!=null) {
throw new UserException("VCF header already contains the INFO header ID="+this.winName);
}
header.addMetaDataLine(new VCFInfoHeaderLine(
this.winName,
VCFHeaderLineCount.UNBOUNDED,
VCFHeaderLineType.String,
"Window : start|end|number-of-matching-variants|number-of-non-matching-variants"
));
super.writer.writeHeader(header);
super.initialize();
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:31,代码来源:WindowVariants.java
示例14: doWork
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public int doWork(final List<String> args) {
if(this.window_size<=0) {
LOG.error("Bad window size.");
return -1;
}
if(this.window_shift<=0) {
LOG.error("Bad window shift.");
return -1;
}
if(this.winName==null || this.winName.isEmpty()) {
LOG.error("Bad INFO ID windowName");
return -1;
}
try {
final Map<String,String> exprMap=new HashMap<>();
for(final String expStr:this.selectExpressions) {
exprMap.put("expr"+(1+exprMap.size()), expStr);
}
this.jexls = VariantContextUtils.initializeMatchExps(exprMap);
return doVcfToVcf(args, outputFile);
}
catch(final Exception err) {
LOG.error(err);
return -1;
}
finally
{
}
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:33,代码来源:VariantsInWindow.java
示例15: test
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public boolean test(final VariantContext ctx) {
return VariantContextUtils.match(ctx,this.jexlVCMatchExps).
values().
stream().
anyMatch(B->B.booleanValue());
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:8,代码来源:JexlVariantPredicate.java
示例16: create
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
public static BiPredicate<VariantContext,Genotype> create(final List<String> exps) {
final List<String> expressions = exps.stream().
filter(S->!StringUtil.isBlank(S)).
collect(Collectors.toList());
if( expressions.isEmpty()) return ACCEPT_ALL;
final List<String> dummyNames = expressions.stream().
map(S->"JEXLGT"+(++ID_GENERATOR)).
collect(Collectors.toList());
return new JexlGenotypePredicate(VariantContextUtils.initializeMatchExps(dummyNames, expressions));
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:12,代码来源:JexlGenotypePredicate.java
示例17: test
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
@Override
public boolean test(final VariantContext ctx,Genotype gt) {
return VariantContextUtils.match(ctx,gt,this.jexlVCMatchExps).
values().
stream().
anyMatch(B->B.booleanValue());
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:8,代码来源:JexlGenotypePredicate.java
示例18: SamRecordJEXLFilter
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
private SamRecordJEXLFilter(final String exprStr) {
this.exprStr = exprStr;
try {
this.expr=VariantContextUtils.engine.get().createExpression(exprStr);
} catch(final JexlException err) {
throw new IllegalArgumentException("Cannot compile JEXL expression", err);
}
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:9,代码来源:SamRecordJEXLFilter.java
示例19: onTraversalStart
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
/**
* Set up the VCF writer, the sample expressions and regexs, filters inputs, and the JEXL matcher
*
*/
@Override
public void onTraversalStart() {
final Map<String, VCFHeader> vcfHeaders = Collections.singletonMap(getDrivingVariantsFeatureInput().getName(), getHeaderForVariants());
// Initialize VCF header lines
final Set<VCFHeaderLine> headerLines = createVCFHeaderLineList(vcfHeaders);
for (int i = 0; i < selectExpressions.size(); i++) {
// It's not necessary that the user supply select names for the JEXL expressions, since those
// expressions will only be needed for omitting records. Make up the select names here.
selectNames.add(String.format("select-%d", i));
}
jexls = VariantContextUtils.initializeMatchExps(selectNames, selectExpressions);
// Prepare the sample names and types to be used by the corresponding filters
samples = createSampleNameInclusionList(vcfHeaders);
selectedTypes = createSampleTypeInclusionList();
// Look at the parameters to decide which analysis to perform
discordanceOnly = discordanceTrack != null;
if (discordanceOnly) {
logger.info("Selecting only variants discordant with the track: " + discordanceTrack.getName());
}
concordanceOnly = concordanceTrack != null;
if (concordanceOnly) {
logger.info("Selecting only variants concordant with the track: " + concordanceTrack.getName());
}
if (mendelianViolations) {
sampleDB = initializeSampleDB();
mv = new MendelianViolation(mendelianViolationQualThreshold, false, true);
}
selectRandomFraction = fractionRandom > 0;
if (selectRandomFraction) {
logger.info("Selecting approximately " + 100.0*fractionRandom + "% of the variants at random from the variant track");
}
//TODO: this should be refactored/consolidated as part of
// https://github.com/broadinstitute/gatk/issues/121 and
// https://github.com/broadinstitute/gatk/issues/1116
Set<VCFHeaderLine> actualLines = null;
SAMSequenceDictionary sequenceDictionary = null;
if (hasReference()) {
Path refPath = referenceArguments.getReferencePath();
sequenceDictionary= this.getReferenceDictionary();
actualLines = VcfUtils.updateHeaderContigLines(headerLines, refPath, sequenceDictionary, suppressReferencePath);
}
else {
sequenceDictionary = getHeaderForVariants().getSequenceDictionary();
if (null != sequenceDictionary) {
actualLines = VcfUtils.updateHeaderContigLines(headerLines, null, sequenceDictionary, suppressReferencePath);
}
else {
actualLines = headerLines;
}
}
vcfWriter = createVCFWriter(outFile);
vcfWriter.writeHeader(new VCFHeader(actualLines, samples));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:68,代码来源:SelectVariants.java
示例20: addAnnotations
import htsjdk.variant.variantcontext.VariantContextUtils; //导入依赖的package包/类
private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC, final Set<String> selectedSampleNames) {
if (fullyDecode) {
return; // TODO -- annotations are broken with fully decoded data
}
if (keepOriginalChrCounts) {
final int[] indexOfOriginalAlleleForNewAllele;
final List<Allele> newAlleles = builder.getAlleles();
final int numOriginalAlleles = originalVC.getNAlleles();
// if the alleles already match up, we can just copy the previous list of counts
if (numOriginalAlleles == newAlleles.size()) {
indexOfOriginalAlleleForNewAllele = null;
}
// otherwise we need to parse them and select out the correct ones
else {
indexOfOriginalAlleleForNewAllele = new int[newAlleles.size() - 1];
Arrays.fill(indexOfOriginalAlleleForNewAllele, -1);
// note that we don't care about the reference allele at position 0
for (int newI = 1; newI < newAlleles.size(); newI++) {
final Allele newAlt = newAlleles.get(newI);
for (int oldI = 0; oldI < numOriginalAlleles - 1; oldI++) {
if (newAlt.equals(originalVC.getAlternateAllele(oldI), false)) {
indexOfOriginalAlleleForNewAllele[newI - 1] = oldI;
break;
}
}
}
}
if (originalVC.hasAttribute(VCFConstants.ALLELE_COUNT_KEY)) {
builder.attribute(GATKVCFConstants.ORIGINAL_AC_KEY,
getReorderedAttributes(originalVC.getAttribute(VCFConstants.ALLELE_COUNT_KEY), indexOfOriginalAlleleForNewAllele));
}
if (originalVC.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY)) {
builder.attribute(GATKVCFConstants.ORIGINAL_AF_KEY,
getReorderedAttributes(originalVC.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY), indexOfOriginalAlleleForNewAllele));
}
if (originalVC.hasAttribute(VCFConstants.ALLELE_NUMBER_KEY)) {
builder.attribute(GATKVCFConstants.ORIGINAL_AN_KEY, originalVC.getAttribute(VCFConstants.ALLELE_NUMBER_KEY));
}
}
VariantContextUtils.calculateChromosomeCounts(builder, false);
if (keepOriginalDepth && originalVC.hasAttribute(VCFConstants.DEPTH_KEY)) {
builder.attribute(GATKVCFConstants.ORIGINAL_DP_KEY, originalVC.getAttribute(VCFConstants.DEPTH_KEY));
}
boolean sawDP = false;
int depth = 0;
for (final String sample : selectedSampleNames ) {
final Genotype g = originalVC.getGenotype(sample);
if (!g.isFiltered()) {
if (g.hasDP()) {
depth += g.getDP();
sawDP = true;
}
}
}
if (sawDP) {
builder.attribute(VCFConstants.DEPTH_KEY, depth);
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:67,代码来源:SelectVariants.java
注:本文中的htsjdk.variant.variantcontext.VariantContextUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论