Potentially change, delete, or insert VCF FORMAT and INFO fields in accordance with a change of alleles from the original record to the replacement. For example, if alleles have been combined, then it is appropriate to add the AD elements for the corresponding alleles. @param original original VCF
(final VcfRecord original, final VcfRecord replacement, final int[] alleleMap)
| 159 | * @param alleleMap mapping from alleles in original record into replacement record |
| 160 | */ |
| 161 | public void adjust(final VcfRecord original, final VcfRecord replacement, final int[] alleleMap) { |
| 162 | try { |
| 163 | final int numAlleles = MathUtils.max(alleleMap) + 1; |
| 164 | assert numAlleles == replacement.getAltCalls().size() + 1; |
| 165 | |
| 166 | for (String field : original.getInfo().keySet()) { |
| 167 | if (mInfoPolicies.containsKey(field)) { |
| 168 | adjustInfoField(original, replacement, alleleMap, numAlleles, field, mInfoPolicies.get(field)); |
| 169 | } |
| 170 | } |
| 171 | for (String field : original.getFormats()) { |
| 172 | if (mFormatPolicies.containsKey(field)) { |
| 173 | adjustFormatField(original, replacement, alleleMap, numAlleles, field, mFormatPolicies.get(field)); |
| 174 | } |
| 175 | } |
| 176 | } catch (final VcfFormatException e) { |
| 177 | throw e; |
| 178 | } catch (final RuntimeException e) { |
| 179 | // Log any records that lead to exceptions during adjustment |
| 180 | Diagnostic.userLog("Problem adjusting: " + original.toString()); |
| 181 | throw e; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | private void validateTypedField(TypedField<?> f) { |
| 186 | final VcfNumber n = f.getNumber(); |