Skip to content

Commit

Permalink
Merge pull request #93 from PixelgenTechnologies/improve-read-renaming
Browse files Browse the repository at this point in the history
Improve read renaming
  • Loading branch information
fbdtemme authored May 28, 2024
2 parents f0bc911 + 6407896 commit 7e470cc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [[PR #90](https://github.com/nf-core/pixelator/pull/90)] - The `graph` and `annotate` steps are now using `process_high` as their resource tags
- [[PR #91](https://github.com/nf-core/pixelator/pull/91)] - Set `process_high` to use 64GB of RAM and `process_high_memory` to use 128GB of RAM
- [[PR #92](https://github.com/nf-core/pixelator/pull/92)] - Minor touch-ups to the documentation
- [[PR #93](https://github.com/nf-core/pixelator/pull/93)] - Merge RENAME_READS functionality into PIXELATOR_AMPLICON

### Software dependencies

Expand Down
7 changes: 0 additions & 7 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ process {
publishDir = [ enabled: false ]
}

withName: RENAME_READS {
publishDir = [
enabled: false,
path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
]
}


// use explicit (params.my_option instanceof Integer) checks to avoid issues with 0 evaluating false
// since most pixelator flags do accept zero as a value
Expand Down
22 changes: 21 additions & 1 deletion modules/local/pixelator/single-cell/amplicon/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ process PIXELATOR_AMPLICON {
def prefix = task.ext.prefix ?: "${meta.id}"
def args = task.ext.args ?: ''

// Make list of old name and new name pairs to use for renaming in the bash while loop
def old_new_pairs = (reads instanceof Path || reads.size() == 1)
? [[ reads, "${prefix}${getFileSuffix(reads)}" ]]
: reads.withIndex().collect { entry, index -> [ entry, "${prefix}_${index + 1}${getFileSuffix(entry)}" ] }

def rename_to = old_new_pairs*.join(' ').join(' ')
def renamed_reads = old_new_pairs.collect { old_name, new_name -> new_name }.join(' ')

"""
printf "%s %s\\n" $rename_to | while read old_name new_name; do
[ -f "\${new_name}" ] || ln -s \$old_name \$new_name
done
pixelator \\
--cores $task.cpus \\
--log-file ${prefix}.pixelator-amplicon.log \\
Expand All @@ -35,11 +47,19 @@ process PIXELATOR_AMPLICON {
amplicon \\
--output . \\
$args \\
${reads}
${renamed_reads}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pixelator: \$(echo \$(pixelator --version 2>/dev/null) | sed 's/pixelator, version //g' )
END_VERSIONS
"""
}


// for .gz files also include the second to last extension if it is present. E.g., .fasta.gz
// Source: nf-core/modules/cat/cat
def getFileSuffix(filename) {
def match = filename =~ /^.*?((\.\w{1,5})?(\.\w{1,5}\.gz$))/
return match ? match[0][1] : filename.substring(filename.lastIndexOf('.'))
}
45 changes: 0 additions & 45 deletions modules/local/rename_reads.nf

This file was deleted.

11 changes: 1 addition & 10 deletions workflows/pixelator.nf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ include { CAT_FASTQ } from '../modules/nf-core/cat/fastq/main'
//
// MODULE: Defined locally
//
include { RENAME_READS } from '../modules/local/rename_reads'
include { PIXELATOR_COLLECT_METADATA } from '../modules/local/pixelator/collect_metadata'
include { PIXELATOR_AMPLICON } from '../modules/local/pixelator/single-cell/amplicon/main'
include { PIXELATOR_QC } from '../modules/local/pixelator/single-cell/qc/main'
Expand Down Expand Up @@ -126,18 +125,10 @@ workflow PIXELATOR {

ch_versions = ch_versions.mix(CAT_FASTQ.out.versions.first())


//
// MODULE: Rename input reads to match the sample ids from the samplesheet
//
RENAME_READS ( ch_cat_fastq )
ch_renamed_reads = RENAME_READS.out.reads
ch_versions = ch_versions.mix(RENAME_READS.out.versions.first())

//
// MODULE: Run pixelator single-cell amplicon
//
PIXELATOR_AMPLICON ( ch_renamed_reads )
PIXELATOR_AMPLICON ( ch_cat_fastq )
ch_merged = PIXELATOR_AMPLICON.out.merged
ch_versions = ch_versions.mix(PIXELATOR_AMPLICON.out.versions.first())

Expand Down

0 comments on commit 7e470cc

Please sign in to comment.