Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix samtools piping #325

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 18 additions & 14 deletions CRISPResso2/CRISPRessoWGSCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,18 @@ def write_trimmed_fastq(in_bam_filename, bpstart, bpend, out_fastq_filename):
n_reasd (int): number of reads written to the output fastq file
"""
p = sb.Popen(
'samtools view %s | cut -f1,4,6,10,11' % in_bam_filename,
stdout = sb.PIPE,
stderr = sb.STDOUT,
shell=True
)

output=p.communicate()[0].decode('utf-8')
n_reads=0
f'samtools view {in_bam_filename} | cut -f1,4,6,10,11',
stdout=sb.PIPE,
stderr=sb.PIPE,
shell=True,
text=True,
)

output, stderr = p.communicate()
n_reads = 0
if stderr:
logger.debug('Stderr from samtools view:')
logger.debug(stderr)

with gzip.open(out_fastq_filename, 'wt') as outfile:
for line in output.split('\n'):
Expand Down Expand Up @@ -318,13 +322,13 @@ def print_stacktrace_if_debug():
))
sys.exit()

parser = CRISPRessoShared.getCRISPRessoArgParser(parser_title = 'CRISPRessoWGS Parameters', required_params=[],
parser = CRISPRessoShared.getCRISPRessoArgParser(parser_title = 'CRISPRessoWGS Parameters', required_params=[],
suppress_params=['bam_input',
'bam_chr_loc'
'fastq_r1',
'fastq_r2',
'amplicon_seq',
'amplicon_name',
'bam_chr_loc',
'fastq_r1',
'fastq_r2',
'amplicon_seq',
'amplicon_name',
])

#tool specific optional
Expand Down