Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update list validation to allow variable names without CO number #4631

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions lib/CXGN/BrAPI/v2/ObservationUnits.pm
Original file line number Diff line number Diff line change
Expand Up @@ -858,21 +858,7 @@ sub _refresh_matviews {
my $bs = CXGN::BreederSearch->new( { dbh=>$dbh, dbname=>$c->config->{dbname}, } );

# Refresh materialized view so data can be retrieved
my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'phenotypes', 'concurrent', $c->config->{basepath});
# Wait until materialized view is reset. Wait 5 minutes total, then throw an error
my $refreshing = 1;
my $refresh_time = 0;
while ($refreshing && $refresh_time < $timeout) {
my $refresh_status = $bs->matviews_status();
if (!$refresh->{connection}->alive) {
$refreshing = 0;
} elsif ($refresh_time >= $timeout) {
return {error => CXGN::BrAPI::JSONResponse->return_error($self->status, "Refreshing materialized views is taking too long to return a response", 500)};
} else {
sleep 1;
$refresh_time += 1;
}
}
$bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'phenotypes', 'concurrent', $c->config->{basepath}, 0);
}

sub _order {
Expand Down
25 changes: 20 additions & 5 deletions lib/CXGN/List/Validate/Plugin/Traits.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sub validate {
my $schema = shift;
my $list = shift;
my $validator = shift;
my $context = SGN::Context->new;
my @missing;
my @wrong_ids;

Expand All @@ -27,6 +28,9 @@ sub validate {
my @parts = split (/\|/ , $term);
my ($db_name, $accession) = split ":", pop @parts;
my $trait_name = join '|', @parts;
if(!$context->get_conf('list_trait_require_id')) {
$trait_name = $term;
}

$accession =~ s/\s+$//;
$accession =~ s/^\s+//;
Expand All @@ -35,30 +39,41 @@ sub validate {
$trait_name =~ s/\s+$//;
$trait_name =~ s/^\s+//;

print STDERR $db_name."\n";
print STDERR $trait_name."\n";
if (!$context->get_conf('list_trait_require_id') && ($db_name eq '' || $db_name eq $trait_name)) {
$db_name = $context->get_conf('trait_ontology_db_name');
}

my $db_rs = $schema->resultset("General::Db")->search( { 'me.name' => $db_name });
if ($db_rs->count() == 0) {
#print STDERR "Problem found with term $term at db $db_name\n";
print STDERR "Problem found with term $term at db $db_name\n";
push @missing, $term;
} else {
my $db = $db_rs->first();
my $query = {
'dbxref.db_id' => $db->db_id(),
'dbxref.accession' => $accession,
};

if (!$context->get_conf('list_trait_require_id') && $accession eq '') {
$query->{'me.name'} = $trait_name;
} else {
$query->{'dbxref.accession'} = $accession;
}
if ( $db_name eq 'COMP' && $validator->{composable_validation_check_name} ) {
$query->{'me.name'} = $trait_name;
}
my $rs = $schema->resultset("Cv::Cvterm")->search($query, {'join' => 'dbxref'});

my $is_missing = 0;
if ($rs->count == 0) {
#print STDERR "Problem found with term $term at cvterm rs from accession $accession point 2\n";
print STDERR "Problem found with term $term at cvterm rs from accession $accession point 2\n";
push @missing, $term;
$is_missing = 1;
} else {
my $rs_var = $rs->search_related('cvterm_relationship_subjects', {'type.name' => 'VARIABLE_OF'}, { 'join' => 'type'});
if ($rs_var->count == 0) {
#print STDERR "Problem found with term $term at variable check point 3\n";
print STDERR "Problem found with term $term at variable check point 3\n";
push @missing, $term;
$is_missing = 1;
}
Expand Down Expand Up @@ -89,7 +104,7 @@ sub validate {
}

}
# print STDERR Dumper \@missing;
print STDERR Dumper \@missing;
print STDERR Dumper \@wrong_ids;
return {
missing => \@missing,
Expand Down
2 changes: 2 additions & 0 deletions sgn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ allow_repeat_measures 0
#export trait names as synonyms (1) or the original trait name (0)
fieldbook_trait_synonym 1

list_trait_require_id 1

# Cluster backend
backend Slurm

Expand Down