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

Method adjust

src/main/java/com/rtg/vcf/Adjuster.java:161–183  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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();

Callers 11

testMalformedInfoMethod · 0.95
testMalformedFormatMethod · 0.95
testSumMethod · 0.95
testSumMissingElementMethod · 0.95
testSumFloatMethod · 0.95
testNoPolicyMethod · 0.95
testDropPolicyMethod · 0.95
testRetainPolicyMethod · 0.95
decomposeMethod · 0.80

Calls 11

maxMethod · 0.95
adjustInfoFieldMethod · 0.95
adjustFormatFieldMethod · 0.95
userLogMethod · 0.95
getAltCallsMethod · 0.80
getInfoMethod · 0.80
getFormatsMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
sizeMethod · 0.45
keySetMethod · 0.45

Tested by 10

testMalformedInfoMethod · 0.76
testMalformedFormatMethod · 0.76
testSumMethod · 0.76
testSumMissingElementMethod · 0.76
testSumFloatMethod · 0.76
testNoPolicyMethod · 0.76
testDropPolicyMethod · 0.76
testRetainPolicyMethod · 0.76