Skip to content

Commit

Permalink
check for definedness in missing report.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmueller committed Feb 15, 2025
1 parent 16da8d9 commit 9cf343a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/CXGN/File/Parse/Plugin/Plain.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package CXGN::File::Parse::Plugin::Plain;

use Data::Dumper;
use CXGN::File::Parse;
use Text::CSV;

Expand Down Expand Up @@ -87,7 +88,7 @@ sub parse {
$v = $super->clean_value($v, $h);
$row_info{$h} = $v;

if ( $v && $v ne '' ) {
if ( defined($v) && $v ne '' ) {
if ( ref($v) eq 'ARRAY' ) {
if ( scalar(@$v) > 0 ) {
foreach (@$v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ sub parse {
my $observationunit_name = $row->{'observationunit_name'};

for my $trait_name (@$trait_columns) {
my $value_string = $row->{$trait_name} || '';
my $value_string = defined($row->{$trait_name}) ? $row->{$trait_name} : '';
my $timestamp = '';
my $trait_value = '';
if ($timestamp_included){
Expand Down
10 changes: 5 additions & 5 deletions lib/CXGN/Phenotypes/StorePhenotypes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ sub create_hash_lookups {
my %trait_objs;
my @trait_list = @{$self->trait_list};
@trait_list = map { $_ eq 'notes' ? () : ($_) } @trait_list; # omit notes from trait validation
print STDERR "trait list after filtering @trait_list\n";
#print STDERR "trait list after filtering @trait_list\n";
my @stock_list = @{$self->stock_list};
my @cvterm_ids;

Expand All @@ -228,7 +228,7 @@ sub create_hash_lookups {
$self->stock_id_list($stock_id_list->{'transform'});

foreach my $trait_name (@trait_list) {
print STDERR "trait: $trait_name\n";
#print STDERR "trait: $trait_name\n";
my $trait_cvterm = SGN::Model::Cvterm->get_cvterm_row_from_trait_name($schema, $trait_name);
$trait_objs{$trait_name} = $trait_cvterm;
push @cvterm_ids, $trait_cvterm->cvterm_id();
Expand Down Expand Up @@ -276,7 +276,7 @@ sub verify {
my @plot_list = @{$self->stock_list};
my @trait_list = @{$self->trait_list};
@trait_list = map { $_ eq 'notes' ? () : ($_) } @trait_list; # omit notes from trait validation
print STDERR Dumper \@trait_list;
#print STDERR Dumper \@trait_list;
my %plot_trait_value = %{$self->values_hash};
my %phenotype_metadata = %{$self->metadata_hash};
my $timestamp_included = $self->has_timestamps;
Expand Down Expand Up @@ -447,12 +447,12 @@ sub verify {
} elsif (exists($check_unique_trait_stock_timestamp{$trait_cvterm_id, $stock_id, $timestamp})) {
my $prev = $check_unique_trait_stock_timestamp{$trait_cvterm_id, $stock_id, $timestamp};
if ( defined($prev) ) {
$warning_message = $warning_message."<small>$plot_name already has a <strong>different value</strong> ($prev) than in your file (" . ($trait_value ? $trait_value : "<em>blank</em>") . ") stored in the database for the trait $trait_name for the timestamp $timestamp.</small><hr>";
$warning_message = $warning_message."<small>$plot_name already has a <strong>different value</strong> ($prev) than in your file (" . (defined($trait_value) ? $trait_value : "<em>blank</em>") . ") stored in the database for the trait $trait_name for the timestamp $timestamp.</small><hr>";
}
} elsif (exists($check_unique_trait_stock{$trait_cvterm_id, $stock_id})) {
my $prev = $check_unique_trait_stock{$trait_cvterm_id, $stock_id};
if ( defined($prev) ) {
$warning_message = $warning_message."<small>$plot_name already has a <strong>different value</strong> ($prev) than in your file (" . ($trait_value ? $trait_value : "<em>blank</em>") . ") stored in the database for the trait $trait_name.</small><hr>";
$warning_message = $warning_message."<small>$plot_name already has a <strong>different value</strong> ($prev) than in your file (" . (defined($trait_value) ? $trait_value : "<em>blank</em>") . ") stored in the database for the trait $trait_name.</small><hr>";
}
}

Expand Down

0 comments on commit 9cf343a

Please sign in to comment.