本文整理汇总了Java中htsjdk.variant.variantcontext.Allele.isReference方法的典型用法代码示例。如果您正苦于以下问题:Java Allele.isReference方法的具体用法?Java Allele.isReference怎么用?Java Allele.isReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.Allele
的用法示例。
在下文中一共展示了Allele.isReference方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateOutputAlleleSubset
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* Provided the exact mode computations it returns the appropiate subset of alleles that progress to genotyping.
* @param afcr the exact model calcualtion result.
* @return never {@code null}.
*/
private OutputAlleleSubset calculateOutputAlleleSubset(final AFCalculationResult afcr) {
final List<Allele> alleles = afcr.getAllelesUsedInGenotyping();
final int alternativeAlleleCount = alleles.size() - 1;
Allele[] outputAlleles = new Allele[alternativeAlleleCount];
int[] mleCounts = new int[alternativeAlleleCount];
int outputAlleleCount = 0;
boolean siteIsMonomorphic = true;
for (final Allele alternativeAllele : alleles) {
if (alternativeAllele.isReference()) continue;
final boolean isPlausible = afcr.isPolymorphicPhredScaledQual(alternativeAllele, configuration.genotypeArgs.STANDARD_CONFIDENCE_FOR_EMITTING);
final boolean toOutput = isPlausible || forceKeepAllele(alternativeAllele);
siteIsMonomorphic &= ! isPlausible;
if (!toOutput) continue;
outputAlleles[outputAlleleCount] = alternativeAllele;
mleCounts[outputAlleleCount++] = afcr.getAlleleCountAtMLE(alternativeAllele);
}
return new OutputAlleleSubset(outputAlleleCount,outputAlleles,mleCounts,siteIsMonomorphic);
}
示例2: determinePolymorphicType
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
private static VariantContext.Type determinePolymorphicType(List<Allele> alleles) {
VariantContext.Type typePrevious = null;
Allele ref = null;
for (Allele allele : alleles) {
if (allele.isReference()) {
ref = allele;
continue;
}
// find the type of this allele relative to the reference
VariantContext.Type type = typeOfBiallelicVariant(ref, allele);
// for the first alternate allele, set the type to be that one
// if the type of this allele is different from that of a previous one, assign it the MIXED type and quit
if (typePrevious == null) {
typePrevious = type;
} else if (type != typePrevious) {
typePrevious = VariantContext.Type.MIXED;
return typePrevious;
}
}
return typePrevious;
}
示例3: getVariationTypeForComplexInDels
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
@NotNull private static VariationType getVariationTypeForComplexInDels(Genotype genotype) {
Allele firstAllele = genotype.getAllele(0);
Allele secondAllele = genotype.getAllele(1);
if (firstAllele.length() == secondAllele.length()) { // if it is a change
return firstAllele.length() == 1 ? VariationType.SNV : VariationType.MNP;
}
VariationType type;
if (firstAllele.isReference()) { // if it is an insertion/deletion
type = genotype.getAlleles().get(0).length() > genotype.getAlleles().get(1).length() ?
VariationType.DEL : VariationType.INS;
} else if (secondAllele.isReference()) {
type = genotype.getAlleles().get(1).length() > genotype.getAlleles().get(0).length() ?
VariationType.DEL : VariationType.INS;
} else {
type = VariationType.MIXED;
}
return type;
}
示例4: remapAlleles
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* This method does a couple of things:
* <ul><li>
* remaps the vc alleles considering the differences between the final reference allele and its own reference,</li>
* <li>
* collects alternative alleles present in variant context and add them to the {@code finalAlleles} set.
* </li></ul>
*
* @param vcAlleles the variant context allele list.
* @param refAllele final reference allele.
* @param finalAlleles where to add the final set of non-ref called alleles.
* @return never {@code null}
*/
//TODO as part of a larger refactoring effort {@link #remapAlleles} can be merged with {@link GATKVariantContextUtils#remapAlleles}.
private static List<Allele> remapAlleles(final List<Allele> vcAlleles, final Allele refAllele, final LinkedHashSet<Allele> finalAlleles) {
final Allele vcRef = vcAlleles.get(0);
if (!vcRef.isReference()) throw new IllegalStateException("the first allele of the vc allele list must be reference");
final byte[] refBases = refAllele.getBases();
final int extraBaseCount = refBases.length - vcRef.getBases().length;
if (extraBaseCount < 0) throw new IllegalStateException("the wrong reference was selected");
final List<Allele> result = new ArrayList<>(vcAlleles.size());
for (final Allele a : vcAlleles) {
if (a.isReference()) {
result.add(refAllele);
} else if (a.isSymbolic()) {
result.add(a);
// we always skip <NON_REF> when adding to finalAlleles this is done outside if applies.
if (!a.equals(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE))
finalAlleles.add(a);
} else if (a.isCalled()) {
final Allele newAllele;
if (extraBaseCount > 0) {
final byte[] oldBases = a.getBases();
final byte[] newBases = Arrays.copyOf(oldBases,oldBases.length + extraBaseCount);
System.arraycopy(refBases,refBases.length - extraBaseCount,newBases,oldBases.length,extraBaseCount);
newAllele = Allele.create(newBases,false);
} else
newAllele = a;
result.add(newAllele);
finalAlleles.add(newAllele);
} else { // NO_CALL and strange miscellanea
result.add(a);
}
}
return result;
}
示例5: makeCombinedAltAllelesVariantContext
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
private VariantContext makeCombinedAltAllelesVariantContext(final VariantContext vc) {
final int nAltAlleles = vc.getNAlleles() - 1;
if ( nAltAlleles == 1 )
return vc;
else {
final VariantContextBuilder vcb = new VariantContextBuilder(vc);
final Allele reference = vcb.getAlleles().get(0);
vcb.alleles(Arrays.asList(reference, GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE));
final int genotypeCount = GenotypeLikelihoodCalculators.genotypeCount(2, vc.getNAlleles());
final double[] hetLikelihoods = new double[vc.getNAlleles() - 1];
final double[] homAltLikelihoods = new double[genotypeCount - hetLikelihoods.length - 1];
final double[] newLikelihoods = new double[3];
final List<Genotype> newGenotypes = new ArrayList<>(vc.getNSamples());
for (final Genotype oldGenotype : vc.getGenotypes()) {
final GenotypeBuilder gb = new GenotypeBuilder(oldGenotype);
final List<Allele> oldAlleles = oldGenotype.getAlleles();
if (oldAlleles != null) {
final List<Allele> newAlleles = new ArrayList<>(oldAlleles.size());
for (int i = 0; i < oldAlleles.size(); i++) {
final Allele oldAllele = oldAlleles.get(i);
if (oldAllele.isReference())
newAlleles.add(reference);
else if (oldAllele.isNoCall())
newAlleles.add(Allele.NO_CALL);
else
newAlleles.add(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE);
}
gb.alleles(newAlleles);
}
if (combineAltAlleleLikelihoods(oldGenotype, genotypeCount, newLikelihoods, hetLikelihoods, homAltLikelihoods))
gb.PL(newLikelihoods);
newGenotypes.add(gb.make());
}
return vcb.genotypes(newGenotypes).make();
}
}
示例6: printVerboseData
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
protected void printVerboseData(final String pos, final VariantContext vc, final GenotypeLikelihoodsCalculationModel.Model model) {
Allele refAllele = null, altAllele = null;
for (Allele allele : vc.getAlleles()) {
if (allele.isReference())
refAllele = allele;
else
altAllele = allele;
}
for (int i = 0; i <= numberOfGenomes; i++) {
StringBuilder AFline = new StringBuilder("AFINFO\t");
AFline.append(pos);
AFline.append('\t');
AFline.append(refAllele);
AFline.append('\t');
if (altAllele != null)
AFline.append(altAllele);
else
AFline.append("N/A");
AFline.append('\t');
AFline.append(i).append('/').append(numberOfGenomes).append('\t');
AFline.append(String.format("%.2f\t", ((float) i) / numberOfGenomes));
AFline.append(String.format("%.8f\t", getAlleleFrequencyPriors(vc, configuration.genotypeArgs.samplePloidy, model)[i]));
verboseWriter.println(AFline.toString());
}
verboseWriter.println("Qscore = " + vc.getLog10PError());
verboseWriter.println();
}
示例7: pileupElementMatches
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
public static boolean pileupElementMatches(PileupElement pileupElement, Allele allele, Allele refAllele, byte refBase) {
if (DEBUG)
System.out.format("PE: base:%s isNextToDel:%b isNextToIns:%b eventBases:%s eventLength:%d Allele:%s RefAllele:%s\n",
pileupElement.getBase(), pileupElement.isBeforeDeletionStart(),
pileupElement.isBeforeInsertion(), pileupElement.getBasesOfImmediatelyFollowingInsertion(), pileupElement.getLengthOfImmediatelyFollowingIndel(), allele.toString(), refAllele.toString());
//pileupElement.
// if test allele is ref, any base mismatch, or any insertion/deletion at start of pileup count as mismatch
if (allele.isReference()) {
// for a ref allele, any base mismatch or new indel is a mismatch.
if (allele.getBases().length > 0)
// todo - can't check vs. allele because allele is not padded so it doesn't include the reference base at this location
// could clean up/simplify this when unpadding is removed
return (pileupElement.getBase() == refBase && !pileupElement.isBeforeInsertion() && !pileupElement.isBeforeDeletionStart());
else
// either null allele to compare, or ref/alt lengths are different (indel by definition).
// if we have an indel that we are comparing against a REF allele, any indel presence (of any length/content) is a mismatch
return (!pileupElement.isBeforeInsertion() && !pileupElement.isBeforeDeletionStart());
}
// for non-ref alleles to compare:
if (refAllele.getBases().length == allele.getBases().length)
// alleles have the same length (eg snp or mnp)
return pileupElement.getBase() == allele.getBases()[0];
// for non-ref alleles,
byte[] alleleBases = allele.getBases();
int eventLength = alleleBases.length - refAllele.getBases().length;
if (eventLength < 0 && pileupElement.isBeforeDeletionStart() && pileupElement.getLengthOfImmediatelyFollowingIndel() == -eventLength)
return true;
if (eventLength > 0 && pileupElement.isBeforeInsertion() &&
Arrays.equals(pileupElement.getBasesOfImmediatelyFollowingInsertion().getBytes(), Arrays.copyOfRange(alleleBases, 1, alleleBases.length))) // allele contains ref byte, but pileupElement's event bases doesn't
return true;
return false;
}
示例8: isUsableAlternateAllele
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
static private boolean isUsableAlternateAllele(final Allele allele) {
return ! (allele.isReference() || allele.isSymbolic() );
}
示例9: altAlleleIndex
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* Computes the offset into linear vectors indexed by alt allele for allele
*
* Things like our MLE allele count vector are indexed by alt allele index, with
* the first alt allele being 0, the second 1, etc. This function computes the index
* associated with allele.
*
* @param allele the allele whose alt index we'd like to know
* @throws IllegalArgumentException if allele isn't in allelesUsedInGenotyping
* @return an index value greater than 0 suitable for indexing into the MLE and other alt allele indexed arrays
*/
private int altAlleleIndex(final Allele allele) {
if ( allele.isReference() ) throw new IllegalArgumentException("Cannot get the alt allele index for reference allele " + allele);
final int index = allelesUsedInGenotyping.indexOf(allele);
if ( index == -1 )
throw new IllegalArgumentException("could not find allele " + allele + " in " + allelesUsedInGenotyping);
else
return index - 1;
}