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

Replace Peach API with BioStudies in export_atlas_ebeye_xml.pl #28

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
49 changes: 41 additions & 8 deletions bin/export_atlas_ebeye_xml.pl
Original file line number Diff line number Diff line change
Expand Up @@ -906,17 +906,50 @@ 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';
my $response = $ua->get($url);

my $privacy;

if( $response->is_success ) {
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};

if ($is_public) {
$privacy="public";
} else {
$privacy="private";
}
}
else{
$logger->error(
"Accession ",
$expId,
" not found: \"",
$response->decoded_content,
"\". Defaulting to unknown."
);

$privacy="unknown";

}
}
elsif ($privacy ne 'public' && $privacy ne 'private'){
$logger->logdie( "Invalid privacy \"$privacy\" for \"$expId\"" );

else {
$logger->error(
"Problem querying ArrayExpress for $expId privacy status: ",
$response->status_line,
". Defaulting to unknown."
);

$privacy="unknown";


}

$exptPrivacies->{ $expId } = $privacy;
}
return $exptPrivacies->{ $expId };
Expand Down