Add coverm/contig to nf-core/modules#997
Conversation
|
Converting this to draft until I add the module logic to the subworkflows, will ping when done. |
|
Update to changes:
|
|
This one is good to go but will require merging nf-core/modules#10588 for the lint checks to pass. |
|
PS all code generated by @claude was reviewed |
|
Making this into draft again until the upstream update to the coverm module is merged. |
c0d42d6 to
55f610f
Compare
Add CoverM to calculate read alignment metrics for contig/bin alignments (nf-core#587) - Run `nf-core modules install coverm/contig` - Create new module directory and modify modules.json
Introduces --coverm_mapper (default: 'bowtie2') to control which aligner is used when estimating contig depths. CoverM-native mappers skip bowtie2 alignment and let CoverM handle reads→depths directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- COVERM_CONTIG_SHORTREAD/LONGREAD replace both METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS variants - bowtie2 path: BAMs → CoverM (bam_input=true) - coverm-native path: reads+assembly → CoverM (bam_input=false) - Add runtime error when BAM-requiring binners are used with coverm-native - Rename emit metabat2depths → contig_depths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add COVERM_CONTIG_SHORTREAD and COVERM_CONTIG_LONGREAD blocks with --methods metabat to output MetaBAT2-compatible depth format. Shortread also passes --mapper for coverm-native aligner selection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CoverM outputs uncompressed depth files; update get_mag_depths.py and CONVERT_DEPTHS to accept both .gz and plain-text inputs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS references with COVERM_CONTIG and update depth file extension from .txt.gz to .txt. Snapshots will need regeneration after the first test run to capture updated version strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add --depth_calculator (coverm|metabat2, default: coverm) to switch between COVERM_CONTIG and METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS for contig depth estimation - Add --coverm_methods with full CoverM methods enum (default: metabat) to configure the coverage calculation method passed to CoverM - Restore METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_SHORTREAD/LONGREAD config blocks in modules.config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update coverm/contig to use eval/topic-based versioning and handle methods as List or string; remove versions.yml generation - Remove ch_versions.mix for COVERM_CONTIG (topic versioning is automatic) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Sync coverm/contig main.nf and meta.yml to reference (eval/topic versioning, List-aware methods string handling) - Remove ch_versions.mix for COVERM_CONTIG calls (topic versioning is automatic; no versions.yml emitted) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add coverm to dependencies - Add nf-core#997 to 'Added' section
- Reflect addition of COVERM_CONTIG as contig depth calculator
- Use version topics
|
This is now ready for review, but changes are extensive so some advice on testing would be welcome. Thanks |
|
Thanks @vinisalazar ! I need to focus on taxprofiler for the next few weeks... @dialvarezs do you think you can go through this? |
prototaxites
left a comment
There was a problem hiding this comment.
Hi @vinisalazar, this looks really good! I have a few thoughts on the implementation that I think it's worth having a discussion about?
| // Validate: BAM-requiring binners cannot be used with CoverM native mappers | ||
| // because no BAM files are produced in that path |
There was a problem hiding this comment.
CoverM will output BAM files if --bam-file-cache-directory is set! We should force that option so we can get them.
There was a problem hiding this comment.
Sounds good to me
subworkflows/local/binning/main.nf
Outdated
| [meta, bams, bais] | ||
| // Validate: BAM-requiring binners cannot be used with CoverM native mappers | ||
| // because no BAM files are produced in that path | ||
| if (params.coverm_mapper != 'bowtie2') { |
There was a problem hiding this comment.
Would suggest we call this param coverage_mapper?
subworkflows/local/binning/main.nf
Outdated
| METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_LONGREAD(ch_summarizedepth_input.longread) | ||
| ch_versions = ch_versions.mix(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_LONGREAD.out.versions) | ||
| // Long reads always come as BAMs (from minimap2) | ||
| if (params.depth_calculator == 'coverm') { |
There was a problem hiding this comment.
IMO, though others may disagree, we should just drop JGISUMMARIZEBAMCONTIGDEPTHS entirely and replace it with CoverM. The outputs in "metabat" mode should be value-for-value identical, and supporting both requires a lot of complicated control flow.
There was a problem hiding this comment.
I agree with this. If CoverM produces a equivalent output, then keeping it it's just unnecessary complexity.
There was a problem hiding this comment.
I would be happy to implement this. Would you need me to rebase this branch and edit the commits I've already made, or is it okay to just add commits on top?
There was a problem hiding this comment.
Commits on top, I'm personally not fussy about super clean git history (unless @dialvarezs @prototaxites have a stronger opinion)
There was a problem hiding this comment.
No, fine with me too. Can always do a squash commit if things are really bad!
There was a problem hiding this comment.
Note I'm the person who is often reluctant to deprecate existing/accepted modules, and often rather prefer keep adding new altenrative options unless there is a very very clear case of something being superior.
But like @dialvarezs says - if the output is the exact same then I'm fine with the older module being deprecated.
| * Binning preparation for short reads | ||
| */ | ||
|
|
||
| include { BOWTIE2_ASSEMBLY_BUILD } from '../../../modules/local/bowtie2_assembly_build/main' |
There was a problem hiding this comment.
Question, would it make sense to move CoverM into this workflow (and drop the long reads one) so that we have a unified place where all coverage estimation happens?
There was a problem hiding this comment.
That makes sense to me too. l'll see how this could be done when working on the "drop the JGIBAMSUMMARIZE..." part.
|
Thanks @prototaxites @dialvarezs @jfy133 for your comments. I have limited time to work on this, but I will try to put in some effort in the next 1-2 weeks. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CoverM in --methods metabat mode produces value-for-value identical output, so JGISUMMARIZEBAMCONTIGDEPTHS and the depth_calculator param are now removed. CoverM is always used for contig depth estimation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…identity shortread_percentidentity and longread_percentidentity previously set --percentIdentity on JGISUMMARIZEBAMCONTIGDEPTHS; now they pass --min-read-percent-identity to COVERM_CONTIG_SHORTREAD and COVERM_CONTIG_LONGREAD respectively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When using a CoverM-native mapper (non-bowtie2), pass --bam-file-cache-directory so that CoverM caches the BAM files it generates internally during alignment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove references to the dropped depth_calculator param and jgi_summarize_bam_contig_depths. Rename coverm_mapper → coverage_mapper throughout. Update percentidentity help text to reference CoverM's --min-read-percent-identity flag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@prototaxites @dialvarezs implemented the changes requested here, starting from e5b6fa2. However, I'm having a hard time interpreting the tests. The ones that passed in the CI still show errors when inspecting the logs, and others just failed. I ran the
I will try to debug to see how to get these tests to pass, but open to suggestions if you have any. |
|
Hey @vinisalazar, I'm going to give a look at this tomorrow. |


Add CoverM to calculate read alignment metrics for contig/bin alignments (#587)
nf-core modules install coverm/contigPR checklist
nf-core pipelines lint).nextflow run . -profile test,docker --outdir <OUTDIR>).nextflow run . -profile debug,test,docker --outdir <OUTDIR>).docs/usage.mdis updated.docs/output.mdis updated.CHANGELOG.mdis updated.README.mdis updated (including new tool citations and authors/contributors).