From 034da34c95d0084c27c0e7d9cc09e1ea5b6a7fa7 Mon Sep 17 00:00:00 2001 From: Jillian Rowe Date: Tue, 28 Feb 2017 10:30:08 +0400 Subject: [PATCH 1/4] read in actual data - not dummy --- lib/BioX/Workflow/Command/REST/run.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/BioX/Workflow/Command/REST/run.pm b/lib/BioX/Workflow/Command/REST/run.pm index cf9d1cf..65fd6a0 100644 --- a/lib/BioX/Workflow/Command/REST/run.pm +++ b/lib/BioX/Workflow/Command/REST/run.pm @@ -129,7 +129,7 @@ resource run => sub { #TODO if using select don't want to print opts or start $biox->print_opts; - $biox->workflow_data($href); + $biox->workflow_data($data); $biox->apply_global_attributes; $biox->global_attr->create_outdir(0); From fcae9de5d5d5f7676b3574991e8a00695f6ac69c Mon Sep 17 00:00:00 2001 From: Jillian Rowe Date: Tue, 28 Feb 2017 13:19:46 +0400 Subject: [PATCH 2/4] get rid of errors --- lib/BioX/Workflow/Command/REST/run.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/BioX/Workflow/Command/REST/run.pm b/lib/BioX/Workflow/Command/REST/run.pm index 65fd6a0..7a09d8b 100644 --- a/lib/BioX/Workflow/Command/REST/run.pm +++ b/lib/BioX/Workflow/Command/REST/run.pm @@ -119,7 +119,7 @@ resource run => sub { chdir($tmp_dir); my $samples = $params->{samples}; - my $data = $params->{data} || $href; + my $data = $params->{data}; my $select_rules = $params->{select_rules}; my ( $stdout, $stderr, $exit ) = capture { @@ -130,6 +130,7 @@ resource run => sub { #TODO if using select don't want to print opts or start $biox->print_opts; $biox->workflow_data($data); + print Dumper($biox->workflow_data); $biox->apply_global_attributes; $biox->global_attr->create_outdir(0); From 9cf5006122a80e67f05c3c12c06fa136a2aebc53 Mon Sep 17 00:00:00 2001 From: Jillian Rowe Date: Tue, 28 Feb 2017 13:46:20 +0400 Subject: [PATCH 3/4] commiting --- lib/BioX/Workflow/Command/REST/run.pm | 10 +-- rest-test-data.json | 113 ++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 rest-test-data.json diff --git a/lib/BioX/Workflow/Command/REST/run.pm b/lib/BioX/Workflow/Command/REST/run.pm index 7a09d8b..01b0941 100644 --- a/lib/BioX/Workflow/Command/REST/run.pm +++ b/lib/BioX/Workflow/Command/REST/run.pm @@ -3,6 +3,7 @@ package Main; use MooseX::App::Command; extends 'BioX::Workflow::Command::run'; with 'BioX::Workflow::Command::run::Utils::Rules'; +use Data::Dumper; option '+workflow' => ( required => 0, ); @@ -36,6 +37,8 @@ use Raisin::API; use Types::Standard qw(HashRef Any Int Str ArrayRef); use File::Temp qw/ tempfile tempdir /; use Capture::Tiny ':all'; +use Data::Dumper; +use Try::Tiny; my $href = { global => [ @@ -110,10 +113,6 @@ resource run => sub { post sub { my $params = shift; - print "Params are\n"; - use Data::Dumper; - print Dumper($params); - my $biox = Main->new(); my $tmp_dir = tempdir( CLEANUP => 0 ); chdir($tmp_dir); @@ -130,15 +129,12 @@ resource run => sub { #TODO if using select don't want to print opts or start $biox->print_opts; $biox->workflow_data($data); - print Dumper($biox->workflow_data); $biox->apply_global_attributes; $biox->global_attr->create_outdir(0); $biox->global_attr->coerce_abs_dir(0); $biox->get_global_keys; - $biox->write_workflow_meta('start'); - $biox->iterate_rules; }; diff --git a/rest-test-data.json b/rest-test-data.json new file mode 100644 index 0000000..71008da --- /dev/null +++ b/rest-test-data.json @@ -0,0 +1,113 @@ +{ + "data": { + "global": [{ + "indir": "R_151215_YOUIDA_M001_pt1of7" + }, + { + "outdir": "R_151215_YOUIDA_M001_pt1of7/processed" + }, + { + "file_rule": "(15.*)$" + }, + { + "by_sample_outdir": 1 + }, + { + "find_by_dir": 1 + }, + { + "wait": 0 + }, + { + "trimmomatic_dir": "R_151215_YOUIDA_M001_pt1of7/processed/{$sample}/trimmomatic" + }, + { + "trimmomatic": "R_151215_YOUIDA_M001_pt1of7/processed/{$sample}/trimmomatic" + }, + { + "raw_fastqc_dir": "R_151215_YOUIDA_M001_pt1of7/processed/{$sample}" + }, + { + "raw_fastqc": "R_151215_YOUIDA_M001_pt1of7/processed/{$sample}" + }, + { + "analysis_dir": "R_151215_YOUIDA_M001_pt1of7/processed/analysis" + }, + { + "READ1": "{$self->raw_fastqc_dir}/raw_fastqc/{$sample}_read1.fastq.gz" + }, + { + "READ2": "{$self->raw_fastqc_dir}/raw_fastqc/{$sample}_read2.fastq.gz" + }, + { + "TR1": "{$self->trimmomatic_dir}/{$sample}_read1_trimmomatic" + }, + { + "TR2": "{$self->trimmomatic_dir}/{$sample}_read2_trimmomatic" + } + ], + "rules": [{ + "raw_fastqc": { + "local": [{ + "CAT1": "{$self->indir}/*_R1*.fastq.gz" + }, + { + "CAT2": "{$self->indir}/*_R1*.fastq.gz" + }, + { + "before_meta": "HPC Directives\n\n#\n#HPC jobname=raw_fastqc\n#HPC module=gencore/1 gencore_dev gencore_qc\n#HPC ntasks=1\n#HPC procs=1\n#HPC commands_per_node=1\n#HPC mem=12GB\n#HPC walltime=01:00:00\n#HPC cpus_per_task=3\n#HPC partition=serial\n" + } + ], + "process": "#TASK tags={$sample}_R1\n#mkdir -p {$self->{outdir}}/{$sample}_R1_FASTQC && \\\n# cat {$self->CAT1} > {$self->READ1} && \\\n# fastqc --extract \\\n# {$self->READ1} \\\n# -o {$self->{outdir}}/{$sample}_R1_FASTQC/ -t 3\n\n#TASK tags={$sample}_R2\n#mkdir -p {$self->{outdir}}/{$sample}_R2_FASTQC && \\\n# cat {$self->CAT2} > {$self->READ2} && \\\n# fastqc --extract \\\n# {$self->READ2} \\\n# -o {$self->{outdir}}/{$sample}_R2_FASTQC/ -t 3\n" + } + }, + { + "trimmomatic": { + "local": [{ + "before_meta": "HPC Directives\n\n#\n#HPC jobname=trimmomatic\n#HPC module=gencore/1 gencore_dev gencore_qc\n#HPC mem=25GB\n#HPC walltime=48:00:00\n#HPC cpus_per_task=12\n#HPC ntasks=1\n#HPC procs=1\n#HPC commands_per_node=1\n#HPC partition=serial\n#\n" + }], + "process": "#TASK tags={$sample}\ntrimmomatic \\\n PE -threads 12 \\\n -trimlog {$self->outdir}/{$sample}_trimmomatic.log \\\n {$self->READ1} \\\n {$self->READ2} \\\n {$self->TR1}_1PE.fastq \\\n {$self->TR1}_1SE.fastq \\\n {$self->TR2}_2PE.fastq \\\n {$self->TR2}_2SE.fastq \\\n TRAILING:3 LEADING:3 SLIDINGWINDOW:4:15 MINLEN:36\n" + } + }, + { + "trimmomatic_fastqc": { + "local": [{ + "OUTPUT": "{$self->outdir}/{$sample}" + }, + { + "before_meta": "HPC Directives\n\n#\n#HPC jobname=trimmomatic_fastqc\n#HPC deps=trimmomatic\n#HPC module=gencore/1 gencore_dev gencore_qc\n#HPC mem=12GB\n#HPC ntasks=1\n#HPC procs=1\n#HPC commands_per_node=1\n#HPC walltime=20:00:00\n#HPC cpus_per_task=4\n#HPC partition=serial\n#\n" + } + ], + "process": "#TASK tags={$sample}\nmkdir -p {$self->OUTPUT}_FASTQC_read1_TRIMMED && \\\n fastqc --extract \\\n {$self->TR1}_1PE.fastq \\\n -o {$self->OUTPUT}_FASTQC_read1_TRIMMED/ -t 4\n\n#TASK tags={$sample}\nmkdir -p {$self->OUTPUT}_FASTQC_read2_TRIMMED && \\\n fastqc --extract \\\n {$self->TR2}_2PE.fastq \\\n -o {$self->OUTPUT}_FASTQC_read2_TRIMMED/ -t 4\n" + } + }, + { + "trimmomatic_gzip": { + "local": [{ + "indir": "{$self->trimmomatic}" + }, + { + "INPUT": "{$self->trimmomatic}/{$sample}" + }, + { + "before_meta": "HPC Directives\n\n#\n#HPC jobname=trimmomatic_gzip\n#HPC deps=trimmomatic\n#HPC mem=10GB\n#HPC module=gencore/1 gencore_dev gencore_qc\n#HPC walltime=12:30:00\n#HPC cpus_per_task=1\n#HPC commands_per_node=1\n#HPC partition=serial\n#\n" + } + ], + "process": "#TASK tags={$sample}\ngzip -f {$self->TR1}_1PE.fastq\n\n#TASK tags={$sample}\ngzip -f {$self->TR2}_2PE.fastq\n" + } + }, + { + "remove_trimmomatic_logs": { + "local": [{ + "create_outdir": 0 + }, + { + "before_meta": "HPC Directives\n\n#\n#HPC jobname=remove_trimmomatic_logs\n#HPC deps=trimmomatic\n#HPC module=gencore/1 gencore_dev gencore_qc\n#HPC mem=4GB\n#HPC walltime=00:20:00\n#HPC cpus_per_task=1\n#HPC commands_per_node=1\n#HPC partition=serial\n#\n" + } + ], + "process": "#TASK tags={$sample}\nfind {$self->trimmomatic_dir} -name \"*_trimmomatic.log\" -type f -delete\n" + } + } + ] + } +} From 44ee9889b156ad5faba4e35e95d8c8acaa6b5a42 Mon Sep 17 00:00:00 2001 From: Jillian Rowe Date: Tue, 28 Feb 2017 14:56:58 +0400 Subject: [PATCH 4/4] fixing eval_process --- lib/BioX/Workflow/Command/REST/run.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/BioX/Workflow/Command/REST/run.pm b/lib/BioX/Workflow/Command/REST/run.pm index 01b0941..0f37cae 100644 --- a/lib/BioX/Workflow/Command/REST/run.pm +++ b/lib/BioX/Workflow/Command/REST/run.pm @@ -24,6 +24,8 @@ around 'eval_process' => sub { } push(@{$self->text_obj->{$self->rule_name}}, $text); + + return $text; }; package BioX::Workflow::Command::REST::run;