seedlot upload with accession synonyms. seedlot upload works to update existing seedlots
[sgn.git] / lib / SGN / Controller / solGS / gebvsComparison.pm
blob9a1d628036af92b6f2291e43b59e3d204c0ac9a9
1 =head1 AUTHOR
3 Isaak Y Tecle <iyt2@cornell.edu>
5 =head1 LICENSE
7 This library is free software. You can redistribute it and/or modify
8 it under the same terms as Perl itself.
10 =head1 DESCRIPTION
12 SGN::Controller::solGS::gebvsComparison - Controller for comparing GEBVs of training and selection populations
14 =cut
17 package SGN::Controller::solGS::gebvsComparison;
19 use Moose;
20 use namespace::autoclean;
22 use JSON;
25 BEGIN { extends 'Catalyst::Controller' }
29 sub get_training_pop_gebvs :Path('/solgs/get/gebvs/training/population/') Args(0) {
30 my ($self, $c) = @_;
32 $c->stash->{training_pop_id} = $c->req->param('training_pop_id');
33 $c->stash->{trait_id} = $c->req->param('trait_id');
34 $c->stash->{population_type} = 'training_population';
36 my $ret->{gebv_exists} = undef;
38 $self->get_training_pop_gebv_file($c);
39 my $gebv_file = $c->stash->{training_gebv_file};
41 if (-s $gebv_file)
43 $c->stash->{gebv_file} = $gebv_file;
44 $self->get_gebv_arrayref($c);
45 my $gebv_arrayref = $c->stash->{gebv_arrayref};
47 $ret->{gebv_exists} = 1;
48 $ret->{gebv_arrayref} = $gebv_arrayref;
51 $ret = to_json($ret);
53 $c->res->content_type('application/json');
54 $c->res->body($ret);
59 sub get_selection_pop_gebvs :Path('/solgs/get/gebvs/selection/population/') Args(0) {
60 my ($self, $c) = @_;
62 $c->stash->{selection_pop_id} = $c->req->param('selection_pop_id');
63 $c->stash->{training_pop_id} = $c->req->param('training_pop_id');
64 $c->stash->{trait_id} = $c->req->param('trait_id');
65 $c->stash->{population_type} = 'selection_population';
67 my $ret->{gebv_exists} = undef;
69 $self->get_selection_pop_gebv_file($c);
70 my $gebv_file = $c->stash->{selection_gebv_file};
72 if (-s $gebv_file)
74 $c->stash->{gebv_file} = $gebv_file;
75 $self->get_gebv_arrayref($c);
76 my $gebv_arrayref = $c->stash->{gebv_arrayref};
78 $ret->{gebv_exists} = 1;
79 $ret->{gebv_arrayref} = $gebv_arrayref;
82 $ret = to_json($ret);
84 $c->res->content_type('application/json');
85 $c->res->body($ret);
90 sub get_training_pop_gebv_file {
91 my ($self, $c) = @_;
93 my $pop_id = $c->stash->{training_pop_id};
94 my $trait_id = $c->stash->{trait_id};
96 $c->controller('solGS::solGS')->get_trait_details($c, $trait_id);
97 my $trait_abbr = $c->stash->{trait_abbr};
99 my $gebv_file;
101 if ($pop_id && $trait_id)
103 my $dir = $c->stash->{solgs_cache_dir};
104 my $file = "gebv_kinship_${trait_abbr}_${pop_id}";
106 $gebv_file = $c->controller('solGS::solGS')->grep_file($dir, $file);
110 $c->stash->{training_gebv_file} = $gebv_file;
115 sub get_selection_pop_gebv_file {
116 my ($self, $c) = @_;
118 my $selection_pop_id = $c->stash->{selection_pop_id};
119 my $training_pop_id = $c->stash->{training_pop_id};
120 my $trait_id = $c->stash->{trait_id};
122 my $gebv_file;
124 if ($selection_pop_id && $trait_id && $training_pop_id)
126 my $dir = $c->stash->{solgs_cache_dir};
127 my $identifier = $training_pop_id . "_" . $selection_pop_id;
128 my $file = "prediction_pop_gebvs_${identifier}_${trait_id}";
129 $gebv_file = $c->controller('solGS::solGS')->grep_file($dir, $file);
132 $c->stash->{selection_gebv_file} = $gebv_file;
137 sub get_gebv_arrayref {
138 my ($self, $c) = @_;
140 my $file = $c->stash->{gebv_file};
141 my $gebv_arrayref = $c->controller('solGS::solGS')->convert_to_arrayref_of_arrays($c, $file);
143 $c->stash->{gebv_arrayref} = $gebv_arrayref;
147 sub check_population_type {
148 my ($self, $c, $pop_id) = @_;
150 my $type = $c->model('solGS::solGS')->get_population_type($pop_id);
152 $c->stash->{population_type} = $type;
156 sub begin : Private {
157 my ($self, $c) = @_;
159 $c->controller("solGS::solGS")->get_solgs_dirs($c);
164 ####
166 ####