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 downsample #222

Merged
merged 3 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flowcraft/generator/templates/downsample_fastq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ process downsample_fastq_{{ pid }} {
{% include "post.txt" ignore missing %}

tag { "${sample_id}" }
publishDir "results/downsample_fastq_{{ pid }}/", pattern: "*_ss.*"

publishDir "results/downsample_fastq_{{ pid }}/", pattern: "*_ss_*.*"

input:
set sample_id, file(fastq_pair) from {{ input_channel }}
Expand All @@ -27,7 +28,7 @@ process downsample_fastq_{{ pid }} {
val clear from checkpointClear_{{ pid }}

output:
set sample_id, file('*_ss.*') into {{ output_channel }}
set sample_id, file('*_ss_*.*') into {{ output_channel }}
{% with task_name="downsample_fastq" %}
{%- include "compiler_channels.txt" ignore missing -%}
{% endwith %}
Expand Down
10 changes: 6 additions & 4 deletions flowcraft/templates/downsample_fastq.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ def main(sample_id, fastq_pair, genome_size, depth, clear, seed):
# print ("Writing R1.fq.gz")
ps = subprocess.Popen(('seqtk', 'sample', parsed_seed, p1, str(ratio)),
stdout=subprocess.PIPE)
with open('{}_ss.fq.gz'.format(bn1), 'w') as outfile:
with open('{}_ss_{}.fq.gz'.format(bn1, str(target_depth)), 'w') as \
outfile:
subprocess.Popen(('gzip', '--fast', '-c'),
stdin=ps.stdout, stdout=outfile )
ps.wait()

# print ("Writing R2.fq.gz")
ps = subprocess.Popen(('seqtk', 'sample', parsed_seed, p2, str(ratio)),
stdout=subprocess.PIPE)
with open('{}_ss.fq.gz'.format(bn2), 'w') as outfile:
with open('{}_ss_{}.fq.gz'.format(bn2, str(target_depth)), 'w') as \
outfile:
subprocess.Popen(('gzip', '--fast', '-c'),
stdin=ps.stdout, stdout=outfile)
ps.wait()
Expand All @@ -157,8 +159,8 @@ def main(sample_id, fastq_pair, genome_size, depth, clear, seed):
os.remove(rp)

else:
shutil.copy(p1, "{}._ss.fq.gz".format(bn1))
shutil.copy(p2, "{}._ss.fq.gz".format(bn2))
os.symlink(p1, "{}_ss_{}.fq.gz".format(bn1, str(target_depth)))
os.symlink(p2, "{}_ss_{}.fq.gz".format(bn2, str(target_depth)))

# Record the original estimated coverage
with open(".report.json", "w") as fh:
Expand Down