Commit 6765ee11 authored by Tiago Grego's avatar Tiago Grego
Browse files

do not return undef, just return

parent 7ce07f86
...@@ -101,7 +101,7 @@ sub munge_chr_id { ...@@ -101,7 +101,7 @@ sub munge_chr_id {
my $bam = $self->bam_open; my $bam = $self->bam_open;
warn "Failed to open BAM file " . $self->url unless $bam; warn "Failed to open BAM file " . $self->url unless $bam;
return undef unless $bam; return unless $bam;
my $header = $bam->header; my $header = $bam->header;
...@@ -130,7 +130,7 @@ sub munge_chr_id { ...@@ -130,7 +130,7 @@ sub munge_chr_id {
} }
warn " *** could not parse_region for BAM with $chr_id in file " . $self->url ."\n"; warn " *** could not parse_region for BAM with $chr_id in file " . $self->url ."\n";
return undef; return;
} }
sub fetch_paired_alignments { sub fetch_paired_alignments {
......
...@@ -130,7 +130,7 @@ sub munge_chr_id { ...@@ -130,7 +130,7 @@ sub munge_chr_id {
warn "Failed to open BigBed file " . $self->url unless $bb; warn "Failed to open BigBed file " . $self->url unless $bb;
return undef unless $bb; return unless $bb;
my $list = $bb->chromList; my $list = $bb->chromList;
my $head = $list->head; my $head = $list->head;
......
...@@ -77,7 +77,7 @@ sub munge_chr_id { ...@@ -77,7 +77,7 @@ sub munge_chr_id {
warn "Failed to open BigWig file " . $self->url unless $bw; warn "Failed to open BigWig file " . $self->url unless $bw;
return undef unless $bw; return unless $bw;
my $list = $bw->chromList; my $list = $bw->chromList;
my $head = $list->head; my $head = $list->head;
......
...@@ -107,7 +107,7 @@ sub munge_chr_id { ...@@ -107,7 +107,7 @@ sub munge_chr_id {
} }
warn " *** could not parse_region for BAM/CRAM with $chr_id in file " . $self->url ."\n"; warn " *** could not parse_region for BAM/CRAM with $chr_id in file " . $self->url ."\n";
return undef; return;
} }
sub fetch_paired_alignments { sub fetch_paired_alignments {
......
...@@ -312,7 +312,7 @@ sub validate_metadata { ...@@ -312,7 +312,7 @@ sub validate_metadata {
## TODO - implement validation! ## TODO - implement validation!
} }
return undef; return;
} }
=head2 validate_record =head2 validate_record
......
...@@ -57,9 +57,9 @@ sub open { ...@@ -57,9 +57,9 @@ sub open {
## This format has no metadata ## This format has no metadata
sub is_metadata { return undef; } sub is_metadata { return; }
sub read_metadata { return undef; } sub read_metadata { return; }
=head2 read_record =head2 read_record
......
...@@ -619,7 +619,7 @@ sub get_info_description { ...@@ -619,7 +619,7 @@ sub get_info_description {
sub get_raw_formats { sub get_raw_formats {
my $self = shift; my $self = shift;
return undef if (!$self->get_metadata_by_pragma('header')->[8] || $self->get_metadata_by_pragma('header')->[8] ne 'FORMAT'); return if (!$self->get_metadata_by_pragma('header')->[8] || $self->get_metadata_by_pragma('header')->[8] ne 'FORMAT');
return $self->{'record'}[8]; return $self->{'record'}[8];
} }
...@@ -667,14 +667,14 @@ sub get_metadata_description { ...@@ -667,14 +667,14 @@ sub get_metadata_description {
if (!defined($type) || !defined($id)) { if (!defined($type) || !defined($id)) {
carp("You need to provide a meta type (e.g. 'INFO') and a meta entry ID (e.g. 'AA')"); carp("You need to provide a meta type (e.g. 'INFO') and a meta entry ID (e.g. 'AA')");
return undef; return;
} }
my $meta = $self->get_metadata_by_pragma($type); my $meta = $self->get_metadata_by_pragma($type);
foreach my $meta_entry (@$meta) { foreach my $meta_entry (@$meta) {
return $meta_entry->{'Description'} if ($meta_entry->{'ID'} eq $id); return $meta_entry->{'Description'} if ($meta_entry->{'ID'} eq $id);
} }
return undef; return;
} }
......
...@@ -60,9 +60,9 @@ sub open { ...@@ -60,9 +60,9 @@ sub open {
## This format has no metadata ## This format has no metadata
sub is_metadata { return undef; } sub is_metadata { return; }
sub read_metadata { return undef; } sub read_metadata { return; }
=head2 set_fields =head2 set_fields
......
...@@ -58,9 +58,9 @@ sub open { ...@@ -58,9 +58,9 @@ sub open {
## This format has no metadata ## This format has no metadata
sub is_metadata { return undef; } sub is_metadata { return; }
sub read_metadata { return undef; } sub read_metadata { return; }
=head2 set_fields =head2 set_fields
......
...@@ -62,7 +62,7 @@ sub is_metadata { ...@@ -62,7 +62,7 @@ sub is_metadata {
sub read_metadata { sub read_metadata {
### No useful metadata, just column names ### No useful metadata, just column names
return undef; return;
} }
=head2 set_fields =head2 set_fields
......
...@@ -274,7 +274,7 @@ sub get_score { ...@@ -274,7 +274,7 @@ sub get_score {
my $self = shift; my $self = shift;
my $val = $self->get_raw_score(); my $val = $self->get_raw_score();
if ($val && $val =~ /^\.$/) { if ($val && $val =~ /^\.$/) {
return undef; return;
} else { } else {
return $val; return $val;
} }
......
...@@ -168,7 +168,7 @@ sub get_field { ...@@ -168,7 +168,7 @@ sub get_field {
} }
# If the field doesn't exist, return undef # If the field doesn't exist, return undef
return undef; return;
} }
=head2 batch_fields =head2 batch_fields
...@@ -230,7 +230,7 @@ sub fetch_callback { ...@@ -230,7 +230,7 @@ sub fetch_callback {
} }
# If the field doesn't exist, return undef # If the field doesn't exist, return undef
return undef return;
} }
1; 1;
...@@ -283,7 +283,7 @@ sub sv_cipos { ...@@ -283,7 +283,7 @@ sub sv_cipos {
return "$info=$cipos"; return "$info=$cipos";
} else { } else {
return undef; return;
} }
} }
...@@ -300,7 +300,7 @@ sub sv_ciend { ...@@ -300,7 +300,7 @@ sub sv_ciend {
return "$info=$ciend"; return "$info=$ciend";
} else { } else {
return undef; return;
} }
} }
...@@ -312,7 +312,7 @@ sub sv_imprecise { ...@@ -312,7 +312,7 @@ sub sv_imprecise {
if (($object->outer_start && $object->inner_start) || ($object->inner_end && $object->outer_end)) { if (($object->outer_start && $object->inner_start) || ($object->inner_end && $object->outer_end)) {
return $info; return $info;
} else { } else {
return undef; return;
} }
} }
......
...@@ -50,7 +50,7 @@ sub sanitise_path { ...@@ -50,7 +50,7 @@ sub sanitise_path {
} }
} }
else { else {
return undef; return;
} }
} }
...@@ -127,7 +127,7 @@ sub get_compression { ...@@ -127,7 +127,7 @@ sub get_compression {
return 'gz' if $file =~ /\.gz$/; return 'gz' if $file =~ /\.gz$/;
return 'zip' if $file =~ /\.zip$/; return 'zip' if $file =~ /\.zip$/;
return 'bz' if $file =~ /\.bz2?$/; return 'bz' if $file =~ /\.bz2?$/;
return undef; return;
} }
} }
......
...@@ -43,7 +43,7 @@ sub create_path { ...@@ -43,7 +43,7 @@ sub create_path {
my @directories = make_path($path, { %$params, 'error' => \my $error }); my @directories = make_path($path, { %$params, 'error' => \my $error });
if (@$error) { if (@$error) {
return undef if $no_exception; return if $no_exception;
throw(sprintf qq(Could not create the given path '%s' due to following errors: \n%s), $path, displayable_error($error)); throw(sprintf qq(Could not create the given path '%s' due to following errors: \n%s), $path, displayable_error($error));
} }
...@@ -62,7 +62,7 @@ sub remove_directory { ...@@ -62,7 +62,7 @@ sub remove_directory {
my $file_count = remove_tree($path, { %$params, 'error' => \my $error}); my $file_count = remove_tree($path, { %$params, 'error' => \my $error});
if (@$error) { if (@$error) {
return undef if $no_exception; return if $no_exception;
throw(sprintf qq(Could not remove the given directory '%s' due to following errors: \n%s), $path, displayable_error($error)); throw(sprintf qq(Could not remove the given directory '%s' due to following errors: \n%s), $path, displayable_error($error));
} }
...@@ -111,14 +111,14 @@ sub copy_dir_contents { ...@@ -111,14 +111,14 @@ sub copy_dir_contents {
my $no_exception = delete $params->{'no_exception'}; my $no_exception = delete $params->{'no_exception'};
my $contents = []; my $contents = [];
my %exclude = map { $_ =~ s/\/$//r => 1 } @{$params->{'exclude'} || []}; my %exclude = map { $_ =~ s/\/$//r => 1 } @{$params->{'exclude'} || []};
my $dir_contents = list_dir_contents($source_dir, {'no_exception' => $no_exception}) or return undef; my $dir_contents = list_dir_contents($source_dir, {'no_exception' => $no_exception}) or return;
if (!-d $dest_dir) { if (!-d $dest_dir) {
if ($params->{'create_path'}) { if ($params->{'create_path'}) {
push @$contents, @{ create_path($dest_dir) }; push @$contents, @{ create_path($dest_dir) };
} else { } else {
throw("Destination directory $dest_dir does not exist.") unless $no_exception; throw("Destination directory $dest_dir does not exist.") unless $no_exception;
return undef; return;
} }
} }
...@@ -188,7 +188,7 @@ sub list_dir_contents { ...@@ -188,7 +188,7 @@ sub list_dir_contents {
if (!$dh) { if (!$dh) {
throw("An error occurred while reading the directory $dir: $!") unless $params->{'no_exception'}; throw("An error occurred while reading the directory $dir: $!") unless $params->{'no_exception'};
return undef; return;
} }
while (my $content = $dh->read) { while (my $content = $dh->read) {
......
...@@ -191,7 +191,7 @@ sub fetch_file { ...@@ -191,7 +191,7 @@ sub fetch_file {
else { else {
if ($@) { if ($@) {
throw(sprintf qq(Could not fetch contents of file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'}; throw(sprintf qq(Could not fetch contents of file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'};
return undef; return;
} }
else { else {
return $content; return $content;
...@@ -237,7 +237,7 @@ sub read_file { ...@@ -237,7 +237,7 @@ sub read_file {
else { else {
if ($@) { if ($@) {
throw(sprintf qq(Could not read file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'}; throw(sprintf qq(Could not read file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'};
return undef; return;
} }
else { else {
return $content; return $content;
...@@ -285,7 +285,7 @@ sub read_lines { ...@@ -285,7 +285,7 @@ sub read_lines {
else { else {
if ($@) { if ($@) {
throw(sprintf qq(Could not read lines from file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'}; throw(sprintf qq(Could not read lines from file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'};
return undef; return;
} }
else { else {
return $content; return $content;
...@@ -347,7 +347,7 @@ sub preview_file { ...@@ -347,7 +347,7 @@ sub preview_file {
else { else {
if ($@) { if ($@) {
throw(sprintf qq(Could not fetch preview of file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'}; throw(sprintf qq(Could not fetch preview of file '%s' due to following errors: \n%s), $path, $@) unless $args->{'no_exception'};
return undef; return;
} }
else { else {
return $lines; return $lines;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment