Skip to content
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
11 changes: 7 additions & 4 deletions src/naming_conventions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ Check the status of a Uniprot ID mapping job. Returns `true` if the results are
ready. Otherwise, returns the status object.
"""
function map_uniprot_status(jobID)
resp = HTTP.get("https://rest.uniprot.org/idmapping/status/$jobID", ["Accept" => "application/json"]; decompress = true)
# `decompress = false` suppresses the `Accept-Encoding: gzip` request header, so the
# body arrives as plain text. Uniprot does not always honor a compression request, and
# unconditionally gunzipping the response fails whenever it returns one uncompressed.
resp = HTTP.get("https://rest.uniprot.org/idmapping/status/$jobID", ["Accept" => "application/json"]; decompress = false)
if resp.status == 200
status = JSON3.read(String(HTTP.decode(resp)))
status = JSON3.read(String(resp.body))
haskey(status, "results") && return true
return status
end
Expand All @@ -181,9 +184,9 @@ end
Retrieve the results of a Uniprot ID mapping job.
"""
function map_uniprot_retrieve(jobID)
resp = HTTP.get("https://rest.uniprot.org/idmapping/stream/$jobID", ["Accept" => "application/json"]; decompress = true)
resp = HTTP.get("https://rest.uniprot.org/idmapping/stream/$jobID", ["Accept" => "application/json"]; decompress = false)
if resp.status == 200
return JSON3.read(String(HTTP.decode(resp)))
return JSON3.read(String(resp.body))
end
return nothing
end
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ using Test
end
end
@test startswith(query_ebi_proteins("Q7TQA6"; format=:fasta), ">sp|Q7TQA6")
@test count(==('>'), query_ebi_proteins(["C3N734", "H2C869", "Q3V4T1", "P20220"]; format=:fasta)) == 4
# Reviewed (SwissProt) accessions: unreviewed entries get withdrawn when
# the underlying genome annotation changes, silently shrinking the count.
@test count(==('>'), query_ebi_proteins(["P29274", "P29275", "P15409", "Q7TQA6"]; format=:fasta)) == 4
q = query_ncbi(obj)
@test q["total_count"] == 1
end
Expand Down
Loading