Merge pull request #5191 from solgenomics/topic/quality_control
[sgn.git] / lib / CXGN / BrAPI / v1 / Calls.pm
blobdacaed45a1c0ecbbcd0f24c188cc2f1273e7afb6
1 package CXGN::BrAPI::v1::Calls;
3 use Moose;
4 use Data::Dumper;
5 use CXGN::BrAPI::Pagination;
6 use CXGN::BrAPI::JSONResponse;
8 extends 'CXGN::BrAPI::v1::Common';
10 sub search {
11 my $self = shift;
12 my $inputs = shift;
13 my $datatype_param = $inputs->{datatype}->[0];
14 my $page_size = $self->page_size;
15 my $page = $self->page;
17 $page_size = 1000;
19 my $status = $self->status;
20 my @available = (
21 ['token', ['json'], ['POST','DELETE'], ['1.0','1.2','1.3'] ],
22 ['calls', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
23 ['observationlevels', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
24 ['germplasm-search', ['json'], ['GET','POST'], ['1.0','1.2'] ],
25 ['search/germplasm', ['json'], ['GET','POST'], ['1.3'] ],
26 ['germplasm', ['json'], ['GET'], ['1.3'] ],
27 ['germplasm/{germplasmDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
28 ['germplasm/{germplasmDbId}/pedigree', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
29 ['germplasm/{germplasmDbId}/progeny', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
30 ['germplasm/{germplasmDbId}/markerprofiles', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
31 ['germplasm/{germplasmDbId}/attributes', ['json'], ['GET'], ['1.0','1.2'] ],
32 ['attributes', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
33 ['attributes/categories', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
34 ['markerprofiles', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
35 ['markerprofiles/{markerprofileDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
36 ['markerprofiles/methods', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
37 ['allelematrix-search', ['json','tsv','csv','xls'], ['GET','POST'], ['1.0','1.2'] ],
38 ['allelematrices-search', ['json','tsv','csv','xls'], ['GET','POST'], ['1.0','1.2'] ],
39 ['search/allelematrices', ['json'], ['GET','POST'], ['1.3'] ],
40 ['allelematrices', ['json'], ['GET'], ['1.3'] ],
41 ['programs', ['json'], ['GET','POST'], ['1.0','1.2','1.3'] ],
42 ['crops', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
43 ['seasons', ['json'], ['GET','POST'], ['1.0','1.2','1.3'] ],
44 ['studytypes', ['json'], ['GET','POST'], ['1.0','1.2','1.3'] ],
45 ['trials', ['json'], ['GET','POST'], ['1.0','1.2','1.3'] ],
46 ['trials/{trialDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
47 ['studies-search', ['json'], ['GET','POST'], ['1.0','1.2'] ],
48 ['search/studies', ['json'], ['GET','POST'], ['1.3'] ],
49 ['studies', ['json'], ['GET'], ['1.3'] ],
50 ['studies/{studyDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
51 ['studies/{studyDbId}/germplasm', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
52 ['studies/{studyDbId}/observationvariables', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
53 ['studies/{studyDbId}/observationunits', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
54 ['studies/{studyDbId}/table', ['json','csv','xls','tsv'], ['GET'], ['1.0','1.2','1.3'] ],
55 ['studies/{studyDbId}/layout', ['json'], ['GET'], ['1.0','1.2'] ],
56 ['studies/{studyDbId}/layouts', ['json'], ['GET'], ['1.3'] ],
57 ['studies/{studyDbId}/observations', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
58 ['phenotypes-search', ['json'], ['GET','POST'], ['1.0','1.2'] ],
59 ['search/phenotypes', ['json'], ['GET','POST'], ['1.3'] ],
60 ['phenotypes', ['json'], ['GET','POST'], ['1.3'] ],
61 ['phenotypes-search/table', ['json'], ['GET','POST'], ['1.0','1.2'] ],
62 ['phenotypes-search/tsv', ['json'], ['GET','POST'], ['1.0','1.2'] ],
63 ['phenotypes-search/csv', ['json'], ['GET','POST'], ['1.0','1.2'] ],
64 ['observationunits', ['json'], ['GET'], ['1.3'] ],
65 ['search/observationunits', ['json'], ['GET','POST'], ['1.3'] ],
66 ['observationtables', ['json'], ['GET'], ['1.3'] ],
67 ['search/observationtables', ['json'], ['GET','POST'], ['1.3'] ],
68 ['traits', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
69 ['traits', ['json'], ['POST'], ['1.3'] ],
70 ['traits/{traitDbId}', ['json'], ['GET'], ['1.0','1.2'] ],
71 ['traits/{traitDbId}', ['json'], ['PUT'], ['1.3'] ],
72 ['maps', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
73 ['maps/{mapDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
74 ['maps/{mapDbId}/positions', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
75 ['maps/{mapDbId}/positions/id', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
76 ['locations', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
77 ['variables/datatypes', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
78 ['ontologies', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
79 ['variables', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
80 ['variables/{observationVariableDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
81 ['variables-search', ['json'], ['GET','POST'], ['1.0','1.2'] ],
82 ['samples-search', ['json'], ['GET','POST'], ['1.0','1.2'] ],
83 ['search/samples', ['json'], ['GET','POST'], ['1.3'] ],
84 ['samples', ['json'], ['GET'], ['1.3'] ],
85 ['samples/{sampleDbId}', ['json'], ['GET'], ['1.0','1.2','1.3'] ],
86 ['images', ['json'],['GET','POST'], ['1.3']],
87 ['images/{imageDbId}', ['json'], ['GET','PUT'], ['1.3']],
88 ['images/{imageDbId}/imagecontent', ['json'], ['PUT'], ['1.3']],
89 ['lists', ['json'], ['GET','POST'],['1.3']],
90 ['lists/{listDbId}',['json'], ['GET','PUT'], ['1.3']],
91 ['lists/{listDbId}/items',['json'], ['POST'], ['1.3']],
92 ['markers',['json'], ['GET'], ['1.0', '1.3']],
93 ['markers/{markerDbId}',['json'], ['GET'],[ '1.0', '1.1', '1.2', '1.3']],
94 ['methods',['json'], ['GET','POST'], ['1.3']],
95 ['methods/{methodDbId}',['json'], ['GET','PUT'], ['1.3']],
96 ['people',['json'], ['GET', 'POST'],['1.3']],
97 ['people/{personDbId}', ['json'], ['GET','PUT'], ['1.3']],
98 ['scales', ['json'], ['GET','POST'], ['1.3']],
99 ['scales/{scaleDbId}', ['json'], ['GET','PUT'],['1.3']],
100 ['search/germplasm/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
101 ['search/images', ['json'], ['POST'], ['1.3']],
102 ['search/images/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
103 ['search/markers', ['json'], ['POST'], ['1.3']],
104 ['search/markers/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
105 ['search/observationtables/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
106 ['search/observationunits/searchResultsDbId', ['json'], ['GET'], ['1.3']],
107 ['search/programs', ['json'], ['POST'], ['1.3']],
108 ['search/programs/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
109 ['search/samples/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
110 ['search/studies/{searchResultsDbId}', ['json'], ['GET'], ['1.3']],
113 my @call_search;
114 if ($datatype_param){
115 foreach my $a (@available){
116 foreach (@{$a->[1]}){
117 if ($_ eq $datatype_param){
118 push @call_search, $a;
122 } else {
123 @call_search = @available;
126 my @data;
127 my ($data_window, $pagination) = CXGN::BrAPI::Pagination->paginate_array(\@call_search, $page_size, $page);
128 foreach (@$data_window){
129 push @data, {
130 call=>$_->[0],
131 datatypes=>$_->[1],
132 methods=>$_->[2],
133 versions=>$_->[3]
136 my %result = (data=>\@data);
137 my @data_files;
138 return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, 'Calls result constructed');