Skip to content

Commit

Permalink
Fix/prepare fastqs self compatibility 20240521 (#9)
Browse files Browse the repository at this point in the history
* prepare_fastqs should now be able to import its output

* fix: allow to keep alignment files via --keep_alignment_file, v.0.12.7
  • Loading branch information
cschu authored Jun 20, 2024
1 parent 5b0e543 commit 663af34
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions bin/prepare_fastqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,14 @@ def process_sample(

print("PRE", prefixes, file=sys.stderr)

def rx_filter(s, x=1):
return re.search(r"[._R]" + str(x) + r"$", s) and not re.search(r"(orphan|single)s?", s)

# partition fastqs into R1, R2, and 'other' sets
r1 = [(p, f) for p, f in zip(prefixes, fastqs) if re.search(r"[._R]1$", p)]
r2 = [(p, f) for p, f in zip(prefixes, fastqs) if re.search(r"[._R]2$", p)]
# r1 = [(p, f) for p, f in zip(prefixes, fastqs) if re.search(r"[._R]1$", p)]
r1 = [(p, f) for p, f in zip(prefixes, fastqs) if rx_filter(p, x=1)]
# r2 = [(p, f) for p, f in zip(prefixes, fastqs) if re.search(r"[._R]2$", p)]
r2 = [(p, f) for p, f in zip(prefixes, fastqs) if rx_filter(p, x=2)]
others = sorted(list(set(fastqs).difference({f for _, f in r1}).difference({f for _, f in r2})))

# check if R1/R2 sets have equal sizes or are empty
Expand All @@ -180,7 +185,7 @@ def process_sample(
if len(r1) == len(r2) and r1:
check_pairwise(r1, r2)

# sort R1/R2 for concatenation, get rid off prefixes
# sort R1/R2 for concatenation, get rid of prefixes
r1 = sorted(f for _, f in r1)
r2 = sorted(f for _, f in r2)

Expand Down
6 changes: 4 additions & 2 deletions nevermore/modules/profilers/gffquant.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process stream_gffquant {
tuple val(sample), path("profiles/${sample}/*.{txt.gz,pd.txt}"), emit: results //, optional: (!params.gq_panda) ? true : false
tuple val(sample), path("profiles/${sample}/*.{txt.gz,pd.txt}"), emit: profiles //, optional: (params.gq_panda) ? true : false
tuple val(sample), path("logs/${sample}.log")
tuple val(sample), path("alignments/${sample}*.sam"), emit: alignments, optional: true
tuple val(sample), path("alignments/${sample}/${sample}*.sam"), emit: alignments, optional: true

script:
def gq_output = "-o profiles/${sample}/${sample}"
Expand All @@ -22,7 +22,7 @@ process stream_gffquant {
gq_params += (params.gq_min_seqlen) ? (" --min_seqlen " + params.gq_min_seqlen) : ""
gq_params += (params.gq_min_identity) ? (" --min_identity " + params.gq_min_identity) : ""
gq_params += (params.gq_restrict_metrics) ? " --restrict_metrics ${params.gq_restrict_metrics}" : ""
gq_params += (params.gq_keep_alignments) ? " --keep_alignment_file ${sample}.sam" : ""
gq_params += (params.gq_keep_alignments) ? " --keep_alignment_file alignments/${sample}.sam" : ""
gq_params += (params.gq_unmarked_orphans) ? " --unmarked_orphans" : ""

gq_params += " -t ${task.cpus}"
Expand Down Expand Up @@ -57,10 +57,12 @@ process stream_gffquant {
}

def gq_cmd = "gffquant ${gq_output} ${gq_params} --db GQ_DATABASE --reference \$(readlink ${reference}) --aligner ${params.gq_aligner} ${input_files}"
def mkdir_alignments = (params.keep_alignment_file != null && params.keep_alignment_file != false) ? "mkdir -p alignments/${sample}/" : ""

"""
set -e -o pipefail
mkdir -p logs/ tmp/ profiles/
${mkdir_alignments}
echo 'Copying database...'
cp -v ${gq_db} GQ_DATABASE
${gq_cmd} &> logs/${sample}.log
Expand Down
2 changes: 1 addition & 1 deletion nevermore/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.12.6"
"version": "0.12.7"
}
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ manifest {
description = "Metaomics pipeline toolbox"
name = "nevermore"
nextflowVersion = ">=22.10.6"
version = "0.12.6"
version = "0.12.7"
}

0 comments on commit 663af34

Please sign in to comment.