本文整理汇总了Java中htsjdk.variant.variantcontext.Genotype.hasAnyAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Genotype.hasAnyAttribute方法的具体用法?Java Genotype.hasAnyAttribute怎么用?Java Genotype.hasAnyAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.Genotype
的用法示例。
在下文中一共展示了Genotype.hasAnyAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableFromSamples
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
* Create the contingency table by retrieving the per-sample strand bias annotation and adding them together
*
* @param genotypes the genotypes from which to pull out the per-sample strand bias annotation
* @param minCount minimum threshold for the sample strand bias counts for each ref and alt.
* If both ref and alt counts are above minCount the whole sample strand bias is added to the resulting table
* @return the table used for several strand bias tests, will be null if none of the genotypes contain the per-sample SB annotation
*/
protected int[][] getTableFromSamples(final GenotypesContext genotypes, final int minCount) {
if (genotypes == null) {
throw new IllegalArgumentException("Genotypes cannot be null.");
}
final int[] sbArray = {0, 0, 0, 0}; // reference-forward-reverse -by- alternate-forward-reverse
boolean foundData = false;
for (final Genotype g : genotypes) {
if (g.isNoCall() || !g.hasAnyAttribute(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME))
continue;
foundData = true;
final ArrayList<Integer> sbbsString = (ArrayList<Integer>) g.getAnyAttribute(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME);
final int[] data = Utils.list2Array(sbbsString);
if (passesMinimumThreshold(data, minCount)) {
for (int index = 0; index < sbArray.length; index++) {
sbArray[index] += data[index];
}
}
}
return (foundData ? decodeSBBS(sbArray) : null);
}
示例2: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@Override
public Map<String, Object> annotate(RefMetaDataTracker tracker, ChromosomeInformationShare ref, VariantContext vc) {
// do not process if not a variant
if (!vc.isVariant())
return null;
// if the genotype and strand bias are provided, calculate the
// annotation from the Genotype (GT) field
if (vc.hasGenotypes()) {
for (final Genotype g : vc.getGenotypes()) {
if (g.hasAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY)) {
return calculateAnnotationFromGTfield(vc.getGenotypes());
}
}
}
return null;
}
示例3: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@Override
//template method for calculating strand bias annotations using the three different methods
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> stratifiedPerReadAlleleLikelihoodMap) {
if (!vc.isVariant())
return null;
if (vc.hasGenotypes()) {
boolean hasSB = false;
for (final Genotype g : vc.getGenotypes()) {
if (g.hasAnyAttribute(StrandBiasBySample.STRAND_BIAS_BY_SAMPLE_KEY_NAME)) {
hasSB = true;
break;
}
}
if (hasSB)
return calculateAnnotationFromGTfield(vc.getGenotypes());
}
//stratifiedContexts can come come from VariantAnnotator, but will be size 0 if no reads were provided
if (vc.isSNP() && stratifiedContexts != null && stratifiedContexts.size() > 0) {
return calculateAnnotationFromStratifiedContexts(stratifiedContexts, vc);
}
//stratifiedPerReadAllelelikelihoodMap can come from HaplotypeCaller call to VariantAnnotatorEngine
else if (stratifiedPerReadAlleleLikelihoodMap != null) {
return calculateAnnotationFromLikelihoodMap(stratifiedPerReadAlleleLikelihoodMap, vc);
} else
// for non-snp variants, we need per-read likelihoods.
// for snps, we can get same result from simple pileup
return null;
}
示例4: getTableFromSamples
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
*/
protected int[][] getTableFromSamples(final GenotypesContext genotypes, final int minCount) {
if (genotypes == null) {
if (!getTableFromSamplesWarningLogged) {
getTableFromSamplesWarningLogged = true;
}
return null;
}
final int[] sbArray = { 0, 0, 0, 0 }; // reference-forward-reverse -by-
// alternate-forward-reverse
boolean foundData = false;
for (final Genotype g : genotypes) {
if (g.isNoCall() || !g.hasAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY))
continue;
foundData = true;
int[] data;
if (g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY).getClass().equals(String.class)) {
final String sbbsString = (String) g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY);
data = encodeSBBS(sbbsString);
} else if (g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY).getClass()
.equals(ArrayList.class)) {
ArrayList sbbsList = (ArrayList) g.getAnyAttribute(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY);
data = encodeSBBS(sbbsList);
} else
throw new IllegalArgumentException(
"Unexpected " + GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY + " type");
if (passesMinimumThreshold(data, minCount)) {
for (int index = 0; index < sbArray.length; index++) {
sbArray[index] += data[index];
}
}
}
return (foundData ? decodeSBBS(sbArray) : null);
}
示例5: parseOtherGenotypeFields
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private static boolean parseOtherGenotypeFields(String field, VariantContext vc,
ListValue.Builder lvBuilder, Genotype g, VCFHeader header) {
if (!g.hasAnyAttribute(field)) {
return false;
}
final VCFFormatHeaderLine metaData = header.getFormatHeaderLine(field);
if (metaData == null) {
logger.log(Level.WARNING, String.format("Could not find matching VCF header field for "
+ "genotype field %s", field));
return false;
}
VCFHeaderLineType type = metaData.getType();
Object value = g.getExtendedAttribute(field);
final int fieldCount = metaData.getCount(vc);
if (fieldCount == 1) {
lvBuilder.addValues(createTypedValue(type, value));
return true;
}
if (!(value instanceof String)) {
throw new IllegalStateException("received non-Flag genotype field as non-String type");
}
String[] valueArray = ((String) value).split(",");
if (valueArray.length == 1) {
throw new IllegalStateException(String.format("header indicating a count greater than 1 "
+ "with non-List type found for field %s",
field));
}
boolean allFalse = true;
for (int i = 0; i < valueArray.length; i++) {
VCFHeaderLineType thisType = VCFHeaderLineType.String;
if (!valueArray[i].equals(VCFConstants.MISSING_VALUE_v4)) {
thisType = type;
allFalse = false;
}
lvBuilder.addValues(createTypedValue(thisType, valueArray[i]));
}
// We only add the lvBuilder if there is at least one non-missing value
return !allFalse;
}