Skip to content

Commit

Permalink
Fixed data_file_path. Moved code to construct the segmentation base f…
Browse files Browse the repository at this point in the history
…ile path into a subroutine. Simplified code to detect missing file_path value into the data_file table
  • Loading branch information
Thomas Maurel committed Nov 12, 2018
1 parent 5662407 commit 6b165f2
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/Bio/EnsEMBL/DataCheck/Checks/SegmentationFileHasBigBed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,22 @@ sub skip_tests {
}
}

sub build_segmentation_base_file_path {
my ($self,$data_file_path) = @_;
my $species = $self->species;
my $core_dba = $self->get_dna_dba();
my $meta = $core_dba->get_MetaContainer();
my $assembly_default = $meta->single_value_by_key('assembly.default');
my $base_file_path = "$data_file_path/$species/$assembly_default/";
return $base_file_path;
}

sub tests {
my ($self) = @_;
my $data_file_path = '/nfs/panda/ensembl/production/ensemblftp/data_files2/';
my $data_file_path = '/nfs/panda/ensembl/production/ensemblftp/data_files/';
my $table_name = 'segmentation_file';
my $file_type = 'BIGBED';
my $species = $self->species;
my $core_dba = $self->get_dba($self->species, 'core');
fail("Core database found in registry") if ! defined $core_dba;
my $meta = $core_dba->get_MetaContainer();
my $assembly_default = $meta->single_value_by_key('assembly.default');
my $base_file_path = $self->build_segmentation_base_file_path($data_file_path);
my $helper = $self->dba->dbc->sql_helper;
my $missing_file_for_segmentation_file_id = 0;
my $sql = qq/
Expand All @@ -83,16 +89,12 @@ sub tests {
table_id = ?
/;
my $file_path = $helper->execute_simple(-SQL => $sql2,-PARAMS => [$table_name,$file_type,$segmentation_file_id])->[0];
my $desc = "$file_type file entry found in the data_file table for $table_name with name ".$segmentation_files->{$segmentation_file_id}." and id $segmentation_file_id";
ok(defined $file_path, $desc);
if (defined $file_path){
my $segmentation_file = "$data_file_path/$species/$assembly_default/$file_path";
ok(-e $segmentation_file,"$segmentation_file exists on disk") or diag("$segmentation_file doest not exist on the disk for segmentation id $segmentation_file_id and name ".$segmentation_files->{$segmentation_file_id});
}
else{
diag("No $file_type file entry found in the data_file table for $table_name with name ".$segmentation_files->{$segmentation_file_id}." and id $segmentation_file_id");
$missing_file_for_segmentation_file_id ++;
my $segmentation_file = $base_file_path."$file_path";
ok(-e $segmentation_file,"$segmentation_file exists on disk") or diag("$segmentation_file doest not exist on the disk for segmentation id $segmentation_file_id and name ".$segmentation_files->{$segmentation_file_id});
}
}
my $desc = "All segmentation_file_id have an associated path in data_file table";
is($missing_file_for_segmentation_file_id, 0, $desc);
}
1;

0 comments on commit 6b165f2

Please sign in to comment.