diff --git a/ddl/versions/83/audit-up.sql b/ddl/versions/83/audit-up.sql new file mode 100644 index 0000000000..97e317d63f --- /dev/null +++ b/ddl/versions/83/audit-up.sql @@ -0,0 +1,2 @@ +ALTER TABLE audit.designs ADD COLUMN nonsense_design_crispr_id INT; +ALTER TABLE audit.crisprs ADD COLUMN nonsense_crispr_original_crispr_id INT; diff --git a/ddl/versions/83/fixtures.sql b/ddl/versions/83/fixtures.sql new file mode 100755 index 0000000000..780d0cf354 --- /dev/null +++ b/ddl/versions/83/fixtures.sql @@ -0,0 +1,4 @@ +INSERT INTO schema_versions(version) VALUES (83); + +INSERT INTO design_types(id) VALUES( 'nonsense' ); +INSERT INTO design_oligo_types(id) VALUES( 'N' ); diff --git a/ddl/versions/83/up.sql b/ddl/versions/83/up.sql new file mode 100755 index 0000000000..abab1a04ce --- /dev/null +++ b/ddl/versions/83/up.sql @@ -0,0 +1,5 @@ +ALTER TABLE designs ADD COLUMN nonsense_design_crispr_id INT; +ALTER TABLE designs ADD foreign key (nonsense_design_crispr_id) references crisprs(id); + +ALTER TABLE crisprs ADD COLUMN nonsense_crispr_original_crispr_id INT; +ALTER TABLE crisprs ADD foreign key (nonsense_crispr_original_crispr_id) references crisprs(id); diff --git a/lib/LIMS2/Model/Schema/Result/Crispr.pm b/lib/LIMS2/Model/Schema/Result/Crispr.pm index e4949340c1..e956c3bd87 100644 --- a/lib/LIMS2/Model/Schema/Result/Crispr.pm +++ b/lib/LIMS2/Model/Schema/Result/Crispr.pm @@ -77,6 +77,12 @@ __PACKAGE__->table("crisprs"); data_type: 'integer' is_nullable: 1 +=head2 nonsense_crispr_original_crispr_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -99,6 +105,8 @@ __PACKAGE__->add_columns( { data_type => "boolean", is_nullable => 1 }, "wge_crispr_id", { data_type => "integer", is_nullable => 1 }, + "nonsense_crispr_original_crispr_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -234,6 +242,56 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 nonsense_crispr_original_crispr + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "nonsense_crispr_original_crispr", + "LIMS2::Model::Schema::Result::Crispr", + { id => "nonsense_crispr_original_crispr_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 nonsense_crisprs + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "nonsense_crisprs", + "LIMS2::Model::Schema::Result::Crispr", + { "foreign.nonsense_crispr_original_crispr_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 nonsense_designs + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "nonsense_designs", + "LIMS2::Model::Schema::Result::Design", + { "foreign.nonsense_design_crispr_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 off_target_summaries Type: has_many @@ -295,8 +353,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-08-12 11:27:44 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:y6PtCetsdH2ctfQWcfNotQ +# Created by DBIx::Class::Schema::Loader v0.07022 @ 2015-02-16 14:06:06 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L+7iayAit59h54+arAUOMg __PACKAGE__->many_to_many("crispr_groups" => "crispr_group_crisprs", "crispr_group"); @@ -326,6 +384,7 @@ sub as_hash { pam_right => !defined $self->pam_right ? '' : $self->pam_right == 1 ? 'true' : 'false', wge_crispr_id => $self->wge_crispr_id, crispr_primers => [ map { $_->as_hash } $self->crispr_primers ], + nonsense_crispr_original_crispr_id => $self->nonsense_crispr_original_crispr_id, ); $h{off_targets} = [ map { $_->as_hash } $self->off_targets ]; @@ -543,6 +602,11 @@ sub is_pair { return; } sub is_group { return; } +sub is_nonsense_crispr { + my $self = shift; + return $self->nonsense_crispr_original_crispr_id ? 1 : 0; +} + # You can replace this text with custom code or comments, and it will be preserved on regeneration __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/LIMS2/Model/Schema/Result/Design.pm b/lib/LIMS2/Model/Schema/Result/Design.pm index 1fb4979687..e375bed92a 100644 --- a/lib/LIMS2/Model/Schema/Result/Design.pm +++ b/lib/LIMS2/Model/Schema/Result/Design.pm @@ -106,6 +106,12 @@ __PACKAGE__->table("designs"); data_type: 'integer' is_nullable: 1 +=head2 nonsense_design_crispr_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -143,6 +149,8 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"true", is_nullable => 0 }, "global_arm_shortened", { data_type => "integer", is_nullable => 1 }, + "nonsense_design_crispr_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -234,6 +242,26 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 nonsense_design_crispr + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "nonsense_design_crispr", + "LIMS2::Model::Schema::Result::Crispr", + { id => "nonsense_design_crispr_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + =head2 oligos Type: has_many @@ -310,8 +338,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-07-04 10:08:09 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Y003qJa2tDYf+S/ExLwtUA +# Created by DBIx::Class::Schema::Loader v0.07022 @ 2015-02-16 13:37:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:o2o5Z9QfEnGbLi3Wchpl3g # You can replace this text with custom code or comments, and it will be preserved on regeneration @@ -365,18 +393,19 @@ sub as_hash { $self->discard_changes; my %h = ( - id => $self->id, - name => $self->name, - type => $self->design_type_id, - created_at => $self->created_at->iso8601, - created_by => $self->created_by->name, - phase => $self->phase, - validated_by_annotation => $self->validated_by_annotation, - target_transcript => $self->target_transcript, - species => $self->species_id, - assigned_genes => [ map { $_->gene_id } $self->genes ], - cassette_first => $self->cassette_first, - global_arm_shortened => $self->global_arm_shortened, + id => $self->id, + name => $self->name, + type => $self->design_type_id, + created_at => $self->created_at->iso8601, + created_by => $self->created_by->name, + phase => $self->phase, + validated_by_annotation => $self->validated_by_annotation, + target_transcript => $self->target_transcript, + species => $self->species_id, + assigned_genes => [ map { $_->gene_id } $self->genes ], + cassette_first => $self->cassette_first, + global_arm_shortened => $self->global_arm_shortened, + nonsense_design_crispr_id => $self->nonsense_design_crispr_id, ); if ( ! $suppress_relations ) {