Skip to content

Commit

Permalink
Tolerate 404's in RNAcentral lookup
Browse files Browse the repository at this point in the history
The new MD5 based endpoint will return a 404 for cases where the MD5 is
unknown. An error response is assumed to be unusual and a error
condition because, previously the API would return a empty list and it
would not fail. This leads to failing the QC of any sequence not in
RNAcentral.

This change makes a failing response treated as not found. This could
cover up errors in the RNAcentral API and then fail later, I assume but
hopefully this would be caught elsewhere.
  • Loading branch information
blakesweeney committed Jul 12, 2024
1 parent c4c268a commit 37f8c53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Rfam/Lib/Bio/Rfam/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2942,21 +2942,21 @@ sub rnacentral_md5_lookup {
my $rnacentral_url = "https://rnacentral.org/api/v1/md5/" . $in_md5;
#printf("rnacentral_url: $rnacentral_url\n");
my $json = get($rnacentral_url);
if(! defined $json) { croak "ERROR trying to fetch from rnacentral using md5: " . $in_md5; }
# Decode the entire JSON
my $decoded_json = decode_json($json);
#print Dumper $decoded_json;

my $have_seq = 0;
my $md5 = undef;
my $id = undef;
my $desc = undef;

if((defined $decoded_json->{'rnacentral_id'})) {
$have_seq = 1;
$md5 = $in_md5;
$id = $decoded_json->{'rnacentral_id'};
$desc = $decoded_json->{'description'};
if( defined $json) {
# Decode the entire JSON
my $decoded_json = decode_json($json);
if((defined $decoded_json->{'rnacentral_id'})) {
$have_seq = 1;
$md5 = $in_md5;
$id = $decoded_json->{'rnacentral_id'};
$desc = $decoded_json->{'description'};
}
}

return ($have_seq, $md5, $id, $desc);
Expand Down

0 comments on commit 37f8c53

Please sign in to comment.