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)
| 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. |