Skip to content

Commit

Permalink
make db changes to allow storing of nonsense crisprs and designs
Browse files Browse the repository at this point in the history
  • Loading branch information
sajp committed Feb 17, 2015
1 parent ce2741d commit a7758a5
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 16 deletions.
2 changes: 2 additions & 0 deletions 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;
4 changes: 4 additions & 0 deletions 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' );
5 changes: 5 additions & 0 deletions 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);
68 changes: 66 additions & 2 deletions lib/LIMS2/Model/Schema/Result/Crispr.pm
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -234,6 +242,56 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 nonsense_crispr_original_crispr
Type: belongs_to
Related object: L<LIMS2::Model::Schema::Result::Crispr>
=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<LIMS2::Model::Schema::Result::Crispr>
=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<LIMS2::Model::Schema::Result::Design>
=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
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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 ];
Expand Down Expand Up @@ -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;
57 changes: 43 additions & 14 deletions lib/LIMS2/Model/Schema/Result/Design.pm
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -234,6 +242,26 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 nonsense_design_crispr
Type: belongs_to
Related object: L<LIMS2::Model::Schema::Result::Crispr>
=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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit a7758a5

Please sign in to comment.