2 package SGN
::Controller
::AJAX
::BrAPI
;
9 use CXGN
::BreedersToolbox
::Projects
;
11 use CXGN
::Trial
::TrialLayout
;
14 use CXGN
::Trial
::TrialCreate
;
15 use CXGN
::Trial
::Search
;
16 use CXGN
::Location
::LocationLookup
;
18 use JSON
qw( decode_json );
22 use File
::Slurp qw
| read_file
|;
23 use Spreadsheet
::WriteExcel
;
28 BEGIN { extends
'Catalyst::Controller::REST' };
31 # Leaving default Content-Type to not break everything. If data is passed that is not parsable as json, and the
32 # data type is not handled in the map below, we get a catalyst error with a 200 response which is not ideal.
33 default => 'application/json',
35 map => { 'application/json' => 'JSON',
36 # would be nice if we could do image/* instead of explicitly listing each type
37 # also should see if a single list of image types can be used for this and for _get_extension in Images.pm
38 'image/_*' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
39 'image/jpeg' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
40 'image/png' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
41 'image/gif' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
42 'image/svg+xml' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
43 'application/pdf' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
44 'application/postscript' => [ 'Callback', { deserialize
=> \
&deserialize_image
, serialize
=> \
&serialize_image
} ],
48 has
'brapi_module' => (
54 isa
=> 'Bio::Chado::Schema',
58 my $DEFAULT_PAGE_SIZE=10;
60 # don't do anything, let catalyst handle putting body into a temp file
61 sub deserialize_image
{
62 my ( $self, $data, $c ) = @_;
63 # want $c->request->data to be undefined so that parsing in brapi sub skips it
67 # have to serialize the json because using the callbacks in the config map
69 my ( $self, $data, $c ) = @_;
70 my $json = JSON
->new->allow_nonref;
73 $json->convert_blessed;
74 my $json_text = $json->encode( $c->stash->{rest
} );
76 $c->response->content_type('application/json');
80 sub brapi
: Chained
('/') PathPart
('brapi') CaptureArgs
(1) {
86 my $page = $c->req->param("page") || 0;
87 my $page_size = $c->req->param("pageSize") || $DEFAULT_PAGE_SIZE;
88 my $authorization_token = $c->req->headers->header("Authorization");
89 my $bearer_token = undef;
91 if (defined $authorization_token) {
92 my @bearer = split(/\s/, $authorization_token);
93 if (scalar @bearer == 2) {
94 if ($bearer[0] eq "Bearer") {
95 $bearer_token = $bearer[1];
100 my $session_token = $c->req->headers->header("access_token") || $bearer_token;
102 if (defined $c->request->data){
103 my $data_type = ref $c->request->data;
105 $current_page = $c->request->data->{"page"} if ($data_type ne 'ARRAY');
106 my $current_page_size;
107 $current_page_size = $c->request->data->{"pageSize"} if ($data_type ne 'ARRAY');
108 my $current_session_token;
109 $current_session_token = $c->request->data->{"access_token"} if ($data_type ne 'ARRAY');
110 $page = $current_page || $page || 0;
111 $page_size = $current_page_size || $page_size || $DEFAULT_PAGE_SIZE;
112 $session_token = $current_session_token|| $session_token;
114 my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado');
115 my $metadata_schema = $c->dbic_schema("CXGN::Metadata::Schema");
116 my $phenome_schema = $c->dbic_schema("CXGN::Phenome::Schema");
117 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
118 push @status, { 'INFO' => "BrAPI base call found with page=$page, pageSize=$page_size" };
120 my $brapi = CXGN
::BrAPI
->new({
122 brapi_module_inst
=> {
124 bcs_schema
=> $bcs_schema,
125 metadata_schema
=> $metadata_schema,
126 phenome_schema
=> $phenome_schema,
127 people_schema
=> $people_schema,
128 page_size
=> $page_size,
133 $self->brapi_module($brapi);
134 $self->bcs_schema($bcs_schema);
136 $c->response->headers->header( "Access-Control-Allow-Origin" => '*' );
137 $c->response->headers->header( "Access-Control-Allow-Methods" => "POST, GET, PUT, DELETE" );
138 $c->response->headers->header( 'Access-Control-Allow-Headers' => 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization');
139 $c->stash->{session_token
} = $session_token;
141 if (defined $c->request->data){
142 # All POST requests accept for search methods require a json array body
143 if ($c->request->method eq "POST" && index($c->request->env->{REQUEST_URI
}, "search") == -1){
144 if (ref $c->request->data ne 'ARRAY') {
145 my $response = CXGN
::BrAPI
::JSONResponse
->return_error($c->stash->{status
}, 'JSON array body required', 400);
146 _standard_response_construction
($c, $response);
148 $c->stash->{clean_inputs
} = _clean_inputs
($c->req->params,$c->request->data);
149 } elsif ($c->request->method eq "PUT") {
150 if (ref $c->request->data eq 'ARRAY') {
151 my $response = CXGN
::BrAPI
::JSONResponse
->return_error($c->stash->{status
}, 'JSON hash body required', 400);
152 _standard_response_construction
($c, $response);
154 $c->stash->{clean_inputs
} = $c->request->data;
156 $c->stash->{clean_inputs
} = $c->request->data;
160 $c->stash->{clean_inputs
} = _clean_inputs
($c->req->params);
164 #useful because javascript can pass 'undef' as an empty value, and also standardizes all inputs as arrayrefs
166 no warnings
'uninitialized';
171 my %data = ref $alldata eq 'ARRAY' ?
map { $_ => $_} @
{$alldata} : %{$alldata};
172 %$params = $params ?
(%data, %$params) : %data;
175 foreach (keys %$params){
176 my $values = $params->{$_};
178 if (ref \
$values eq 'SCALAR' || ref $values eq 'ARRAY'){
180 if (ref \
$values eq 'SCALAR') {
181 push @
$ret_val, $values;
182 } elsif (ref $values eq 'ARRAY'){
186 @
$ret_val = grep {$_ ne undef} @
$ret_val;
187 @
$ret_val = grep {$_ ne ''} @
$ret_val;
188 $_ =~ s/\[\]$//; #ajax POST with arrays adds [] to the end of the name e.g. germplasmName[]. since all inputs are arrays now we can remove the [].
189 $params->{$_} = $ret_val;
191 elsif (ref $values eq 'HASH') {
192 $params->{$_} = $values;
195 die "Input $_ is not a scalar, arrayref, or a single level hash\n";
202 sub _validate_request
{
204 my $data_type = shift;
206 my $required_fields = shift;
207 my $required_field_prefix = shift;
209 if ($required_fields) {
210 # Validate each array element
211 if ($data_type eq 'ARRAY') {
212 foreach my $object (values %{$data}) {
213 # Ignore the query params if they were passed in. Their included in the body
214 if (ref($object) eq 'HASH') {
215 _validate_request
($c, 'HASH', $object, $required_fields);
220 # Check all of our fields
221 foreach my $required_field (@
{$required_fields}) {
222 # Check if the required field has another level or not
223 if (ref($required_field) eq 'HASH') {
224 # Check the field keys and recurse
225 foreach my $sub_req_field (keys %{$required_field}) {
226 if ($data_type eq 'HASH') {
227 if (!$data->{$sub_req_field}) {
228 _missing_field_response
($c, $sub_req_field, $required_field_prefix);
230 my $sub_data = $data->{$sub_req_field};
231 _validate_request
($c, 'HASH', $sub_data, $required_field->{$sub_req_field},
232 $required_field_prefix ?
sprintf("%s.%s", $required_field_prefix, $sub_req_field): $sub_req_field);
239 if ($data_type eq 'HASH') {
240 if (!$data->{$required_field}) {
241 _missing_field_response
($c, $required_field, $required_field_prefix);
248 sub _missing_field_response
{
250 my $field_name = shift;
252 my $response = CXGN
::BrAPI
::JSONResponse
->return_error($c->stash->{status
}, $prefix ?
sprintf("%s.%s required", $prefix, $field_name) : sprintf("%s required", $field_name), 400);
253 _standard_response_construction
($c, $response);
256 sub _authenticate_user
{
258 my $force_authenticate = shift;
259 my $status = $c->stash->{status
};
264 my $wildcard = 'any';
266 print STDERR
"AUTHENTICATING USER status: $status\n";
267 my %server_permission;
269 print STDERR
"SERVER PERMISSION CHECK...\n";
270 my $server_permission = $c->config->{"brapi_" . $c->request->method};
271 my @server_permission = split ',', $server_permission;
272 %server_permission = map { $_ => 1 } @server_permission;
275 if(!$rc && !%server_permission){
276 $server_permission{$wildcard} = 1;
279 print STDERR
"SERVER CHECK DONE...\n";
280 # Check if there is a config for default brapi user. This will be overwritten if a token is passed.
281 # Will still throw error if auth is required
282 if ($c->config->{brapi_default_user
} && $c->config->{brapi_require_login
} == 0) {
283 print STDERR
"BRAPI DEFAULT USER CHECK...\n";
284 $user_id = CXGN
::People
::Person
->get_person_by_username($c->dbc->dbh, $c->config->{brapi_default_user
});
285 $user_type = $c->config->{brapi_default_user_role
};
286 if (! defined $user_id) {
287 my $brapi_package_result = CXGN
::BrAPI
::JSONResponse
->return_error($status, 'Default brapi user was not found');
288 _standard_response_construction
($c, $brapi_package_result, 500);
292 # If our brapi config is set to authenticate or the controller calling this asks for forcing of
293 # authentication or serverinfo call method request auth, we authenticate.
294 my $login = CXGN
::Login
->new($c->dbc->dbh);
295 if ($c->config->{brapi_require_login
} == 1 || $force_authenticate || !exists($server_permission{$wildcard})){
296 print STDERR
"REQUIRE LOGIN... logging in user\n";
297 print STDERR
"SESSION TOKEN: ".$c->stash->{session_token
}."\n";
298 if ($c->stash->{session_token
}) {
299 ($user_id, $user_type, $user_pref, $expired) = $login->query_from_cookie($c->stash->{session_token
});
300 print STDERR
"LOGGING IN USER: ".$user_id." : ".$user_type." : ".$expired;
303 print STDERR
"GET USER ID FROM LOGIN...\n";
305 $user_id = $c->user->get_object->get_sp_person_id();
306 ($user_type) = $c->user->get_object->get_user_type();
308 my $cookie_string = $login->get_login_cookie();
309 print STDERR
"USER ID: $user_id, EXPIRED: $expired, USER TYPE: $user_type\n";
310 $c->stash->{session_token
} = $login->get_login_cookie();
314 if (!$user_id || $expired || !$user_type || (!exists($server_permission{$user_type}) && !exists($server_permission{$wildcard}))) {
315 my $brapi_package_result = CXGN
::BrAPI
::JSONResponse
->return_error($status, 'You must login and have permission to access this BrAPI call.');
317 _standard_response_construction
($c, $brapi_package_result, 401);
321 return (1, $user_id, $user_type, $user_pref, $expired);
324 sub _standard_response_construction
{
326 my $brapi_package_result = shift;
327 my $return_status = shift;
328 my $status = $brapi_package_result->{status
};
329 my $pagination = $brapi_package_result->{pagination
};
330 my $result = $brapi_package_result->{result
};
331 my $datafiles = $brapi_package_result->{datafiles
};
333 # some older brapi stuff uses parameter, could refactor at some point
334 if (!$return_status) { $return_status = $brapi_package_result->{http_code
} };
336 my %metadata = (pagination
=>$pagination, status
=>$status, datafiles
=>$datafiles);
337 my %response = (metadata
=>\
%metadata, result
=>$result);
338 $c->stash->{rest
} = \
%response;
339 $c->response->status((!$return_status) ?
200 : $return_status);
343 =head2 /brapi/v1/token
345 Usage: For logging a user in and loggin a user out through the API
351 "grant_type" : "password", //(optional, text, `password`) ... The grant type, only allowed value is password, but can be ignored
352 "username" : "user38", // (required, text, `thepoweruser`) ... The username
353 "password" : "secretpw", // (optional, text, `mylittlesecret`) ... The password
354 "client_id" : "blabla" // (optional, text, `blabla`) ... The client id, currently ignored.
364 "userDisplayName": "John Smith",
365 "access_token": "..."
366 "expires_in": "The lifetime in seconds of the access token"
373 "access_token" : "..." // (optional, text, `R6gKDBRxM4HLj6eGi4u5HkQjYoIBTPfvtZzUD8TUzg4`) ... The user access token. Default: current user token.
380 "status" : { "message" : "User has been logged out successfully."},
388 sub authenticate_token
: Chained
('brapi') PathPart
('token') Args
(0) : ActionClass
('REST') { }
390 sub authenticate_token_DELETE
{
393 my $brapi = $self->brapi_module;
394 my $brapi_module = $brapi->brapi_wrapper('Authentication');
395 my $brapi_package_result = $brapi_module->logout();
396 _standard_response_construction
($c, $brapi_package_result);
399 sub authenticate_token_GET
{
402 process_authenticate_token
($self,$c);
405 sub authenticate_token_POST
{
408 process_authenticate_token
($self,$c);
411 sub process_authenticate_token
{
414 my $clean_inputs = $c->stash->{clean_inputs
};
415 my $brapi = $self->brapi_module;
416 my $brapi_module = $brapi->brapi_wrapper('Authentication');
417 my $brapi_package_result = $brapi_module->login(
418 $clean_inputs->{grant_type
}->[0],
419 $clean_inputs->{password
}->[0],
420 $clean_inputs->{username
}->[0],
421 $clean_inputs->{client_id
}->[0],
424 my $status = $brapi_package_result->{status
};
425 my $pagination = $brapi_package_result->{pagination
};
426 my $result = $brapi_package_result->{result
};
427 my $datafiles = $brapi_package_result->{datafiles
};
429 my %metadata = (pagination
=>$pagination, status
=>$status, datafiles
=>$datafiles);
430 my %response = (metadata
=>\
%metadata, access_token
=>$result->{access_token
}, userDisplayName
=>$result->{userDisplayName
}, expires_in
=>$CXGN::Login
::LOGIN_TIMEOUT
);
431 $c->stash->{rest
} = \
%response;
435 =head2 /brapi/v1/calls
437 Usage: For determining which calls have been implemented and with which datafile types and methods
457 "call": "allelematrix",
468 "call": "germplasm/id/mcpd",
477 "call": "doesntexistyet",
492 sub calls
: Chained
('brapi') PathPart
('calls') Args
(0) : ActionClass
('REST') { }
497 my ($auth) = _authenticate_user
($c);
498 my $clean_inputs = $c->stash->{clean_inputs
};
499 my $brapi = $self->brapi_module;
500 my $brapi_module = $brapi->brapi_wrapper('Calls');
501 my $brapi_package_result = $brapi_module->search(
504 _standard_response_construction
($c, $brapi_package_result);
507 =head2 /brapi/v2/serverinfo
509 Usage: For determining which endpoints have been implemented and with which datafile types and methods
529 "call": "allelematrix",
540 "call": "germplasm/id/mcpd",
549 "call": "doesntexistyet",
564 sub serverinfo
: Chained
('brapi') PathPart
('serverinfo') Args
(0) : ActionClass
('REST') { }
569 my ($auth) = _authenticate_user
($c);
570 my $clean_inputs = $c->stash->{clean_inputs
};
571 my $brapi = $self->brapi_module;
572 my $brapi_module = $brapi->brapi_wrapper('ServerInfo');
573 my $brapi_package_result = $brapi_module->search($c,$clean_inputs);
574 _standard_response_construction
($c, $brapi_package_result);
577 sub crops
: Chained
('brapi') PathPart
('crops') Args
(0) : ActionClass
('REST') { }
582 my $supported_crop = $c->config->{'supportedCrop'};
583 my $brapi = $self->brapi_module;
584 my $brapi_module = $brapi->brapi_wrapper('Crops');
585 my $brapi_package_result = $brapi_module->crops($supported_crop);
586 _standard_response_construction
($c, $brapi_package_result);
589 sub commoncropnames
: Chained
('brapi') PathPart
('commoncropnames') Args
(0) : ActionClass
('REST') { }
591 sub commoncropnames_GET
{
594 my $supported_crop = $c->config->{'supportedCrop'};
595 my $brapi = $self->brapi_module;
596 my $brapi_module = $brapi->brapi_wrapper('CommonCropNames');
597 my $brapi_package_result = $brapi_module->crops($supported_crop);
598 _standard_response_construction
($c, $brapi_package_result);
601 sub observation_levels
: Chained
('brapi') PathPart
('observationlevels') Args
(0) : ActionClass
('REST') { }
603 sub observation_levels_GET
{
606 my $brapi = $self->brapi_module;
607 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
608 my $brapi_package_result = $brapi_module->observation_levels();
609 _standard_response_construction
($c, $brapi_package_result);
612 sub seasons
: Chained
('brapi') PathPart
('seasons') Args
(0) : ActionClass
('REST') { }
617 my ($auth, $user_id) = _authenticate_user
($c);
618 my $clean_inputs = $c->stash->{clean_inputs
};
619 my $postedData = $clean_inputs;
621 foreach my $season (values %{$postedData}) {
623 seasonDbId
=>$season->{year
},
625 year
=>$season->{year
}
628 my $pagination = CXGN
::BrAPI
::Pagination
->pagination_response(scalar(@data), scalar(@data), 1);
629 my %result = (data
=>\
@data);
632 _standard_response_construction
($c, CXGN
::BrAPI
::JSONResponse
->return_success(\
%result, $pagination, \
@data_files, $status, "Season created successfully"));
638 seasons_process
($self, $c);
641 sub seasons_process
{
644 my ($auth) = _authenticate_user
($c);
645 my $clean_inputs = $c->stash->{clean_inputs
};
646 my $brapi = $self->brapi_module;
647 my $brapi_module = $brapi->brapi_wrapper('Studies');
648 my $brapi_package_result = $brapi_module->seasons(
649 $clean_inputs->{year
}->[0],
651 _standard_response_construction
($c, $brapi_package_result);
654 sub season_single
: Chained
('brapi') PathPart
('seasons') CaptureArgs
(1) {
658 $c->stash->{seasonDbId
} = $id;
661 sub season_fetch
: Chained
('season_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
664 sub season_fetch_GET
{
667 my ($auth) = _authenticate_user
($c);
668 my $clean_inputs = $c->stash->{clean_inputs
};
669 my $brapi = $self->brapi_module;
670 my $brapi_module = $brapi->brapi_wrapper('Seasons');
671 my $brapi_package_result = $brapi_module->detail($c->stash->{seasonDbId
});
672 _standard_response_construction
($c, $brapi_package_result);
675 sub season_search
: Chained
('brapi') PathPart
('search/seasons') Args
(0) : ActionClass
('REST') { }
677 sub season_search_POST
{
680 save_results
($self,$c,$c->stash->{clean_inputs
},'Seasons');
683 sub season_search_retrieve
: Chained
('brapi') PathPart
('search/seasons') Args
(1) {
686 my $search_id = shift;
687 retrieve_results
($self, $c, $search_id, 'Seasons');
691 =head2 brapi/v1/studyTypes
693 Usage: To retrieve a list of programs being worked onthe various study types
710 "description": "Description for Nursery study type"
714 "description": "Description for Nursery study type"
724 sub study_types
: Chained
('brapi') PathPart
('studytypes') Args
(0) : ActionClass
('REST') { }
726 sub study_types_POST
{
729 study_types_process
($self, $c);
732 sub study_types_GET
{
735 study_types_process
($self, $c);
738 sub study_types_process
{
741 my ($auth) = _authenticate_user
($c);
742 my $brapi = $self->brapi_module;
743 my $brapi_module = $brapi->brapi_wrapper('Studies');
744 my $brapi_package_result = $brapi_module->study_types();
745 _standard_response_construction
($c, $brapi_package_result);
751 =head2 /brapi/v1/germplasm-search?germplasmName=&germplasmGenus=&germplasmSubTaxa=&germplasmDbId&germplasmPUI=http://data.inra.fr/accession/234Col342&germplasmSpecies=Triticum&panel=diversitypanel1&collection=none&pageSize=pageSize&page=page
753 Usage: For searching a germplasm by name. Allows for exact and wildcard match methods. http://docs.brapi.apiary.io/#germplasm
759 "germplasmPUI" : "http://...", // (optional, text, `http://data.inra.fr/accession/234Col342`) ... The name or synonym of external genebank accession identifier
760 "germplasmDbId" : 986, // (optional, text, `986`) ... The name or synonym of external genebank accession identifier
761 "germplasmSpecies" : "tomato", // (optional, text, `aestivum`) ... The name or synonym of genus or species ( merge with below ?)
762 "germplasmGenus" : "Solanum lycopersicum", //(optional, text, `Triticum, Hordeum`) ... The name or synonym of genus or species
763 "germplasmName" : "XYZ1", // (optional, text, `Triticum, Hordeum`) ... The name or synonym of the accession
764 "accessionNumber" : "ITC1234" // optional
765 "pageSize" : 100, // (optional, integer, `1000`) ... The size of the pages to be returned. Default is `1000`.
766 "page": 1 (optional, integer, `10`) ... Which result page is requested
785 "germplasmDbId": "01BEL084609",
786 "defaultDisplayName": "Pahang",
787 "accessionNumber": "ITC0609",
788 "germplasmName": "Pahang",
789 "germplasmPUI": "http://www.crop-diversity.org/mgis/accession/01BEL084609",
790 "pedigree": "TOBA97/SW90.1057",
791 "germplasmSeedSource": "Female GID:4/Male GID:4",
793 "commonCropName": "banana",
794 "instituteCode": "01BEL084",
795 "instituteName": "ITC",
796 "biologicalStatusOfAccessionCode": 412,
797 "countryOfOriginCode": "UNK",
798 "typeOfGermplasmStorageCode": 10,
800 "species": "acuminata",
801 "speciesAuthority": "",
802 "subtaxa": "sp malaccensis var pahang",
803 "subtaxaAuthority": "",
807 "donorAccessionNumber": "",
808 "donorInstituteCode": "",
812 "acquisitionDate": "19470131"
820 sub germplasm_search_old
: Chained
('brapi') PathPart
('germplasm-search') Args
(0) : ActionClass
('REST') { }
822 sub germplasm_search_old_GET
{
825 my ($auth) = _authenticate_user
($c);
826 my $clean_inputs = $c->stash->{clean_inputs
};
827 my $brapi = $self->brapi_module;
828 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
829 my $brapi_package_result = $brapi_module->search({
830 germplasmName
=> $clean_inputs->{germplasmName
},
831 accessionNumber
=> $clean_inputs->{accessionNumber
},
832 germplasmGenus
=> $clean_inputs->{germplasmGenus
},
833 germplasmSubTaxa
=> $clean_inputs->{germplasmSubTaxa
},
834 germplasmSpecies
=> $clean_inputs->{germplasmSpecies
},
835 germplasmDbId
=> $clean_inputs->{germplasmDbId
},
836 germplasmPUI
=> $clean_inputs->{germplasmPUI
},
837 matchMethod
=> $clean_inputs->{matchMethod
},
839 _standard_response_construction
($c, $brapi_package_result);
842 sub germplasm_search_old_POST
{
845 # my ($auth) = _authenticate_user($c);
846 my $clean_inputs = $c->stash->{clean_inputs
};
847 my $brapi = $self->brapi_module;
848 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
849 my $brapi_package_result = $brapi_module->search({
850 germplasmName
=> $clean_inputs->{germplasmNames
},
851 accessionNumber
=> $clean_inputs->{accessionNumbers
},
852 germplasmGenus
=> $clean_inputs->{germplasmGenus
},
853 germplasmSubTaxa
=> $clean_inputs->{germplasmSubTaxa
},
854 germplasmSpecies
=> $clean_inputs->{germplasmSpecies
},
855 germplasmDbId
=> $clean_inputs->{germplasmDbIds
},
856 germplasmPUI
=> $clean_inputs->{germplasmPUIs
},
857 matchMethod
=> $clean_inputs->{matchMethod
},
859 _standard_response_construction
($c, $brapi_package_result);
862 sub germplasm
: Chained
('brapi') PathPart
('germplasm') Args
(0) : ActionClass
('REST') { }
867 my $auth = _authenticate_user
($c);
868 my $clean_inputs = $c->stash->{clean_inputs
};
869 my $brapi = $self->brapi_module;
870 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
871 my $brapi_package_result = $brapi_module->search($clean_inputs,$c);
873 _standard_response_construction
($c, $brapi_package_result);
879 my ($auth,$user_id) = _authenticate_user
($c);
880 my $clean_inputs = $c->stash->{clean_inputs
};
881 my $data = $clean_inputs;
883 foreach my $germplasm (values %{$data}) {
884 push @all_germplasm, $germplasm;
886 my $brapi = $self->brapi_module;
887 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
888 my $brapi_package_result = $brapi_module->store(\
@all_germplasm,$user_id,$c);
890 _standard_response_construction
($c, $brapi_package_result);
893 sub germplasm_search_save
: Chained
('brapi') PathPart
('search/germplasm') Args
(0) : ActionClass
('REST') { }
895 sub germplasm_search_save_POST
{
898 save_results
($self,$c,$c->stash->{clean_inputs
},'Germplasm');
901 sub germplasm_search_retrieve
: Chained
('brapi') PathPart
('search/germplasm') Args
(1) {
904 my $search_id = shift;
905 retrieve_results
($self, $c, $search_id, 'Germplasm');
908 =head2 brapi/v1/germplasm/{id}
910 Usage: To retrieve details for a single germplasm
919 "germplasmDbId": "01BEL084609",
920 "defaultDisplayName": "Pahang",
921 "germplasmName": "Pahang",
922 "accessionNumber": "ITC0609",
923 "germplasmPUI": "http://www.crop-diversity.org/mgis/accession/01BEL084609",
924 "pedigree": "TOBA97/SW90.1057",
925 "seedSource": "Female GID:4/Male GID:4",
926 "synonyms": ["Pahanga","Pahange"],
934 sub germplasm_single
: Chained
('brapi') PathPart
('germplasm') CaptureArgs
(1) {
937 my $stock_id = shift;
939 $c->stash->{stock_id
} = $stock_id;
943 sub germplasm_detail
: Chained
('germplasm_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
945 sub germplasm_detail_GET
{
948 my ($auth) = _authenticate_user
($c);
949 my $clean_inputs = $c->stash->{clean_inputs
};
950 my $brapi = $self->brapi_module;
951 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
952 my $brapi_package_result = $brapi_module->germplasm_detail(
953 $c->stash->{stock_id
},$c
955 _standard_response_construction
($c, $brapi_package_result);
958 sub germplasm_detail_PUT
{
961 my ($auth,$user_id) = _authenticate_user
($c);
962 my $clean_inputs = $c->stash->{clean_inputs
};
963 my $data = $clean_inputs;
965 push @all_germplasm, $data;
966 my $brapi = $self->brapi_module;
967 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
968 my $brapi_package_result = $brapi_module->update($c->stash->{stock_id
},\
@all_germplasm,$user_id,$c);
970 _standard_response_construction
($c, $brapi_package_result);
973 =head2 brapi/v1/germplasm/{id}/MCPD
975 MCPD CALL NO LONGER IN BRAPI SPEC
977 Usage: To retrieve multi crop passport descriptor for a single germplasm
986 "germplasmDbId": "01BEL084609",
987 "defaultDisplayName": "Pahang",
988 "accessionNumber": "ITC0609",
989 "germplasmName": "Pahang",
990 "germplasmPUI": "http://www.crop-diversity.org/mgis/accession/01BEL084609",
991 "pedigree": "TOBA97/SW90.1057",
992 "germplasmSeedSource": "Female GID:4/Male GID:4",
994 "commonCropName": "banana",
995 "instituteCode": "01BEL084",
996 "instituteName": "ITC",
997 "biologicalStatusOfAccessionCode": 412,
998 "countryOfOriginCode": "UNK",
999 "typeOfGermplasmStorageCode": 10,
1001 "species": "acuminata",
1002 "speciesAuthority": "",
1003 "subtaxa": "sp malaccensis var pahang",
1004 "subtaxaAuthority": "",
1008 "donorAccessionNumber": "",
1009 "donorInstituteCode": "",
1013 "acquisitionDate": "19470131"
1020 sub germplasm_mcpd
: Chained
('germplasm_single') PathPart
('mcpd') Args
(0) : ActionClass
('REST') { }
1022 sub germplasm_mcpd_GET
{
1025 my ($auth) = _authenticate_user
($c);
1026 my $clean_inputs = $c->stash->{clean_inputs
};
1027 my $brapi = $self->brapi_module;
1028 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
1029 my $brapi_package_result = $brapi_module->germplasm_mcpd(
1030 $c->stash->{stock_id
}
1032 _standard_response_construction
($c, $brapi_package_result);
1036 #BrAPI Trials are modeled as Folders
1037 sub trials_list
: Chained
('brapi') PathPart
('trials') Args
(0) : ActionClass
('REST') { }
1039 sub trials_list_GET
{
1042 trials_search_process
($self, $c);
1045 sub trials_list_POST
{
1048 my ($auth,$user_id) = _authenticate_user
($c);
1049 my $clean_inputs = $c->stash->{clean_inputs
};
1050 my $data = $clean_inputs;
1052 foreach my $trials (values %{$data}) {
1053 push @all_trials, $trials;
1055 my $brapi = $self->brapi_module;
1056 my $brapi_module = $brapi->brapi_wrapper('Trials');
1057 my $brapi_package_result = $brapi_module->store(\
@all_trials,$user_id);
1058 _standard_response_construction
($c, $brapi_package_result);
1061 sub trials_search_process
{
1064 my ($auth) = _authenticate_user
($c);
1065 my $clean_inputs = $c->stash->{clean_inputs
};
1066 my $brapi = $self->brapi_module;
1067 my $brapi_module = $brapi->brapi_wrapper('Trials');
1068 my $brapi_package_result = $brapi_module->search({
1069 crop
=> $c->config->{supportedCrop
},
1070 contactDbIds
=> $clean_inputs->{contactDbId
},
1071 searchDateRangeStart
=> $clean_inputs->{searchDateRangeStart
},
1072 searchDateRangeEnd
=> $clean_inputs->{searchDateRangeEnd
},
1073 trialPUIs
=> $clean_inputs->{trialPUI
},
1074 externalReferenceIDs
=> $clean_inputs->{externalReferenceID
},
1075 externalReferenceIds
=> $clean_inputs->{externalReferenceId
},
1076 externalReferenceSources
=> $clean_inputs->{externalReferenceSource
},
1077 active
=> $clean_inputs->{active
},
1078 commonCropNames
=> $clean_inputs->{commonCropName
},
1079 programDbIds
=> $clean_inputs->{programDbId
},
1080 locationDbIds
=> $clean_inputs->{locationDbId
},
1081 studyDbIds
=> $clean_inputs->{studyDbId
},
1082 trialDbIds
=> $clean_inputs->{trialDbId
},
1083 trialNames
=> $clean_inputs->{trialName
},
1086 _standard_response_construction
($c, $brapi_package_result);
1090 sub trials_single
: Chained
('brapi') PathPart
('trials') CaptureArgs
(1) {
1093 my $folder_id = shift;
1095 $c->stash->{trial_id
} = $folder_id;
1099 sub trials_detail
: Chained
('trials_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1101 sub trials_detail_PUT
{
1104 my ($auth,$user_id) = _authenticate_user
($c);
1105 my $clean_inputs = $c->stash->{clean_inputs
};
1106 my $data = $clean_inputs;
1107 $data->{trialDbId
} = $c->stash->{trial_id
};
1108 my $brapi = $self->brapi_module;
1109 my $brapi_module = $brapi->brapi_wrapper('Trials');
1110 my $brapi_package_result = $brapi_module->update($data,$user_id,$c->config->{supportedCrop
});
1111 _standard_response_construction
($c, $brapi_package_result);
1114 sub trials_detail_GET
{
1117 my ($auth) = _authenticate_user
($c);
1118 my $clean_inputs = $c->stash->{clean_inputs
};
1119 my $brapi = $self->brapi_module;
1120 my $brapi_module = $brapi->brapi_wrapper('Trials');
1121 my $brapi_package_result = $brapi_module->details(
1122 $c->stash->{trial_id
},
1123 $c->config->{supportedCrop
}
1125 _standard_response_construction
($c, $brapi_package_result);
1128 sub trials_search_save
: Chained
('brapi') PathPart
('search/trials') Args
(0) : ActionClass
('REST') { }
1130 sub trials_search_save_POST
{
1133 save_results
($self,$c,$c->stash->{clean_inputs
},'Trials');
1136 sub trials_search_retrieve
: Chained
('brapi') PathPart
('search/trials') Args
(1) {
1139 my $search_id = shift;
1140 retrieve_results
($self, $c, $search_id, 'Trials');
1144 =head2 brapi/v1/germplasm/{id}/pedigree?notation=purdy
1146 Usage: To retrieve pedigree information for a single germplasm
1148 Return JSON example:
1155 "germplasmDbId": "382",
1156 "pedigree": "TOBA97/SW90.1057",
1166 sub germplasm_pedigree
: Chained
('germplasm_single') PathPart
('pedigree') Args
(0) : ActionClass
('REST') { }
1168 sub germplasm_pedigree_POST
{
1171 #my $auth = _authenticate_user($c);
1174 sub germplasm_pedigree_GET
{
1177 my ($auth) = _authenticate_user
($c);
1178 my $clean_inputs = $c->stash->{clean_inputs
};
1179 my $brapi = $self->brapi_module;
1180 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
1181 my $brapi_package_result = $brapi_module->germplasm_pedigree({
1182 stock_id
=> $c->stash->{stock_id
},
1183 notation
=> $clean_inputs->{notation
}->[0]
1185 _standard_response_construction
($c, $brapi_package_result);
1189 =head2 brapi/v1/germplasm/{id}/progeny?notation=purdy
1191 Usage: To retrieve progeny (direct descendant) information for a single germplasm
1193 Return JSON example:
1201 "germplasmDbId": "382",
1202 "defaultDisplayName": "Pahang",
1204 "progenyGermplasmDbId": "403",
1205 "parentType": "FEMALE"
1207 "progenyGermplasmDbId": "402",
1208 "parentType": "MALE"
1210 "progenyGermplasmDbId": "405",
1211 "parentType": "SELF"
1220 sub germplasm_progeny
: Chained
('germplasm_single') PathPart
('progeny') Args
(0) : ActionClass
('REST') { }
1222 sub germplasm_progeny_POST
{
1227 sub germplasm_progeny_GET
{
1230 my ($auth) = _authenticate_user
($c);
1231 my $clean_inputs = $c->stash->{clean_inputs
};
1232 my $brapi = $self->brapi_module;
1233 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
1234 my $brapi_package_result = $brapi_module->germplasm_progeny({
1235 stock_id
=> $c->stash->{stock_id
}
1237 _standard_response_construction
($c, $brapi_package_result);
1240 sub germplasm_attributes_detail
: Chained
('germplasm_single') PathPart
('attributes') Args
(0) : ActionClass
('REST') { }
1242 sub germplasm_attributes_detail_GET
{
1245 my ($auth) = _authenticate_user
($c);
1246 my $clean_inputs = $c->stash->{clean_inputs
};
1247 my $brapi = $self->brapi_module;
1248 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributes');
1249 my $brapi_package_result = $brapi_module->germplasm_attributes_germplasm_detail({
1250 stock_id
=> $c->stash->{stock_id
},
1251 attribute_dbids
=> $clean_inputs->{attributeDbId
}
1253 _standard_response_construction
($c, $brapi_package_result);
1256 =head2 brapi/v1/germplasm/{id}/markerprofiles
1258 Usage: To retrieve markerprofile ids for a single germplasm
1260 Return JSON example:
1267 "germplasmDbId": "382",
1279 sub germplasm_markerprofile
: Chained
('germplasm_single') PathPart
('markerprofiles') Args
(0) : ActionClass
('REST') { }
1281 sub germplasm_markerprofile_POST
{
1284 #my $auth = _authenticate_user($c);
1287 sub germplasm_markerprofile_GET
{
1290 my ($auth) = _authenticate_user
($c);
1291 my $clean_inputs = $c->stash->{clean_inputs
};
1292 my $brapi = $self->brapi_module;
1293 my $brapi_module = $brapi->brapi_wrapper('Germplasm');
1294 my $brapi_package_result = $brapi_module->germplasm_markerprofiles(
1295 $c->stash->{stock_id
}
1297 _standard_response_construction
($c, $brapi_package_result);
1302 # Germplasm Attributes
1305 sub germplasm_attributes_list
: Chained
('brapi') PathPart
('attributes') Args
(0) : ActionClass
('REST') { }
1307 sub germplasm_attributes_list_GET
{
1310 germplasm_attributes_process
($self, $c);
1313 sub germplasm_attributes_process
{
1316 my ($auth) = _authenticate_user
($c);
1317 my $clean_inputs = $c->stash->{clean_inputs
};
1318 my $brapi = $self->brapi_module;
1319 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributes');
1320 my $brapi_package_result = $brapi_module->search($clean_inputs);
1321 _standard_response_construction
($c, $brapi_package_result);
1324 sub attribute_single
: Chained
('brapi') PathPart
('attributes') CaptureArgs
(1) {
1327 my $attribute_id = shift;
1329 $c->stash->{attribute_id
} = $attribute_id;
1332 sub attribute_detail
: Chained
('attribute_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1334 sub attribute_detail_GET
{
1337 my ($auth) = _authenticate_user
($c);
1338 my $clean_inputs = $c->stash->{clean_inputs
};
1339 my $brapi = $self->brapi_module;
1340 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributes');
1341 my $brapi_package_result = $brapi_module->detail($c->stash->{attribute_id
});
1342 _standard_response_construction
($c, $brapi_package_result);
1345 sub germplasm_attribute_categories_list
: Chained
('brapi') PathPart
('attributes/categories') Args
(0) : ActionClass
('REST') { }
1347 sub germplasm_attribute_categories_list_GET
{
1350 my ($auth) = _authenticate_user
($c);
1351 my $brapi = $self->brapi_module;
1352 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributes');
1353 my $brapi_package_result = $brapi_module->germplasm_attributes_categories_list();
1354 _standard_response_construction
($c, $brapi_package_result);
1357 sub attributes_save
: Chained
('brapi') PathPart
('search/attributes') Args
(0) : ActionClass
('REST') { }
1359 sub attributes_save_POST
{
1362 save_results
($self,$c,$c->stash->{clean_inputs
},'GermplasmAttributes');
1365 sub attributes_retrieve
: Chained
('brapi') PathPart
('search/attributes') Args
(1) {
1368 my $search_id = shift;
1369 retrieve_results
($self, $c, $search_id, 'GermplasmAttributes');
1373 sub germplasm_attributes_values
: Chained
('brapi') PathPart
('attributevalues') Args
(0) : ActionClass
('REST') { }
1375 sub germplasm_attributes_values_GET
{
1378 my ($auth) = _authenticate_user
($c);
1379 my $clean_inputs = $c->stash->{clean_inputs
};
1380 my $brapi = $self->brapi_module;
1381 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributeValues');
1382 my $brapi_package_result = $brapi_module->search($clean_inputs);
1383 _standard_response_construction
($c, $brapi_package_result);
1386 sub germplasm_attributes_values_single
: Chained
('brapi') PathPart
('attributevalues') CaptureArgs
(1) {
1389 my $value_id = shift;
1391 $c->stash->{value_id
} = $value_id;
1394 sub germplasm_attributes_values_detail
: Chained
('germplasm_attributes_values_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1396 sub germplasm_attributes_values_detail_GET
{
1399 my ($auth) = _authenticate_user
($c);
1400 my $clean_inputs = $c->stash->{clean_inputs
};
1401 $clean_inputs->{attributeValueDbId
}=[$c->stash->{value_id
}];
1402 my $brapi = $self->brapi_module;
1403 my $brapi_module = $brapi->brapi_wrapper('GermplasmAttributeValues');
1404 my $brapi_package_result = $brapi_module->search($clean_inputs);
1405 _standard_response_construction
($c, $brapi_package_result);
1408 sub attributes_values_save
: Chained
('brapi') PathPart
('search/attributevalues') Args
(0) : ActionClass
('REST') { }
1410 sub attributes_values_save_POST
{
1413 save_results
($self,$c,$c->stash->{clean_inputs
},'GermplasmAttributeValues');
1416 sub attributes_values_retrieve
: Chained
('brapi') PathPart
('search/attributevalues') Args
(1) {
1419 my $search_id = shift;
1420 retrieve_results
($self, $c, $search_id, 'GermplasmAttributeValues');
1423 =head2 brapi/v1/markerprofiles?germplasm=germplasmDbId&extract=extractDbId&method=methodDbId
1425 Usage: To retrieve markerprofile ids for a single germplasm
1427 Return JSON example:
1441 "markerProfileDbId": "993",
1442 "germplasmDbId" : 2374,
1443 "extractDbId" : 3939,
1444 "analysisMethod": "GoldenGate",
1448 "markerProfileDbId": "994",
1449 "germplasmDbId" : 2374,
1450 "extractDbId" : 3939,
1451 "analysisMethod": "GBS",
1462 sub markerprofile_search_process
{
1465 my ($auth) = _authenticate_user
($c);
1466 my $default_protocol = $self->bcs_schema->resultset('NaturalDiversity::NdProtocol')->find({name
=>$c->config->{default_genotyping_protocol
}});
1467 my $default_protocol_id = $default_protocol ?
$default_protocol->nd_protocol_id : 0;
1468 my $clean_inputs = $c->stash->{clean_inputs
};
1469 my $brapi = $self->brapi_module;
1470 my $brapi_module = $brapi->brapi_wrapper('Markerprofiles');
1471 my $brapi_package_result = $brapi_module->markerprofiles_search({
1472 cache_file_path
=> $c->config->{cache_file_path
},
1473 shared_cluster_dir
=> $c->config->{cluster_shared_tempdir
},
1474 study_ids
=> $clean_inputs->{studyDbId
},
1475 stock_ids
=> $clean_inputs->{germplasmDbId
},
1476 extract_ids
=> $clean_inputs->{extractDbId
},
1477 sample_ids
=> $clean_inputs->{sampleDbId
},
1478 protocol_ids
=> $clean_inputs->{methodDbId
}
1480 _standard_response_construction
($c, $brapi_package_result);
1483 sub markerprofiles_list
: Chained
('brapi') PathPart
('markerprofiles') Args
(0) : ActionClass
('REST') { }
1485 sub markerprofiles_list_POST
{
1488 markerprofile_search_process
($self, $c);
1491 sub markerprofiles_list_GET
{
1494 markerprofile_search_process
($self, $c);
1498 =head2 brapi/v1/markerprofiles/markerprofilesDbId
1500 Usage: To retrieve data for a single markerprofile
1502 Return JSON example:
1515 "germplasmDbId": 993,
1516 "extractDbId" : 38383,
1517 "markerprofileDbId": 37484,
1518 "analysisMethod": "GBS-Pst1",
1519 "encoding": "AA,BB,AB",
1520 "data" : [ { "marker1": "AA" }, { "marker2":"AB" }, ... ]
1528 sub markerprofiles_single
: Chained
('brapi') PathPart
('markerprofiles') CaptureArgs
(1) {
1532 $c->stash->{markerprofile_id
} = $id; # this is genotypeprop_id
1535 sub genotype_fetch
: Chained
('markerprofiles_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1537 sub genotype_fetch_POST
{
1540 #my $auth = _authenticate_user($c);
1543 sub genotype_fetch_GET
{
1546 my ($auth) = _authenticate_user
($c);
1547 my $clean_inputs = $c->stash->{clean_inputs
};
1548 my $brapi = $self->brapi_module;
1549 my $brapi_module = $brapi->brapi_wrapper('Markerprofiles');
1550 my $brapi_package_result = $brapi_module->markerprofiles_detail({
1551 cache_file_path
=> $c->config->{cache_file_path
},
1552 shared_cluster_dir
=> $c->config->{cluster_shared_tempdir
},
1553 markerprofile_id
=> $c->stash->{markerprofile_id
},
1554 unknown_string
=> $clean_inputs->{unknownString
}->[0],
1555 sep_phased
=> $clean_inputs->{sepPhased
}->[0],
1556 sep_unphased
=> $clean_inputs->{sepUnphased
}->[0],
1557 expand_homozygotes
=> $clean_inputs->{expandHomozygotes
}->[0],
1559 _standard_response_construction
($c, $brapi_package_result);
1563 sub markerprofiles_methods
: Chained
('brapi') PathPart
('markerprofiles/methods') Args
(0) {
1566 my ($auth) = _authenticate_user
($c);
1567 my $brapi = $self->brapi_module;
1568 my $brapi_module = $brapi->brapi_wrapper('Markerprofiles');
1569 my $brapi_package_result = $brapi_module->markerprofiles_methods();
1570 _standard_response_construction
($c, $brapi_package_result);
1575 =head2 brapi/v1/allelematrices-search?markerprofileDbId=100&markerprofileDbId=101
1577 Usage: Gives a matrix data structure for a given list of markerprofileDbIds
1579 Return JSON example:
1591 "makerprofileDbIds": ["markerprofileId1","markerprofileId2","markerprofileId3"],
1593 { "markerDbId1":["AB","AA","AA"] },
1594 { "markerDbId2":["AA","AB","AA"] },
1595 { "markerDbId3":["AB","AB","BB"] }
1604 sub allelematrices
: Chained
('brapi') PathPart
('allelematrices-search') Args
(0) : ActionClass
('REST') { }
1606 sub allelematrices_POST
{
1609 allelematrix_search_process
($self, $c);
1612 sub allelematrices_GET
{
1615 allelematrix_search_process
($self, $c);
1618 sub allelematrices_new
: Chained
('brapi') PathPart
('allelematrices') Args
(0) : ActionClass
('REST') { }
1620 sub allelematrices_new_GET
{
1623 allelematrix_search_process
($self, $c);
1626 sub allelematrices_cached
: Chained
('brapi') PathPart
('search/allelematrices') Args
(0) : ActionClass
('REST') { }
1628 sub allelematrices_cached_POST
{
1631 allelematrix_search_process
($self, $c);
1634 sub allelematrices_cached_GET
{
1637 allelematrix_search_process
($self, $c);
1641 sub allelematrix
: Chained
('brapi') PathPart
('allelematrix-search') Args
(0) : ActionClass
('REST') { }
1643 sub allelematrix_POST
{
1646 allelematrix_search_process
($self, $c);
1649 sub allelematrix_GET
{
1652 allelematrix_search_process
($self, $c);
1655 sub allelematrix_search_process
{
1658 # my ($auth) = _authenticate_user($c);
1660 my $clean_inputs = $c->stash->{clean_inputs
};
1661 my $format = $clean_inputs->{format
}->[0];
1664 if ($format eq 'tsv' || $format eq 'csv' || $format eq 'xls'){
1665 my $dir = $c->tempfiles_subdir('download');
1666 ($file_path, $uri) = $c->tempfile( TEMPLATE
=> 'download/allelematrix_'.$format.'_'.'XXXXX');
1668 my $brapi = $self->brapi_module;
1669 my $brapi_module = $brapi->brapi_wrapper('Markerprofiles');
1670 my $brapi_package_result = $brapi_module->markerprofiles_allelematrix({
1671 cache_file_path
=> $c->config->{cache_file_path
},
1672 shared_cluster_dir
=> $c->config->{cluster_shared_tempdir
},
1673 markerprofile_ids
=> $clean_inputs->{markerprofileDbId
},
1674 marker_ids
=> $clean_inputs->{markerDbId
},
1675 unknown_string
=> $clean_inputs->{unknownString
}->[0],
1676 sep_phased
=> $clean_inputs->{sepPhased
}->[0],
1677 sep_unphased
=> $clean_inputs->{sepUnphased
}->[0],
1678 expand_homozygotes
=> $clean_inputs->{expandHomozygotes
}->[0],
1680 main_production_site_url
=> $c->config->{main_production_site_url
},
1681 file_path
=> $file_path,
1684 _standard_response_construction
($c, $brapi_package_result);
1688 =head2 brapi/v2/plates
1692 sub plates
: Chained
('brapi') PathPart
('plates') Args
(0) : ActionClass
('REST') { }
1697 my ($auth,$user_id) = _authenticate_user
($c);
1698 my $clean_inputs = $c->stash->{clean_inputs
};
1699 my $brapi = $self->brapi_module;
1700 my $brapi_module = $brapi->brapi_wrapper('Plates');
1701 my $brapi_package_result = $brapi_module->search($clean_inputs,$user_id);
1702 _standard_response_construction
($c, $brapi_package_result);
1705 sub plates_single
: Chained
('brapi') PathPart
('plates') CaptureArgs
(1) {
1708 my $plate_id = shift;
1710 $c->stash->{plate_id
} = $plate_id;
1713 sub plates_detail
: Chained
('plates_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1715 sub plates_detail_GET
{
1718 my ($auth,$user_id) = _authenticate_user
($c);
1719 my $clean_inputs = $c->stash->{clean_inputs
};
1720 my $brapi = $self->brapi_module;
1721 my $brapi_module = $brapi->brapi_wrapper('Plates');
1722 my $brapi_package_result = $brapi_module->detail($c->stash->{plate_id
},$user_id);
1723 _standard_response_construction
($c, $brapi_package_result);
1726 sub plates_search_save
: Chained
('brapi') PathPart
('search/plates') Args
(0) : ActionClass
('REST') { }
1728 sub plates_search_save_POST
{
1731 save_results
($self,$c,$c->stash->{clean_inputs
},'Plates');
1734 sub plates_search_retrieve
: Chained
('brapi') PathPart
('search/Plates') Args
(1) {
1737 my $search_id = shift;
1738 retrieve_results
($self, $c, $search_id, 'Plates');
1742 =head2 brapi/v2/lists
1746 sub lists
: Chained
('brapi') PathPart
('lists') Args
(0) : ActionClass
('REST') { }
1751 my ($auth,$user_id) = _authenticate_user
($c, $c->config->{brapi_lists_require_login
});
1752 my $clean_inputs = $c->stash->{clean_inputs
};
1753 my $brapi = $self->brapi_module;
1754 my $brapi_module = $brapi->brapi_wrapper('Lists');
1755 my $brapi_package_result;
1756 if($c->config->{brapi_lists_require_login
}) {
1757 $brapi_package_result = $brapi_module->search($clean_inputs, $user_id, 1);
1759 $brapi_package_result = $brapi_module->search($clean_inputs, undef, 0);
1761 _standard_response_construction
($c, $brapi_package_result);
1767 my ($auth,$user_id) = _authenticate_user
($c);
1768 my $clean_inputs = $c->stash->{clean_inputs
};
1769 my $data = $clean_inputs;
1771 foreach my $list (values %{$data}) {
1772 push @all_lists, $list;
1774 my $brapi = $self->brapi_module;
1775 my $brapi_module = $brapi->brapi_wrapper('Lists');
1776 my $brapi_package_result = $brapi_module->store(\
@all_lists,$user_id);
1777 _standard_response_construction
($c, $brapi_package_result);
1780 sub list_single
: Chained
('brapi') PathPart
('lists') CaptureArgs
(1) {
1783 my $list_id = shift;
1785 $c->stash->{list_id
} = $list_id;
1788 sub list_detail
: Chained
('list_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1790 sub list_detail_GET
{
1793 my ($auth,$user_id) = _authenticate_user
($c);
1794 my $clean_inputs = $c->stash->{clean_inputs
};
1795 my $brapi = $self->brapi_module;
1796 my $brapi_module = $brapi->brapi_wrapper('Lists');
1797 my $brapi_package_result = $brapi_module->detail($c->stash->{list_id
},$user_id);
1798 _standard_response_construction
($c, $brapi_package_result);
1801 sub list_detail_PUT
{
1804 my ($auth,$user_id) = _authenticate_user
($c);
1805 my $clean_inputs = $c->stash->{clean_inputs
};
1806 my $data = $clean_inputs;
1807 $data->{listDbId
} = $c->stash->{list_id
};
1808 my $brapi = $self->brapi_module;
1809 my $brapi_module = $brapi->brapi_wrapper('Lists');
1810 my $brapi_package_result = $brapi_module->update($data,$user_id);
1811 _standard_response_construction
($c, $brapi_package_result);
1814 sub list_items
: Chained
('list_single') PathPart
('items') Args
(0) : ActionClass
('REST') { }
1816 sub list_items_POST
{
1819 my ($auth,$user_id) = _authenticate_user
($c);
1820 my $clean_inputs = $c->stash->{clean_inputs
};
1821 my $brapi = $self->brapi_module;
1822 my $brapi_module = $brapi->brapi_wrapper('Lists');
1823 my $brapi_package_result = $brapi_module->store_items($c->stash->{list_id
},$clean_inputs,$user_id);
1824 _standard_response_construction
($c, $brapi_package_result);
1827 sub list_data
: Chained
('list_single') PathPart
('data') Args
(0) : ActionClass
('REST') { }
1829 sub list_data_POST
{
1832 my ($auth,$user_id) = _authenticate_user
($c);
1833 my $clean_inputs = $c->stash->{clean_inputs
};
1834 my $brapi = $self->brapi_module;
1835 my $brapi_module = $brapi->brapi_wrapper('Lists');
1836 my $brapi_package_result = $brapi_module->store_items($c->stash->{list_id
},$clean_inputs,$user_id);
1837 _standard_response_construction
($c, $brapi_package_result);
1841 sub list_search_save
: Chained
('brapi') PathPart
('search/lists') Args
(0) : ActionClass
('REST') { }
1843 sub list_search_save_POST
{
1846 save_results
($self,$c,$c->stash->{clean_inputs
},'Lists');
1849 sub list_search_retrieve
: Chained
('brapi') PathPart
('search/lists') Args
(1) {
1852 my $search_id = shift;
1853 retrieve_results
($self, $c, $search_id, 'Lists');
1856 =head2 brapi/v2/people
1860 sub people
: Chained
('brapi') PathPart
('people') Args
(0) : ActionClass
('REST') { }
1865 my ($auth) = _authenticate_user
($c);
1866 my $clean_inputs = $c->stash->{clean_inputs
};
1867 my $brapi = $self->brapi_module;
1868 my $brapi_module = $brapi->brapi_wrapper('People');
1869 my $brapi_package_result = $brapi_module->search($clean_inputs,$c);
1870 _standard_response_construction
($c, $brapi_package_result);
1873 sub people_single
: Chained
('brapi') PathPart
('people') CaptureArgs
(1) {
1876 my $people_id = shift;
1878 $c->stash->{people_id
} = $people_id;
1881 sub people_detail
: Chained
('people_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1883 sub people_detail_GET
{
1886 my ($auth) = _authenticate_user
($c);
1887 my $clean_inputs = $c->stash->{clean_inputs
};
1888 my $brapi = $self->brapi_module;
1889 my $brapi_module = $brapi->brapi_wrapper('People');
1890 my $brapi_package_result = $brapi_module->detail($c->stash->{people_id
},$c);
1891 _standard_response_construction
($c, $brapi_package_result);
1894 sub people_search_save
: Chained
('brapi') PathPart
('search/people') Args
(0) : ActionClass
('REST') { }
1896 sub people_search_save_POST
{
1899 save_results
($self,$c,$c->stash->{clean_inputs
},'People');
1902 sub people_search_retrieve
: Chained
('brapi') PathPart
('search/people') Args
(1) {
1905 my $search_id = shift;
1906 retrieve_results
($self, $c, $search_id, 'People');
1909 =head2 brapi/v1/programs
1911 Usage: To retrieve a list of programs being worked on
1913 Return JSON example:
1927 "programDbid": "123",
1928 "name": "Wheat Resistance Program",
1929 "objective" : "Disease resistance",
1930 "leadPerson" : "Dr. Henry Beachell"
1933 "programDbId": "456",
1934 "name": "Wheat Improvement Program",
1935 "objective" : "Yield improvement",
1936 "leadPerson" : "Dr. Norman Borlaug"
1946 sub programs_list
: Chained
('brapi') PathPart
('programs') Args
(0) : ActionClass
('REST') { }
1948 sub programs_list_POST
{
1951 my ($auth,$user_id) = _authenticate_user
($c);
1952 my $clean_inputs = $c->stash->{clean_inputs
};
1953 my $data = $clean_inputs;
1955 foreach my $program (values %{$data}) {
1956 push @all_programs, $program;
1958 my $brapi = $self->brapi_module;
1959 my $brapi_module = $brapi->brapi_wrapper('Programs');
1961 my $brapi_package_result = $brapi_module->store(\
@all_programs, $user_id);
1962 _standard_response_construction
($c, $brapi_package_result);
1965 sub programs_list_GET
{
1968 my ($auth) = _authenticate_user
($c);
1969 my $clean_inputs = $c->stash->{clean_inputs
};
1970 my $brapi = $self->brapi_module;
1971 my $brapi_module = $brapi->brapi_wrapper('Programs');
1972 my $brapi_package_result = $brapi_module->search({
1973 program_names
=> $clean_inputs->{programName
},
1974 programNames
=> $clean_inputs->{programName
},
1975 abbreviations
=> $clean_inputs->{abbreviation
},
1976 externalReferenceIDs
=> $clean_inputs->{externalReferenceID
},
1977 externalReferenceSources
=> $clean_inputs->{externalReferenceSource
},
1978 commonCropNames
=> $clean_inputs->{commonCropName
},
1979 crop
=> $c->config->{supportedCrop
}
1981 _standard_response_construction
($c, $brapi_package_result);
1984 sub programs_single
: Chained
('brapi') PathPart
('programs') CaptureArgs
(1) {
1987 my $program_id = shift;
1989 $c->stash->{program_id
} = $program_id;
1992 sub programs_detail
: Chained
('programs_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
1994 sub programs_detail_GET
{
1997 my ($auth) = _authenticate_user
($c);
1998 my $clean_inputs = $c->stash->{clean_inputs
};
1999 my $brapi = $self->brapi_module;
2000 my $brapi_module = $brapi->brapi_wrapper('Programs');
2001 my $brapi_package_result = $brapi_module->detail(
2002 $c->stash->{program_id
},
2003 $c->config->{supportedCrop
}
2005 _standard_response_construction
($c, $brapi_package_result);
2008 sub programs_detail_PUT
{
2011 my ($auth,$user_id) = _authenticate_user
($c);
2012 my $user_id = undef;
2013 my $clean_inputs = $c->stash->{clean_inputs
};
2014 my $data = $clean_inputs;
2015 $data->{programDbId
} = $c->stash->{program_id
};
2016 my $brapi = $self->brapi_module;
2017 my $brapi_module = $brapi->brapi_wrapper('Programs');
2018 my $brapi_package_result = $brapi_module->update($data,$user_id);
2019 _standard_response_construction
($c, $brapi_package_result);
2022 sub programs_search_save
: Chained
('brapi') PathPart
('search/programs') Args
(0) : ActionClass
('REST') { }
2024 sub programs_search_save_POST
{
2026 my $c = shift; #print $self;
2027 save_results
($self,$c,$c->stash->{clean_inputs
},'Programs');
2030 sub programs_search_retrieve
: Chained
('brapi') PathPart
('search/programs') Args
(1) {
2033 my $search_id = shift;
2034 retrieve_results
($self, $c, $search_id, 'Programs');
2038 =head2 brapi/v1/studies?programId=programId
2040 Usage: To retrieve studies
2042 Return JSON example:
2057 "name": "Earlygenerationtesting",
2058 "studyType": "Trial",
2059 "years": ["2005", "2008"],
2063 "studyPUI" : "PUI string",
2064 "studyType": "Trial",
2065 "startDate": "2015-06-01",
2066 "endDate" : "2015-12-31",
2072 "name": "Earlygenerationtesting",
2073 "seasons": ["2005", "2008"],
2077 "studyPUI" : "PUI string",
2078 "studyType": "Trial",
2079 "startDate": "2015-06-01",
2080 "endDate" : "2015-12-31",
2091 sub studies_search
: Chained
('brapi') PathPart
('studies-search') Args
(0) : ActionClass
('REST') { }
2093 sub studies_search_POST
{
2096 # my ($auth) = _authenticate_user($c);
2097 my $clean_inputs = $c->stash->{clean_inputs
};
2098 my $brapi = $self->brapi_module;
2099 my $brapi_module = $brapi->brapi_wrapper('Studies');
2100 my $brapi_package_result = $brapi_module->search({
2101 programDbIds
=> $clean_inputs->{programDbIds
},
2102 programNames
=> $clean_inputs->{programNames
},
2103 studyDbIds
=> $clean_inputs->{studyDbIds
},
2104 studyNames
=> $clean_inputs->{studyNames
},
2105 trialDbIds
=> $clean_inputs->{trialDbIds
},
2106 trialNames
=> $clean_inputs->{trialNames
},
2107 studyLocationDbIds
=> $clean_inputs->{locationDbIds
},
2108 studyLocationNames
=> $clean_inputs->{studyLocations
},
2109 studyTypeName
=> $clean_inputs->{studyType
},
2110 germplasmDbIds
=> $clean_inputs->{germplasmDbIds
},
2111 germplasmNames
=> $clean_inputs->{germplasmNames
},
2112 seasons
=> $clean_inputs->{seasonDbIds
},
2113 observationVariableDbIds
=> $clean_inputs->{observationVariableDbIds
},
2114 observationVariableNames
=> $clean_inputs->{observationVariableNames
},
2115 active
=> $clean_inputs->{active
}->[0],
2116 sortBy
=> $clean_inputs->{sortBy
}->[0],
2117 sortOrder
=> $clean_inputs->{sortOrder
}->[0],
2119 _standard_response_construction
($c, $brapi_package_result);
2122 sub studies_search_GET
{
2125 my ($auth) = _authenticate_user
($c);
2126 my $clean_inputs = $c->stash->{clean_inputs
};
2127 my $brapi = $self->brapi_module;
2128 my $brapi_module = $brapi->brapi_wrapper('Studies');
2129 my $brapi_package_result = $brapi_module->search({
2130 programDbIds
=> $clean_inputs->{programDbId
},
2131 programNames
=> $clean_inputs->{programName
},
2132 studyDbIds
=> $clean_inputs->{studyDbId
},
2133 studyNames
=> $clean_inputs->{studyName
},
2134 trialDbIds
=> $clean_inputs->{trialDbId
},
2135 trialNames
=> $clean_inputs->{trialName
},
2136 studyLocationDbIds
=> $clean_inputs->{locationDbId
},
2137 studyLocationNames
=> $clean_inputs->{locationName
},
2138 seasons
=> $clean_inputs->{seasonDbId
},
2139 studyTypeName
=> $clean_inputs->{studyType
},
2140 germplasmDbIds
=> $clean_inputs->{germplasmDbId
},
2141 germplasmNames
=> $clean_inputs->{germplasmName
},
2142 observationVariableDbIds
=> $clean_inputs->{observationVariableDbId
},
2143 observationVariableNames
=> $clean_inputs->{observationVariableName
},
2144 active
=> $clean_inputs->{active
}->[0],
2145 sortBy
=> $clean_inputs->{sortBy
}->[0],
2146 sortOrder
=> $clean_inputs->{sortOrder
}->[0],
2148 _standard_response_construction
($c, $brapi_package_result);
2151 sub studies
: Chained
('brapi') PathPart
('studies') Args
(0) : ActionClass
('REST') { }
2156 my $auth = _authenticate_user
($c);
2157 my $clean_inputs = $c->stash->{clean_inputs
};
2158 my $brapi = $self->brapi_module;
2159 my $brapi_module = $brapi->brapi_wrapper('Studies');
2160 my $brapi_package_result = $brapi_module->search({
2161 programDbIds
=> $clean_inputs->{programDbId
},
2162 programNames
=> $clean_inputs->{programName
},
2163 studyDbIds
=> $clean_inputs->{studyDbId
},
2164 studyNames
=> $clean_inputs->{studyName
},
2165 trialDbIds
=> $clean_inputs->{trialDbId
},
2166 trialNames
=> $clean_inputs->{trialName
},
2167 studyLocationDbIds
=> $clean_inputs->{locationDbId
},
2168 studyLocationNames
=> $clean_inputs->{locationName
},
2169 seasons
=> $clean_inputs->{seasonDbId
},
2170 seasonDbIds
=> $clean_inputs->{seasonDbId
},
2171 studyTypes
=> $clean_inputs->{studyType
},
2172 germplasmDbIds
=> $clean_inputs->{germplasmDbId
},
2173 germplasmNames
=> $clean_inputs->{germplasmName
},
2174 observationVariableDbIds
=> $clean_inputs->{observationVariableDbId
},
2175 observationVariableNames
=> $clean_inputs->{observationVariableName
},
2176 crop
=> $c->config->{supportedCrop
},
2177 active
=> $clean_inputs->{active
}->[0],
2178 sortBy
=> $clean_inputs->{sortBy
}->[0],
2179 sortOrder
=> $clean_inputs->{sortOrder
}->[0],
2180 commonCropNames
=> $clean_inputs->{commonCropName
},
2182 _standard_response_construction
($c, $brapi_package_result);
2188 my ($auth, $user_id) = _authenticate_user
($c);
2189 my $clean_inputs = $c->stash->{clean_inputs
};
2190 my $data = $clean_inputs;
2191 _validate_request
($c, 'ARRAY', $data, ['trialDbId', 'studyName', 'studyType', 'locationDbId', {'experimentalDesign' => ['PUI']}]);
2194 foreach my $study (values %{$data}) {
2195 push @all_studies, $study;
2197 my $brapi = $self->brapi_module;
2198 my $brapi_module = $brapi->brapi_wrapper('Studies');
2199 my $brapi_package_result = $brapi_module->store(\
@all_studies, $user_id, $c);
2200 _standard_response_construction
($c, $brapi_package_result);
2203 sub studies_search_save
: Chained
('brapi') PathPart
('search/studies') Args
(0) : ActionClass
('REST') { }
2205 sub studies_search_save_POST
{
2208 save_results
($self,$c,$c->stash->{clean_inputs
},'Studies');
2211 sub studies_search_retrieve
: Chained
('brapi') PathPart
('search/studies') Args
(1) {
2214 my $search_id = shift;
2215 retrieve_results
($self, $c, $search_id, 'Studies');
2219 =head2 brapi/v1/studies/{studyId}/germplasm?pageSize=20&page=1
2221 Usage: To retrieve all germplasm used in a study
2223 Return JSON example:
2236 "studyName": "myBestTrial",
2239 "germplasmDbId": "382",
2240 "trialEntryNumberId": "1",
2241 "defaultDisplayName": "Pahang",
2242 "germplasmName": "Pahang",
2243 "accessionNumber": "ITC0609",
2244 "germplasmPUI": "http://www.crop-diversity.org/mgis/accession/01BEL084609",
2245 "pedigree": "TOBA97/SW90.1057",
2247 "synonyms": ["01BEL084609"],
2250 "germplasmDbId": "394",
2251 "trialEntryNumberId": "2",
2252 "defaultDisplayName": "Pahang",
2253 "germplasmName": "Pahang",
2254 "accessionNumber": "ITC0727",
2255 "germplasmPUI": "http://www.crop-diversity.org/mgis/accession/01BEL084727",
2256 "pedigree": "TOBA97/SW90.1057",
2258 "synonyms": [ "01BEL084727"],
2268 sub studies_single
: Chained
('brapi') PathPart
('studies') CaptureArgs
(1) {
2271 my $study_id = shift;
2273 $c->stash->{study_id
} = $study_id;
2277 sub studies_germplasm
: Chained
('studies_single') PathPart
('germplasm') Args
(0) : ActionClass
('REST') { }
2279 sub studies_germplasm_POST
{
2282 my ($auth) = _authenticate_user
($c);
2284 my $metadata = $c->req->params("metadata");
2285 my $result = $c->req->params("result");
2286 my %metadata_hash = %$metadata;
2287 my %result_hash = %$result;
2289 #print STDERR Dumper($metadata);
2290 #print STDERR Dumper($result);
2292 my $pagintation = $metadata_hash{"pagination"};
2295 sub studies_germplasm_GET
{
2298 my ($auth) = _authenticate_user
($c);
2299 my $brapi = $self->brapi_module;
2300 my $brapi_module = $brapi->brapi_wrapper('Studies');
2301 my $brapi_package_result = $brapi_module->studies_germplasm(
2302 $c->stash->{study_id
}
2304 _standard_response_construction
($c, $brapi_package_result);
2307 sub studies_info
: Chained
('studies_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
2309 sub studies_info_POST
{
2312 #my $auth = _authenticate_user($c);
2315 sub studies_info_GET
{
2318 my ($auth) = _authenticate_user
($c);
2319 my $clean_inputs = $c->stash->{clean_inputs
};
2320 my $brapi = $self->brapi_module;
2321 my $brapi_module = $brapi->brapi_wrapper('Studies');
2322 my $brapi_package_result = $brapi_module->detail(
2323 $c->stash->{study_id
},
2324 $c->config->{main_production_site_url
},
2325 $c->config->{supportedCrop
}
2327 _standard_response_construction
($c, $brapi_package_result);
2330 sub studies_info_PUT
{
2333 my ($auth,$user_id) = _authenticate_user
($c);
2334 my $clean_inputs = $c->stash->{clean_inputs
};
2335 my $data = $clean_inputs;
2336 _validate_request
($c, 'HASH', $data, ['trialDbId', 'studyName', 'studyType', 'locationDbId', {'experimentalDesign' => ['PUI']}]);
2337 $data->{studyDbId
} = $c->stash->{study_id
};
2339 my $brapi = $self->brapi_module;
2340 my $brapi_module = $brapi->brapi_wrapper('Studies');
2341 my $brapi_package_result = $brapi_module->update($data,$user_id,$c);
2342 _standard_response_construction
($c, $brapi_package_result);
2345 sub studies_observation_variables
: Chained
('studies_single') PathPart
('observationvariables') Args
(0) : ActionClass
('REST') { }
2347 sub studies_observation_variables_POST
{
2350 #my $auth = _authenticate_user($c);
2353 sub studies_observation_variables_GET
{
2356 my ($auth) = _authenticate_user
($c);
2357 my $brapi = $self->brapi_module;
2358 my $brapi_module = $brapi->brapi_wrapper('Studies');
2359 my $brapi_package_result = $brapi_module->studies_observation_variables(
2360 $c->stash->{study_id
},
2361 $c->config->{supportedCrop
}
2363 _standard_response_construction
($c, $brapi_package_result);
2367 sub studies_layout
: Chained
('studies_single') PathPart
('layout') Args
(0) : ActionClass
('REST') { }
2369 sub studies_layout_POST
{
2372 #my $auth = _authenticate_user($c);
2375 sub studies_layout_GET
{
2378 my $clean_inputs = $c->stash->{clean_inputs
};
2379 my ($auth) = _authenticate_user
($c);
2380 my $format = $clean_inputs->{format
}->[0] || 'json';
2383 if ($format eq 'tsv' || $format eq 'csv' || $format eq 'xls'){
2384 my $dir = $c->tempfiles_subdir('download');
2385 my $time_stamp = strftime
"%Y-%m-%dT%H%M%S", localtime();
2386 my $temp_file_name = $time_stamp . "phenotype_download_$format"."_XXXX";
2387 ($file_path, $uri) = $c->tempfile( TEMPLATE
=> "download/$temp_file_name");
2390 my $brapi = $self->brapi_module;
2391 my $brapi_module = $brapi->brapi_wrapper('Studies');
2392 my $brapi_package_result = $brapi_module->studies_layout({
2393 study_id
=> $c->stash->{study_id
},
2395 main_production_site_url
=> $c->config->{main_production_site_url
},
2396 file_path
=> $file_path,
2399 _standard_response_construction
($c, $brapi_package_result);
2402 sub studies_layouts
: Chained
('studies_single') PathPart
('layouts') Args
(0) : ActionClass
('REST') { }
2404 sub studies_layouts_GET
{
2407 my $clean_inputs = $c->stash->{clean_inputs
};
2408 my ($auth) = _authenticate_user
($c);
2409 my $format = $clean_inputs->{format
}->[0] || 'json';
2412 if ($format eq 'tsv' || $format eq 'csv' || $format eq 'xls'){
2413 my $dir = $c->tempfiles_subdir('download');
2414 my $time_stamp = strftime
"%Y-%m-%dT%H%M%S", localtime();
2415 my $temp_file_name = $time_stamp . "phenotype_download_$format"."_XXXX";
2416 ($file_path, $uri) = $c->tempfile( TEMPLATE
=> "download/$temp_file_name");
2419 my $brapi = $self->brapi_module;
2420 my $brapi_module = $brapi->brapi_wrapper('Studies');
2421 my $brapi_package_result = $brapi_module->studies_layout({
2422 study_id
=> $c->stash->{study_id
},
2424 main_production_site_url
=> $c->config->{main_production_site_url
},
2425 file_path
=> $file_path,
2428 _standard_response_construction
($c, $brapi_package_result);
2432 =head2 brapi/v1/studies/<studyDbId>/observationunits?observationVariableDbId=2
2434 Usage: To retrieve phenotypic values on a the plot level for an entire trial
2436 Return JSON example:
2438 "metadata" : "status": [],
2450 "observationVariableDbId" : 393939,
2451 "observationVariableName" : "Yield",
2452 "plotName": "ZIPA_68_Ibadan_2014",
2453 "timestamp" : "2015-11-05 15:12",
2454 "uploadedBy" : {dbUserId},
2455 "operator" : "Jane Doe",
2456 "germplasmName": 143,
2467 sub studies_observations
: Chained
('studies_single') PathPart
('observationunits') Args
(0) : ActionClass
('REST') { }
2469 sub studies_observations_GET
{
2472 my $clean_inputs = $c->stash->{clean_inputs
};
2473 # my ($auth) = _authenticate_user($c);
2474 my $brapi = $self->brapi_module;
2475 my $brapi_module = $brapi->brapi_wrapper('Studies');
2476 my $brapi_package_result = $brapi_module->observation_units({
2477 study_id
=> $c->stash->{study_id
},
2478 observationVariableDbIds
=> $clean_inputs->{observationVariableDbId
},
2479 data_level
=> $clean_inputs->{observationLevel
}->[0]
2481 _standard_response_construction
($c, $brapi_package_result);
2485 =head2 brapi/v1/studies/<studyDbId>/table
2487 Usage: To retrieve phenotypic values for a study, in a manner representative of a table, with headers and data separated
2489 Return JSON example:
2502 "observationVariableDbId": [ '', '', '', '', '', '', '', '', 44444, 55555, 66666...],
2503 "observationVariableName": [ "plotDbId", "plotName", "block", "rep", "germplasmID", "germplasmName", "operator", "timestamp", "Yield", "Color", "Dry Matter"...],
2507 [1, "plot1", 1, 1, "CIP1", 41, "user1", "2015-11-05 15:12", 10, "yellow", 9, ...],
2508 [2, "plot2", 1, 1, "CIP2", 42, "user1", "2015-11-05 20:12", 3, "red", 4, ...]
2517 sub studies_table
: Chained
('studies_single') PathPart
('table') Args
(0) : ActionClass
('REST') { }
2519 sub studies_table_GET
{
2522 my ($auth) = _authenticate_user
($c);
2524 my $clean_inputs = $c->stash->{clean_inputs
};
2525 my $format = $clean_inputs->{format
}->[0];
2528 if ($format eq 'tsv' || $format eq 'csv' || $format eq 'xls'){
2529 my $dir = $c->tempfiles_subdir('download');
2530 my $time_stamp = strftime
"%Y-%m-%dT%H%M%S", localtime();
2531 my $temp_file_name = $time_stamp . "phenotype_download_$format"."_XXXX";
2532 ($file_path, $uri) = $c->tempfile( TEMPLATE
=> "download/$temp_file_name");
2534 my $brapi = $self->brapi_module;
2535 my $brapi_module = $brapi->brapi_wrapper('Studies');
2536 my $brapi_package_result = $brapi_module->studies_table({
2537 study_id
=> $c->stash->{study_id
},
2538 data_level
=> $clean_inputs->{observationLevel
}->[0],
2539 search_type
=> $clean_inputs->{search_type
}->[0],
2540 exclude_phenotype_outlier
=> $clean_inputs->{exclude_phenotype_outlier
}->[0],
2541 trait_ids
=> $clean_inputs->{observationVariableDbId
},
2542 trial_ids
=> $clean_inputs->{studyDbId
},
2544 main_production_site_url
=> $c->config->{main_production_site_url
},
2545 file_path
=> $file_path,
2549 _standard_response_construction
($c, $brapi_package_result);
2553 =head2 brapi/v1/studies/<studyDbId>/observations?observationVariableDbId=2
2555 Usage: To retrieve phenotypic values on a the plot level for an entire trial
2557 Return JSON example:
2559 "metadata" : "status": [],
2571 "observationVariableDbId" : 393939,
2572 "observationVariableName" : "Yield",
2573 "plotName": "ZIPA_68_Ibadan_2014",
2574 "timestamp" : "2015-11-05 15:12",
2575 "uploadedBy" : {dbUserId},
2576 "operator" : "Jane Doe",
2577 "germplasmName": 143,
2588 sub studies_observations_granular
: Chained
('studies_single') PathPart
('observations') Args
(0) : ActionClass
('REST') { }
2590 sub studies_observations_granular_PUT
{
2593 my $clean_inputs = $c->stash->{clean_inputs
};
2594 my $observations = $clean_inputs->{observations
};
2595 #print STDERR "Observations are ". Dumper($observations) . "\n";
2596 save_observation_results
($self, $c, $observations, 'v1');
2599 sub studies_observations_granular_GET
{
2602 my $clean_inputs = $c->stash->{clean_inputs
};
2603 my ($auth) = _authenticate_user
($c);
2604 my $brapi = $self->brapi_module;
2605 my $brapi_module = $brapi->brapi_wrapper('Studies');
2606 my $brapi_package_result = $brapi_module->observation_units_granular({
2607 study_id
=> $c->stash->{study_id
},
2608 observationVariableDbIds
=> $clean_inputs->{observationVariableDbId
},
2609 data_level
=> $clean_inputs->{observationLevel
}->[0],
2610 search_type
=> $clean_inputs->{search_type
}->[0],
2611 exclude_phenotype_outlier
=> $clean_inputs->{exclude_phenotype_outlier
}->[0],
2613 _standard_response_construction
($c, $brapi_package_result);
2616 =head2 brapi/v1/phenotypes?observationUnitLevel=plot&studyDbId=876&studyPUI=&studyLocation=&studySet=&studyProject=&treatmentFactor=lowInput&germplasmGenus=&germplasmSubTaxa=&germplasmDbId&germplasmPUI=http://data.inra.fr/accession/234Col342&germplasmSpecies=Triticum&panel=diversitypanel1&collection=none&observationVariables=CO_321:000034,CO_321:000025&location=bergheim&season=2005,2006&pageSize={pageSize}&page={page}
2618 Usage: To retrieve a phenotype dataset
2620 Return JSON example:
2633 "observationUnitDbId": 20,
2634 "observationUnitPUI": "http://phenome-fppn.fr/maugio/bloc/12/2345",
2637 "studyLocation": "Bergheim",
2638 "studyPUI": "http://phenome-fppn.fr/phenoarch/2014/1",
2639 "studyProject": "Inovine",
2640 "studySet": ["National Network", "Frost suceptibility network"],
2641 "studyPlatform": "Phenome",
2642 "observationUnitLevelTypes" : [ "plant","plot", "bloc"],
2643 "observationUnitLevelLabels": [ "1","26123", "1"],
2644 "germplasmPUI": "http://inra.fr/vassal/41207Col0001E",
2645 "germplasmDbId": 3425,
2646 "germplasmName": "charger",
2650 "factor" : "water regimen" ,
2651 "modality":"water deficit"
2665 "instanceNumber" : 1,
2666 "observationVariableDbId": 35,
2668 "observationValue" : "red",
2669 "observationTimeStamp": null,
2670 "quality": "reliability of the observation",
2671 "collectionFacilityLabel": "phenodyne",
2672 "collector" : "John Doe and team"
2675 "instanceNumber" : 1,
2676 "observationVariableDbId": 35,
2678 "observationValue" : 32,
2679 "observationTimeStamp": "2006-07-03::10:00",
2681 "collectionFacilityLabel": null,
2682 "collector" : "userURIOrName"
2693 sub phenotypes_search
: Chained
('brapi') PathPart
('phenotypes-search') Args
(0) : ActionClass
('REST') { }
2695 sub phenotypes_search_POST
{
2698 # my ($auth) = _authenticate_user($c);
2699 my $clean_inputs = $c->stash->{clean_inputs
};
2700 my $brapi = $self->brapi_module;
2701 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2702 my $brapi_package_result = $brapi_module->search($c->stash->{clean_inputs
});
2703 _standard_response_construction
($c, $brapi_package_result);
2706 sub phenotypes_search_GET
{
2709 my ($auth) = _authenticate_user
($c);
2710 my $clean_inputs = $c->stash->{clean_inputs
};
2711 my $brapi = $self->brapi_module;
2712 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2713 my $brapi_package_result = $brapi_module->search($c->stash->{clean_inputs
});
2714 _standard_response_construction
($c, $brapi_package_result);
2719 sub observation_units
: Chained
('brapi') PathPart
('observationunits') Args
(0) ActionClass
('REST') { }
2721 sub observation_units_GET
{
2725 my ($auth) = _authenticate_user
($c);
2726 my $clean_inputs = $c->stash->{clean_inputs
};
2727 my $brapi = $self->brapi_module;
2728 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2729 my $brapi_package_result = $brapi_module->search($c->stash->{clean_inputs
}, $c);
2730 _standard_response_construction
($c, $brapi_package_result);
2733 sub observation_units_POST
{
2737 # The observation units need an operator, so login required
2738 my $force_authenticate = $c->config->{brapi_observation_units_require_login
};
2739 my ($auth,$user_id) = _authenticate_user
($c, $force_authenticate);
2740 my $clean_inputs = $c->stash->{clean_inputs
};
2741 my $data = $clean_inputs;
2742 _validate_request
($c, 'ARRAY', $data, [
2744 'observationUnitName',
2746 'observationUnitPosition' => [
2748 'observationLevel' => ['levelName', 'levelCode'],
2754 foreach my $unit (values %{$data}) {
2755 push @all_units, $unit;
2757 my $brapi = $self->brapi_module;
2758 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2759 my $brapi_package_result = $brapi_module->observationunits_store(\
@all_units,$c,$user_id);
2760 _standard_response_construction
($c, $brapi_package_result);
2763 sub observation_units_PUT
{
2767 my $force_authenticate = $c->config->{brapi_observation_units_require_login
};
2768 my ($auth,$user_id) = _authenticate_user
($c, $force_authenticate);
2769 my $clean_inputs = $c->stash->{clean_inputs
};
2770 my %data = %$clean_inputs;
2772 foreach my $unit (keys %data) {
2773 my $observationUnitDbId = $unit;
2774 my $units = $data{$unit};
2775 $units->{observationUnitDbId
} = $observationUnitDbId;
2776 push @all_units, $units;
2778 my $brapi = $self->brapi_module;
2779 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2780 my $brapi_package_result = $brapi_module->observationunits_update(\
@all_units,$c,$user_id);
2781 _standard_response_construction
($c, $brapi_package_result);
2784 sub observation_units_table
: Chained
('brapi') PathPart
('observationunits/table') Args
(0) : ActionClass
('REST') { }
2786 sub observation_units_table_GET
{
2789 my ($auth) = _authenticate_user
($c);
2790 my $clean_inputs = $c->stash->{clean_inputs
};
2791 my $brapi = $self->brapi_module;
2792 my $brapi_module = $brapi->brapi_wrapper('ObservationTables');
2793 my $brapi_package_result = $brapi_module->search_observationunit_tables($c->stash->{clean_inputs
});
2794 _standard_response_construction
($c, $brapi_package_result);
2797 sub observation_unit_single
: Chained
('brapi') PathPart
('observationunits') Args
(1) ActionClass
('REST') {
2800 my $observation_unit_db_id = shift;
2802 $c->stash->{observation_unit_db_id
} = $observation_unit_db_id;
2805 sub observation_unit_single_PUT
{
2808 my $observation_unit_db_id = shift;
2809 my $clean_inputs = $c->stash->{clean_inputs
};
2810 my ($auth) = _authenticate_user
($c);
2811 my $observationUnits = $clean_inputs;
2812 $observationUnits->{observationUnitDbId
} = $observation_unit_db_id;
2813 my @all_observations_units;
2814 push @all_observations_units, $observationUnits;
2815 my $brapi = $self->brapi_module;
2816 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2817 my $brapi_package_result = $brapi_module->observationunits_update(\
@all_observations_units, $c);
2819 _standard_response_construction
($c, $brapi_package_result);
2822 sub observation_unit_single_GET
{
2825 my ($auth) = _authenticate_user
($c);
2826 my $clean_inputs = $c->stash->{clean_inputs
};
2827 my $brapi = $self->brapi_module;
2828 my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
2829 my $brapi_package_result = $brapi_module->detail(
2830 $c->stash->{observation_unit_db_id
}, $c);
2831 _standard_response_construction
($c, $brapi_package_result);
2834 sub observation_units_search_save
: Chained
('brapi') PathPart
('search/observationunits') Args
(0) : ActionClass
('REST') { }
2836 sub observation_units_search_save_POST
{
2839 save_results
($self,$c,$c->stash->{clean_inputs
},'ObservationUnits');
2842 sub observation_units_search_retrieve
: Chained
('brapi') PathPart
('search/observationunits') Args
(1) {
2845 my $search_id = shift;
2846 retrieve_results
($self, $c, $search_id, 'ObservationUnits');
2850 sub phenotypes_search_table
: Chained
('brapi') PathPart
('phenotypes-search/table') Args
(0) : ActionClass
('REST') { }
2852 sub phenotypes_search_table_POST
{
2855 process_phenotypes_search_table
($self, $c);
2858 sub phenotypes_search_table_GET
{
2861 process_phenotypes_search_table
($self, $c);
2864 sub process_phenotypes_search_table
{
2867 # my ($auth) = _authenticate_user($c);
2868 my $clean_inputs = $c->stash->{clean_inputs
};
2869 my $brapi = $self->brapi_module;
2870 my $brapi_module = $brapi->brapi_wrapper('ObservationTables');
2871 my $brapi_package_result = $brapi_module->search_table($c->stash->{clean_inputs
});
2872 _standard_response_construction
($c, $brapi_package_result);
2875 sub observation_tables_search_save
: Chained
('brapi') PathPart
('search/observationtables') Args
(0) : ActionClass
('REST') { }
2877 sub observation_tables_search_save_POST
{
2880 save_results
($self,$c,$c->stash->{clean_inputs
},'ObservationTables');
2883 sub observation_tables_search_retrieve
: Chained
('brapi') PathPart
('search/observationtables') Args
(1) {
2886 my $search_id = shift;
2887 retrieve_results
($self, $c, $search_id, 'ObservationTables');
2890 sub phenotypes_search_csv
: Chained
('brapi') PathPart
('phenotypes-search/csv') Args
(0) : ActionClass
('REST') { }
2892 sub phenotypes_search_csv_POST
{
2895 process_phenotypes_search_csv
($self, $c);
2898 sub phenotypes_search_csv_GET
{
2901 process_phenotypes_search_csv
($self, $c);
2904 sub process_phenotypes_search_csv
{
2907 # my ($auth) = _authenticate_user($c);
2908 my $clean_inputs = $c->stash->{clean_inputs
};
2909 my $dir = $c->tempfiles_subdir('download');
2910 my $time_stamp = strftime
"%Y-%m-%dT%H%M%S", localtime();
2911 my $temp_file_name = $time_stamp . "phenotype_download_csv"."_XXXX";
2912 my ($file_path, $uri) = $c->tempfile( TEMPLATE
=> "download/$temp_file_name");
2914 my $brapi = $self->brapi_module;
2915 my $brapi_module = $brapi->brapi_wrapper('Phenotypes');
2916 my $brapi_package_result = $brapi_module->search_table_csv_or_tsv({
2917 trait_ids
=> $clean_inputs->{observationVariableDbIds
},
2918 accession_ids
=> $clean_inputs->{germplasmDbIds
},
2919 study_ids
=> $clean_inputs->{studyDbIds
},
2920 location_ids
=> $clean_inputs->{locationDbIds
},
2921 years
=> $clean_inputs->{seasonDbIds
},
2922 data_level
=> $clean_inputs->{observationLevel
}->[0],
2923 search_type
=> $clean_inputs->{search_type
}->[0],
2924 exclude_phenotype_outlier
=> $clean_inputs->{exclude_phenotype_outlier
}->[0],
2926 main_production_site_url
=> $c->config->{main_production_site_url
},
2927 file_path
=> $file_path,
2930 _standard_response_construction
($c, $brapi_package_result);
2933 sub phenotypes_search_tsv
: Chained
('brapi') PathPart
('phenotypes-search/tsv') Args
(0) : ActionClass
('REST') { }
2935 sub phenotypes_search_tsv_POST
{
2938 process_phenotypes_search_tsv
($self, $c);
2941 sub phenotypes_search_tsv_GET
{
2944 process_phenotypes_search_tsv
($self, $c);
2947 sub process_phenotypes_search_tsv
{
2950 # my ($auth) = _authenticate_user($c);
2951 my $clean_inputs = $c->stash->{clean_inputs
};
2952 my $dir = $c->tempfiles_subdir('download');
2953 my $time_stamp = strftime
"%Y-%m-%dT%H%M%S", localtime();
2954 my $temp_file_name = $time_stamp . "phenotype_download_tsv"."_XXXX";
2955 my ($file_path, $uri) = $c->tempfile( TEMPLATE
=> "download/$temp_file_name");
2957 my $brapi = $self->brapi_module;
2958 my $brapi_module = $brapi->brapi_wrapper('Phenotypes');
2959 my $brapi_package_result = $brapi_module->search_table_csv_or_tsv({
2960 trait_ids
=> $clean_inputs->{observationVariableDbIds
},
2961 accession_ids
=> $clean_inputs->{germplasmDbIds
},
2962 study_ids
=> $clean_inputs->{studyDbIds
},
2963 location_ids
=> $clean_inputs->{locationDbIds
},
2964 years
=> $clean_inputs->{seasonDbIds
},
2965 data_level
=> $clean_inputs->{observationLevel
}->[0],
2966 search_type
=> $clean_inputs->{search_type
}->[0],
2967 exclude_phenotype_outlier
=> $clean_inputs->{exclude_phenotype_outlier
}->[0],
2969 main_production_site_url
=> $c->config->{main_production_site_url
},
2970 file_path
=> $file_path,
2973 _standard_response_construction
($c, $brapi_package_result);
2977 sub traits_list
: Chained
('brapi') PathPart
('traits') Args
(0) : ActionClass
('REST') { }
2979 sub traits_list_POST
{
2982 #my $auth = _authenticate_user($c);
2985 sub traits_list_GET
{
2988 my ($auth) = _authenticate_user
($c);
2989 my $clean_inputs = $c->stash->{clean_inputs
};
2990 my $brapi = $self->brapi_module;
2991 my $brapi_module = $brapi->brapi_wrapper('Traits');
2992 my $brapi_package_result = $brapi_module->list({
2993 trait_ids
=> $clean_inputs->{traitDbIds
},
2994 names
=> $clean_inputs->{names
}
2996 _standard_response_construction
($c, $brapi_package_result);
3000 sub traits_single
: Chained
('brapi') PathPart
('traits') CaptureArgs
(1) {
3003 my $trait_id = shift;
3005 $c->stash->{trait_id
} = $trait_id;
3009 sub trait_detail
: Chained
('traits_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
3011 sub trait_detail_GET
{
3014 my ($auth) = _authenticate_user
($c);
3015 my $clean_inputs = $c->stash->{clean_inputs
};
3016 my $brapi = $self->brapi_module;
3017 my $brapi_module = $brapi->brapi_wrapper('Traits');
3018 my $brapi_package_result = $brapi_module->detail(
3019 $c->stash->{trait_id
}, $c
3021 _standard_response_construction
($c, $brapi_package_result);
3025 =head2 brapi/v1/maps?species=speciesId
3027 Usage: To retrieve a list of all maps available in the database.
3029 Return JSON example:
3045 "species": "Some species",
3048 "publishedDate": "2008-04-16",
3049 "markerCount": 1000,
3050 "linkageGroupCount": 7,
3051 "comments": "This map contains ..."
3055 "name": "Some Other map",
3056 "species": "Some Species",
3059 "publishedDate": "2009-01-12",
3060 "markerCount": 1501,
3061 "linkageGroupCount": 7,
3062 "comments": "this is blah blah"
3072 sub maps_list
: Chained
('brapi') PathPart
('maps') Args
(0) : ActionClass
('REST') { }
3074 sub maps_list_POST
{
3077 #my $auth = _authenticate_user($c);
3083 my ($auth) = _authenticate_user
($c);
3084 my $clean_inputs = $c->stash->{clean_inputs
};
3085 my $brapi = $self->brapi_module;
3086 my $brapi_module = $brapi->brapi_wrapper('GenomeMaps');
3087 my $brapi_package_result = $brapi_module->list({
3088 config
=> $c->config,
3089 mapDbId
=> $clean_inputs->{mapDbId
},
3090 commonCropName
=> $clean_inputs->{commonCropName
},
3091 scientificName
=> $clean_inputs->{scientificName
},
3092 type
=> $clean_inputs->{type
},
3095 _standard_response_construction
($c, $brapi_package_result);
3100 =head2 brapi/v1/maps/<map_id>
3102 Usage: To retrieve details for a specific map_id
3104 Return JSON example:
3122 "linkageGroupId": 1,
3123 "numberMarkers": 100000,
3124 "maxPosition": 10000000
3127 "linkageGroupId": 2,
3128 "numberMarkers": 1247,
3129 "maxPostion": 12347889
3139 sub maps_single
: Chained
('brapi') PathPart
('maps') CaptureArgs
(1) {
3144 $c->stash->{map_id
} = $map_id;
3148 sub maps_details
: Chained
('maps_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
3150 sub maps_details_POST
{
3153 #my $auth = _authenticate_user($c);
3156 sub maps_details_GET
{
3159 my ($auth) = _authenticate_user
($c);
3160 my $clean_inputs = $c->stash->{clean_inputs
};
3161 my $brapi = $self->brapi_module;
3162 my $brapi_module = $brapi->brapi_wrapper('GenomeMaps');
3163 my $brapi_package_result = $brapi_module->detail(
3166 _standard_response_construction
($c, $brapi_package_result);
3170 =head2 brapi/v1/maps/<map_id>/position?linkageGroupIdList=1,2,3
3172 Usage: To retrieve marker position data for a species map_id. Can provide a list of linkage groups (e.g. chromosomes) to narrow result set.
3174 Return JSON example:
3177 "pagination" : { "pageSize": 30, "currentPage": 2, "totalCount": 40, "totalPages":2 },
3184 "markerName": "marker1",
3186 "linkageGroup": "1A"
3189 "markerName": "marker2",
3191 "linkageGroup": "1A"
3201 sub maps_marker_detail
: Chained
('maps_single') PathPart
('positions') Args
(0) : ActionClass
('REST') { }
3203 sub maps_marker_detail_POST
{
3206 #my $auth = _authenticate_user($c);
3209 sub maps_marker_detail_GET
{
3212 my ($auth) = _authenticate_user
($c);
3213 my $clean_inputs = $c->stash->{clean_inputs
};
3214 my $brapi = $self->brapi_module;
3215 my $brapi_module = $brapi->brapi_wrapper('GenomeMaps');
3216 my $brapi_package_result = $brapi_module->positions({
3217 map_id
=> $c->stash->{map_id
},
3218 linkage_group_ids
=> $clean_inputs->{linkageGroupId
},
3219 min
=> $clean_inputs->{min
}->[0],
3220 max
=> $clean_inputs->{max
}->[0],
3222 _standard_response_construction
($c, $brapi_package_result);
3225 sub maps_marker_linkagegroup_detail
: Chained
('maps_single') PathPart
('positions') Args
(1) : ActionClass
('REST') { }
3227 sub maps_marker_linkagegroup_detail_GET
{
3230 my $linkage_group_id = shift;
3231 my ($auth) = _authenticate_user
($c);
3232 my $clean_inputs = $c->stash->{clean_inputs
};
3233 my $brapi = $self->brapi_module;
3234 my $brapi_module = $brapi->brapi_wrapper('GenomeMaps');
3235 my $brapi_package_result = $brapi_module->positions({
3236 map_id
=> $c->stash->{map_id
},
3237 linkage_group_ids
=> [$linkage_group_id],
3238 min
=> $clean_inputs->{min
}->[0],
3239 max
=> $clean_inputs->{max
}->[0],
3241 _standard_response_construction
($c, $brapi_package_result);
3244 =head2 brapi/v2/maps/map_id/linkagegroups
3247 sub maps_marker_detail_lg
: Chained
('maps_single') PathPart
('linkagegroups') Args
(0) : ActionClass
('REST') { }
3249 sub maps_marker_detail_lg_GET
{
3252 my ($auth) = _authenticate_user
($c);
3253 my $clean_inputs = $c->stash->{clean_inputs
};
3254 my $brapi = $self->brapi_module;
3255 my $brapi_module = $brapi->brapi_wrapper('GenomeMaps');
3256 my $brapi_package_result = $brapi_module->linkagegroups({
3257 map_id
=> $c->stash->{map_id
},
3258 linkage_group_ids
=> $clean_inputs->{linkageGroupId
},
3259 min
=> $clean_inputs->{min
}->[0],
3260 max
=> $clean_inputs->{max
}->[0],
3262 _standard_response_construction
($c, $brapi_package_result);
3265 =head2 brapi/v2/markerpositions
3268 sub maps_markerpositions
: Chained
('brapi') PathPart
('markerpositions') Args
(0) : ActionClass
('REST') { }
3270 sub maps_markerpositions_GET
{
3273 my ($auth) = _authenticate_user
($c);
3274 my $clean_inputs = $c->stash->{clean_inputs
};
3275 my $brapi = $self->brapi_module;
3276 my $brapi_module = $brapi->brapi_wrapper('MarkerPositions');
3277 my $brapi_package_result = $brapi_module->search({
3278 mapDbId
=> $clean_inputs->{mapDbId
},
3279 variantDbId
=> $clean_inputs->{variantDbId
},
3280 linkageGroupName
=> $clean_inputs->{linkageGroupName
},
3281 maxPosition
=> $clean_inputs->{maxPosition
},
3282 minPosition
=> $clean_inputs->{minPosition
},
3284 _standard_response_construction
($c, $brapi_package_result);
3287 sub maps_markerpositions_save
: Chained
('brapi') PathPart
('search/markerpositions') Args
(0) : ActionClass
('REST') { }
3289 sub maps_markerpositions_save_POST
{
3292 save_results
($self,$c,$c->stash->{clean_inputs
},'MarkerPositions');
3295 sub maps_markerpositions_retrieve
: Chained
('brapi') PathPart
('search/markerpositions') Args
(1) {
3298 my $search_id = shift;
3299 retrieve_results
($self, $c, $search_id, 'MarkerPositions');
3302 =head2 brapi/<version>/locations
3304 Usage: To retrieve locations.
3306 Return JSON example:
3312 sub locations_list
: Chained
('brapi') PathPart
('locations') Args
(0) : ActionClass
('REST') { }
3314 sub locations_list_POST
{
3317 my ($auth,$user_id) = _authenticate_user
($c);
3318 my $clean_inputs = $c->stash->{clean_inputs
};
3319 my $data = $clean_inputs;
3321 foreach my $location (values %{$data}) {
3322 push @all_locations, $location;
3324 my $brapi = $self->brapi_module;
3325 my $brapi_module = $brapi->brapi_wrapper('Locations');
3326 my $brapi_package_result = $brapi_module->store(\
@all_locations,$user_id);
3327 _standard_response_construction
($c, $brapi_package_result);
3330 sub locations_list_GET
{
3333 my ($auth) = _authenticate_user
($c);
3334 my $clean_inputs = $c->stash->{clean_inputs
};
3335 my $brapi = $self->brapi_module;
3336 my $brapi_module = $brapi->brapi_wrapper('Locations');
3337 my $brapi_package_result = $brapi_module->search($clean_inputs);
3338 _standard_response_construction
($c, $brapi_package_result);
3341 sub locations_detail
: Chained
('brapi') PathPart
('locations') Args
(1) : ActionClass
('REST') { }
3343 sub locations_detail_GET
{
3346 my $location_id = shift;
3347 my ($auth) = _authenticate_user
($c);
3348 my $clean_inputs = $c->stash->{clean_inputs
};
3349 my $brapi = $self->brapi_module;
3350 my $brapi_module = $brapi->brapi_wrapper('Locations');
3351 my $brapi_package_result = $brapi_module->detail($location_id);
3352 _standard_response_construction
($c, $brapi_package_result);
3355 sub locations_detail_PUT
{
3358 my $location_id = shift;
3359 my ($auth,$user_id) = _authenticate_user
($c);
3360 my $user_id = undef;
3361 my $clean_inputs = $c->stash->{clean_inputs
};
3362 my $data = $clean_inputs;
3364 $data->{locationDbId
} = $location_id;
3365 push @all_locations, $data;
3366 my $brapi = $self->brapi_module;
3367 my $brapi_module = $brapi->brapi_wrapper('Locations');
3368 my $brapi_package_result = $brapi_module->store(\
@all_locations,$user_id);
3369 # Format the response to be single hash
3370 $brapi_package_result->{result
} = $brapi_package_result->{result
}->{data
}[0];
3371 _standard_response_construction
($c, $brapi_package_result);
3374 sub locations_search_save
: Chained
('brapi') PathPart
('search/locations') Args
(0) : ActionClass
('REST') { }
3376 sub locations_search_save_POST
{
3379 save_results
($self,$c,$c->stash->{clean_inputs
},'Locations');
3382 sub locations_search_retrieve
: Chained
('brapi') PathPart
('search/locations') Args
(1) {
3385 my $search_id = shift;
3386 retrieve_results
($self, $c, $search_id, 'Locations');
3389 sub observationvariable_data_type_list
: Chained
('brapi') PathPart
('variables/datatypes') Args
(0) : ActionClass
('REST') { }
3391 sub observationvariable_data_type_list_POST
{
3394 #my $auth = _authenticate_user($c);
3397 sub observationvariable_data_type_list_GET
{
3400 my ($auth) = _authenticate_user
($c);
3401 my $clean_inputs = $c->stash->{clean_inputs
};
3402 my $brapi = $self->brapi_module;
3403 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3404 my $brapi_package_result = $brapi_module->observation_variable_data_types();
3405 _standard_response_construction
($c, $brapi_package_result);
3408 sub observationvariable_ontologies
: Chained
('brapi') PathPart
('ontologies') Args
(0) : ActionClass
('REST') { }
3410 sub observationvariable_ontologies_POST
{
3413 #my $auth = _authenticate_user($c);
3416 sub observationvariable_ontologies_GET
{
3419 my ($auth) = _authenticate_user
($c);
3421 #Using code pattern found in SGN::Controller::Ontology->onto_browser
3422 my $onto_root_namespaces = $c->config->{onto_root_namespaces
};
3423 my @namespaces = split ", ", $onto_root_namespaces;
3424 foreach my $n (@namespaces) {
3425 $n =~ s/\s*(\w+)\s*\(.*\)/$1/g;
3427 #print STDERR Dumper \@namespaces;
3429 my $clean_inputs = $c->stash->{clean_inputs
};
3430 my $brapi = $self->brapi_module;
3431 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3432 my $brapi_package_result = $brapi_module->observation_variable_ontologies({
3433 name_spaces
=> \
@namespaces,
3434 ontologyDbId
=> $clean_inputs->{ontologyDbId
}
3436 _standard_response_construction
($c, $brapi_package_result);
3439 sub observationvariable_search
: Chained
('brapi') PathPart
('variables-search') Args
(0) : ActionClass
('REST') { }
3441 sub observationvariable_search_POST
{
3444 _observationvariable_search_process
($self, $c);
3447 sub observationvariable_search_GET
{
3450 _observationvariable_search_process
($self, $c);
3453 sub _observationvariable_search_process
{
3456 # my ($auth) = _authenticate_user($c);
3458 my $clean_inputs = $c->stash->{clean_inputs
};
3459 my $brapi = $self->brapi_module;
3460 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3461 my $brapi_package_result = $brapi_module->search({
3462 observationvariable_db_ids
=> $clean_inputs->{observationVariableDbId
},
3463 ontology_db_names
=> $clean_inputs->{ontologyXref
},
3464 ontology_dbxref_terms
=> $clean_inputs->{ontologyDbId
},
3465 method_db_ids
=> $clean_inputs->{methodDbId
},
3466 scale_db_ids
=> $clean_inputs->{scaleDbId
},
3467 observationvariable_names
=> $clean_inputs->{name
},
3468 observationvariable_datatypes
=> $clean_inputs->{datatype
},
3469 observationvariable_classes
=> $clean_inputs->{traitClass
},
3470 studyDbIds
=> $clean_inputs->{studyDbId
},
3472 _standard_response_construction
($c, $brapi_package_result);
3475 sub variables_search_save
: Chained
('brapi') PathPart
('search/variables') Args
(0) : ActionClass
('REST') { }
3477 sub variables_search_save_POST
{
3480 save_results
($self,$c,$c->stash->{clean_inputs
},'ObservationVariables');
3483 sub variables_search_retrieve
: Chained
('brapi') PathPart
('search/variables') Args
(1) {
3486 my $search_id = shift;
3487 retrieve_results
($self, $c, $search_id, 'ObservationVariables');
3490 sub observationvariable_list
: Chained
('brapi') PathPart
('variables') Args
(0) : ActionClass
('REST') { }
3492 # Endpoint for POST variables
3493 sub observationvariable_list_POST
{
3497 my $can_post_variables = $c->config->{brapi_post_variables
};
3498 if (not $can_post_variables){
3499 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], "Not configured to post Observation Variables");
3500 _standard_response_construction
($c, $error, 404);
3503 my $force_authenticate = $c->config->{brapi_variables_require_login
};
3504 my ($auth,$user_id) = _authenticate_user
($c, $force_authenticate);
3506 my $clean_inputs = $c->stash->{clean_inputs
};
3507 my $data = $clean_inputs;
3508 _validate_request
($c, 'ARRAY', $data, [
3509 'observationVariableName',
3510 {'scale' => ['dataType', 'scaleName']},
3511 {'method' => ['methodName', 'methodClass']},
3512 {'trait' => ['traitName', 'status']}
3518 foreach my $variable (values %{$data}) {
3519 push @all_variables, $variable;
3522 my $brapi = $self->brapi_module;
3523 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3524 $response = $brapi_module->store(\
@all_variables, $c);
3526 if ($_->isa('CXGN::BrAPI::Exceptions::ConflictException')){
3527 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], $_->message);
3528 _standard_response_construction
($c, $error, 409);
3531 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], "An unknown error has occurred.");
3532 _standard_response_construction
($c, $error, 500);
3536 _standard_response_construction
($c, $response);
3539 sub observationvariable_list_GET
{
3542 my ($auth) = _authenticate_user
($c);
3543 my $clean_inputs = $c->stash->{clean_inputs
};
3544 my $supported_crop = $c->config->{'supportedCrop'};
3545 my $brapi = $self->brapi_module;
3546 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3547 my $brapi_package_result = $brapi_module->search({
3548 observationVariableDbIds
=> $clean_inputs->{observationVariableDbId
},
3549 traitClasses
=> $clean_inputs->{traitClass
},
3550 studyDbIds
=> $clean_inputs->{studyDbId
},
3551 externalReferenceIds
=> $clean_inputs->{externalReferenceId
},
3552 externalReferenceSources
=> $clean_inputs->{externalReferenceSource
},
3553 supportedCrop
=>$supported_crop,
3555 _standard_response_construction
($c, $brapi_package_result);
3558 sub observationvariable_detail
: Chained
('brapi') PathPart
('variables') Args
(1) : ActionClass
('REST') { }
3560 sub observationvariable_detail_GET
{
3563 my $trait_id = shift;
3564 my ($auth) = _authenticate_user
($c);
3565 my $clean_inputs = $c->stash->{clean_inputs
};
3566 my $supported_crop = $c->config->{'supportedCrop'};
3567 my $brapi = $self->brapi_module;
3568 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3569 my $brapi_package_result = $brapi_module->detail(
3572 _standard_response_construction
($c, $brapi_package_result);
3575 # Endpoint for PUT variables
3576 sub observationvariable_detail_PUT
{
3579 my $variableDbId = shift;
3580 my $force_authenticate = $c->config->{brapi_variables_require_login
};
3581 my ($auth,$user_id) = _authenticate_user
($c, $force_authenticate);
3583 my $can_put_variables = $c->config->{brapi_put_variables
};
3584 if (not $can_put_variables){
3585 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], "Not configured to update Observation Variables");
3586 _standard_response_construction
($c, $error, 404);
3591 my $clean_inputs = $c->stash->{clean_inputs
};
3592 #TODO: Parse into a trait object to check bad requests
3593 my $data = $clean_inputs;
3594 $data->{observationVariableDbId
} = $variableDbId;
3596 my $brapi = $self->brapi_module;
3597 my $brapi_module = $brapi->brapi_wrapper('ObservationVariables');
3598 $response = $brapi_module->update($data,$c);
3601 if ($_->isa('CXGN::BrAPI::Exceptions::NotFoundException')){
3602 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], $_->message);
3603 _standard_response_construction
($c, $error, 404);
3605 my $error = CXGN
::BrAPI
::JSONResponse
->return_error([], "An unknown error has occurred.");
3606 _standard_response_construction
($c, $error, 500);
3610 _standard_response_construction
($c, $response);
3614 sub samples_list
: Chained
('brapi') PathPart
('samples-search') Args
(0) : ActionClass
('REST') { }
3616 sub samples_list_POST
{
3619 _sample_search_process
($self, $c);
3622 sub samples_list_GET
{
3625 _sample_search_process
($self, $c);
3628 sub _sample_search_process
{
3631 # my ($auth) = _authenticate_user($c);
3632 my $clean_inputs = $c->stash->{clean_inputs
};
3633 my $brapi = $self->brapi_module;
3634 my $brapi_module = $brapi->brapi_wrapper('Samples');
3635 my $brapi_package_result = $brapi_module->search({
3636 sampleDbId
=> $clean_inputs->{sampleDbId
},
3637 sampleName
=> $clean_inputs->{sampleName
},
3638 plateDbId
=> $clean_inputs->{plateDbId
},
3639 plateName
=> $clean_inputs->{plateName
},
3640 germplasmDbId
=> $clean_inputs->{germplasmDbId
},
3641 germplasmName
=> $clean_inputs->{germplasmName
},
3642 observationUnitDbId
=> $clean_inputs->{observationUnitDbId
},
3643 observationUnitName
=> $clean_inputs->{observationUnitName
},
3645 _standard_response_construction
($c, $brapi_package_result);
3648 sub samples
: Chained
('brapi') PathPart
('samples') Args
(0) : ActionClass
('REST') { }
3653 my $auth = _authenticate_user
($c);
3654 my $clean_inputs = $c->stash->{clean_inputs
};
3655 my $brapi = $self->brapi_module;
3656 my $brapi_module = $brapi->brapi_wrapper('Samples');
3657 my $brapi_package_result = $brapi_module->search($clean_inputs);
3658 _standard_response_construction
($c, $brapi_package_result);
3661 sub samples_list_search
: Chained
('brapi') PathPart
('search/samples') Args
(0) : ActionClass
('REST') { }
3663 sub samples_list_search_POST
{
3666 save_results
($self,$c,$c->stash->{clean_inputs
},'Samples');
3669 sub samples_list_search_retrieve
: Chained
('brapi') PathPart
('search/samples') Args
(1) {
3672 my $search_id = shift;
3673 retrieve_results
($self, $c, $search_id, 'Samples');
3677 =head2 brapi/v1/samples/<sampleDbId>
3679 Usage: To retrieve details for a specific sample
3681 Return JSON example:
3694 "sampleDbId": "Unique-Plant-SampleID",
3695 "observationUnitDbId": "abc123",
3696 "germplasmDbId": "def456",
3697 "studyDbId": "StudyId-123",
3698 "plotDbId": "PlotId-123",
3699 "plantDbId" : "PlantID-123",
3700 "plateDbId": "PlateID-123",
3702 "takenBy": "Mr. Technician",
3703 "sampleTimestamp": "2016-07-27T14:43:22+0100",
3704 "sampleType" : "TypeOfSample",
3705 "tissueType" : "TypeOfTissue",
3706 "notes": "Cut from infected leaf",
3711 sub samples_single
: Chained
('brapi') PathPart
('samples') CaptureArgs
(1) {
3714 my $sample_id = shift;
3716 $c->stash->{sample_id
} = $sample_id;
3720 sub sample_details
: Chained
('samples_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
3722 sub sample_details_POST
{
3725 #my $auth = _authenticate_user($c);
3728 sub sample_details_GET
{
3731 my ($auth) = _authenticate_user
($c);
3732 my $clean_inputs = $c->stash->{clean_inputs
};
3733 my $brapi = $self->brapi_module;
3734 my $brapi_module = $brapi->brapi_wrapper('Samples');
3735 my $brapi_package_result = $brapi_module->detail(
3736 $c->stash->{sample_id
}
3738 _standard_response_construction
($c, $brapi_package_result);
3745 sub authenticate
: Chained
('brapi') PathPart
('authenticate/oauth') Args
(0) {
3749 my $host = $c->config->{main_production_site_url
};
3750 $c->res->redirect("https://accounts.google.com/o/oauth2/auth?scope=profile&response_type=code&client_id=1068256137120-62dvk8sncnbglglrmiroms0f5d7lg111.apps.googleusercontent.com&redirect_uri=$host/oauth2callback");
3752 $c->stash->{rest
} = { success
=> 1 };
3757 =head2 brapi/v1/phenotypes
3759 Usage: To store phenotypes
3761 Request body example:
3765 "observationUnitDbId": "observationUnitDbId0",
3768 "collector": "collector0",
3769 "observationDbId": "observationDbId0",
3770 "observationTimeStamp": "2018-01-01T14:47:23-0600",
3771 "observationVariableDbId": "observationVariableDbId0",
3772 "observationVariableName": "observationVariableName0",
3773 "season": "season0",
3777 "collector": "collector1",
3778 "observationDbId": "observationDbId1",
3779 "observationTimeStamp": "2018-01-01T14:47:23-0600",
3780 "observationVariableDbId": "observationVariableDbId1",
3781 "observationVariableName": "observationVariableName1",
3782 "season": "season1",
3786 "studyDbId": "studyDbId0"
3789 "observationUnitDbId": "observationUnitDbId1",
3792 "collector": "collector0",
3793 "observationDbId": "observationDbId0",
3794 "observationTimeStamp": "2018-01-01T14:47:23-0600",
3795 "observationVariableDbId": "observationVariableDbId0",
3796 "observationVariableName": "observationVariableName0",
3797 "season": "season0",
3801 "collector": "collector1",
3802 "observationDbId": "observationDbId1",
3803 "observationTimeStamp": "2018-01-01T14:47:23-0600",
3804 "observationVariableDbId": "observationVariableDbId1",
3805 "observationVariableName": "observationVariableName1",
3806 "season": "season1",
3810 "studyDbId": "studyDbId1"
3815 Response JSON example:
3830 "germplasmDbId": "8383",
3831 "germplasmName": "Pahang",
3832 "observationDbId": "12345",
3833 "observationLevel": "plot",
3834 "observationTimestamp": "2015-11-05T15:12:56+01:00",
3835 "observationUnitDbId": "11",
3836 "observationUnitName": "ZIPA_68_Ibadan_2014",
3837 "observationVariableDbId": "CO_334:0100632",
3838 "observationVariableName": "Yield",
3839 "operator": "Jane Doe",
3841 "uploadedBy": "dbUserId",
3852 sub phenotypes
: Chained
('brapi') PathPart
('phenotypes') Args
(0) : ActionClass
('REST') { }
3854 sub phenotypes_POST
{
3857 my $clean_inputs = $c->stash->{clean_inputs
};
3858 my $data = $clean_inputs->{data
};
3859 my @all_observations;
3860 foreach my $observationUnit (@
{$data}) {
3861 my $observationUnitDbId = $observationUnit->{observationUnitDbId
};
3862 my $observations = $observationUnit->{observations
};
3863 foreach my $observation (@
{$observations}) {
3864 $observation->{observationUnitDbId
} = $observationUnitDbId;
3865 push @all_observations, $observation;
3868 save_observation_results
($self, $c, \
@all_observations, 'v1');
3871 =head2 brapi/v2/observations
3873 Usage: To store observations
3875 Request body example:
3879 "collector": "string", //optional
3880 "observationDbId": "string", // if populated then update existing otherwise add new
3881 "observationTimeStamp": "2018-06-19T18:59:45.751Z", //optional
3882 "observationUnitDbId": "string", //required
3883 "observationVariableDbId": "string", //required
3884 "value": "string" //required
3888 Response JSON example:
3903 "germplasmDbId": "8383",
3904 "germplasmName": "Pahang",
3905 "observationDbId": "12345",
3906 "observationLevel": "plot",
3907 "observationTimestamp": "2015-11-05T15:12:56+01:00",
3908 "observationUnitDbId": "11",
3909 "observationUnitName": "ZIPA_68_Ibadan_2014",
3910 "observationVariableDbId": "CO_334:0100632",
3911 "observationVariableName": "Yield",
3912 "operator": "Jane Doe",
3914 "uploadedBy": "dbUserId",
3925 sub observations
: Chained
('brapi') PathPart
('observations') Args
(0) : ActionClass
('REST') { }
3927 sub observations_PUT
{
3930 my $version = $c->request->captures->[0];
3931 my $brapi_package_result;
3932 if ($version eq 'v2'){
3933 my $force_authenticate = $c->config->{brapi_observations_require_login
};
3934 my ($auth,$user_id,$user_type) = _authenticate_user
($c,$force_authenticate);
3935 my $clean_inputs = $c->stash->{clean_inputs
};
3936 my %observations = %$clean_inputs;
3937 my @all_observations;
3938 foreach my $observation (keys %observations) {
3939 my $observationDbId = $observation;
3940 my $observations = $observations{$observation};
3941 $observations->{observationDbId
} = $observationDbId;
3942 push @all_observations, $observations;
3944 my $brapi = $self->brapi_module;
3945 my $brapi_module = $brapi->brapi_wrapper('Observations');
3946 $brapi_package_result = $brapi_module->observations_store({
3947 observations
=> \
@all_observations,
3948 user_id
=> $user_id,
3949 user_type
=> $user_type,
3952 } elsif ($version eq 'v1'){
3953 my $clean_inputs = $c->stash->{clean_inputs
};
3954 my $observations = $clean_inputs->{observations
};
3955 save_observation_results
($self, $c, $observations, 'v1');
3958 my $status = $brapi_package_result->{status
};
3959 my $http_status_code = _get_http_status_code
($status);
3961 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
3964 sub observations_GET
{
3967 my $auth = _authenticate_user
($c);
3968 my $clean_inputs = $c->stash->{clean_inputs
};
3969 my $brapi = $self->brapi_module;
3970 my $brapi_module = $brapi->brapi_wrapper('Observations');
3971 my $brapi_package_result = $brapi_module->search({
3972 observationLevel
=> $clean_inputs->{observationLevel
},
3973 seasonDbId
=> $clean_inputs->{seasonDbId
},
3974 locationDbId
=> $clean_inputs->{locationDbId
},
3975 studyDbId
=> $clean_inputs->{studyDbId
},
3976 germplasmDbId
=> $clean_inputs->{germplasmDbId
},
3977 programDbId
=> $clean_inputs->{programDbId
},
3978 observationTimeStampRangeStart
=> $clean_inputs->{observationTimeStampRangeStart
},
3979 observationTimeStampRangeEnd
=> $clean_inputs->{observationTimeStampRangeEnd
},
3980 observationUnitDbId
=> $clean_inputs->{observationUnitDbId
},
3981 observationDbId
=> $clean_inputs->{observationDbId
},
3982 observationVariableDbId
=> $clean_inputs->{observationVariableDbId
}
3985 _standard_response_construction
($c, $brapi_package_result);
3988 sub observations_POST
{
3991 my $force_authenticate = $c->config->{brapi_observations_require_login
};
3992 my ($auth,$user_id,$user_type) = _authenticate_user
($c, $force_authenticate);
3993 my $clean_inputs = $c->stash->{clean_inputs
};
3994 my $data = $clean_inputs;
3995 my @all_observations;
3996 foreach my $observation (values %{$data}) {
3997 push @all_observations, $observation;
3999 my $brapi = $self->brapi_module;
4000 my $brapi_module = $brapi->brapi_wrapper('Observations');
4001 my $brapi_package_result = $brapi_module->observations_store({
4002 observations
=> \
@all_observations,
4003 user_id
=> $user_id,
4004 user_type
=> $user_type,
4008 my $status = $brapi_package_result->{status
};
4009 my $http_status_code = _get_http_status_code
($status);
4011 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4014 sub observations_table
: Chained
('brapi') PathPart
('observations/table') Args
(0) : ActionClass
('REST') { }
4016 sub observations_table_GET
{
4019 my ($auth) = _authenticate_user
($c);
4020 my $clean_inputs = $c->stash->{clean_inputs
};
4021 my $brapi = $self->brapi_module;
4022 my $brapi_module = $brapi->brapi_wrapper('ObservationTables');
4023 my $brapi_package_result = $brapi_module->search($c->stash->{clean_inputs
});
4024 _standard_response_construction
($c, $brapi_package_result);
4027 sub observations_single
: Chained
('brapi') PathPart
('observations') CaptureArgs
(1) {
4030 print STDERR
" Capturing id\n";
4031 $c->stash->{observation_id
} = shift;
4034 sub observations_detail
: Chained
('observations_single') PathPart
('') Args
(0) ActionClass
('REST') { }
4036 sub observations_detail_GET
{
4039 my $clean_inputs = $c->stash->{clean_inputs
};
4040 my $brapi = $self->brapi_module;
4041 my $brapi_module = $brapi->brapi_wrapper('Observations');
4042 my $brapi_package_result = $brapi_module->detail({
4043 observationDbId
=> $c->stash->{observation_id
}
4045 _standard_response_construction
($c, $brapi_package_result);
4048 sub observations_detail_PUT
{
4051 my ($auth,$user_id,$user_type) = _authenticate_user
($c);
4052 my $clean_inputs = $c->stash->{clean_inputs
};
4053 my $observations = $clean_inputs;
4054 my @all_observations;
4055 $observations->{observationDbId
} = $c->stash->{observation_id
};
4056 push @all_observations, $observations;
4058 my $brapi = $self->brapi_module;
4059 my $brapi_module = $brapi->brapi_wrapper('Observations');
4060 my $brapi_package_result = $brapi_module->observations_store({
4061 observations
=> \
@all_observations,
4062 user_id
=> $user_id,
4063 user_type
=> $user_type,
4068 my $status = $brapi_package_result->{status
};
4069 my $http_status_code = _get_http_status_code
($status);
4071 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4074 sub observation_search_save
: Chained
('brapi') PathPart
('search/observations') Args
(0) : ActionClass
('REST') { }
4076 sub observation_search_save_POST
{
4079 save_results
($self,$c,$c->stash->{clean_inputs
},'Observations');
4082 sub observation_search_retrieve
: Chained
('brapi') PathPart
('search/observations') Args
(1) {
4085 my $search_id = shift;
4086 retrieve_results
($self, $c, $search_id, 'Observations');
4089 sub save_observation_results
{
4092 my $observations = shift;
4093 my $version = shift;
4095 # Check that the user is a user. We don't check other permissions for now.
4096 my $force_authenticate = $c->config->{brapi_observations_require_login
};
4097 my ($auth_success, $user_id, $user_type, $user_pref, $expired) = _authenticate_user
($c, $force_authenticate);
4099 my $dbh = $c->dbc->dbh;
4100 my $p = CXGN
::People
::Person
->new($dbh, $user_id);
4101 my $username = $p->get_username;
4102 my $clean_inputs = $c->stash->{clean_inputs
};
4103 my $brapi = $self->brapi_module;
4105 my $dir = $c->tempfiles_subdir('/delete_nd_experiment_ids');
4106 my $temp_file_nd_experiment_id = $c->config->{basepath
}."/".$c->tempfile( TEMPLATE
=> 'delete_nd_experiment_ids/fileXXXX');
4108 my $brapi_module = $brapi->brapi_wrapper('Observations');
4109 my $brapi_package_result = $brapi_module->observations_store({
4110 observations
=> $observations,
4111 user_id
=> $user_id,
4112 username
=> $username,
4113 user_type
=> $user_type,
4114 version
=> $version,
4115 archive_path
=> $c->config->{archive_path
},
4116 tempfiles_subdir
=> $c->config->{basepath
}."/".$c->config->{tempfiles_subdir
},
4117 basepath
=> $c->config->{basepath
},
4118 dbhost
=> $c->config->{dbhost
},
4119 dbname
=> $c->config->{dbname
},
4120 dbuser
=> $c->config->{dbuser
},
4121 dbpass
=> $c->config->{dbpass
},
4122 temp_file_nd_experiment_id
=> $temp_file_nd_experiment_id
4125 my $status = $brapi_package_result->{status
};
4126 my $http_status_code = _get_http_status_code
($status);
4128 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4131 =head2 brapi/v1/markers
4133 Usage: To retrieve markers
4136 Side Effects: deprecated on BrAPI v2.0
4140 sub markers_search
: Chained
('brapi') PathPart
('markers') Args
(0) : ActionClass
('REST') { }
4142 sub markers_search_GET
{
4145 my ($auth) = _authenticate_user
($c);
4146 my $clean_inputs = $c->stash->{clean_inputs
};
4147 my $brapi = $self->brapi_module;
4148 my $brapi_module = $brapi->brapi_wrapper('Markers');
4149 my $brapi_package_result = $brapi_module->search();
4150 _standard_response_construction
($c, $brapi_package_result);
4153 sub markers_search_save
: Chained
('brapi') PathPart
('search/markers') Args
(0) : ActionClass
('REST') { }
4155 sub markers_search_save_POST
{
4157 my $c = shift; #print "--\n-" ; print Dumper($self); print "--\n-" ;
4158 save_results
($self,$c,$c->stash->{clean_inputs
},'Markers');
4161 sub markers_search_retrieve
: Chained
('brapi') PathPart
('search/markers') Args
(1) {
4164 my $search_id = shift;
4165 retrieve_results
($self, $c, $search_id, 'Markers');
4169 =head2 brapi/v2/variants
4171 Usage: To retrieve variants
4178 sub variants_search
: Chained
('brapi') PathPart
('variants') Args
(0) : ActionClass
('REST') { }
4180 sub variants_search_GET
{
4183 my ($auth) = _authenticate_user
($c);
4184 my $clean_inputs = $c->stash->{clean_inputs
};
4185 my $brapi = $self->brapi_module;
4186 my $brapi_module = $brapi->brapi_wrapper('Variants');
4187 my $brapi_package_result = $brapi_module->search($clean_inputs);
4188 _standard_response_construction
($c, $brapi_package_result);
4191 sub variants_single
: Chained
('brapi') PathPart
('variants') CaptureArgs
(1) {
4194 print STDERR
" Capturing variants id\n";
4195 $c->stash->{variants_id
} = shift;
4198 sub variants_detail
: Chained
('variants_single') PathPart
('') Args
(0) ActionClass
('REST') { }
4200 sub variants_detail_GET
{
4203 my $clean_inputs = $c->stash->{clean_inputs
};
4204 my $brapi = $self->brapi_module;
4205 my $brapi_module = $brapi->brapi_wrapper('Variants');
4206 my $brapi_package_result = $brapi_module->detail({
4207 variantDbId
=> $c->stash->{variants_id
}
4209 _standard_response_construction
($c, $brapi_package_result);
4212 sub variants_calls_detail
: Chained
('variants_single') PathPart
('calls') Args
(0) : ActionClass
('REST') { }
4214 sub variants_calls_detail_POST
{
4217 #my $auth = _authenticate_user($c);
4220 sub variants_calls_detail_GET
{
4223 my ($auth) = _authenticate_user
($c);
4224 my $clean_inputs = $c->stash->{clean_inputs
};
4225 my $brapi = $self->brapi_module;
4226 my $brapi_module = $brapi->brapi_wrapper('Variants');
4227 my $brapi_package_result = $brapi_module->calls({
4228 variantDbId
=> $c->stash->{variants_id
},
4229 variantSetDbId
=> $c->stash->{variantSetDbId
},
4230 unknown_string
=> $clean_inputs->{unknownString
}->[0],
4231 sep_phased
=> $clean_inputs->{sepPhased
}->[0],
4232 sep_unphased
=> $clean_inputs->{sepUnphased
}->[0],
4233 expand_homozygotes
=> $clean_inputs->{expandHomozygotes
}->[0],
4235 _standard_response_construction
($c, $brapi_package_result);
4238 sub variants_search_save
: Chained
('brapi') PathPart
('search/variants') Args
(0) : ActionClass
('REST') { }
4240 sub variants_search_save_POST
{
4243 save_results
($self,$c,$c->stash->{clean_inputs
},'Variants');
4246 sub variants_search_retrieve
: Chained
('brapi') PathPart
('search/variants') Args
(1) {
4249 my $search_id = shift;
4250 retrieve_results
($self, $c, $search_id, 'Variants');
4254 =head2 brapi/v1/observations-search
4256 Usage: To retrieve observations
4258 Request body example:
4260 "collector": ["string","string"], //optional
4261 "observationDbId": ["string","string"], //optional
4262 "observationUnitDbId": ["string","string"], //optional
4263 "observationVariableDbId": ["string","string"] //optional
4265 Response JSON example:
4280 "germplasmDbId": "8383",
4281 "germplasmName": "Pahang",
4282 "observationDbId": "12345",
4283 "observationLevel": "plot",
4284 "observationTimestamp": "2015-11-05T15:12:56+01:00",
4285 "observationUnitDbId": "11",
4286 "observationUnitName": "ZIPA_68_Ibadan_2014",
4287 "observationVariableDbId": "CO_334:0100632",
4288 "observationVariableName": "Yield",
4289 "operator": "Jane Doe",
4291 "uploadedBy": "dbUserId",
4302 sub observations_search
: Chained
('brapi') PathPart
('observations-search') Args
(0) : ActionClass
('REST') { }
4304 sub observations_search_POST
{
4307 observations_search_process
($self, $c);
4310 sub observations_search_GET
{
4313 observations_search_process
($self, $c);
4316 sub observations_search_process
{
4319 # my ($auth) = _authenticate_user($c);
4320 my $clean_inputs = $c->stash->{clean_inputs
};
4321 my $brapi = $self->brapi_module;
4322 my $brapi_module = $brapi->brapi_wrapper('Observations');
4323 my $brapi_package_result = $brapi_module->search({
4324 collectors
=> $clean_inputs->{collectors
},
4325 observationDbIds
=> $clean_inputs->{observationDbIds
},
4326 observationUnitDbIds
=> $clean_inputs->{observationUnitDbIds
},
4327 observationVariableDbIds
=> $clean_inputs->{observationVariableDbIds
}
4329 _standard_response_construction
($c, $brapi_package_result);
4332 =head2 brapi/<version>/events
4333 Usage: To retrieve events (events are treatments/management factors in the database)
4335 Request body example:
4338 Response JSON example:
4341 "https://brapi.org/jsonld/context/metadata.jsonld"
4346 "fileDescription": "This is an Excel data file",
4347 "fileMD5Hash": "c2365e900c81a89cf74d83dab60df146",
4348 "fileName": "datafile.xlsx",
4350 "fileType": "application/vnd.ms-excel",
4351 "fileURL": "https://wiki.brapi.org/examples/datafile.xlsx"
4362 "message": "Request accepted, response successful",
4363 "messageType": "INFO"
4370 "additionalInfo": {},
4372 "2018-10-08T18:15:11Z",
4373 "2018-11-09T18:16:12Z"
4375 "eventDbId": "8566d4cb",
4376 "eventDescription": "A set of plots was watered",
4377 "eventParameters": [
4379 "key": "http://www.example.fr/vocabulary/2018#hasContact,",
4380 "value": "http://www.example.fr/id/agent/marie,",
4381 "valueRdfType": "http://xmlns.com/foaf/0.1/Agent,"
4384 "key": "fertilizer",
4385 "value": "nitrogen",
4386 "valueRdfType": null
4389 "eventType": "Watering",
4390 "eventTypeDbId": "4e7d691e",
4391 "observationUnitDbIds": [
4396 "studyDbId": "2cc2001f"
4405 sub events_search
: Chained
('brapi') PathPart
('events') Args
(0) : ActionClass
('REST') { }
4407 sub events_search_POST
{
4410 events_search_process
($self, $c);
4413 sub events_search_GET
{
4416 events_search_process
($self, $c);
4419 sub events_search_process
{
4422 my ($auth) = _authenticate_user
($c);
4423 my $clean_inputs = $c->stash->{clean_inputs
};
4424 my $brapi = $self->brapi_module;
4425 my $brapi_module = $brapi->brapi_wrapper('Events');
4426 my $brapi_package_result = $brapi_module->search($clean_inputs);
4427 _standard_response_construction
($c, $brapi_package_result);
4430 =head2 brapi/<version>/images
4432 Usage: To retrieve observations
4434 Request body example:
4437 Response JSON example:
4451 "message": "Request accepted, response successful",
4452 "messageType": "INFO"
4459 "additionalInfo": {},
4460 "copyright": "Copyright 2018 Bob Robertson",
4461 "description": "This is a picture of a tomato",
4462 "descriptiveOntologyTerms": [],
4463 "externalReferences": [
4465 "referenceID": "doi:10.155454/12349537E12",
4466 "referenceSource": "DOI"
4469 "imageDbId": "a55efb9c",
4470 "imageFileName": "image_0000231.jpg",
4471 "imageFileSize": 50000,
4484 "imageName": "Tomato Image 1",
4485 "imageTimeStamp": "2018-01-01T14:47:23-0600",
4486 "imageURL": "https://wiki.brapi.org/images/tomato",
4488 "mimeType": "image/jpeg",
4489 "observationDbIds": [
4493 "observationUnitDbId": "b7e690b6"
4504 sub images
: Chained
('brapi') PathPart
('images') Args
(0) : ActionClass
('REST') { }
4509 my ($auth) = _authenticate_user
($c);
4510 my $clean_inputs = $c->stash->{clean_inputs
};
4511 my $brapi = $self->brapi_module;
4512 my $brapi_module = $brapi->brapi_wrapper('Images');
4513 my $brapi_package_result = $brapi_module->search($clean_inputs);
4514 _standard_response_construction
($c, $brapi_package_result);
4521 # Check user auth. This matches observations PUT observations endpoint authorization.
4522 # No specific roles are check, just that the user has an account.
4523 my $force_authenticate = $c->config->{brapi_images_require_login
};
4524 my ($auth_success, $user_id, $user_type, $user_pref, $expired) = _authenticate_user
($c, $force_authenticate);
4526 my $clean_inputs = $c->stash->{clean_inputs
};
4528 foreach my $image (values %{$clean_inputs}) {
4529 push @all_images, $image;
4531 my $brapi = $self->brapi_module;
4532 my $brapi_module = $brapi->brapi_wrapper('Images');
4533 my $image_dir = File
::Spec
->catfile($c->config->{static_datasets_path
}, $c->config->{image_dir
});
4535 my $brapi_package_result = $brapi_module->image_metadata_store(\
@all_images, $image_dir, $user_id, $user_type);
4536 my $status = $brapi_package_result->{status
};
4537 my $http_status_code = _get_http_status_code
($status);
4539 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4542 sub images_by_id
: Chained
('brapi') PathPart
('images') CaptureArgs
(1) {
4545 print STDERR
"Images_base... capturing image_id\n";
4546 $c->stash->{image_id
} = shift;
4549 sub images_single
: Chained
('images_by_id') PathPart
('') Args
(0) ActionClass
('REST') { }
4551 sub images_single_GET
{
4554 my $brapi = $self->brapi_module;
4555 my $brapi_module = $brapi->brapi_wrapper('Images');
4556 my $brapi_package_result = $brapi_module->detail( { image_id
=> $c->stash->{image_id
} });
4557 _standard_response_construction
($c, $brapi_package_result);
4560 # /brapi/v1/images PUT
4561 # sub image_store : Chained('brapi') PathPart('images') Args(0) ActionClass('REST') { }
4563 sub images_single_PUT
{
4567 # Check user auth. This matches observations PUT observations endpoint authorization.
4568 # No specific roles are check, just that the user has an account.
4569 my $force_authenticate = $c->config->{brapi_images_require_login
};
4570 my ($auth_success, $user_id, $user_type, $user_pref, $expired) = _authenticate_user
($c, $force_authenticate);
4572 my $clean_inputs = $c->stash->{clean_inputs
};
4573 my $image = $clean_inputs;
4574 $image->{imageDbId
} = $c->stash->{image_id
};
4576 push @all_images, $image;
4577 my $brapi = $self->brapi_module;
4578 my $brapi_module = $brapi->brapi_wrapper('Images');
4579 my $image_dir = File
::Spec
->catfile($c->config->{static_datasets_path
}, $c->config->{image_dir
});
4580 my $brapi_package_result = $brapi_module->image_metadata_store(\
@all_images, $image_dir, $user_id, $user_type, $c->stash->{image_id
});
4581 my $status = $brapi_package_result->{status
};
4582 my $http_status_code = _get_http_status_code
($status);
4584 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4588 # /brapi/v1/images/<image_id>/imagecontent
4589 sub image_content_store
: Chained
('images_by_id') PathPart
('imagecontent') Args
(0) ActionClass
('REST') { }
4591 sub image_content_store_PUT
{
4595 # Check user auth. This matches observations PUT observations endpoint authorization.
4596 # No specific roles are check, just that the user has an account.
4597 my $force_authenticate = $c->config->{brapi_images_require_login
};
4598 my ($auth_success, $user_id, $user_type, $user_pref, $expired) = _authenticate_user
($c, $force_authenticate);
4600 my $clean_inputs = $c->stash->{clean_inputs
};
4601 print STDERR Dumper
($clean_inputs);print Dumper
$c->req->body();
4602 my $brapi = $self->brapi_module;
4603 my $brapi_module = $brapi->brapi_wrapper('Images');
4604 my $image_dir = File
::Spec
->catfile($c->config->{static_datasets_path
}, $c->config->{image_dir
});
4606 my $brapi_package_result = $brapi_module->image_data_store($image_dir, $c->stash->{image_id
}, $c->req->body(), $c->req->content_type());
4608 my $status = $brapi_package_result->{status
};
4609 my $http_status_code = _get_http_status_code
($status);
4611 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4614 sub image_search_save
: Chained
('brapi') PathPart
('search/images') Args
(0) : ActionClass
('REST') { }
4616 sub image_search_save_POST
{
4618 my $c = shift; #print "--\n-" ; print Dumper($self); print "--\n-" ;
4619 save_results
($self,$c,$c->stash->{clean_inputs
},'Images');
4622 sub image_search_retrieve
: Chained
('brapi') PathPart
('search/images') Args
(1) {
4625 my $search_id = shift;
4626 retrieve_results
($self, $c, $search_id, 'Images');
4629 sub _get_http_status_code
{
4631 my $http_status_code = 200;
4635 if ($_->{messageType
} eq "403") {
4636 $http_status_code = 403;
4639 elsif ($_->{messageType
} eq "401") {
4640 $http_status_code = 401;
4643 elsif ($_->{messageType
} eq "400") {
4644 $http_status_code = 400;
4647 elsif ($_->{messageType
} eq "200") {
4648 $http_status_code = 200;
4653 return $http_status_code;
4656 =head2 brapi/v2/callsets
4658 Usage: To retrieve data for callsets
4660 Return JSON example:
4675 "additionalInfo": {},
4676 "callSetDbId": "eb2bfd3d",
4677 "callSetName": "Sample_123_DNA_Run_456",
4678 "created": "2018-01-01T14:47:23-0600",
4679 "sampleDbId": "5e50e11d",
4680 "studyDbId": "708149c1",
4681 "updated": "2018-01-01T14:47:23-0600",
4695 sub callsets
: Chained
('brapi') PathPart
('callsets') Args
(0) : ActionClass
('REST') { }
4700 my ($auth) = _authenticate_user
($c);
4701 my $clean_inputs = $c->stash->{clean_inputs
};
4702 my $brapi = $self->brapi_module;
4703 my $brapi_module = $brapi->brapi_wrapper('CallSets');
4704 my $brapi_package_result = $brapi_module->search({
4705 variantSetDbId
=> $clean_inputs->{variantSetDbId
},
4706 sampleDbId
=> $clean_inputs->{sampleDbId
},
4707 callSetName
=> $clean_inputs->{callSetName
},
4708 # studyDbId => $clean_inputs->{studyDbId},
4709 germplasmDbId
=> $clean_inputs->{germplasmDbId
},
4710 callSetDbId
=> $clean_inputs->{callSetDbId
},
4712 _standard_response_construction
($c, $brapi_package_result);
4715 sub callsets_single
: Chained
('brapi') PathPart
('callsets') CaptureArgs
(1) {
4719 $c->stash->{callset_id
} = $id;
4722 sub callsets_fetch
: Chained
('callsets_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
4724 sub callsets_fetch_GET
{
4727 my ($auth) = _authenticate_user
($c);
4728 my $clean_inputs = $c->stash->{clean_inputs
};
4729 my $brapi = $self->brapi_module;
4730 my $brapi_module = $brapi->brapi_wrapper('CallSets');
4731 my $brapi_package_result = $brapi_module->detail({
4732 callset_id
=> $c->stash->{callset_id
},
4733 unknown_string
=> $clean_inputs->{unknownString
}->[0],
4734 sep_phased
=> $clean_inputs->{sepPhased
}->[0],
4735 sep_unphased
=> $clean_inputs->{sepUnphased
}->[0],
4736 expand_homozygotes
=> $clean_inputs->{expandHomozygotes
}->[0],
4738 _standard_response_construction
($c, $brapi_package_result);
4741 sub callsets_call_detail
: Chained
('callsets_single') PathPart
('calls') Args
(0) : ActionClass
('REST') { }
4743 sub callsets_call_detail_GET
{
4746 my ($auth) = _authenticate_user
($c);
4747 my $clean_inputs = $c->stash->{clean_inputs
};
4748 my $brapi = $self->brapi_module;
4749 my $brapi_module = $brapi->brapi_wrapper('CallSets');
4750 my $brapi_package_result = $brapi_module->calls({
4751 callset_id
=> $c->stash->{callset_id
},
4753 _standard_response_construction
($c, $brapi_package_result);
4756 sub callsets_call_filter_detail
: Chained
('callsets_single') PathPart
('calls') Args
(1) : ActionClass
('REST') { }
4758 sub callsets_call_filter_detail_GET
{
4761 my ($auth) = _authenticate_user
($c);
4762 my $clean_inputs = $c->stash->{clean_inputs
};
4763 my $brapi = $self->brapi_module;
4764 my $brapi_module = $brapi->brapi_wrapper('CallSets');
4765 my $brapi_package_result = $brapi_module->calls({
4766 callset_id
=> $c->stash->{callset_id
},
4768 _standard_response_construction
($c, $brapi_package_result);
4771 sub callsets_search_save
: Chained
('brapi') PathPart
('search/callsets') Args
(0) : ActionClass
('REST') { }
4773 sub callsets_search_save_POST
{
4776 save_results
($self,$c,$c->stash->{clean_inputs
},'CallSets');
4779 sub callsets_search_retrieve
: Chained
('brapi') PathPart
('search/callsets') Args
(1) {
4782 my $search_id = shift;
4783 retrieve_results
($self, $c, $search_id, 'CallSets');
4787 =head2 brapi/v2/variantsets
4789 Usage: To retrieve data for variantsets
4791 Return JSON example:
4806 "additionalInfo": {},
4809 "analysisDbId": "6191a6bd",
4810 "analysisName": "Standard QC",
4811 "created": "2018-01-01T14:47:23-0600",
4812 "description": "This is a formal description of a QC methodology.",
4814 "https://github.com/genotyping/QC"
4817 "updated": "2018-01-01T14:47:23-0600"
4820 "availableFormats": [
4822 "dataFormat": "VCF",
4823 "fileFormat": "application/excel",
4824 "fileURL": "https://brapi.org/example/VCF_1.xlsx"
4827 "dataFormat": "VCF",
4828 "fileFormat": "text/csv",
4829 "fileURL": "https://brapi.org/example/VCF_2.csv"
4832 "callSetCount": 341,
4833 "referenceSetDbId": "57eae639",
4834 "studyDbId": "2fc3b034",
4835 "variantCount": 250,
4836 "variantSetDbId": "87a6ac1e",
4837 "variantSetName": "Maize QC DataSet 002334"
4847 sub variantsets
: Chained
('brapi') PathPart
('variantsets') Args
(0) : ActionClass
('REST') { }
4849 sub variantsets_GET
{
4852 my ($auth) = _authenticate_user
($c);
4853 my $clean_inputs = $c->stash->{clean_inputs
};
4854 my $brapi = $self->brapi_module;
4855 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4856 my $brapi_package_result = $brapi_module->search({
4857 variantSetDbId
=> $clean_inputs->{variantSetDbId
},
4858 variantDbId
=> $clean_inputs->{variantDbId
},
4859 callSetDbId
=> $clean_inputs->{callSetDbId
},
4860 studyDbId
=> $clean_inputs->{studyDbId
},
4861 studyName
=> $clean_inputs->{studyName
}
4863 _standard_response_construction
($c, $brapi_package_result);
4866 ### VariantSet single
4868 sub variantsets_single
: Chained
('brapi') PathPart
('variantsets') CaptureArgs
(1) {
4872 $c->stash->{variantSetDbId
} = $id;
4875 sub variantsets_fetch
: Chained
('variantsets_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
4878 sub variantsets_fetch_GET
{
4881 my ($auth) = _authenticate_user
($c);
4882 my $clean_inputs = $c->stash->{clean_inputs
};
4883 my $brapi = $self->brapi_module;
4884 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4885 my $brapi_package_result = $brapi_module->detail({
4886 variantSetDbId
=> $c->stash->{variantSetDbId
},
4888 _standard_response_construction
($c, $brapi_package_result);
4891 sub variantsets_callset_detail
: Chained
('variantsets_single') PathPart
('callsets') Args
(0) : ActionClass
('REST') { }
4893 sub variantsets_callset_detail_GET
{
4896 my ($auth) = _authenticate_user
($c);
4897 my $clean_inputs = $c->stash->{clean_inputs
};
4898 my $brapi = $self->brapi_module;
4899 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4900 my $brapi_package_result = $brapi_module->callsets({
4901 variantSetDbId
=> $c->stash->{variantSetDbId
},
4902 callSetDbId
=> $clean_inputs->{callSetDbId
},
4903 callSetName
=> $clean_inputs->{callSetName
}
4905 _standard_response_construction
($c, $brapi_package_result);
4908 sub variantsets_calls_detail
: Chained
('variantsets_single') PathPart
('calls') Args
(0) : ActionClass
('REST') { }
4910 sub variantsets_calls_detail_GET
{
4913 my ($auth) = _authenticate_user
($c);
4914 my $clean_inputs = $c->stash->{clean_inputs
};
4915 my $brapi = $self->brapi_module;
4916 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4917 my $brapi_package_result = $brapi_module->calls({
4918 variantSetDbId
=> $c->stash->{variantSetDbId
},
4919 unknown_string
=> $clean_inputs->{unknownString
}->[0],
4920 sep_phased
=> $clean_inputs->{sepPhased
}->[0],
4921 sep_unphased
=> $clean_inputs->{sepUnphased
}->[0],
4922 expand_homozygotes
=> $clean_inputs->{expandHomozygotes
}->[0],
4924 _standard_response_construction
($c, $brapi_package_result);
4927 sub variantsets_variants_detail
: Chained
('variantsets_single') PathPart
('variants') Args
(0) : ActionClass
('REST') { }
4929 sub variantsets_variants_detail_GET
{
4932 my ($auth) = _authenticate_user
($c);
4933 my $clean_inputs = $c->stash->{clean_inputs
};
4934 my $brapi = $self->brapi_module;
4935 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4936 my $brapi_package_result = $brapi_module->variants({
4937 variantSetDbId
=> $c->stash->{variantSetDbId
},
4939 _standard_response_construction
($c, $brapi_package_result);
4942 sub variantsets_extract
: Chained
('brapi') PathPart
('variantsets/extract') Args
(0) : ActionClass
('REST') { }
4944 sub variantsets_extract_POST
{
4947 # my $force_authenticate = 1;
4948 # my ($auth_success, $user_id, $user_type, $user_pref, $expired) = _authenticate_user($c, $force_authenticate);
4950 my $clean_inputs = $c->stash->{clean_inputs
};
4951 my $brapi = $self->brapi_module;
4952 my $brapi_module = $brapi->brapi_wrapper('VariantSets');
4953 my $brapi_package_result = $brapi_module->extract($clean_inputs);
4954 my $status = $brapi_package_result->{status
};
4955 my $http_status_code = _get_http_status_code
($status);
4957 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
4960 sub variantsets_search_save
: Chained
('brapi') PathPart
('search/variantsets') Args
(0) : ActionClass
('REST') { }
4962 sub variantsets_search_save_POST
{
4965 save_results
($self,$c,$c->stash->{clean_inputs
},'VariantSets');
4968 sub variantsets_search_retrieve
: Chained
('brapi') PathPart
('search/variantsets') Args
(1) {
4971 my $search_id = shift;
4972 retrieve_results
($self, $c, $search_id, 'VariantSets');
4976 =head2 brapi/v2/calls
4978 Usage: To retrieve data for calls
4980 Return JSON example:
4995 "additionalInfo": {},
4996 "callSetDbId": "16466f55",
4997 "callSetName": "Sample_123_DNA_Run_456",
5003 "genotype_likelihood": [
5006 "phaseSet": "6410afc5",
5007 "variantDbId": "538c8ecf",
5008 "variantName": "Marker A"
5011 "expandHomozygotes": true,
5014 "unknownString": "-"
5024 sub calls_search_save
: Chained
('brapi') PathPart
('search/calls') Args
(0) : ActionClass
('REST') { }
5026 sub calls_search_save_POST
{
5029 save_results
($self,$c,$c->stash->{clean_inputs
},'Calls');
5032 sub calls_search_retrieve
: Chained
('brapi') PathPart
('search/calls') Args
(1) {
5035 my $search_id = shift;
5036 retrieve_results
($self, $c, $search_id, 'Calls');
5039 =head2 brapi/v2/referencesets
5041 Usage: To retrieve data for reference sets
5043 Return JSON example:
5058 "additionalInfo": {},
5059 "assemblyPUI": "doi://10.12345/fake/9876",
5060 "description": "Description for an assembly",
5061 "md5checksum": "c2365e900c81a89cf74d83dab60df146",
5062 "referenceSetDbId": "7e029a84",
5063 "referenceSetName": "Assembly version",
5064 "sourceAccessions": [
5068 "sourceURI": "https://wiki.brapi.org/files/demo.fast",
5070 "term": "sonic hedgehog",
5071 "termURI": "MGI:MGI:98297"
5082 sub referencesets
: Chained
('brapi') PathPart
('referencesets') Args
(0) : ActionClass
('REST') { }
5084 sub referencesets_GET
{
5087 my ($auth) = _authenticate_user
($c);
5088 my $clean_inputs = $c->stash->{clean_inputs
};
5089 my $brapi = $self->brapi_module;
5090 my $brapi_module = $brapi->brapi_wrapper('ReferenceSets');
5091 my $brapi_package_result = $brapi_module->search($clean_inputs);
5092 _standard_response_construction
($c, $brapi_package_result);
5095 sub referencesets_single
: Chained
('brapi') PathPart
('referencesets') CaptureArgs
(1) {
5099 $c->stash->{referenceSetDbId
} = $id;
5102 sub referencesets_fetch
: Chained
('referencesets_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
5105 sub referencesets_fetch_GET
{
5108 my ($auth) = _authenticate_user
($c);
5109 my $clean_inputs = $c->stash->{clean_inputs
};
5110 my $brapi = $self->brapi_module;
5111 my $brapi_module = $brapi->brapi_wrapper('ReferenceSets');
5112 my $brapi_package_result = $brapi_module->detail($c->stash->{referenceSetDbId
});
5113 _standard_response_construction
($c, $brapi_package_result);
5116 sub referencesets_search
: Chained
('brapi') PathPart
('search/referencesets') Args
(0) : ActionClass
('REST') { }
5118 sub referencesets_search_POST
{
5121 save_results
($self,$c,$c->stash->{clean_inputs
},'ReferenceSets');
5124 sub referencesets_search_retrieve
: Chained
('brapi') PathPart
('search/referencesets') Args
(1) {
5127 my $search_id = shift;
5128 retrieve_results
($self, $c, $search_id, 'ReferenceSets');
5131 =head2 brapi/v2/reference
5133 Usage: To retrieve data for reference
5135 Return JSON example:
5150 "additionalInfo": {},
5152 "md5checksum": "c2365e900c81a89cf74d83dab60df146",
5153 "referenceDbId": "fc0a81d0",
5154 "referenceName": "Chromosome 2",
5155 "referenceSetDbId": "c1ecfef1",
5156 "sourceAccessions": [
5159 "sourceDivergence": 0.01,
5160 "sourceURI": "https://wiki.brapi.org/files/demo.fast",
5162 "term": "sonic hedgehog",
5163 "termURI": "MGI:MGI:98297"
5174 sub reference
: Chained
('brapi') PathPart
('references') Args
(0) : ActionClass
('REST') { }
5179 my ($auth) = _authenticate_user
($c);
5180 my $clean_inputs = $c->stash->{clean_inputs
};
5181 my $brapi = $self->brapi_module;
5182 my $brapi_module = $brapi->brapi_wrapper('References');
5183 my $brapi_package_result = $brapi_module->search($clean_inputs);
5184 _standard_response_construction
($c, $brapi_package_result);
5187 sub reference_single
: Chained
('brapi') PathPart
('references') CaptureArgs
(1) {
5191 $c->stash->{referenceDbId
} = $id;
5194 sub reference_fetch
: Chained
('reference_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
5197 sub reference_fetch_GET
{
5200 my ($auth) = _authenticate_user
($c);
5201 my $clean_inputs = $c->stash->{clean_inputs
};
5202 my $brapi = $self->brapi_module;
5203 my $brapi_module = $brapi->brapi_wrapper('References');
5204 my $brapi_package_result = $brapi_module->detail($c->stash->{referenceDbId
});
5205 _standard_response_construction
($c, $brapi_package_result);
5208 sub reference_search
: Chained
('brapi') PathPart
('search/references') Args
(0) : ActionClass
('REST') { }
5210 sub reference_search_POST
{
5213 save_results
($self,$c,$c->stash->{clean_inputs
},'References');
5216 sub reference_search_retrieve
: Chained
('brapi') PathPart
('search/references') Args
(1) {
5219 my $search_id = shift;
5220 retrieve_results
($self, $c, $search_id, 'Referenced');
5224 =head2 brapi/v2/crossingprojects
5228 sub crossingprojects
: Chained
('brapi') PathPart
('crossingprojects') Args
(0) : ActionClass
('REST') { }
5230 sub crossingprojects_GET
{
5233 my ($auth) = _authenticate_user
($c);
5234 my $clean_inputs = $c->stash->{clean_inputs
};
5235 my $brapi = $self->brapi_module;
5236 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5237 my $brapi_package_result = $brapi_module->search($clean_inputs);
5238 _standard_response_construction
($c, $brapi_package_result);
5241 sub crossingprojects_POST
{
5244 my ($auth,$user_id) = _authenticate_user
($c);
5245 my $clean_inputs = $c->stash->{clean_inputs
};
5247 my $data = $clean_inputs;
5249 foreach my $project (values %{$data}) {
5250 push @all_data, $project;
5252 my $brapi = $self->brapi_module;
5253 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5254 my $brapi_package_result = $brapi_module->store_crossingproject(\
@all_data,$c,$user_id);
5257 my $status = $brapi_package_result->{status
};
5258 my $http_status_code = _get_http_status_code
($status);
5259 _standard_response_construction
($c, $brapi_package_result);
5262 sub crossingproject_single
: Chained
('brapi') PathPart
('crossingprojects') CaptureArgs
(1) {
5266 $c->stash->{crossingProjectDbId
} = $id;
5269 sub crossingproject_fetch
: Chained
('crossingproject_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
5272 sub crossingproject_fetch_GET
{
5275 my ($auth) = _authenticate_user
($c);
5276 my $clean_inputs = $c->stash->{clean_inputs
};
5277 my $brapi = $self->brapi_module;
5278 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5279 my $brapi_package_result = $brapi_module->detail($c->stash->{crossingProjectDbId
});
5280 _standard_response_construction
($c, $brapi_package_result);
5283 sub crossingproject_fetch_PUT
{
5286 my ($auth,$user_id,$user_type) = _authenticate_user
($c);
5287 my $clean_inputs = $c->stash->{clean_inputs
};
5288 my $brapi = $self->brapi_module;
5289 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5290 my $brapi_package_result = $brapi_module->update_crossingproject($c->stash->{crossingProjectDbId
}, $clean_inputs,$c,$user_id,$user_type);
5291 my $status = $brapi_package_result->{status
};
5292 my $http_status_code = _get_http_status_code
($status);
5293 _standard_response_construction
($c, $brapi_package_result);
5296 =head2 brapi/v2/crosses
5300 sub crosses
: Chained
('brapi') PathPart
('crosses') Args
(0) : ActionClass
('REST') { }
5305 my ($auth) = _authenticate_user
($c);
5306 my $clean_inputs = $c->stash->{clean_inputs
};
5307 my $brapi = $self->brapi_module;
5308 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5309 my $brapi_package_result = $brapi_module->crosses($clean_inputs);
5310 _standard_response_construction
($c, $brapi_package_result);
5316 my ($auth,$user_id) = _authenticate_user
($c);
5317 my $clean_inputs = $c->stash->{clean_inputs
};
5318 my $data = $clean_inputs;
5320 foreach my $cross (values %{$data}) {
5321 push @all_crosses, $cross;
5323 my $brapi = $self->brapi_module;
5324 my $brapi_module = $brapi->brapi_wrapper('Crossing');
5325 my $brapi_package_result = $brapi_module->store_crosses(\
@all_crosses,$c,$user_id);
5326 _standard_response_construction
($c, $brapi_package_result);
5332 # my ($auth) = _authenticate_user($c);
5333 # my $clean_inputs = $c->stash->{clean_inputs};
5334 # my $brapi = $self->brapi_module;
5335 # my $brapi_module = $brapi->brapi_wrapper('Crossing');
5336 # my $brapi_package_result = $brapi_module->update_crosses($clean_inputs);
5337 # _standard_response_construction($c, $brapi_package_result);
5340 =head2 brapi/v2/seedlots
5344 sub seedlots
: Chained
('brapi') PathPart
('seedlots') Args
(0) : ActionClass
('REST') { }
5349 my ($auth) = _authenticate_user
($c);
5350 my $clean_inputs = $c->stash->{clean_inputs
};
5351 my $brapi = $self->brapi_module;
5352 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5353 my $brapi_package_result = $brapi_module->search($clean_inputs);
5354 _standard_response_construction
($c, $brapi_package_result);
5360 my ($auth,$user_id) = _authenticate_user
($c);
5361 my $clean_inputs = $c->stash->{clean_inputs
};
5362 my $data = $clean_inputs;
5364 foreach my $seedlot (values %{$data}) {
5365 push @all_data, $seedlot;
5367 my $brapi = $self->brapi_module;
5368 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5369 my $brapi_package_result = $brapi_module->store_seedlots(\
@all_data,$c,$user_id);
5371 my $status = $brapi_package_result->{status
};
5372 my $http_status_code = _get_http_status_code
($status);
5374 _standard_response_construction
($c, $brapi_package_result, $http_status_code);
5377 sub seedlot_transactions
: Chained
('brapi') PathPart
('seedlots/transactions') Args
(0) : ActionClass
('REST') { }
5379 sub seedlot_transactions_GET
{
5382 my ($auth) = _authenticate_user
($c);
5383 my $clean_inputs = $c->stash->{clean_inputs
};
5384 my $brapi = $self->brapi_module;
5385 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5386 my $brapi_package_result = $brapi_module->all_transactions($clean_inputs);
5387 _standard_response_construction
($c, $brapi_package_result);
5390 sub seedlot_transactions_POST
{
5393 my ($auth,$user_id) = _authenticate_user
($c);
5394 my $clean_inputs = $c->stash->{clean_inputs
};
5395 my $data = $clean_inputs;
5397 foreach my $transaction (values %{$data}) {
5398 push @all_data, $transaction;
5400 my $brapi = $self->brapi_module;
5401 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5402 my $brapi_package_result = $brapi_module->store_seedlot_transaction(\
@all_data,$c,$user_id);
5403 my $status = $brapi_package_result->{status
};
5404 my $http_status_code = _get_http_status_code
($status);
5406 _standard_response_construction
($c, $brapi_package_result);
5409 sub seedlot_single
: Chained
('brapi') PathPart
('seedlots') CaptureArgs
(1) {
5413 $c->stash->{seedLotDbId
} = $id;
5416 sub seedlot_single_fetch
: Chained
('seedlot_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
5419 sub seedlot_single_fetch_GET
{
5422 my ($auth) = _authenticate_user
($c);
5423 my $clean_inputs = $c->stash->{clean_inputs
};
5424 my $brapi = $self->brapi_module;
5425 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5426 my $brapi_package_result = $brapi_module->detail($c->stash->{seedLotDbId
});
5427 _standard_response_construction
($c, $brapi_package_result);
5430 sub seedlot_single_fetch_PUT
{
5433 my ($auth,$user_id) = _authenticate_user
($c);
5434 my $clean_inputs = $c->stash->{clean_inputs
};
5435 my $brapi = $self->brapi_module;
5436 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5437 my $brapi_package_result = $brapi_module->update_seedlot($c->stash->{seedLotDbId
}, $clean_inputs,$c,$user_id);
5438 my $status = $brapi_package_result->{status
};
5439 my $http_status_code = _get_http_status_code
($status);
5440 _standard_response_construction
($c, $brapi_package_result);
5443 sub seedlot_single_transaction_fetch
: Chained
('seedlot_single') PathPart
('transactions') Args
(0) : ActionClass
('REST') { }
5446 sub seedlot_single_transaction_fetch_GET
{
5449 my ($auth) = _authenticate_user
($c);
5450 my $clean_inputs = $c->stash->{clean_inputs
};
5451 my $brapi = $self->brapi_module;
5452 my $brapi_module = $brapi->brapi_wrapper('SeedLots');
5453 my $brapi_package_result = $brapi_module->transactions($c->stash->{seedLotDbId
}, $clean_inputs);
5454 _standard_response_construction
($c, $brapi_package_result);
5457 sub breedingmethods
: Chained
('brapi') PathPart
('breedingmethods') Args
(0) : ActionClass
('REST') { }
5459 sub breedingmethods_GET
{
5462 my $auth = _authenticate_user
($c);
5463 my $clean_inputs = $c->stash->{clean_inputs
};
5464 my $brapi = $self->brapi_module;
5465 my $brapi_module = $brapi->brapi_wrapper('BreedingMethods');
5466 my $brapi_package_result = $brapi_module->search($clean_inputs);
5468 _standard_response_construction
($c, $brapi_package_result);
5471 sub nirs
: Chained
('brapi') PathPart
('nirs') Args
(0) : ActionClass
('REST') { }
5476 my $auth = _authenticate_user
($c);
5477 my $clean_inputs = $c->stash->{clean_inputs
};
5478 my $brapi = $self->brapi_module;
5479 my $brapi_module = $brapi->brapi_wrapper('Nirs');
5480 my $brapi_package_result = $brapi_module->search($clean_inputs);
5482 _standard_response_construction
($c, $brapi_package_result);
5485 sub nirs_single
: Chained
('brapi') PathPart
('nirs') CaptureArgs
(1) {
5488 my $nd_protocol_id = shift;
5490 $c->stash->{nd_protocol_id
} = $nd_protocol_id;
5493 sub nirs_detail
: Chained
('nirs_single') PathPart
('') Args
(0) : ActionClass
('REST') { }
5495 sub nirs_detail_GET
{
5498 my ($auth) = _authenticate_user
($c);
5499 my $clean_inputs = $c->stash->{clean_inputs
};
5500 my $brapi = $self->brapi_module;
5501 my $brapi_module = $brapi->brapi_wrapper('Nirs');
5502 my $brapi_package_result = $brapi_module->nirs_detail(
5503 $c->stash->{nd_protocol_id
}
5505 _standard_response_construction
($c, $brapi_package_result);
5508 sub nirs_matrix
: Chained
('nirs_single') PathPart
('matrix') Args
(0) : ActionClass
('REST') { }
5510 sub nirs_matrix_GET
{
5513 my ($auth) = _authenticate_user
($c);
5514 my $clean_inputs = $c->stash->{clean_inputs
};
5515 my $brapi = $self->brapi_module;
5516 my $brapi_module = $brapi->brapi_wrapper('Nirs');
5517 my $brapi_package_result = $brapi_module->nirs_matrix(
5518 $c->stash->{nd_protocol_id
},
5521 _standard_response_construction
($c, $brapi_package_result);
5525 =head2 brapi/v2/pedigree
5529 sub pedigree
: Chained
('brapi') PathPart
('pedigree') Args
(0) : ActionClass
('REST') { }
5534 my ($auth) = _authenticate_user
($c);
5535 my $clean_inputs = $c->stash->{clean_inputs
};
5536 my $brapi = $self->brapi_module;
5537 my $brapi_module = $brapi->brapi_wrapper('Pedigree');
5538 my $brapi_package_result = $brapi_module->search({
5539 germplasmDbId
=> $clean_inputs->{germplasmDbId
},
5540 pedigreeDepth
=> $clean_inputs->{pedigreeDepth
},
5541 progenyDepth
=> $clean_inputs->{progenyDepth
},
5542 includeFullTree
=> $clean_inputs->{includeFullTree
},
5543 includeSiblings
=> $clean_inputs->{includeSiblings
},
5544 includeParents
=> $clean_inputs->{includeParents
},
5545 includeProgeny
=> $clean_inputs->{includeProgeny
},
5547 _standard_response_construction
($c, $brapi_package_result);
5550 sub pedigree_search
: Chained
('brapi') PathPart
('search/pedigree') Args
(0) : ActionClass
('REST') { }
5552 sub pedigree_search_POST
{
5555 save_results
($self,$c,$c->stash->{clean_inputs
},'Pedigree');
5558 sub pedigree_search_retrieve
: Chained
('brapi') PathPart
('search/pedigree') Args
(1) {
5561 my $search_id = shift;
5562 retrieve_results
($self, $c, $search_id, 'Pedigree');
5571 my $search_params = shift;
5572 my $search_type = shift;
5574 my %server_permission;
5576 my $server_permission = $c->config->{"brapi_GET"};
5577 my @server_permission = split ',', $server_permission;
5578 %server_permission = map { $_ => 1 } @server_permission;
5580 if($rc && !$server_permission{'any'}){
5581 my $auth = _authenticate_user
($c);
5584 my $brapi = $self->brapi_module;
5585 my $brapi_module = $brapi->brapi_wrapper($search_type);
5587 #set default value to 100000 to get as much as possible records when page size is not a parameter
5588 if(!$search_params->{pageSize
}) {
5589 $brapi_module->{page_size
} = 100000;
5592 my $search_result = $brapi_module->search($search_params,$c);
5594 my $dir = $c->tempfiles_subdir('/brapi_searches');
5595 my $tempfile = $c->config->{basepath
}."/".$c->tempfile( TEMPLATE
=> 'brapi_searches/XXXXXXXXXXXXXXXX');
5596 my $results_module = $brapi->brapi_wrapper('Results');
5597 my $brapi_package_result = $results_module->save_results($tempfile, $search_result, $search_type);
5599 _standard_response_construction
($c, $brapi_package_result, 202);
5602 sub retrieve_results
{
5605 my $search_id = shift;
5606 my $search_type = shift;
5607 my $auth = _authenticate_user
($c);
5609 my $clean_inputs = $c->stash->{clean_inputs
};
5610 my $tempfiles_subdir = $c->config->{basepath
} . $c->tempfiles_subdir('brapi_searches');
5611 my $brapi = $self->brapi_module;
5612 my $search_module = $brapi->brapi_wrapper('Results');
5613 my $brapi_package_result = $search_module->retrieve_results($tempfiles_subdir, $search_id);
5614 _standard_response_construction
($c, $brapi_package_result);