-
Notifications
You must be signed in to change notification settings - Fork 142
add MetaBinner #881
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
Merged
Merged
add MetaBinner #881
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
80f1dc8
add MetaBinner
d4straub 213e20a
[automated] Fix code linting
nf-core-bot e5cbdc7
merge dev
d4straub 6665f6e
add script to bin
d4straub 4f5605b
adjust create_metabinner_bins.py usage
d4straub 8230584
update metabinner output
d4straub baab236
refine metabinner output
d4straub 948c3a1
adjust metabinner bin filenames
d4straub 9e4a2cd
adjust metabinner bin file names again
d4straub 6dc9a85
update file publishing, testing, and docs
d4straub 471c9b9
--fix rocrate_readme_sync
d4straub 6f98ee2
ignore metabinner error 1 and 255 and add acknowledgment
d4straub 33eddd5
merge from dev
d4straub a78e110
fix rocrate_readme_sync
d4straub 89e30e9
Update docs/output.md
d4straub 9b0032c
add param bin_metabinner_scale
d4straub 4332440
handle tool version appropriately
d4straub 5d68eb1
update CHANGELOG with acknowledgment
d4straub 41f32b7
merge in dev
d4straub 34ac949
fix rocrate_readme_sync
d4straub ae187a0
split METABINNER into subworkflow
d4straub fbbf820
merge upstream dev
d4straub 04c9e50
fix rocrate_readme_sync
d4straub 981c8f8
Apply suggestion from @dialvarezs
d4straub 3e689bc
Apply suggestion from @dialvarezs
d4straub 17fd583
apply suggestions from code review
d4straub ebb2f12
merge upstream dev
d4straub a4943f9
fix rocrate_readme_sync
d4straub 587cfce
[automated] Fix code linting
nf-core-bot dfb2e07
clean up unzipped file
d4straub 33f87a5
merge upstream dev
d4straub 0ab6474
fix rocrate_readme_sync
d4straub 8f432dd
min_contig_size now via process input val instead of task.ext.
d4straub 96da27f
Merge remote-tracking branch 'upstream/dev' into add-MetaBinner
dialvarezs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| ## Originally written by Hesham Almessady (@HeshamAlmessady) and Adrian Fritz (@AlphaSquad) in https://github.com/hzi-bifo/mag and released under the MIT license. | ||
| ## See git repository (https://github.com/nf-core/mag) for full license text. | ||
|
|
||
| import sys | ||
| import os | ||
| from Bio import SeqIO | ||
|
|
||
| def main(): | ||
| # Argument parsing | ||
| if len(sys.argv) != 6: | ||
| print("Usage: python create_metabinner_bins.py <binning_file> <fasta_file> <output_path> <prefix> <length_threshold>") | ||
| sys.exit(1) | ||
|
|
||
| binning = sys.argv[1] | ||
| fasta = sys.argv[2] | ||
| path = sys.argv[3] | ||
| prefix = sys.argv[4] | ||
| length = int(sys.argv[5]) | ||
|
|
||
| # Create output directory if it doesn't exist | ||
| os.makedirs(path, exist_ok=True) | ||
|
|
||
| # Load binning data into a dictionary | ||
| Metabinner_bins = {} | ||
| with open(binning, 'r') as b: | ||
| for line in b: | ||
| contig, bin = line.strip().split('\t') | ||
| Metabinner_bins[contig] = bin | ||
|
|
||
| # Process the input fasta file | ||
| with open(fasta) as handle: | ||
| for record in SeqIO.parse(handle, "fasta"): | ||
| if len(record) < length: | ||
| f = prefix + ".tooShort.fa" | ||
| elif record.id not in Metabinner_bins: | ||
| f = prefix + ".unbinned.fa" | ||
| else: | ||
| f = prefix + "." + Metabinner_bins[record.id] + ".fa" | ||
| with open(os.path.join(path, f), 'a') as out: | ||
| SeqIO.write(record, out, "fasta") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,4 +39,5 @@ params { | |
| gtdbtk_skip_aniscreen = true | ||
| skip_concoct = true | ||
| skip_comebin = true | ||
| skip_metabinner = true | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - bioconda::metabinner=1.4.4-0 | ||
d4straub marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| process METABINNER_BINS { | ||
| tag "$meta.id" | ||
| label 'process_low' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
| 'https://depot.galaxyproject.org/singularity/metabinner:1.4.4--hdfd78af_0' : | ||
| 'quay.io/biocontainers/metabinner:1.4.4--hdfd78af_0' }" | ||
|
|
||
| input: | ||
| tuple val(meta), path(fasta), path(membership) | ||
| val val_min_contig_size | ||
|
|
||
| output: | ||
| tuple val(meta), path("*.tooShort.fa.gz") , emit: tooshort | ||
| tuple val(meta), path("*.unbinned.fa.gz") , emit: unbinned | ||
| tuple val(meta), path("bins/*.fa.gz") , emit: bins | ||
| path "versions.yml" , emit: versions | ||
|
|
||
| script: | ||
| def prefix = task.ext.prefix ?: "${meta.id}" | ||
| def min_contig_size = val_min_contig_size ?: "1000" | ||
| """ | ||
| # unzip membership file | ||
| zcat ${membership} > membership.tsv | ||
|
|
||
| # collect bins & un-binned fractions | ||
| create_metabinner_bins.py \\ | ||
| membership.tsv \\ | ||
| ${fasta} \\ | ||
| ./bins \\ | ||
| ${prefix} \\ | ||
| ${min_contig_size} | ||
| find ./bins/ -name "*.fa" -type f | xargs -t -n 1 bgzip -@ ${task.cpus} | ||
|
|
||
| # zip contig fractions | ||
| find ./bins/ -name "*[tooShort,unbinned].fa.gz" -type f -exec mv {} . \\; | ||
|
|
||
| cat <<-END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| python: \$(python --version 2>&1 | sed 's/Python //g') | ||
| END_VERSIONS | ||
| """ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - bioconda::metabinner=1.4.4-0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| process METABINNER_KMER { | ||
| tag "$meta.id" | ||
| label 'process_low' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
| 'https://depot.galaxyproject.org/singularity/metabinner:1.4.4--hdfd78af_0' : | ||
| 'quay.io/biocontainers/metabinner:1.4.4--hdfd78af_0' }" | ||
|
|
||
| input: | ||
| tuple val(meta), path(fasta) | ||
| val val_min_contig_size | ||
|
|
||
| output: | ||
| tuple val(meta), path("*_kmer_4_f${min_contig_size}.csv.gz"), emit: composition_profile | ||
| path "versions.yml" , emit: versions | ||
|
|
||
| script: | ||
| def prefix = task.ext.prefix ?: "${meta.id}" | ||
| min_contig_size = val_min_contig_size ?: "1000" | ||
| def VERSION = '1.4.4-0' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. | ||
| """ | ||
| metabinner_path=\$(dirname \$(which run_metabinner.sh)) | ||
|
|
||
| # create composition profile (contigs > ${min_contig_size} p (default 1000), k = 4) | ||
| python \${metabinner_path}/scripts/gen_kmer.py ${fasta} ${min_contig_size} 4 | ||
|
|
||
| gzip -cn ${fasta.baseName}_kmer_4_f${min_contig_size}.csv > ${prefix}_kmer_4_f${min_contig_size}.csv.gz | ||
|
|
||
| cat <<-END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| MetaBinner: $VERSION | ||
| python: \$(python --version 2>&1 | sed 's/Python //g') | ||
| END_VERSIONS | ||
| """ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - bioconda::metabinner=1.4.4-0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.