Hello, Are there any existing modules available to...
# modules
m
Hello, Are there any existing modules available to extract read IDs from BAM files? I couldn’t find anything similar among the nf-core modules. I currently have a custom module that performs this task, but I’d prefer to replace it with an nf-core module if one is available —or contribute my implementation if it would be useful.
m
I'm not sure if there is, but technically the
samtools view
module could be abused to give you want you need.
ext.args2
could be supplied with a pipe command and you write out the read IDs to a file captured by an optional channel.
m
Thank you for your reply. I will give it a try
s
technically possible, but not necessarily a good idea 😉
this 1
m
Hello @Simon Pearce, can you say more as why it's not a good idea? Do you think it would be relevant to contribute my implementation to nf-core modules?
s
the samtools view module emits:
Copy code
tuple val(meta), path("${prefix}.bam"), emit: bam, optional: true
    tuple val(meta), path("${prefix}.cram"), emit: cram, optional: true
    tuple val(meta), path("${prefix}.sam"), emit: sam, optional: true
    tuple val(meta), path("${prefix}.${file_type}.bai"), emit: bai, optional: true
    tuple val(meta), path("${prefix}.${file_type}.csi"), emit: csi, optional: true
    tuple val(meta), path("${prefix}.${file_type}.crai"), emit: crai, optional: true
    tuple val(meta), path("${prefix}.unselected.${file_type}"), emit: unselected, optional: true
    tuple val(meta), path("${prefix}.unselected.${file_type}.{csi,crai}"), emit: unselected_index, optional: true
so yes, you could write some code that writes e.g. a
foo.crai
file that contains the read names (but is NOT an index), but that would be weird and unintuitive
m
I also remember too late that we're able to make changes to modules incorporated into pipelines and then use
nf-core modules patch <tool/subtool>
to maintain a diff so the module is updatable, but keeps the changes you make. E,g. you can do
Copy code
nf-core modules install samtools/view
vim modules/nf-core/samtools/view/main.nf # edit the file to include post processing and new output channel
nf-core modules patch samtools/view
git add modules/nf-core/samtools/view/
git commit ...
s
yeah, that is also true