Skip to content

Commit

Permalink
add visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
luisas committed Dec 9, 2024
1 parent 7eb9b66 commit fffd09e
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/toolsheet.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tree,args_tree,aligner,args_aligner
FAMSA,,FOLDMASON,
FAMSA,,FAMSA,
12 changes: 12 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,16 @@
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

//
// Visualization
//
withName: 'FOLDMASON_MSA2LDDTREPORT' {
ext.prefix = { "${meta.id}_${meta.tree}-args-${meta.argstree_clean}_${meta.aligner}-args-${meta.args_aligner_clean}" }
publishDir = [
path: { "${params.outdir}/visualization" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}
}
3 changes: 2 additions & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
"git_sha": "1f94c91de2b9e9c6b42fca53e823cada9a8b8465",
"installed_by": [
"modules"
]
],
"patch": "modules/nf-core/tcoffee/extractfrompdb/tcoffee-extractfrompdb.diff"
},
"tcoffee/irmsd": {
"branch": "master",
Expand Down
45 changes: 45 additions & 0 deletions modules/local/foldmason_createdb.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
process FOLDMASON_CREATEDB {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "community.wave.seqera.io/library/foldmason:512dd7b3e2453a75"

input:
tuple val(meta) , path(pdbs)

output:
tuple val(meta), path("${prefix}*"), emit: db
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
foldmason createdb \\
${pdbs} \\
${prefix} \\
$args \\
--threads $task.cpus
cat <<-END_VERSIONS > versions.yml
"${task.process}":
foldmason: \$(foldmason | grep "foldmason Version:" | cut -d":" -f 2 | awk '{\$1=\$1;print}')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
foldmason: \$(foldmason | grep "foldmason Version:" | cut -d":" -f 2 | awk '{\$1=\$1;print}')
END_VERSIONS
"""
}
51 changes: 51 additions & 0 deletions modules/local/foldmason_msa2lddtreport.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
process FOLDMASON_MSA2LDDTREPORT {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "community.wave.seqera.io/library/foldmason:512dd7b3e2453a75"

input:
tuple val(meta) , path(msa)
tuple val(meta2) , path(db)
tuple val(meta3) , path(pdbs)
tuple val(meta4) , path(tree)

output:
tuple val(meta), path("${prefix}.html"), emit: html
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
def options_tree = tree ? "--guide-tree $tree" : ""
"""
foldmason msa2lddtreport \\
${meta.id} \\
${msa} \\
${prefix}.html \\
$args \\
${options_tree} \\
--threads $task.cpus
cat <<-END_VERSIONS > versions.yml
"${task.process}":
foldmason: \$(foldmason | grep "foldmason Version:" | cut -d":" -f 2 | awk '{\$1=\$1;print}')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.html
cat <<-END_VERSIONS > versions.yml
"${task.process}":
foldmason: \$(foldmason | grep "foldmason Version:" | cut -d":" -f 2 | awk '{\$1=\$1;print}')
END_VERSIONS
"""
}
43 changes: 43 additions & 0 deletions modules/nf-core/tcoffee/extractfrompdb/tcoffee-extractfrompdb.diff

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ params {
skip_shiny = false
shiny_trace_mode = "latest" // all, latest

// Visualisation options
skip_visualisation = false

// Config options
config_profile_name = null
config_profile_description = null
Expand Down
5 changes: 5 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@
"shiny_trace_mode": {
"type": "string",
"description": "variable containing the shiny_trace mode to be used."
},
"skip_visualisation": {
"type": "boolean",
"fa_icon": "fas fa-fast-forward",
"description": "Skip the visualization generation."
}
}
},
Expand Down
1 change: 1 addition & 0 deletions subworkflows/local/align.nf
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,6 @@ workflow ALIGN {

emit:
msa = ch_msa // channel: [ val(meta), path(msa) ]
trees = trees // channel: [ val(meta), path(tree) ]
versions = ch_versions // channel: [ versions.yml ]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

include { TCOFFEE_EXTRACTFROMPDB } from '../../modules/nf-core/tcoffee/extractfrompdb/main'
workflow PREPROCESS_OPTIONALDATA {

workflow PREPROCESS {
take:
ch_optional_data //channel: [ meta, [file1, ] ]

Expand Down
69 changes: 69 additions & 0 deletions subworkflows/local/visualization.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
include {FOLDMASON_CREATEDB } from '../../modules/local/foldmason_createdb.nf'
include {FOLDMASON_MSA2LDDTREPORT } from '../../modules/local/foldmason_msa2lddtreport.nf'

workflow VISUALIZATION {

take:
ch_msa // channel: [ meta, /path/to/file.* ]
ch_trees // channel: [ meta, /path/to/file.* ]
ch_optional_data // channel: [ meta, /path/to/file.* ]

main:

ch_versions = Channel.empty()
ch_html = Channel.empty()


// Merge the msa and tree
// split the msa meta to be able to merge with the tree meta
ch_msa
.map{
meta, file -> [meta.subMap(["id", "tree", "args_tree", "args_tree_clean"]), meta, file]
}
.join( ch_trees, by:0, remainder: true)
.filter { it.size() == 4 }
.map{
tree_meta, meta, msa, tree -> [meta.subMap(["id"]), meta, msa, tree]
}
.join( ch_optional_data, by:0)
.set { ch_msa_tree_data }


ch_optional_data.view()
//
// FOLDMASON VISUALISATION
//

FOLDMASON_CREATEDB(
ch_optional_data
)


ch_msa_tree_data
.combine(FOLDMASON_CREATEDB.out.db, by:0)
.multiMap{
id, meta, msafile, treefile, pdb, dbfiles ->
msa: [meta, msafile]
db: [id , dbfiles]
pdbs: [id , pdb]
tree: [meta, treefile == null ? [] : treefile]
}.set{
ch_msa_db_tree
}

ch_msa_db_tree.tree.view()

FOLDMASON_MSA2LDDTREPORT(
ch_msa_db_tree.msa,
ch_msa_db_tree.db,
ch_msa_db_tree.pdbs,
ch_msa_db_tree.tree
)

ch_html = FOLDMASON_MSA2LDDTREPORT.out.html

emit:
html = ch_html
versions = ch_versions

}
19 changes: 15 additions & 4 deletions workflows/multiplesequencealign.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ include { STATS } from '../subworkflows/local/stats'
include { ALIGN } from '../subworkflows/local/align'
include { EVALUATE } from '../subworkflows/local/evaluate'
include { TEMPLATES } from '../subworkflows/local/templates'
include { PREPROCESS_OPTIONALDATA} from '../subworkflows/local/preprocess_optionaldata'
include { PREPROCESS } from '../subworkflows/local/preprocess'
include { VISUALIZATION } from '../subworkflows/local/visualization'


//
// MODULE: local modules
Expand Down Expand Up @@ -177,9 +179,9 @@ workflow MULTIPLESEQUENCEALIGN {
ch_versions = ch_versions.mix(FASTAVALIDATOR.out.versions)

if(!params.skip_preprocessing){
PREPROCESS_OPTIONALDATA(ch_optional_data)
ch_optional_data = PREPROCESS_OPTIONALDATA.out.preprocessed_optionaldata
ch_versions = ch_versions.mix(PREPROCESS_OPTIONALDATA.out.versions)
PREPROCESS(ch_optional_data)
ch_optional_data = PREPROCESS.out.preprocessed_optionaldata
ch_versions = ch_versions.mix(PREPROCESS.out.versions)
}


Expand Down Expand Up @@ -259,6 +261,15 @@ workflow MULTIPLESEQUENCEALIGN {
ch_versions = ch_versions.mix(PREPARE_SHINY.out.versions)
}


if (!params.skip_visualisation) {
VISUALIZATION (
ALIGN.out.msa,
ALIGN.out.trees,
ch_optional_data
)
}

softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
Expand Down

0 comments on commit fffd09e

Please sign in to comment.