MCPcopy Create free account
hub / github.com/RealTimeGenomics/rtg-tools / getType

Method getType

src/main/java/com/rtg/vcf/VariantType.java:130–160  ·  view source on GitHub ↗

Determine the type of variant given a genotype @param rec the VCF record containing the allele definitions @param gtSplit the genotype, as allele indices @return the type of variant

(VcfRecord rec, int[] gtSplit)

Source from the content-addressed store, hash-verified

128 * @return the type of variant
129 */
130 public static VariantType getType(VcfRecord rec, int[] gtSplit) {
131 boolean allMissing = true;
132 int altId = 0;
133 int gtPos;
134 for (gtPos = 0; gtPos < gtSplit.length; gtPos++) {
135 final int a = gtSplit[gtPos];
136 if (a != -1) {
137 allMissing = false;
138 if (a != 0) {
139 altId = a;
140 gtPos++;
141 break;
142 }
143 }
144 }
145 if (allMissing) {
146 return VariantType.NO_CALL;
147 }
148 if (altId == 0) {
149 return VariantType.UNCHANGED;
150 }
151 final String[] alleles = VcfUtils.getAlleleStrings(rec);
152 VariantType altType = getType(alleles[0], alleles[altId]);
153 for (; gtPos < gtSplit.length; gtPos++) {
154 final int a = gtSplit[gtPos];
155 if (a > 0 && a != altId) {
156 altType = getPrecedence(altType, getType(alleles[0], alleles[a]));
157 }
158 }
159 return altType;
160 }
161
162 /**
163 * Determine the type of variant given a reference allele and a called/alternative allele.

Callers 7

testGetVariantTypeMethod · 0.95
testGetVariantTypeRecMethod · 0.95
acceptMethod · 0.95
hasDefinedVariantGtMethod · 0.95
acceptMethod · 0.95
decomposeMethod · 0.95

Calls 6

getAlleleStringsMethod · 0.95
getPrecedenceMethod · 0.95
getSymbolicAlleleTypeMethod · 0.95
isInsertionOrDeletionMethod · 0.95
lengthMethod · 0.65
equalsMethod · 0.45

Tested by 2

testGetVariantTypeMethod · 0.76
testGetVariantTypeRecMethod · 0.76