Added eval; site now shows clean dataset missing message instead of server error...
[sgn.git] / lib / SGN / Controller / AJAX / Solgwas.pm
blobd21d6df5c32b57fc2f529d4fb457122a27e2c2ec
1 use strict;
2 use warnings;
4 package SGN::Controller::AJAX::Solgwas;
6 use Moose;
7 use Data::Dumper;
8 use File::Temp qw | tempfile |;
9 use File::Slurp;
10 use File::Spec qw | catfile|;
11 use File::Basename qw | basename |;
12 use File::Copy;
13 use CXGN::Dataset;
14 use CXGN::Dataset::File;
15 #use SGN::Model::Cvterm;
16 #use CXGN::List;
17 #use CXGN::List::Validate;
18 #use CXGN::Trial::Download;
19 #use CXGN::Phenotypes::PhenotypeMatrix;
20 #use CXGN::BreederSearch;
21 use CXGN::Tools::Run;
22 use Cwd qw(cwd);
24 BEGIN { extends 'Catalyst::Controller::REST' }
26 __PACKAGE__->config(
27 default => 'application/json',
28 stash_key => 'rest',
29 map => { 'application/json' => 'JSON' },
33 sub shared_phenotypes: Path('/ajax/solgwas/shared_phenotypes') : {
34 my $self = shift;
35 my $c = shift;
36 my $dataset_id = $c->req->param('dataset_id');
37 my $exclude_outliers = $c->req->param('dataset_trait_outliers');
39 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
40 my $schema = $c->dbic_schema("Bio::Chado::Schema", "sgn_chado");
41 my $ds = CXGN::Dataset->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id);
42 my $traits = $ds->retrieve_traits();
43 my @trait_info;
44 foreach my $t (@$traits) {
45 my $tobj = CXGN::Cvterm->new({ schema=>$schema, cvterm_id => $t->[0] });
46 push @trait_info, [ $tobj->cvterm_id(), $tobj->name()];
49 # my $solgwas_tmp_output = $c->config->{cluster_shared_tempdir}."/solgwas_files";
50 # mkdir $solgwas_tmp_output if ! -d $solgwas_tmp_output;
51 # my ($fh, $tempfile) = tempfile(
52 # "trait_XXXXXX",
53 # DIR=> $solgwas_tmp_output,
54 # );
56 $c->tempfiles_subdir("solgwas_files");
57 my ($fh, $tempfile) = $c->tempfile(TEMPLATE=>"solgwas_files/trait_XXXXX");
58 #my $tmp_dir = File::Spec->catfile($c->config->{basepath}, 'gwas_tmpdir');
59 # my $solgwas_tmp_output = $c->config->{cluster_shared_tempdir}."/solgwas_files";
60 # mkdir $solgwas_tmp_output if ! -d $solgwas_tmp_output;
61 # my ($tmp_fh, $tempfile) = tempfile(
62 # "solgwas_download_XXXXX",
63 # DIR=> $solgwas_tmp_output,
64 # );
65 # my $pheno_filepath = $tempfile . "_phenotype.txt";
67 my $temppath = $c->config->{basepath}."/".$tempfile;
68 # my $temppath = $solgwas_tmp_output . "/" . $tempfile;
69 my $ds2 = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, exclude_dataset_outliers => $exclude_outliers, file_name => $temppath, quotes => 0);
70 my $phenotype_data_ref = $ds2->retrieve_phenotypes();
72 # my $phenotypes = $ds->retrieve_phenotypes();
73 # my $trials_ref = $ds->retrieve_trials();
74 print STDERR Dumper(@trait_info);
75 # my @trials = @$trials_ref;
77 # my $values_path = $c->{basepath} . "./documents/tempfiles/solgwas_files/";
78 # copy($pheno_filepath,$values_path);
80 # my $file_basename = basename($pheno_filepath);
81 # my $file_response = "./documents/tempfiles/solgwas_files/" . $file_basename;
82 # print STDERR $file_response . "\n";
83 # my @co_pheno;
84 $c->stash->{rest} = {
85 options => \@trait_info,
86 tempfile => $tempfile."_phenotype.txt",
87 # tempfile => $file_response,
92 sub extract_trait_data :Path('/ajax/solgwas/getdata') Args(0) {
93 my $self = shift;
94 my $c = shift;
96 my $file = $c->req->param("file");
97 my $trait = $c->req->param("trait");
99 $file = basename($file);
101 my $temppath = File::Spec->catfile($c->config->{basepath}, "static/documents/tempfiles/solgwas_files/".$file);
102 # my $temppath = File::Spec->catfile($c->config->{cluster_shared_tempdir}, "static/documents/tempfiles/solgwas_files/".$file);
103 # my $temppath = File::Spec->catfile($c->config->{basepath}, "static/documents/tempfiles/solgwas_files/solgwas_download_0bDQ5_phenotype.txt");
104 print STDERR Dumper($temppath);
106 my $F;
107 if (! open($F, "<", $temppath)) {
108 $c->stash->{rest} = { error => "Can't find data." };
109 return;
112 my $header = <$F>;
113 chomp($header);
114 print STDERR Dumper($header);
115 my @keys = split("\t", $header);
116 print STDERR Dumper($keys[1]);
117 # add this for loop to remove the crop ontology codes from the keys (and the preceding pipes)
118 for(my $n=0; $n <@keys; $n++) {
119 if ($keys[$n] =~ /\|CO\_/) {
120 $keys[$n] =~ s/\|CO\_.*//;
123 my @data = ();
125 while (<$F>) {
126 chomp;
128 my @fields = split "\t";
129 my %line = ();
130 for(my $n=0; $n <@keys; $n++) {
131 if (exists($fields[$n]) && defined($fields[$n])) {
132 $line{$keys[$n]}=$fields[$n];
135 print STDERR Dumper(\%line);
136 push @data, \%line;
139 $c->stash->{rest} = { data => \@data, trait => $trait};
142 sub generate_pca: Path('/ajax/solgwas/generate_pca') : {
143 my $self = shift;
144 my $c = shift;
145 my $dataset_id = $c->req->param('dataset_id');
146 my $trait_id = $c->req->param('trait_id');
147 my $pc_check = $c->req->param('pc_check');
148 my $kinship_check = $c->req->param('kinship_check');
149 my $forbid_cache = defined($c->req->param('forbid_cache')) ? $c->req->param('forbid_cache') : 0;
152 print STDERR $dataset_id;
153 print STDERR $trait_id;
154 $c->tempfiles_subdir("solgwas_files");
155 # my ($fh, $tempfiletest) = $c->tempfile(TEMPLATE=>"solgwas_files/solgwas_download_XXXXX");
156 my $solgwas_tmp_output = $c->config->{cluster_shared_tempdir}."/solgwas_files";
157 mkdir $solgwas_tmp_output if ! -d $solgwas_tmp_output;
158 my ($tmp_fh, $tempfile) = tempfile(
159 "solgwas_download_XXXXX",
160 DIR=> $solgwas_tmp_output,
162 #my $tmp_dir = File::Spec->catfile($c->config->{basepath}, 'gwas_tmpdir');
163 my $pheno_filepath = $tempfile . "_phenotype.txt";
164 my $geno_filepath = $tempfile . "_genotype.txt";
165 # my $pheno_filepath = "." . $tempfile . "_phenotype.txt";
166 # my $geno_filepath = "." . $tempfile . "_genotype.txt";
167 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
168 my $schema = $c->dbic_schema("Bio::Chado::Schema", "sgn_chado");
169 # my $temppath = $c->config->{basepath}."/".$tempfile;
170 # my $temppath = $c->config->{cluster_shared_tempdir}."/".$tempfile;
171 # my $temppath = $solgwas_tmp_output . "/" . $tempfile;
172 my $temppath = "/" . $tempfile;
174 # my $ds = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, file_name => $temppath);
175 my $ds = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, file_name => $temppath, quotes => 0);
177 ## my $phenotype_data_ref = $ds->retrieve_phenotypes();
178 my $phenotype_data_ref = $ds->retrieve_phenotypes($pheno_filepath);
179 my $protocols = $ds->retrieve_genotyping_protocols();
180 my $protocol_id;
181 foreach (@$protocols) {
182 $protocol_id = $_->[0];
185 # my ($fh, $tempfile2) = $c->tempfile(TEMPLATE=>"solgwas_files/solgwas_genotypes_download_XXXXX");
186 # my $temppath2 = $c->config->{basepath}."/".$tempfile2;
187 # my $ds2 = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, file_name => $temppath2);
188 # $ds2 -> file_name => $temppath2;
190 my $filehandle = $ds->retrieve_genotypes($protocol_id,$geno_filepath, $c->config->{cache_file_path}, $c->config->{cluster_shared_tempdir}, $c->config->{backend}, $c->config->{cluster_host}, $c->config->{'web_cluster_queue'}, $c->config->{basepath}, $forbid_cache);
191 # my $base_filename = $$filehandle;
192 print STDERR $filehandle . "\n";
193 # print STDERR $base_filename . "\n";
194 # $ds-> @$trials_ref = retrieve_genotypes();
195 my $newtrait = $trait_id;
196 $newtrait =~ s/\s/\_/g;
197 $newtrait =~ s/\//\_/g;
198 print STDERR $newtrait . "\n";
199 # my $figure1file = "." . $tempfile . "_" . $newtrait . "_figure1.png";
200 # my $figure2file = "." . $tempfile . "_" . $newtrait . "_figure2.png";
201 # my $figure3file = "." . $tempfile . "_" . $newtrait . "_figure3.png";
202 # my $figure4file = "." . $tempfile . "_" . $newtrait . "_figure4.png";
203 my $tempfile2 = $tempfile;
204 my $figure1file = $tempfile . "_" . $newtrait . "_figure1.png";
205 my $figure2file = $tempfile . "_" . $newtrait . "_figure2.png";
206 my $figure3file = $tempfile . "_" . $newtrait . "_figure3.png";
207 my $figure4file = $tempfile . "_" . $newtrait . "_figure4.png";
209 $trait_id =~ tr/ /./;
210 $trait_id =~ tr/\//./;
211 # my $clean_cmd = "rm /home/vagrant/cxgn/sgn/documents/tempfiles/solgwas_files/SolGWAS_Figure*.png";
212 # system($clean_cmd);
213 my $geno_filepath2 = $tempfile . "_genotype.txt";
214 # my $geno_filepath2 = $base_filename . "_genotype_edit.txt";
215 # my $edit_cmd = "sed -e '1 s/\^/row.names\t/' " . $base_filename . " > " . $geno_filepath2;
216 # system($edit_cmd);
217 # my $geno_filepath3 = "." . $tempfile . "_genotype_edit_subset.txt";
218 my $geno_filepath3 = $tempfile . "_genotype_edit_subset.txt";
220 # my $trim_cmd = "cut -f 1-50 " . $geno_filepath2 . " > " . $geno_filepath3;
221 # system($trim_cmd);
223 # open my $filehandle_in2, "<", "$geno_filepath2" or die "Could not open $geno_filepath2: $!\n";
224 open my $filehandle_out, ">", "$geno_filepath2" or die "Could not create $geno_filepath2: $!\n";
226 my $marker_total;
228 while ( my $line = <$filehandle> ) {
229 my @sample_line = (split /\s+/, $line);
230 $marker_total = scalar(@sample_line);
231 print $filehandle_out $line;
233 close $filehandle;
234 close $filehandle_out;
237 # # Hardcoded number of markers to be selected - make this selectable by user?
238 # my $markers_selected = 500;
239 # # my @column_selection = (0,2);
240 # # Initialize column selection so the row.names are selected first
241 # my @column_selection = (0);
242 # my %columns_seen;
243 # for (my $i=0; $i <= $markers_selected; $i++) {
244 # my $random_current = int(rand($marker_total));
245 # redo if $columns_seen{$random_current}++;
246 # push @column_selection, $random_current;
247 # print STDERR $random_current . "\n";
250 # open my $filehandle_in, "<", "$geno_filepath2" or die "Could not open $geno_filepath2: $!\n";
251 # open my $filehandle_out2, ">", "$geno_filepath3" or die "Could not create $geno_filepath3: $!\n";
253 # # foreach my $item (@column_selection) {
254 # while ( my $line = <$filehandle_in> ) {
255 # my $curr_line;
256 # my @first_item = (split /\s+/, $line);
257 # foreach my $item (@column_selection) {
258 # $curr_line .= $first_item[$item] . "\t";
260 # # $curr_line .= "\n";
261 # print STDERR $curr_line . "\n";
262 # print $filehandle_out2 "$curr_line\n";
265 # close $filehandle_in;
266 # close $filehandle_out2;
268 # my $cmd = "Rscript " . $c->config->{basepath} . "/R/solgwas/solgwas_script.R " . $pheno_filepath . " " . $geno_filepath3 . " " . $trait_id . " " . $figure3file . " " . $figure4file . " " . $pc_check . " " . $kinship_check;
269 # system($cmd);
271 my $cmd = CXGN::Tools::Run->new(
273 backend => $c->config->{backend},
274 submit_host => $c->config->{cluster_host},
275 temp_base => $c->config->{cluster_shared_tempdir} . "/solgwas_files",
276 queue => $c->config->{'web_cluster_queue'},
277 do_cleanup => 0,
278 # don't block and wait if the cluster looks full
279 max_cluster_jobs => 1_000_000_000,
282 $cmd->run_cluster(
283 "Rscript ",
284 $c->config->{basepath} . "/R/solgwas/solgwas_genoPCA_script.R",
285 $geno_filepath2,
286 $figure2file,
288 $cmd->is_cluster(1);
289 $cmd->wait;
292 my $figure_path = "./documents/tempfiles/solgwas_files/";
293 copy($figure2file,$figure_path);
295 my $figure2basename = basename($figure2file);
296 my $figure2file_response = "/documents/tempfiles/solgwas_files/" . $figure2basename;
298 $c->stash->{rest} = {
299 figure2 => $figure2file_response,
300 dummy_response => $dataset_id,
301 dummy_response2 => $trait_id,
306 sub generate_results: Path('/ajax/solgwas/generate_results') : {
307 my $self = shift;
308 my $c = shift;
309 my $dataset_id = $c->req->param('dataset_id');
310 my $trait_id = $c->req->param('trait_id');
311 my $pc_check = $c->req->param('pc_check');
312 my $kinship_check = $c->req->param('kinship_check');
313 my $forbid_cache = defined($c->req->param('forbid_cache')) ? $c->req->param('forbid_cache') : 0;
314 my $exclude_outliers = $c->req->param('dataset_trait_outliers');
316 print STDERR $dataset_id;
317 print STDERR $trait_id;
318 $c->tempfiles_subdir("solgwas_files");
319 # my ($fh, $tempfiletest) = $c->tempfile(TEMPLATE=>"solgwas_files/solgwas_download_XXXXX");
320 my $solgwas_tmp_output = $c->config->{cluster_shared_tempdir}."/solgwas_files";
321 mkdir $solgwas_tmp_output if ! -d $solgwas_tmp_output;
322 my ($tmp_fh, $tempfile) = tempfile(
323 "solgwas_download_XXXXX",
324 DIR=> $solgwas_tmp_output,
326 #my $tmp_dir = File::Spec->catfile($c->config->{basepath}, 'gwas_tmpdir');
327 my $pheno_filepath = $tempfile . "_phenotype.txt";
328 my $geno_filepath = $tempfile . "_genotype.txt";
329 # my $pheno_filepath = "." . $tempfile . "_phenotype.txt";
330 # my $geno_filepath = "." . $tempfile . "_genotype.txt";
331 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
332 my $schema = $c->dbic_schema("Bio::Chado::Schema", "sgn_chado");
333 # my $temppath = $c->config->{basepath}."/".$tempfile;
334 ## my $temppath = $c->config->{cluster_shared_tempdir}."/".$tempfile;
335 # my $temppath = $solgwas_tmp_output . "/" . $tempfile;
336 my $temppath = $tempfile;
338 # my $ds = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, file_name => $temppath);
340 my $ds = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, exclude_dataset_outliers => $exclude_outliers, file_name => $temppath, quotes => 0);
342 ## my $phenotype_data_ref = $ds->retrieve_phenotypes();
343 my $phenotype_data_ref = $ds->retrieve_phenotypes($pheno_filepath);
344 my $protocols = $ds->retrieve_genotyping_protocols();
345 my $protocol_id;
346 foreach (@$protocols) {
347 $protocol_id = $_->[0];
350 # my ($fh, $tempfile2) = $c->tempfile(TEMPLATE=>"solgwas_files/solgwas_genotypes_download_XXXXX");
351 # my $temppath2 = $c->config->{basepath}."/".$tempfile2;
352 # my $ds2 = CXGN::Dataset::File->new(people_schema => $people_schema, schema => $schema, sp_dataset_id => $dataset_id, file_name => $temppath2);
353 # $ds2 -> file_name => $temppath2;
355 my %chromList;
356 my %posList;
357 my $name;
358 my @row;
359 my $chrom;
360 my $pos;
361 my $q = "SELECT s.value->>'name', s.value->>'chrom', s.value->>'pos' from nd_protocolprop, jsonb_each(nd_protocolprop.value) s(key, value) where type_id = (SELECT cvterm_id FROM public.cvterm WHERE name = 'vcf_map_details_markers') and nd_protocol_id = $protocol_id";
362 my $sth = $c->dbc->dbh->prepare($q);
363 $sth->execute();
364 while (@row = $sth->fetchrow_array) {
365 $name = $row[0];
366 $chromList{$name} = $row[1];
367 $posList{$name} = $row[2];
370 my $filehandle = $ds->retrieve_genotypes($protocol_id,$geno_filepath, $c->config->{cache_file_path}, $c->config->{cluster_shared_tempdir}, $c->config->{backend}, $c->config->{cluster_host}, $c->config->{'web_cluster_queue'}, $c->config->{basepath}, $forbid_cache);
371 # my $base_filename = $$filehandle;
372 print STDERR $filehandle . "\n";
373 # print STDERR $base_filename . "\n";
374 # $ds-> @$trials_ref = retrieve_genotypes();
375 my $newtrait = $trait_id;
376 $newtrait =~ s/\s/\_/g;
377 $newtrait =~ s/\//\_/g;
378 $newtrait =~ s/[|%()]/\./g;
379 print STDERR $newtrait . "\n";
380 # my $figure1file = "." . $tempfile . "_" . $newtrait . "_figure1.png";
381 # my $figure2file = "." . $tempfile . "_" . $newtrait . "_figure2.png";
382 # my $figure3file = "." . $tempfile . "_" . $newtrait . "_figure3.png";
383 # my $figure4file = "." . $tempfile . "_" . $newtrait . "_figure4.png";
384 my $tempfile2 = $tempfile;
385 my $figure1file = $tempfile . "_" . $newtrait . "_figure1.png";
386 my $figure2file = $tempfile . "_" . $newtrait . "_figure2.png";
387 my $figure3file = $tempfile . "_" . $newtrait . "_figure3.png";
388 my $figure4file = $tempfile . "_" . $newtrait . "_figure4.png";
389 my $gwasResultsPhenoCsv = $tempfile . "_" . $newtrait . "_gwasresults_pheno.csv";
391 $trait_id =~ tr/ /./;
392 $trait_id =~ tr/\//./;
393 # my $clean_cmd = "rm /home/vagrant/cxgn/sgn/documents/tempfiles/solgwas_files/SolGWAS_Figure*.png";
394 # system($clean_cmd);
395 my $geno_filepath2 = $tempfile . "_genotype.txt";
396 # my $geno_filepath2 = $base_filename . "_genotype_edit.txt";
397 # my $edit_cmd = "sed -e '1 s/\^/row.names\t/' " . $base_filename . " > " . $geno_filepath2;
398 # system($edit_cmd);
399 # my $geno_filepath3 = "." . $tempfile . "_genotype_edit_subset.txt";
400 my $geno_filepath3 = $tempfile . "_genotype_edit_subset.txt";
402 # my $trim_cmd = "cut -f 1-50 " . $geno_filepath2 . " > " . $geno_filepath3;
403 # system($trim_cmd);
405 open my $filehandle_out, ">", "$geno_filepath2" or die "Could not create $geno_filepath2: $!\n";
406 my $line = <$filehandle>;
407 my @sample_line = (split /\t/, $line);
408 splice(@sample_line, 1, 0, "chrom");
409 splice(@sample_line, 2, 0, "pos");
410 $line = join("\t", @sample_line);
411 print $filehandle_out $line;
412 my $marker_total;
414 while ( my $line = <$filehandle> ) {
415 @sample_line = split(/\t/, $line);
416 if ($chromList{$sample_line[0]}) {
417 $chrom = $chromList{$sample_line[0]};
418 } elsif ($sample_line[0] =~ /\_/) {
419 ($chrom, undef) = split /\_/, $sample_line[0];
420 print STDERR "Warning! no chrom data, using $chrom extracted from $sample_line[0]\n";
421 } else {
422 $chrom = "";
424 if ($posList{$sample_line[0]}) {
425 $pos = $posList{$sample_line[0]};
426 } elsif ($sample_line[0] =~ /\_/) {
427 (undef, $pos) = split /\_/, $sample_line[0];
428 print STDERR "Warning! No position data, using $pos extracted from $sample_line[0]\n";
429 } else {
430 $pos = "";
432 splice(@sample_line, 1, 0, $chrom);
433 splice(@sample_line, 2, 0, $pos);
434 $line = join("\t", @sample_line);
435 print $filehandle_out $line;
437 close $filehandle;
438 close $filehandle_out;
441 # # Hardcoded number of markers to be selected - make this selectable by user?
442 # my $markers_selected = 500;
443 # # my @column_selection = (0,2);
444 # # Initialize column selection so the row.names are selected first
445 # my @column_selection = (0);
446 # my %columns_seen;
447 # for (my $i=0; $i <= $markers_selected; $i++) {
448 # my $random_current = int(rand($marker_total));
449 # redo if $columns_seen{$random_current}++;
450 # push @column_selection, $random_current;
451 # print STDERR $random_current . "\n";
454 # open my $filehandle_in, "<", "$geno_filepath2" or die "Could not open $geno_filepath2: $!\n";
455 # open my $filehandle_out2, ">", "$geno_filepath3" or die "Could not create $geno_filepath3: $!\n";
457 # # foreach my $item (@column_selection) {
458 # while ( my $line = <$filehandle_in> ) {
459 # my $curr_line;
460 # my @first_item = (split /\s+/, $line);
461 # foreach my $item (@column_selection) {
462 # $curr_line .= $first_item[$item] . "\t";
464 # # $curr_line .= "\n";
465 # print STDERR $curr_line . "\n";
466 # print $filehandle_out2 "$curr_line\n";
469 # close $filehandle_in;
470 # close $filehandle_out2;
472 # my $cmd = "Rscript " . $c->config->{basepath} . "/R/solgwas/solgwas_script.R " . $pheno_filepath . " " . $geno_filepath3 . " " . $trait_id . " " . $figure3file . " " . $figure4file . " " . $pc_check . " " . $kinship_check;
473 # system($cmd);
474 my $cmd = CXGN::Tools::Run->new(
476 backend => $c->config->{backend},
477 submit_host => $c->config->{cluster_host},
478 temp_base => $c->config->{cluster_shared_tempdir} . "/solgwas_files",
479 queue => $c->config->{'web_cluster_queue'},
480 do_cleanup => 0,
481 # don't block and wait if the cluster looks full
482 max_cluster_jobs => 1_000_000_000,
485 $cmd->run_cluster(
486 "Rscript ",
487 $c->config->{basepath} . "/R/solgwas/solgwas_script.R",
488 $pheno_filepath,
489 $geno_filepath2,
490 $trait_id,
491 $figure3file,
492 $figure4file,
493 $pc_check,
494 $kinship_check,
495 $gwasResultsPhenoCsv,
498 $cmd->is_cluster(1);
499 $cmd->wait;
501 my $figure_path = "./documents/tempfiles/solgwas_files/";
502 copy($figure3file,$figure_path);
503 copy($figure4file,$figure_path);
504 copy($gwasResultsPhenoCsv,$figure_path);
505 # my $figure3basename = $figure3file;
507 # $figure3basename =~ s/\/export\/prod\/tmp\/solgwas\_files\///;
508 my $figure3basename = basename($figure3file);
509 my $figure3file_response = "/documents/tempfiles/solgwas_files/" . $figure3basename;
510 my $figure4basename = basename($figure4file);
511 my $figure4file_response = "/documents/tempfiles/solgwas_files/" . $figure4basename;
512 my $gwasResultsCsvBasename = basename($gwasResultsPhenoCsv);
513 my $gwasCsv_response = "/documents/tempfiles/solgwas_files/" . $gwasResultsCsvBasename;
514 # $figure4file_response =~ s/\.\/static//;
515 $c->stash->{rest} = {
516 figure3 => $figure3file_response,
517 figure4 => $figure4file_response,
518 dummy_response => $dataset_id,
519 dummy_response2 => $trait_id,
520 gwas_csv_response => $gwasCsv_response,