Skip to content

Commit

Permalink
Merge branch 'devel' into david_misc
Browse files Browse the repository at this point in the history
  • Loading branch information
dparrysmith committed Dec 4, 2014
2 parents b112d82 + 27e7121 commit b1819cc
Show file tree
Hide file tree
Showing 28 changed files with 464 additions and 277 deletions.
11 changes: 11 additions & 0 deletions Changes
@@ -1,5 +1,16 @@
{{$NEXT}}

0.272 2014-12-04 07:18:46 Europe/London

0.272 2014-12-03 16:04:43 Europe/London

Bugfix: recovery class foreign key added to correct column
Update interface for crispr es qc, allow validation of qc run.

0.271 2014-12-03 07:42:17 Europe/London

Update Legacy Cre KnockIn report

0.270 2014-11-21 15:05:18 Europe/London

QcRunSummary report gene symbols and support for crispr qc
Expand Down
1 change: 1 addition & 0 deletions ddl/versions/78/fixtures.sql
@@ -0,0 +1 @@
INSERT INTO schema_versions(version) VALUES (78);
2 changes: 2 additions & 0 deletions ddl/versions/78/up.sql
@@ -0,0 +1,2 @@
ALTER TABLE projects ADD CONSTRAINT projects_recovery_class_fkey FOREIGN KEY (recovery_class) REFERENCES project_recovery_class(id);
ALTER TABLE projects DROP CONSTRAINT projects_recovery_comment_fkey;
2 changes: 2 additions & 0 deletions ddl/versions/79/audit-up.sql
@@ -0,0 +1,2 @@
ALTER TABLE audit.crispr_es_qc_wells ADD COLUMN variant_size INT;
ALTER TABLE audit.crispr_es_qc_runs ADD COLUMN validated BOOLEAN;
2 changes: 2 additions & 0 deletions ddl/versions/79/fixtures.sql
@@ -0,0 +1,2 @@
INSERT INTO schema_versions(version) VALUES (79);
INSERT INTO crispr_damage_types( id, description ) VALUES ( 'no-call', 'No automatic damage type call could be made' );
2 changes: 2 additions & 0 deletions ddl/versions/79/up.sql
@@ -0,0 +1,2 @@
ALTER TABLE crispr_es_qc_wells ADD COLUMN variant_size INT;
ALTER TABLE crispr_es_qc_runs ADD COLUMN validated BOOLEAN DEFAULT FALSE;
74 changes: 57 additions & 17 deletions lib/LIMS2/Model/Plugin/CrisprEsQc.pm
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings FATAL => 'all';

use Moose::Role;
use DDP;
use namespace::autoclean;

requires qw( schema check_params throw retrieve log trace );
Expand Down Expand Up @@ -57,6 +58,9 @@ sub pspec_create_crispr_es_qc_well {
vcf_file => { validate => 'non_empty_string', optional => 1 },
crispr_es_qc_run_id => { validate => 'non_empty_string' },
species => { validate => 'existing_species' },
crispr_damage_type => { validate => 'existing_crispr_damage_type', optional => 1, rename => 'crispr_damage_type_id' },
variant_size => { validate => 'integer', optional => 1 },
accepted => { validate => 'boolean', optional => 1 },
};
}

Expand All @@ -70,6 +74,19 @@ sub create_crispr_es_qc_well {

my $validated_params = $self->check_params( $params, $self->pspec_create_crispr_es_qc_well );

# if the qc well has been marked accepted run this logic
if ( $validated_params->{accepted} ) {
my $well = $self->retrieve_well( { id => $validated_params->{well_id} } );
# only mark qc accepted if the linked well is not already accepted in another run
if ( $well->accepted ) {
delete $validated_params->{accepted};
}
# mark the linked well accepted
else {
$well->update( { accepted => 1 } );
}
}

my $species = delete $validated_params->{species};
if ( $validated_params->{crispr_chr_name} ) {
my $chr_name = delete $validated_params->{crispr_chr_name};
Expand Down Expand Up @@ -154,10 +171,33 @@ sub retrieve_crispr_es_qc_run {
return $self->retrieve( CrisprEsQcRuns => $validated_params );
}

sub pspec_update_crispr_well_damage {
=head2 validate_crispr_es_qc_run
Update a crispr es qc run plus all of its wells to validated.
=cut
sub validate_crispr_es_qc_run {
my ( $self, $params ) = @_;

my $crispr_es_qc_run = $self->retrieve_crispr_es_qc_run( $params );
$crispr_es_qc_run->update( { validated => 1 } );

$self->log->info( 'Validated crispr es qc run ' . $crispr_es_qc_run->id );

return;
}

sub pspec_update_crispr_es_qc_well {
return {
id => { validate => 'integer' },
damage_type => { validate => 'existing_crispr_damage_type', optional => 1 },
damage_type => {
validate => 'existing_crispr_damage_type',
optional => 1,
rename => 'crispr_damage_type_id'
},
variant_size => { validate => 'integer', optional => 1 },
accepted => { validate => 'boolean_string', optional => 1 },
MISSING_OPTIONAL_VALID => 1,
};
}

Expand All @@ -166,28 +206,28 @@ sub pspec_update_crispr_well_damage {
Update the crispr_damage type value of a crispr es qc well row
=cut
sub update_crispr_well_damage {
sub update_crispr_es_qc_well{
my ( $self, $params ) = @_;

# to deal with user unsetting a damage type
delete $params->{damage_type} unless $params->{damage_type};

my $validated_params = $self->check_params( $params, $self->pspec_update_crispr_well_damage );
my $validated_params = $self->check_params( $params, $self->pspec_update_crispr_es_qc_well );

my $qc_well = $self->schema->resultset('CrisprEsQcWell')->find(
{
id => $validated_params->{id},
},
);
my $id = delete $validated_params->{id};
my $qc_well = $self->schema->resultset('CrisprEsQcWell')->find( { id => $id } );
unless ( $qc_well ) {
$self->throw(
NotFound => { entity_class => 'CrisprEsQcWell', search_params => $validated_params }
);
NotFound => { entity_class => 'CrisprEsQcWell', search_params => { id => $id } } );
}
my $damage_type = $validated_params->{damage_type} ? $validated_params->{damage_type} : undef;

$qc_well->update( { crispr_damage_type_id => $damage_type } );
$self->log->info( "Updated crispr damage type on crispr es qc well: " . $qc_well->id . ' to: ' . ( $damage_type ? $damage_type : 'unset' ) );
$qc_well->update( $validated_params );

$self->log->info( "Updated crispr es qc well "
. $qc_well->id . ' to: ' . p( $validated_params ) );

if ( exists $validated_params->{accepted} ) {
my $well = $qc_well->well;
$well->update( { accepted => $validated_params->{accepted} } );
$self->log->info( "Updated $well well accepted " . $validated_params->{accepted} );
}

return $qc_well;
}
Expand Down
12 changes: 10 additions & 2 deletions lib/LIMS2/Model/Schema/Result/CrisprEsQcRuns.pm
Expand Up @@ -73,6 +73,12 @@ __PACKAGE__->table("crispr_es_qc_runs");
data_type: 'text'
is_nullable: 1
=head2 validated
data_type: 'boolean'
default_value: false
is_nullable: 1
=cut

__PACKAGE__->add_columns(
Expand All @@ -93,6 +99,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"sub_project",
{ data_type => "text", is_nullable => 1 },
"validated",
{ data_type => "boolean", default_value => \"false", is_nullable => 1 },
);

=head1 PRIMARY KEY
Expand Down Expand Up @@ -155,8 +163,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-04-16 16:43:15
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KStXhk631rbpalREDS3uoA
# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-12-01 11:39:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:A7ZSinww6G/DqZs50j+0+w

sub as_hash {
my ( $self, $options ) = @_;
Expand Down
12 changes: 10 additions & 2 deletions lib/LIMS2/Model/Schema/Result/CrisprEsQcWell.pm
Expand Up @@ -111,6 +111,11 @@ __PACKAGE__->table("crispr_es_qc_wells");
is_foreign_key: 1
is_nullable: 1
=head2 variant_size
data_type: 'integer'
is_nullable: 1
=cut

__PACKAGE__->add_columns(
Expand Down Expand Up @@ -145,6 +150,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"crispr_damage_type_id",
{ data_type => "text", is_foreign_key => 1, is_nullable => 1 },
"variant_size",
{ data_type => "integer", is_nullable => 1 },
);

=head1 PRIMARY KEY
Expand Down Expand Up @@ -232,8 +239,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-10-27 09:07:15
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZqMaBc51jDRz1dseBj+8Ig
# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-12-03 11:52:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HLxWkhqfpzrHco4xOT7tdQ

use JSON;
use List::Util qw ( min max );
Expand Down Expand Up @@ -367,6 +374,7 @@ sub format_well_data {
rev_read => $self->rev_read,
damage_type => $self->crispr_damage_type_id,
vep_output => $json->{vep_output},
variant_size => $self->variant_size,
};
}

Expand Down
17 changes: 9 additions & 8 deletions lib/LIMS2/Model/Schema/Result/Project.pm
Expand Up @@ -86,12 +86,12 @@ __PACKAGE__->table("projects");
=head2 recovery_class
data_type: 'text'
is_foreign_key: 1
is_nullable: 1
=head2 recovery_comment
data_type: 'text'
is_foreign_key: 1
is_nullable: 1
=head2 priority
Expand Down Expand Up @@ -124,9 +124,9 @@ __PACKAGE__->add_columns(
"effort_concluded",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"recovery_class",
{ data_type => "text", is_nullable => 1 },
"recovery_comment",
{ data_type => "text", is_foreign_key => 1, is_nullable => 1 },
"recovery_comment",
{ data_type => "text", is_nullable => 1 },
"priority",
{ data_type => "text", is_nullable => 1 },
);
Expand Down Expand Up @@ -183,7 +183,7 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 recovery_comment
=head2 recovery_class
Type: belongs_to
Expand All @@ -192,9 +192,9 @@ Related object: L<LIMS2::Model::Schema::Result::ProjectRecoveryClass>
=cut

__PACKAGE__->belongs_to(
"recovery_comment",
"recovery_class",
"LIMS2::Model::Schema::Result::ProjectRecoveryClass",
{ id => "recovery_comment" },
{ id => "recovery_class" },
{
is_deferrable => 1,
join_type => "LEFT",
Expand All @@ -218,8 +218,9 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);

# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-10-14 11:17:00
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:djydxXiT/U9oK3BE/QW9iw

# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-12-03 15:40:30
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gp9bd7euuZta5rwWDBvWUQ

sub as_hash {
my $self = shift;
Expand Down
7 changes: 4 additions & 3 deletions lib/LIMS2/Model/Schema/Result/ProjectRecoveryClass.pm
Expand Up @@ -83,12 +83,13 @@ Related object: L<LIMS2::Model::Schema::Result::Project>
__PACKAGE__->has_many(
"projects",
"LIMS2::Model::Schema::Result::Project",
{ "foreign.recovery_comment" => "self.id" },
{ "foreign.recovery_class" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-10-14 14:05:24
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SANap7GZzTCDqebVX8hgAw

# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-12-03 15:40:30
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WWpruQh1u9fbedff6V50mg

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
Expand Down
8 changes: 8 additions & 0 deletions lib/LIMS2/Model/Schema/Result/QcEngSeq.pm
Expand Up @@ -170,5 +170,13 @@ sub design_id {
return $eng_seq_params->{design_id};
}

sub crispr_id {
my $self = shift;

my $eng_seq_params = decode_json( $self->params );

return $eng_seq_params->{crispr_id};
}

__PACKAGE__->meta->make_immutable;
1;
6 changes: 6 additions & 0 deletions lib/LIMS2/Model/Schema/Result/QcTemplateWell.pm
Expand Up @@ -250,5 +250,11 @@ sub design_id {
return $self->qc_eng_seq->design_id;
}

sub crispr_id {
my $self = shift;

return $self->qc_eng_seq->crispr_id;
}

__PACKAGE__->meta->make_immutable;
1;
10 changes: 8 additions & 2 deletions lib/LIMS2/Model/Util/CrisprESQC.pm
Expand Up @@ -694,8 +694,14 @@ sub build_qc_data {
$qc_data{crispr_chr_name} = $crispr->chr_name;
}

if ( $analyser && $analyser->vcf_file_target_region ) {
$qc_data{vcf_file} = $analyser->vcf_file_target_region->slurp;
if ( $analyser ) {
$qc_data{vcf_file} = $analyser->vcf_file_target_region->slurp if $analyser->vcf_file_target_region;
$qc_data{variant_size} = $analyser->variant_size if $analyser->variant_size;
if ( $analyser->variant_type ) {
$qc_data{crispr_damage_type} = $analyser->variant_type;
# if a variant type other can no-call has been made then mark well accepted
$qc_data{accepted} = 1 if $analyser->variant_type ne 'no-call';
}
}

if ( exists $well_reads->{forward} ) {
Expand Down

0 comments on commit b1819cc

Please sign in to comment.