3 SGN::Controller::AJAX::Transgenic - a REST controller class for Vector Constructs.
7 Synchronizes transgenic accessions into the database from the ETHZ CASS database.
11 Nicolas Morales <nm529@cornell.edu>
15 package SGN
::Controller
::AJAX
::Transgenic
;
18 use JSON
-support_by_pp
;
19 use List
::MoreUtils qw
/any /;
22 use SGN
::Model
::Cvterm
;
25 BEGIN { extends
'Catalyst::Controller::REST' }
28 default => 'application/json',
30 map => { 'application/json' => 'JSON', 'text/html' => 'JSON' },
34 sub sync_cass_transgenics
: Path
('/ajax/cass_transgenics/sync') Args
(0) ActionClass
('REST') { }
36 sub sync_cass_transgenics_POST
{
40 my $schema = $c->dbic_schema("Bio::Chado::Schema");
42 my $transgenic_names = decode_json
($c->req->param("data"));
43 my %transgenic_hash = %$transgenic_names;
44 my $transgenics = $transgenic_hash{transgenic
};
45 my @transgenics_array = @
$transgenics;
47 my $stock_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'accession', 'stock_type')->cvterm_id();
48 my $stock_prop_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'transgenic', 'stock_property')->cvterm_id();
50 my $create_db = $schema->resultset("General::Db")->find_or_create({
52 description
=> 'Internal ETHZ CASS DB',
54 url
=> 'https://cass.pb.ethz.ch'
57 foreach (@transgenics_array) {
58 #print STDERR $_->{construct};
59 #print STDERR $_->{construct_id};
60 #print STDERR $_->{level};
62 my $create_stock = $schema->resultset("Stock::Stock")->find_or_create({
63 uniquename
=> $_->{transgenic
},
64 name
=> $_->{transgenic
},
65 type_id
=> $stock_type_id,
68 my $create_dbxref = $schema->resultset("General::Dbxref")->find_or_create({
69 db_id
=> $create_db->db_id(),
70 accession
=> $_->{transgenic_id
},
71 version
=> 'transgenic',
72 description
=> 'ETHZ_CASS transgenic id'
75 my $create_stock_dbxref = $schema->resultset("Stock::StockDbxref")->find_or_create({
76 stock_id
=> $create_stock->stock_id(),
77 dbxref_id
=> $create_dbxref->dbxref_id()
80 my $create_stock_prop = $schema->resultset("Stock::Stockprop")->find_or_create({
81 stock_id
=> $create_stock->stock_id(),
82 type_id
=> $stock_prop_type_id,
87 #print STDERR Dumper $transgenics;
88 #print STDERR $status;
90 $c->stash->{rest
} = {response
=>$status};