3 Isaak Y Tecle <iyt2@cornell.edu>
7 This library is free software. You can redistribute it and/or modify
8 it under the same terms as Perl itself.
12 SGN::Controller::solGS::gebvsComparison - Controller for comparing GEBVs of training and selection populations
17 package SGN
::Controller
::solGS
::gebvsComparison
;
20 use namespace
::autoclean
;
25 BEGIN { extends
'Catalyst::Controller' }
29 sub get_training_pop_gebvs
:Path
('/solgs/get/gebvs/training/population/') Args
(0) {
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
};
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;
53 $c->res->content_type('application/json');
59 sub get_selection_pop_gebvs
:Path
('/solgs/get/gebvs/selection/population/') Args
(0) {
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
};
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;
84 $c->res->content_type('application/json');
90 sub get_training_pop_gebv_file
{
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
};
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
{
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
};
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
{
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
{
159 $c->controller("solGS::solGS")->get_solgs_dirs($c);