Skip to content

Commit

Permalink
Merge pull request #3550 from solgenomics/topic/acronyms_display
Browse files Browse the repository at this point in the history
adds trait acronyms legend in trial detail page
  • Loading branch information
isaak authored Jun 4, 2021
2 parents a6149b9 + 538eaa1 commit 77c35a2
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 194 deletions.
276 changes: 138 additions & 138 deletions js/source/legacy/solGS/correlation.js

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions js/source/legacy/solGS/loadAcronyms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* trait acronyms loader
* Isaak Y Tecle <[email protected]>
*
*/


var solGS = solGS || function solGS () {};

solGS.acronyms = {

loadAcronyms: function() {
var id;
var page = document.URL;

if (page.match(/breeders\/trial\//)) {
id = jQuery('#trial_id').val();
} else {
id = jQuery('#training_pop_id').val();
}

var acros = jQuery.ajax({
type : 'POST',
dataType: 'json',
data : {'id': id},
url : '/solgs/load/trait/acronyms/',
});

return acros;
},


displayAcronyms: function(data) {

var table = jQuery('#trait_acronyms_table').DataTable({
'searching' : false,
'ordering' : false,
'processing': true,
'paging' : false,
'info' : false,
});

table.rows.add(data).draw();

}

/////////////
}
////////////


jQuery(document).ready( function() {
console.log('loading acronyms....')

jQuery('#trait_acronyms_div').show();

solGS.acronyms.loadAcronyms().done( function(res) {
solGS.acronyms.displayAcronyms(res.acronyms);
});

solGS.acronyms.loadAcronyms().fail( function(res) {
jQuery('#trait_acronyms_table').hide();
var errorMsg = 'Error occured loading acronyms';
jQuery('#acronyms_message')
.html(errorMsg)
.show()
.fadeOut(50000);
});

});
7 changes: 6 additions & 1 deletion lib/SGN/Controller/solGS/Correlation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use JSON;
use Try::Tiny;
use Scalar::Util qw /weaken reftype/;
use Storable qw/ nstore retrieve /;


BEGIN { extends 'Catalyst::Controller' }


Expand Down Expand Up @@ -103,12 +105,14 @@ sub correlation_genetic_data :Path('/correlation/genetic/data/') Args(0) {
$c->stash->{pop_id} = $model_id;
$c->stash->{training_pop_id} = $model_id;
$c->stash->{training_traits_ids} = \@traits_ids;

$c->stash->{selection_pop_id} = $corr_pop_id if $pop_type =~ /selection/;

#$c->controller('solGS::Files')->selection_index_file($c);

# $c->controller('solGS::TraitsGebvs')->combine_gebvs_of_traits($c);
$c->controller('solGS::TraitsGebvs')->run_combine_traits_gebvs($c);

my $combined_gebvs_file = $c->stash->{combined_gebvs_file};
my $tmp_dir = $c->stash->{correlation_temp_dir};
$combined_gebvs_file = $c->controller('solGS::Files')->copy_file($combined_gebvs_file, $tmp_dir);
Expand Down Expand Up @@ -237,6 +241,7 @@ sub genetic_correlation_output_files {
my $type = $c->stash->{type};

my $selection_pop_id = $c->stash->{selection_pop_id};

$model_id = $c->stash->{model_id};
my $identifier = $type =~ /selection/ ? $model_id . "_" . $corre_pop_id : $corre_pop_id;

Expand Down Expand Up @@ -271,7 +276,7 @@ sub pheno_correlation_analysis_output :Path('/phenotypic/correlation/analysis/ou

if (-s $corre_json_file)
{
$ret->{acronyms} = $self->trait_acronyms($c);
# $ret->{acronyms} = $self->trait_acronyms($c);
$ret->{status} = 'success';
$ret->{data} = read_file($corre_json_file, {binmode => ':utf8'});
}
Expand Down
29 changes: 23 additions & 6 deletions lib/SGN/Controller/solGS/TraitsGebvs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ sub combine_gebvs_jobs_args {
write_file($gebvs_files, {append => 1, binmode => ':utf8'}, "\t". $index_file)
}

my $identifier = $self->combined_gebvs_file_id($c);
my $tmp_dir = $c->stash->{solgs_tempfiles_dir};
$self->combined_gebvs_file($c);
my $combined_gebvs_file = $c->stash->{combined_gebvs_file};
my $identifier = $self->combined_gebvs_file_id($c);
my $tmp_dir = $c->stash->{solgs_tempfiles_dir};
my $combined_gebvs_file = $c->controller('solGS::Files')->create_tempfile($tmp_dir, "combined_gebvs_${identifier}");

$c->stash->{input_files} = $gebvs_files;
$c->stash->{output_files} = $combined_gebvs_file;
$c->stash->{r_temp_file} = "combining-gebvs-${identifier}";
$c->stash->{r_script} = 'R/solGS/combine_gebvs_files.r';
$c->stash->{analysis_tempfiles_dir} = $tmp_dir;
$c->stash->{analysis_tempfiles_dir} = $tmp_dir;
}
else
{
Expand Down Expand Up @@ -126,7 +126,6 @@ sub get_gebv_files_of_traits {
my $training_pop_id = $c->stash->{training_pop_id} || $c->stash->{combo_pops_id} || $c->stash->{corre_pop_id};
$c->stash->{model_id} = $training_pop_id;
my $selection_pop_id = $c->stash->{selection_pop_id};

my $dir = $c->stash->{solgs_cache_dir};

my $gebv_files;
Expand Down Expand Up @@ -276,6 +275,24 @@ sub create_traits_selection_id {



sub load_acronyms: Path('/solgs/load/trait/acronyms') Args() {
my ($self, $c) = @_;

my $id = $c->req->param('id');
$c->controller('solGS::solGS')->get_all_traits($c, $id);
my $acronyms = $c->controller('solGS::solGS')->get_acronym_pairs($c, $id);

my $ret->{acronyms} = $acronyms;
my $json = JSON->new();
$ret = $json->encode($ret);

$c->res->content_type('application/json');
$c->res->body($ret);

}



#####


Expand Down
2 changes: 1 addition & 1 deletion lib/SGN/Controller/solGS/solGS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ sub get_all_traits {
if (!-s $traits_file)
{
my $page = $c->req->path;
if ($page =~ /solgs\/population\/|anova\/|correlation\// && $pop_id !~ /\D+/)
if ($page =~ /solgs\/population\/|anova\/|correlation\/|acronyms/ && $pop_id !~ /\D+/)
{
$self->save_single_trial_traits($c, $pop_id);
}
Expand Down
4 changes: 4 additions & 0 deletions mason/page/detail_page_2_col_section.mas
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ $sampling_facilities => ()
trial_id => $trial_id
&>

<& /solgs/population/trait_acronyms.mas,
trial_id => $trial_id
&>

% if ($c->req->base =~ /sweetpotatobase/) {
<& /tools/qualityControl/qualityControl.mas,
trial_id => $trial_id
Expand Down
6 changes: 2 additions & 4 deletions mason/solgs/population.mas
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ $training_pop_id = $pop_id;

%}

<& population/acronym.mas,
acronym => $acronym,
&>
<& /solgs/population/trait_acronyms.mas &>

%} else {

Expand All @@ -107,7 +105,7 @@ $training_pop_id = $pop_id;
title => "Genotype Data"
&>

<div id="traits_list_message" style="font-weight:bold;text-align:center;text-transform:uppercase;color:#A7C942">
<div id="traits_list_message" class="message">
<p>There is no genotype data for this population.</p>
</div>

Expand Down
44 changes: 0 additions & 44 deletions mason/solgs/population/acronym.mas

This file was deleted.

53 changes: 53 additions & 0 deletions mason/solgs/population/trait_acronyms.mas
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<%doc>

=head1 NAME

/solgs/population/acronym.mas -- displays a list of traits and their acronyms.

=AUTHOR

Isaak Y Tecle ([email protected])

=cut

</%doc>

<%args>

$trial_id => undef;
$training_pop_id => undef;

</%args>

<%perl>
</%perl>


<& /util/import_javascript.mas, classes => ["solGS.loadAcronyms", "jquery.dataTables"] &>

<&| /page/info_section.mas,
collapsible => 1,
collapsed => 1,
title => "Acronyms legend",
&>


<div id="trait_acronyms_div" style="display:none">
<div id="acronyms_message" class="message"></div>

<table class="table" id="trait_acronyms_table" style="text-align: left;">
<thead>
<tr>
<th>Acronym</th>
<th>Trait</th>
</tr>
</thead>
</table>

<input type="hidden" id="trial_id" value="<% $trial_id %>" />

</div>



</&>

0 comments on commit 77c35a2

Please sign in to comment.