Skip to content

Commit c5d74cc

Browse files
committed
hotfix sporadic full read DNA read miss
1 parent af34c04 commit c5d74cc

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

src/svirlpool/localassembly/consensus.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def _cpu_has_avx2() -> bool:
5252
platforms are assumed to be modern enough or are not the target platform).
5353
"""
5454
import platform
55+
5556
if platform.system() != "Linux":
5657
return True
5758
try:
@@ -273,10 +274,31 @@ def get_full_read_sequences_of_alignments(
273274
):
274275
break
275276
# check if for each readname in dict_supplementary_positions, there is a SeqRecord in dict_read_sequences
276-
for readname in dict_supplementary_positions.keys():
277-
if readname not in dict_read_sequences:
277+
if dict_supplementary_positions:
278+
total = len(dict_supplementary_positions)
279+
missing = [
280+
rn for rn in dict_supplementary_positions if rn not in dict_read_sequences
281+
]
282+
found = total - len(missing)
283+
284+
if total <= 3 and found == 0:
285+
log.warning(
286+
f"No read sequences could be acquired for {total} hard-clipped read(s): "
287+
f"{', '.join(missing)}. Terminating assembly for this region."
288+
)
289+
return {}
290+
291+
if found / total < 0.8:
278292
raise ValueError(
279-
f"readname {readname} not found in dict_read_sequences. Make sure that at least one alignment of the read brings the full read sequence with it."
293+
f"Only {found}/{total} ({100 * found / total:.0f}%) read sequences could be acquired from "
294+
f"supplementary alignments. Missing reads: {', '.join(missing)}. "
295+
f"Make sure that at least one alignment of each read brings the full read sequence with it."
296+
)
297+
298+
if missing:
299+
log.warning(
300+
f"Not all read sequences could be acquired: {found}/{total} found. "
301+
f"Missing read(s): {', '.join(missing)}."
280302
)
281303
# for all other alignments, just add the sequence and reverse flag
282304
for crID in crIDs:

0 commit comments

Comments
 (0)