Skip to content

Commit

Permalink
ensure we fail when conversion of hic pairs fails, don't track mis-so…
Browse files Browse the repository at this point in the history
…rted reads to save memory
  • Loading branch information
skoren committed May 13, 2024
1 parent 4b1f5a4 commit 932e872
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Snakefiles/8-hicPipeline.sm
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ rule transformBWA:
cd 8-hicPipeline

cat > ./transform_bwa.sh <<EOF
#!/bin/sh
set -e
#!/usr/bin/env bash
set -e -o pipefail
{params.SAMTOOLS} view -q 1 ../{input.bwa_mapping} | {PYTHON} {VERKKO}/scripts/parse_sam_pairs.py > ../{output.byread_mapping}
EOF

Expand Down
10 changes: 0 additions & 10 deletions src/scripts/parse_sam_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,15 @@ def print_results(names):

name = ""
names = [ ]
seen = {}
out_of_order = 0

for line in input_stream:
line=line.split()
if name == "":
name = line[0]
if name != line[0]:
seen[name] = 1
print_results(names)
name = line[0]
names = [ ]
if name in seen:
print("Warning: read %s already seen but encountered it again, please confirm your bam file is sorted by read."%(name), file=sys.stderr)
out_of_order += 1
names.append("%s\t%s"%(line[0], line[2]))

if out_of_order > 1000:
print("Error: encountered too many unsorted reads (%d), exiting. Please confirm the input bam is sorted by read."%(out_of_order), file=sys.stderr)
sys.exit(1)

print_results(names)

0 comments on commit 932e872

Please sign in to comment.