Skip to content

Commit

Permalink
Full workflow, with explicit outputs and TODOs resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
aw-watson committed Sep 6, 2024
1 parent 56e79a0 commit f4e8762
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/__pycache__/*
.nextflow*
*/work/*
*/logs/*
*/logs/*
**/ec_info/*
27 changes: 27 additions & 0 deletions runAnnotation/bin/check_server_up.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env perl

use FindBin qw($Bin);
use Getopt::Long;
use strict;
use warnings;
use LWP::UserAgent;

my $url;

GetOptions(
"url=s" => \$url
);


my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $up=0;
my $response = $ua->get($url);

if ($response->is_success) {
$up=1
}
else {
die("$url is not up!")
}
44 changes: 30 additions & 14 deletions runAnnotation/runAnnotation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ process prokkaAnnotate {
val kingdom

output:
path "Annotation.log"
path "${params.projName}.gff", emit: gff
path "*"
path "${params.projName}.err"
path "${params.projName}.faa"
path "${params.projName}.ffn"
path "${params.projName}.fna"
path "${params.projName}.fsa"
path "${params.projName}.gbk"
path "${params.projName}.log"
path "${params.projName}.sqn"
path "${params.projName}.tbl"
path "${params.projName}.tsv"
path "${params.projName}.txt"
path "*.hmm.*", optional:true

script:
def kingdom = kingdom.trim()
Expand Down Expand Up @@ -74,8 +86,11 @@ process rattAnnotate {
path gbk

output:
path "Annotation.log"
path "${params.projName}.gff", emit: gff
path "*"
path "${params.projName}.faa"
path "${params.projName}.fna"
path "${params.projName}.gbk"

shell:
//happens in work directory
Expand Down Expand Up @@ -105,7 +120,10 @@ process annPlot {
path gff

output:
path "*"
path "plot_gff3.log"
path "annotation_stats_plots.pdf"
path "${params.projName}.txt", optional:true
//see what goes missing if we only publish that

script:
def rattReport = params.annotateProgram.equalsIgnoreCase("ratt") ? "awk \'\$1 ~ /CDS|RNA/ {print \$1\": \"\$2}' plot_gff3.log > ${params.projName}.txt" : ""
Expand All @@ -115,7 +133,7 @@ process annPlot {
"""
}

process keggPlot {
process keggPlots {
publishDir(
path: "$params.outDir/AssemblyBasedAnalysis/Annotation",
mode: 'copy'
Expand All @@ -125,14 +143,14 @@ process keggPlot {
path gff

output:
path "*"
path "kegg_map/*"
path "kegg_map.log"

script:
//TODO: check server upstatus
//TODO: will eventually need UI integration.
"""
check_server_up.pl --url "http://rest.kegg.jp" && \
opaver_anno.pl -g $gff -o ./kegg_map -p $params.projName > kegg_map.log 2>&1
"""
}

Expand All @@ -147,24 +165,22 @@ workflow {
kingdom_ch = channel.of(params.taxKingdom)
hmm_ch = channel.fromPath(params.customHMM, checkIfExists:true)
prot_ch = channel.fromPath(params.customProtein, checkIfExists:true)
if (params.taxKingdom == null) {
kingdom_ch = unsetKingdom(contig_ch)
}
//TODO: add safety for bad source reference GenBank file
if (params.annotateProgram =~ /(?i)prokka/) {

if (params.taxKingdom == null) {
kingdom_ch = unsetKingdom(contig_ch)
}
prokkaAnnotate(contig_ch, prot_ch, hmm_ch, kingdom_ch)
annPlot(prokkaAnnotate.out.gff)
if(params.keggView == true) {
keggPlot(prokkaAnnotate.out.gff)
keggPlots(prokkaAnnotate.out.gff)
}
}
else if (params.annotateProgram =~ /(?i)ratt/) {
gb_ch = channel.fromPath(params.sourceGBK, checkIfExists:true)
rattAnnotate(contig_ch, gb_ch)
annPlot(rattAnnotate.out.gff)
if(params.keggView == true) {
keggPlot(rattAnnotate.out.gff)
keggPlots(rattAnnotate.out.gff)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"inputContigs": "test_files/contigs_700up.fa",
"taxKingdom": "Bacteria",
"evalue": "1e-09",
"gcode": "11",
"keggView": true,
"outDir": "prokka_ann",
"customHMM": "test_files/HAMAP.hmm"
}

0 comments on commit f4e8762

Please sign in to comment.