1 #test all functions in CXGN::BreedersToolbox::Projects
9 use SGN::Test::Fixture;
10 use CXGN::BreedersToolbox::Projects;
12 my $f = SGN::Test::Fixture->new();
13 my $schema = $f->bcs_schema();
15 my $p = CXGN::BreedersToolbox::Projects->new({schema=>$schema});
19 my $trial_id = $schema->resultset('Project::Project')->find({name=>'test_trial'})->project_id();
20 ok($p->trial_exists($trial_id));
22 my $projects = $p->get_breeding_programs();
23 #print STDERR Dumper $projects;
24 is_deeply($projects, [
32 my $bp_project_id = $p->get_breeding_program_by_name('test');
35 my ($field_trials, $cross_trials, $genotyping_trials) = $p->get_trials_by_breeding_program($bp_project_id->project_id);
36 my @sorted_field_trials = sort {$a->[0] cmp $b->[0]} @$field_trials;
37 print STDERR Dumper \@sorted_field_trials;
38 is_deeply(\@sorted_field_trials, [
47 'This trial was loaded into the fixture to test solgs.'
52 'another trial for solGS'
61 'CASS_6Genotypes_Sampling_2015',
62 'Copy of trial with postcomposed phenotypes from cassbase.'
64 ], 'test get trials');
65 #print STDERR Dumper $cross_trials;
67 my @sorted_cross_trials = sort {$a->[0] cmp $b->[0]} @$cross_trials;
68 #print STDERR Dumper \@sorted_cross_trials;
69 is_deeply(\@sorted_cross_trials, [
175 ], 'test get crosses');
180 #print STDERR Dumper $genotyping_trials;
181 is_deeply($genotyping_trials, undef, 'test get geno trials');
183 my $locations = $p->get_location_geojson_data();
184 print STDERR Dumper $locations;
185 is_deeply($locations, [{"geometry"=>{"coordinates"=>[-115.86428,32.61359],"type"=>"Point"},"properties"=>{"Abbreviation"=>undef,"Altitude"=>109,"Code"=>"USA","Country"=>"United States","Id"=>"23","Latitude"=>32.61359,"Longitude"=>-115.86428,"NOAAStationID"=>undef,"Name"=>"test_location","Program"=>"test","Trials"=>"<a href=\"/search/trials?location_id=23\">5 trials</a>","Type"=>undef},"type"=>"Feature"},{"geometry"=>{"coordinates"=>[-76.4735,42.45345],"type"=>"Point"},"properties"=>{"Abbreviation"=>undef,"Altitude"=>274,"Code"=>"USA","Country"=>"United States","Id"=>"24","Latitude"=>42.45345,"Longitude"=>-76.4735,"NOAAStationID"=>undef,"Name"=>"Cornell Biotech","Program"=>"test","Trials"=>"<a href=\"/search/trials?location_id=24\">0 trials</a>","Type"=>undef},"type"=>"Feature"},{"geometry"=>{"coordinates"=>[undef,undef],"type"=>"Point"},"properties"=>{"Abbreviation"=>undef,"Altitude"=>undef,"Code"=>undef,"Country"=>undef,"Id"=>"25","Latitude"=>undef,"Longitude"=>undef,"NOAAStationID"=>undef,"Name"=>"NA","Program"=>undef,"Trials"=>"<a href=\"/search/trials?location_id=25\">0 trials</a>","Type"=>undef},"type"=>"Feature"},{"geometry"=>{"coordinates"=>[undef,undef],"type"=>"Point"},"properties"=>{"Abbreviation"=>undef,"Altitude"=>undef,"Code"=>undef,"Country"=>undef,"Id"=>"26","Latitude"=>undef,"Longitude"=>undef,"NOAAStationID"=>undef,"Name"=>"[Computation]","Program"=>undef,"Trials"=>"<a href=\"/search/trials?location_id=26\">0 trials</a>","Type"=>undef},"type"=>"Feature"}]);
189 #'[{"geometry":{"coordinates":[-115.864,32.6136],"type":"Point"},"properties":{"Abbreviation":null,"Altitude":109,"Code":"USA","Country":"United States","Id":"23","Latitude":32.6136,"Longitude":-115.864,"NOAAStationID":null,"Name":"test_location","Program":"test","Trials":"<a href=\"/search/trials?location_id=23\">5 trials</a>","Type":null},"type":"Feature"},{"geometry":{"coordinates":[-76.4735,42.4534],"type":"Point"},"properties":{"Abbreviation":null,"Altitude":274,"Code":"USA","Country":"United States","Id":"24","Latitude":42.4534,"Longitude":-76.4735,"NOAAStationID":null,"Name":"Cornell Biotech","Program":"test","Trials":"<a href=\"/search/trials?location_id=24\">0 trials</a>","Type":null},"type":"Feature"},{"geometry":{"coordinates":[null,null],"type":"Point"},"properties":{"Abbreviation":null,"Altitude":null,"Code":null,"Country":null,"Id":"25","Latitude":null,"Longitude":null,"NOAAStationID":null,"Name":"NA","Program":null,"Trials":"<a href=\"/search/trials?location_id=25\">0 trials</a>","Type":null},"type":"Feature"}]', 'get locations by bp');
191 my $all_locations = $p->get_all_locations();
192 print STDERR Dumper $all_locations;
193 is(scalar(@$all_locations), 4);
194 is_deeply($all_locations,[
210 ], 'get all locations');
212 my $all_locations = $p->get_locations();
213 print STDERR Dumper $all_locations;
214 is_deeply($all_locations, [
247 ], 'get all locations');
249 my @all_years = $p->get_all_years();
250 print STDERR Dumper \@all_years;
251 is_deeply(\@all_years, [
258 my $new_bp = CXGN::BreedersToolbox::Projects->new({
260 name => 'test_new_bp_to_edit',
261 description => 'test_new_bp_desc_to_edit',
263 my $new_bp_result = $new_bp->store_breeding_program();
264 print STDERR Dumper $new_bp_result;
265 ok($new_bp_result->{success});
267 my $edit_bp = CXGN::BreedersToolbox::Projects->new({
269 id => $new_bp_result->{id},
270 name => 'test_new_bp',
271 description => 'test_new_bp_desc',
273 my $edit_bp_result = $edit_bp->store_breeding_program();
274 print STDERR Dumper $edit_bp_result;
275 ok($edit_bp_result->{success});
277 my $bp_projects = $p->get_breeding_program_with_trial($trial_id);
278 #print STDERR Dumper $bp_projects;
279 is_deeply($bp_projects, [
287 my $gt_protocols = $p->get_gt_protocols();
288 #print STDERR Dumper $gt_protocols;
289 is_deeply($gt_protocols, [
292 'GBS ApeKI genotyping v4'
294 ], 'get gt protocols');
296 my $program_id = $schema->resultset('Project::Project')->find({name=>'test_new_bp'})->project_id();
297 ok($p->delete_breeding_program($program_id));