Skip to content

Commit

Permalink
pass a optional list of crisprs_to_validate when creating a crispr_es…
Browse files Browse the repository at this point in the history
…_qc_well, use these ids to create new crispr_validation records linking the crispr_es_qc_wells with their crisprs
  • Loading branch information
sajp committed May 22, 2015
1 parent e19a558 commit deb2b84
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/LIMS2/Model/Plugin/CrisprEsQc.pm
Expand Up @@ -87,6 +87,7 @@ sub pspec_create_crispr_es_qc_well {
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 },
crisprs_to_validate => { validate => 'integer', optional => 1 },
};
}

Expand Down Expand Up @@ -125,7 +126,24 @@ sub create_crispr_es_qc_well {
$validated_params->{crispr_chr_id} = $chr->id;
}

return $self->schema->resultset('CrisprEsQcWell')->create( $validated_params );
my @crisprs_to_validate;
if ( $validated_params->{crisprs_to_validate} ) {
@crisprs_to_validate = @{ delete $validated_params->{crisprs_to_validate} };
}

my $crispr_es_qc_well = $self->schema->resultset('CrisprEsQcWell')->create( $validated_params );

for my $crispr_id ( @crisprs_to_validate ) {
$self->schema->resultset( 'CrisprValidation' )->create(
{
crispr_es_qc_well_id => $crispr_es_qc_well->id,
crispr_id => $crispr_id,
validated => 0, # default to false, in future we may try to automatically set this value
}
);
}

return $crispr_es_qc_well;
}

sub pspec_retrieve_crispr_es_qc_well {
Expand Down

0 comments on commit deb2b84

Please sign in to comment.