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

Method decompose

src/main/java/com/rtg/vcf/Decomposer.java:153–242  ·  view source on GitHub ↗
(final VcfRecord rec)

Source from the content-addressed store, hash-verified

151 }
152
153 protected List<VcfRecord> decompose(final VcfRecord rec) throws IOException {
154 updateTemplate(rec.getSequenceName());
155 ++mTotalRecords;
156 final SplitAlleles result;
157 final int pad;
158 if (VcfUtils.hasRedundantFirstNucleotide(rec)) {
159 pad = 1;
160 result = new SplitAlleles(rec.getRefCall().substring(1), rec.getAltCalls().stream().map(s -> s.substring(1)).collect(Collectors.toList()));
161 } else {
162 pad = 0;
163 result = new SplitAlleles(rec.getRefCall(), rec.getAltCalls());
164 }
165 final Partition partition;
166 try {
167 partition = result.partition();
168 } catch (final RuntimeException e) {
169 // Added by SAI to collect more information regarding Bug#1665
170 // Most likely a StringIndexOutOfBoundsException from deep down in the allele splitting
171 Diagnostic.userLog("Following record caused an exception during decomposition:");
172 Diagnostic.userLog(rec.toString());
173 throw e;
174 }
175 if (partition.isEmpty()) {
176 // If partitioning failed, then simply return the original record
177 return Collections.singletonList(rec);
178 }
179 Partition split = Partition.removeAllRef(partition);
180 if (mBreakMnps) {
181 split = Partition.breakMnps(split);
182 }
183 if (mBreakIndels) {
184 split = Partition.peelIndels(split);
185 }
186 if (split.size() == 0) { // Was a ref only call
187 return Collections.singletonList(rec); // Keep original
188 }
189 if (split.size() == 1 && split.get(0).getAlleles()[0].length() == rec.getRefCall().length() - pad) {
190 if ((pad == 0) || (pad == 1 && needsAnchorBase(split.get(0).getAlleles()))) {
191 return Collections.singletonList(rec); // Keep original
192 }
193 }
194 ++mTotalCallsSplit;
195 final ArrayList<VcfRecord> res = new ArrayList<>(split.size());
196 for (final Slice s : split) {
197 final VcfRecord splitRecord = new VcfRecord(rec);
198 splitRecord.setInfo(ORP, String.valueOf(rec.getStart() + 1)); // 1-based for output
199 splitRecord.setInfo(ORL, String.valueOf(rec.getRefCall().length()));
200 final String[] alleles = s.getAlleles();
201 final boolean needAnchor = needsAnchorBase(alleles);
202 final int offset = s.getOffset() + pad;
203 final int start = splitRecord.getStart() + offset;
204
205 final boolean left;
206 final char anchor;
207 if (mTemplate != null) {
208 left = true;
209 anchor = DnaUtils.base(mCurrentSequence, start - 1);
210 } else {

Callers

nothing calls this directly

Calls 15

updateTemplateMethod · 0.95
getAltCallsMethod · 0.95
partitionMethod · 0.95
userLogMethod · 0.95
removeAllRefMethod · 0.95
breakMnpsMethod · 0.95
peelIndelsMethod · 0.95
needsAnchorBaseMethod · 0.95
setInfoMethod · 0.95
getStartMethod · 0.95
baseMethod · 0.95

Tested by

no test coverage detected