From a9160249a5b44c905f1761eadaaf2d90037a186b Mon Sep 17 00:00:00 2001 From: Anil Thanki Date: Mon, 27 Feb 2023 15:34:58 +0000 Subject: [PATCH 1/3] Update export_atlas_ebeye_xml.pl --- bin/export_atlas_ebeye_xml.pl | 53 ++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/bin/export_atlas_ebeye_xml.pl b/bin/export_atlas_ebeye_xml.pl index 16024c8..3061655 100755 --- a/bin/export_atlas_ebeye_xml.pl +++ b/bin/export_atlas_ebeye_xml.pl @@ -906,19 +906,52 @@ sub get_privacy{ my ( $expId ) = @_; if ( ! exists $exptPrivacies->{ $expId } ){ - my $url = "http://peach.ebi.ac.uk:8480/api/privacy.txt?acc=$expId"; + my $url = "https://www.ebi.ac.uk/biostudies/api/v1/search?type=study&accession=$expId"; my $ua = LWP::UserAgent->new; - my $response = $ua->get($url)->content; - my ($privacy) = $response =~ m/privacy:(\w+)\s/g; - - if (! $privacy ){ - $privacy='unknown'; - } - elsif ($privacy ne 'public' && $privacy ne 'private'){ - $logger->logdie( "Invalid privacy \"$privacy\" for \"$expId\"" ); + my $response = $ua->get($url); + + my $privacy; + + if( $response->is_success ) { + my $data = decode_json($response->content); + my $total_hit = $data->{totalHits}; + if ($total_hit > 0){ + my $is_public = $data->{hits}[0]->{isPublic}; + + if ($is_public) { + $privacy="public"; + } else { + $privacy="private"; + } + } + else{ + $logger->error( + "Accession ", + $expId, + " not found: \"", + $response->decoded_content, + "\". Defaulting to unknown." + ); + + $privacy="unknown"; + + } } - $exptPrivacies->{ $expId } = $privacy; + + else { + $logger->error( + "Problem querying ArrayExpress for $expId privacy status: ", + $response->status_line, + ". Defaulting to unknown." + ); + + $privacy="unknown"; + + } + + $exptPrivacies->{ $expId } = $privacy; + return $exptPrivacies->{ $expId }; } From b472a2c2b57088ffe7117131d1d2b5ed163aa209 Mon Sep 17 00:00:00 2001 From: Anil Thanki Date: Wed, 15 Mar 2023 13:38:48 +0000 Subject: [PATCH 2/3] Update export_atlas_ebeye_xml.pl --- bin/export_atlas_ebeye_xml.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/export_atlas_ebeye_xml.pl b/bin/export_atlas_ebeye_xml.pl index 3061655..b1059bf 100755 --- a/bin/export_atlas_ebeye_xml.pl +++ b/bin/export_atlas_ebeye_xml.pl @@ -948,10 +948,10 @@ sub get_privacy{ $privacy="unknown"; - } - - $exptPrivacies->{ $expId } = $privacy; + } + $exptPrivacies->{ $expId } = $privacy; + } return $exptPrivacies->{ $expId }; } From da9a589159c2a5eb9ad18024d4858ba5faa8929c Mon Sep 17 00:00:00 2001 From: Anil Thanki Date: Tue, 30 May 2023 16:26:18 +0100 Subject: [PATCH 3/3] Update export_atlas_ebeye_xml.pl --- bin/export_atlas_ebeye_xml.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/export_atlas_ebeye_xml.pl b/bin/export_atlas_ebeye_xml.pl index b1059bf..c0f59ed 100755 --- a/bin/export_atlas_ebeye_xml.pl +++ b/bin/export_atlas_ebeye_xml.pl @@ -913,7 +913,7 @@ sub get_privacy{ my $privacy; if( $response->is_success ) { - my $data = decode_json($response->content); + my $data = parse_json(decode ('UTF-8', $response->content)); my $total_hit = $data->{totalHits}; if ($total_hit > 0){ my $is_public = $data->{hits}[0]->{isPublic};