本文整理汇总了Java中htsjdk.variant.variantcontext.Genotype.getAlleles方法的典型用法代码示例。如果您正苦于以下问题:Java Genotype.getAlleles方法的具体用法?Java Genotype.getAlleles怎么用?Java Genotype.getAlleles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.Genotype
的用法示例。
在下文中一共展示了Genotype.getAlleles方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeGenotypes
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private static void mergeGenotypes(GenotypesContext mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniquifySamples) {
//TODO: should we add a check for cases when the genotypeMergeOption is REQUIRE_UNIQUE
for ( final Genotype g : oneVC.getGenotypes() ) {
final String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniquifySamples);
if ( ! mergedGenotypes.containsSample(name) ) {
// only add if the name is new
Genotype newG = g;
if ( uniquifySamples || alleleMapping.needsRemapping() ) {
final List<Allele> alleles = alleleMapping.needsRemapping() ? alleleMapping.remap(g.getAlleles()) : g.getAlleles();
newG = new GenotypeBuilder(g).name(name).alleles(alleles).make();
}
mergedGenotypes.add(newG);
}
}
}
示例2: incrementChromosomeCountsInfo
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
* Increment the number of called alternate and reference plus alternate
* alleles for a genotype
*
* @param calledAltAlleles
* number of called alternate alleles for all genotypes
* @param calledAlleles
* number of called alleles for all genotypes
* @param genotype
* genotype
* @return incremented called alleles
* @throws IllegalArgumentException
* if calledAltAlleles or genotype are null
*/
public static int incrementChromosomeCountsInfo(final Map<Allele, Integer> calledAltAlleles,
final int calledAlleles, final Genotype genotype) {
if (calledAltAlleles == null)
throw new IllegalArgumentException("Called alternate alleles can not be null");
if (genotype == null)
throw new IllegalArgumentException("Genotype can not be null");
int incrementedCalledAlleles = calledAlleles;
if (genotype.isCalled()) {
for (final Allele allele : genotype.getAlleles()) {
incrementedCalledAlleles++;
if (allele.isNonReference()) {
calledAltAlleles.put(allele, calledAltAlleles.get(allele) + 1);
}
}
}
return incrementedCalledAlleles;
}
示例3: calculateMLEAlleleFrequencies
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private ArrayList<Double> calculateMLEAlleleFrequencies(List<Integer> alleleCountsofMLE,
GenotypesContext genotypes) {
int AN = 0;
for (final Genotype g : genotypes)
for (final Allele a : g.getAlleles())
if (!a.isNoCall())
AN++;
final ArrayList<Double> MLEfrequencies = new ArrayList<>(alleleCountsofMLE.size());
// the MLEAC is allowed to be larger than the AN (e.g. in the case of
// all PLs being 0, the GT is ./. but the exact model may arbitrarily
// choose an AC>1)
for (final int AC : alleleCountsofMLE)
MLEfrequencies.add(Math.min(1.0, (double) AC / (double) AN));
return MLEfrequencies;
}
示例4: genotypeAsAlleleIndexes
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/** Get the sample genotype in the same format as it appears on the VCF file.
* I.e. allele indexes separated by '/' or '|' (if phased). E.g. 0/0, 0/1 etc
*/
private String genotypeAsAlleleIndexes(VariantContext ctx, String sample) {
Genotype gt = ctx.getGenotype(sample);
char sep= gt.isPhased() ? '|' : '/';
List<String> all= new ArrayList<String>();
for(Allele a : gt.getAlleles()){
if(a.isNoCall()){
all.add(".");
}
else {
int i= ctx.getAlleleIndex(a);
all.add(Integer.toString(i));
}
}
return '"' + Joiner.on(sep).join(all) + '"';
}
示例5: makeCombinedAltAllelesVariantContext
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的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: calculateMLEAlleleFrequencies
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private ArrayList<Double> calculateMLEAlleleFrequencies(List<Integer> alleleCountsofMLE, GenotypesContext genotypes) {
int AN = 0;
for (final Genotype g : genotypes)
for (final Allele a : g.getAlleles())
if (!a.isNoCall()) AN++;
final ArrayList<Double> MLEfrequencies = new ArrayList<Double>(alleleCountsofMLE.size());
// the MLEAC is allowed to be larger than the AN (e.g. in the case of all PLs being 0, the GT is ./. but the exact model may arbitrarily choose an AC>1)
for (final int AC : alleleCountsofMLE )
MLEfrequencies.add(Math.min(1.0, (double)AC / (double)AN));
return MLEfrequencies;
}
示例7: getTrueAlleles
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
protected VariantContext getTrueAlleles(final RefMetaDataTracker tracker,
final ReferenceContext ref,
Map<String,AlignmentContext> contexts) {
// Get reference base from VCF or Reference
if (UAC.referenceSampleName == null)
return null;
AlignmentContext context = contexts.get(UAC.referenceSampleName);
ArrayList<Allele> trueReferenceAlleles = new ArrayList<Allele>();
VariantContext referenceSampleVC;
if (tracker != null && context != null)
referenceSampleVC = tracker.getFirstValue(UAC.referenceSampleRod, context.getLocation());
else
return null;
if (referenceSampleVC == null) {
trueReferenceAlleles.add(Allele.create(ref.getBase(),true));
return new VariantContextBuilder("pc",ref.getLocus().getContig(), ref.getLocus().getStart(), ref.getLocus().getStop(),trueReferenceAlleles).make();
}
else {
Genotype referenceGenotype = referenceSampleVC.getGenotype(UAC.referenceSampleName);
List<Allele> referenceAlleles = referenceGenotype.getAlleles();
return new VariantContextBuilder("pc",referenceSampleVC.getChr(), referenceSampleVC.getStart(), referenceSampleVC.getEnd(),
referenceSampleVC.getAlleles())
.genotypes(new GenotypeBuilder(UAC.referenceSampleName, referenceAlleles).GQ(referenceGenotype.getGQ()).make())
.make();
}
}
示例8: basicStatics
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private boolean[] basicStatics(Genotype gt, IntArray array, Allele Ref,GenotypeType type) {
boolean[] conf = new boolean[4];
Arrays.fill(conf, false);
List<Allele> alts = gt.getAlleles();
if(type == GenotypeType.NO_CALL || type == GenotypeType.HOM_REF)
return conf;
boolean isBiallelic = determinePolymorphicType(Ref, alts, conf);
if(!isBiallelic)
return new boolean[]{false,false,false,false};
array.incr(VariantEnum.VARIANTS);
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] && isBiallelic && isTransition(alts.get(0),alts.get(1))) {
array.incr(VariantEnum.TRANSITIONS);
} else if (conf[0] && isBiallelic)
array.incr(VariantEnum.TRANSVERSIONS);
return conf;
}
示例9: makeCombinedAltAllelesVariantContext
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的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, GaeaVCFConstants.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(GaeaVCFConstants.NON_REF_SYMBOLIC_ALLELE);
}
gb.alleles(newAlleles);
}
if (oldGenotype.isNonInformative())
gb.PL(BIALLELIC_NON_INFORMATIVE_PLS);
else if (combineAltAlleleLikelihoods(oldGenotype, genotypeCount, newLikelihoods, hetLikelihoods, homAltLikelihoods))
gb.PL(newLikelihoods);
newGenotypes.add(gb.make());
}
return vcb.genotypes(newGenotypes).make();
}
}