Skip to content

Commit

Permalink
Clean up functional annotation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sminot committed Oct 30, 2023
1 parent f350f58 commit c6763f4
Showing 1 changed file with 45 additions and 24 deletions.
69 changes: 45 additions & 24 deletions modules/annotation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,38 @@ workflow Annotation_wf {
run_eggnog = false
if ( params.noannot == false ) {
if ( params.eggnog_db && params.eggnog_dmnd ) {
if ( !file(params.eggnog_db).isEmpty() && !file(params.eggnog_dmnd).isEmpty() ){
eggnog_db = file(params.eggnog_db)
eggnog_dmnd = file(params.eggnog_dmnd)

if ( eggnog_db.isEmpty() ){
log.info"Cannot find file ${params.eggnog_db}, skipping functional annotation"
}
if ( eggnog_dmnd.isEmpty() ){
log.info"Cannot find file ${params.eggnog_dmnd}, skipping functional annotation"
}

if ( !eggnog_db.isEmpty() && !eggnog_dmnd.isEmpty() ){
run_eggnog = true
}

} else {

if ( params.eggnog_db ) {
log.info"Missing --eggnog_dmnd, skipping functional annotation"
}
if ( params.eggnog_dmnd ) {
log.info"Missing --eggnog_db, skipping functional annotation"
}

}
}

// Annotate the clustered genes with eggNOG
if ( run_eggnog ){
eggnog(
shard_genes.out.flatten(),
file(params.eggnog_db),
file(params.eggnog_dmnd)
eggnog_db,
eggnog_dmnd
)
eggnog_tsv = eggnog.out.collect()
} else {
Expand All @@ -84,8 +104,11 @@ workflow Annotation_wf {
run_tax = false
if ( params.noannot == false ) {
if ( params.taxonomic_dmnd ) {
if ( !file(params.taxonomic_dmnd).isEmpty() ){
taxonomic_dmnd = file(taxonomic_dmnd)
if ( !taxonomic_dmnd.isEmpty() ){
run_tax = true
} else {
log.info"Cannot find ${params.taxonomic_dmnd}, skipping taxonomic annotation"
}
}
}
Expand All @@ -94,7 +117,7 @@ workflow Annotation_wf {
if ( run_tax ) {
diamond_tax(
shard_genes.out.flatten(),
file(params.taxonomic_dmnd)
taxonomic_dmnd
)
tax_tsv = diamond_tax.out.collect()
join_tax(
Expand Down Expand Up @@ -262,27 +285,27 @@ def helpMessage() {
""".stripIndent()
}


// Show help message if the user specifies the --help flag at runtime
if (params.help || params.gene_fasta == false || params.output_folder == false){
// Invoke the function above which prints the help message
helpMessage()
// Exit out and do not run anything else
exit 0
}

// Show help message if the user does not specify any annotations
if (params.taxonomic_dmnd == false && params.eggnog_dmnd == false && params.eggnog_db == false){
// Invoke the function above which prints the help message
helpMessage()
// Exit out and do not run anything else
exit 0
}

workflow {

main:


// Show help message if the user specifies the --help flag at runtime
if (params.help || params.gene_fasta == false || params.output_folder == false){
// Invoke the function above which prints the help message
helpMessage()
// Exit out and do not run anything else
exit 0
}

// Show help message if the user does not specify any annotations
if (params.taxonomic_dmnd == false && params.eggnog_dmnd == false && params.eggnog_db == false){
// Invoke the function above which prints the help message
helpMessage()
// Exit out and do not run anything else
exit 0
}

// Make sure we can find the input files
if(file(params.gene_fasta).isEmpty()){
log.info"""Cannot find input file ${params.gene_fasta}""".stripIndent()
Expand All @@ -294,6 +317,4 @@ workflow {
file(params.gene_fasta)
)



}

0 comments on commit c6763f4

Please sign in to comment.