3 CXGN::Transformation::AddTransformationIdentifier - a module for adding transformation identifier
8 package CXGN
::Transformation
::AddTransformationIdentifier
;
11 use MooseX
::FollowPBP
;
12 use Moose
::Util
::TypeConstraints
;
14 use CXGN
::Location
::LocationLookup
;
16 use SGN
::Model
::Cvterm
;
19 has
'chado_schema' => (
20 isa
=> 'DBIx::Class::Schema',
30 has
'phenome_schema' => (
32 isa
=> 'DBIx::Class::Schema',
33 predicate
=> 'has_phenome_schema',
37 has
'transformation_identifier' => (
43 has
'plant_material' => (
49 has
'vector_construct' => (
65 has
'transformation_project_id' => (
72 sub add_transformation_identifier
{
74 my $schema = $self->get_chado_schema();
75 my $phenome_schema = $self->get_phenome_schema();
76 my $transformation_identifier = $self->get_transformation_identifier();
77 my $plant_material = $self->get_plant_material();
78 my $vector_construct = $self->get_vector_construct();
79 my $transformation_notes = $self->get_notes();
80 my $transformation_project_id = $self->get_transformation_project_id();
81 my $plant_material_stock_id;
82 my $vector_construct_stock_id;
84 my $transformation_stock_id;
86 my $owner_id = $self->get_owner_id();;
90 my $transformation_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'transformation', 'stock_type')->cvterm_id();
91 my $transformation_experiment_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'transformation_experiment', 'experiment_type')->cvterm_id();
92 my $transformation_project_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'transformation_project', 'project_type')->cvterm_id();
93 my $plant_material_of_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'plant_material_of', 'stock_relationship')->cvterm_id();
94 my $vector_construct_of_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'vector_construct_of', 'stock_relationship')->cvterm_id();
95 # my $transformation_notes_cvterm_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'transformation_notes', 'stock_property')->cvterm_id();
96 my $accession_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'accession', 'stock_type')->cvterm_id();
97 my $vector_construct_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'vector_construct', 'stock_type')->cvterm_id();
99 my $project_location_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'project location', 'project_property')->cvterm_id();
100 my $geolocation_rs = $schema->resultset("Project::Projectprop")->find({project_id
=> $transformation_project_id, type_id
=> $project_location_cvterm_id});
102 my $plant_material_rs = $schema->resultset("Stock::Stock")->find({
103 uniquename
=> $plant_material,
104 type_id
=> $accession_cvterm_id,
107 if ($plant_material_rs) {
108 $plant_material_stock_id = $plant_material_rs->stock_id();
111 my $vector_construct_rs = $schema->resultset("Stock::Stock")->find({
112 uniquename
=> $vector_construct,
113 type_id
=> $vector_construct_cvterm_id,
116 if ($vector_construct_rs) {
117 $vector_construct_stock_id = $vector_construct_rs->stock_id();
120 my $experiment = $schema->resultset('NaturalDiversity::NdExperiment')->create({
121 nd_geolocation_id
=> $geolocation_rs->value,
122 type_id
=> $transformation_experiment_cvterm_id,
124 my $nd_experiment_id = $experiment->nd_experiment_id();
126 my $transformation_identifier_stock = $schema->resultset("Stock::Stock")->find_or_create({
127 name
=> $transformation_identifier,
128 uniquename
=> $transformation_identifier,
129 type_id
=> $transformation_cvterm_id,
132 $transformation_identifier_stock->find_or_create_related('stock_relationship_objects', {
133 type_id
=> $plant_material_of_cvterm_id,
134 object_id
=> $transformation_identifier_stock->stock_id(),
135 subject_id
=> $plant_material_stock_id,
138 $transformation_identifier_stock->find_or_create_related('stock_relationship_objects', {
139 type_id
=> $vector_construct_of_cvterm_id,
140 object_id
=> $transformation_identifier_stock->stock_id(),
141 subject_id
=> $vector_construct_stock_id,
144 $experiment->find_or_create_related('nd_experiment_stocks' , {
145 stock_id
=> $transformation_identifier_stock->stock_id(),
146 type_id
=> $transformation_experiment_cvterm_id,
149 $experiment->find_or_create_related('nd_experiment_projects', {
150 project_id
=> $transformation_project_id,
153 $transformation_stock_id = $transformation_identifier_stock->stock_id();
155 print STDERR
"TRANSFORMATION STOCK ID =".Dumper
($transformation_stock_id)."\n";
156 my $transaction_error;
158 $schema->txn_do($coderef);
160 print STDERR
"Transaction Error: $_\n";
161 $transaction_error = $_;
164 if ($transaction_error){
165 return { error
=>$transaction_error };
167 $phenome_schema->resultset("StockOwner")->find_or_create({
168 stock_id
=> $transformation_stock_id,
169 sp_person_id
=> $owner_id,
172 return { success
=>1, transformation_id
=>$transformation_stock_id };