Skip to content

Commit

Permalink
Merge remote-tracking branch 'js10-remote/devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
dkj committed May 29, 2015
2 parents e757cdf + 051400a commit 2bd1c7b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 9 deletions.
10 changes: 3 additions & 7 deletions lib/npg_qc/Schema/Result/VerifyBamId.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,13 @@ __PACKAGE__->table('verify_bam_id');
=head2 freeLK0
accessor: 'free_lk0'
data_type: 'decimal'
default_value: 0.00
is_nullable: 0
size: [11,2]
=head2 freeLK1
accessor: 'free_lk1'
data_type: 'decimal'
default_value: 0.00
is_nullable: 0
Expand Down Expand Up @@ -164,15 +162,13 @@ __PACKAGE__->add_columns(
},
'freeLK0',
{
accessor => 'free_lk0',
data_type => 'decimal',
default_value => '0.00',
is_nullable => 0,
size => [11, 2],
},
'freeLK1',
{
accessor => 'free_lk1',
data_type => 'decimal',
default_value => '0.00',
is_nullable => 0,
Expand Down Expand Up @@ -234,17 +230,17 @@ __PACKAGE__->add_unique_constraint('unq_run_lane_verify', ['id_run', 'position',
with 'npg_qc::Schema::Flators', 'npg_qc::autoqc::role::verify_bam_id';


# Created by DBIx::Class::Schema::Loader v0.07036 @ 2015-02-13 15:21:35
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AqOkJZFkV3LvyDSgZLez2g
# Created by DBIx::Class::Schema::Loader v0.07036 @ 2015-05-28 16:47:33
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FK7FU+Oo6v6VCmsi3TyjqA

__PACKAGE__->set_flators4non_scalar(qw( info ));
__PACKAGE__->set_inflator4scalar('tag_index');


our $VERSION = '0';

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;

1;
__END__
Expand Down
6 changes: 5 additions & 1 deletion scripts/npgqc_dbix_schema_loader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@
{
debug => 0,
dump_directory => q[lib],
naming => q[current],
naming => {
relationships => 'current',
monikers => 'current',
column_accessors => 'preserve',
},
skip_load_external => 1,
use_moose => 1,
preserve_case => 1,
Expand Down
53 changes: 53 additions & 0 deletions t/50-schema-result-VerifyBamId.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use strict;
use warnings;
use Test::More tests => 8;
use Test::Exception;
use Test::Deep;
use Moose::Meta::Class;
use JSON;
use npg_testing::db;

use_ok('npg_qc::Schema::Result::VerifyBamId');

my $schema = Moose::Meta::Class->create_anon_class(
roles => [qw/npg_testing::db/])
->new_object({})->create_test_db(q[npg_qc::Schema]);

my $json =
q {
{
"avg_depth":1.41,
"freeLK0":815501.89,
"freeLK1":815501.89,
"freemix":0,
"id_run":"7321",
"info":{"Check":"npg_qc::autoqc::checks::verify_bam_id","Check_version":"58.0","Verifier":"verifyBamID","Verify_options":" --bam in/7321_7#5.bam --vcf /lustre/scratch110/srpipe/population_snv/Homo_sapiens/1000G_Omni25_genotypes_2141/Standard/1000Genomes/Standard-1000Genomes.vcf.gz --self --ignoreRG --minQ 20 --minAF 0.05 --maxDepth 500 --precise --out /tmp/lew2Twr019/7321_7#5.bam"},
"number_of_reads":1908387,
"number_of_snps":1351960,
"path":"in",
"position":"7",
"tag_index":"5"}
};

my $values = from_json($json);
my $rs = $schema->resultset('VerifyBamId');
isa_ok($rs->new($values), 'npg_qc::Schema::Result::VerifyBamId');

{
my %values1 = %{$values};
my $v1 = \%values1;

$rs->result_class->deflate_unique_key_components($v1);
is($v1->{'tag_index'}, 5, 'tag index deflated');
lives_ok {$rs->find_or_new($v1)->set_inflated_columns($v1)->update_or_insert()} 'lane record inserted';
my $rs1 = $rs->search({});
is ($rs1->count, 1, q[one row created in the table]);
my $row = $rs1->next;
is($row->tag_index, 5, 'tag index inflated');
is(ref $row->info, 'HASH', 'info returned as hash ref');
cmp_deeply($row->info, $values->{'info'},
'info hash content is correct');
}
1;


25 changes: 24 additions & 1 deletion t/60-autoqc-db_loader.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 58;
use Test::More tests => 66;
use Test::Exception;
use Test::Warn;
use Moose::Meta::Class;
Expand Down Expand Up @@ -118,6 +118,29 @@ my $schema = Moose::Meta::Class->create_anon_class(
is($is_rs->search({})->count, $current_count+1, 'a new records added');
}

{
my $is_rs = $schema->resultset('VerifyBamId');
my $current_count = $is_rs->search({})->count;
my $count_loaded;

my $db_loader = npg_qc::autoqc::db_loader->new(
schema => $schema,
json_file => ['t/data/autoqc/7321_7#8.verify_bam_id.json'],
verbose => 0,
);
lives_ok {$count_loaded = $db_loader->load()} 'file loaded';
is($count_loaded, 1, 'reported one file loaded');
$current_count++;
is ($is_rs->search({})->count, $current_count, 'one record added to the table');
lives_ok {$db_loader->load()} 'reload VerifyBamId result';
my $rs = $is_rs->search({});
is($rs->count, $current_count, 'no new records added');
my $row = $rs->next;
is($row->freemix, 0.00025, 'freemix');
is($row->freeLK0, 823213.22, 'freeLK0');
is($row->freeLK1, 823213.92, 'freeLK1');
}

{
my $is_rs = $schema->resultset('InsertSize');
$is_rs->delete_all();
Expand Down
1 change: 1 addition & 0 deletions t/data/autoqc/7321_7#8.verify_bam_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"__CLASS__":"npg_qc::autoqc::results::verify_bam_id-58.0","avg_depth":1.43,"freeLK0":823213.22,"freeLK1":823213.92,"freemix":0.00025,"id_run":"7321","info":{"Check":"npg_qc::autoqc::checks::verify_bam_id","Check_version":"58.0","Verifier":"verifyBamID","Verify_options":" --bam in/7321_7#8.bam --vcf /lustre/scratch110/srpipe/population_snv/Homo_sapiens/1000G_Omni25_genotypes_2141/Standard/1000Genomes/Standard-1000Genomes.vcf.gz --self --ignoreRG --minQ 20 --minAF 0.05 --maxDepth 500 --precise --out /tmp/IxVQiyJg_W/7321_7#8.bam"},"number_of_reads":1930480,"number_of_snps":1351960,"path":"in","position":"7","tag_index":"8"}

0 comments on commit 2bd1c7b

Please sign in to comment.