Skip to content

Commit

Permalink
Merge pull request #20 from BioJulia/fix-eutils-http-body
Browse files Browse the repository at this point in the history
Bugfix for #19
  • Loading branch information
mirestrepo authored Oct 5, 2018
2 parents cb25daf + 089dae7 commit d09d6ce
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 178 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.3.1] - 2018-10-5
### Changes
- eutils.jl to use the correct http parameter when passing the body to POST
- tests/eutils.jl to perform efetch with large number of PMID which breaks if incorrect http format is used
### Removed
- *.toml files to wait until versioning is ready for new Pkg

## [0.3.0] - 2018-09-21
### Changed
- Updated HUMANS.md.
- Added compatibility with Julia 1.0

Expand Down
158 changes: 0 additions & 158 deletions Manifest.toml

This file was deleted.

15 changes: 0 additions & 15 deletions Project.toml

This file was deleted.

8 changes: 4 additions & 4 deletions src/eutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Parameters: db, id, WebEnv.
function epost(ctx::AbstractDict=empty_context(); params...)
params = process_parameters(params, ctx)
body = HTTP.escapeuri(params)
res = HTTP.request("POST", string(baseURL, "epost.fcgi"), query=body)
res = HTTP.request("POST", string(baseURL, "epost.fcgi"), body=body)
set_context!(ctx, res)
return res
end
Expand All @@ -107,7 +107,7 @@ Parameters: db, id, query_key, WebEnv, retstart, retmax, retmode, version.
function esummary(ctx::AbstractDict=empty_context(); params...)
params = process_parameters(params, ctx)
body = HTTP.escapeuri(params)
return HTTP.request("POST", string(baseURL, "esummary.fcgi"), query=body)
return HTTP.request("POST", string(baseURL, "esummary.fcgi"), body=body)
end

"""
Expand All @@ -121,7 +121,7 @@ strand, seq_start, seq_stop, complexity.
function efetch(ctx::AbstractDict=empty_context(); params...)
params = process_parameters(params, ctx)
body = HTTP.escapeuri(params)
return HTTP.request("POST", string(baseURL, "efetch.fcgi"), query=body, retry_non_idempotent=true)
return HTTP.request("POST", string(baseURL, "efetch.fcgi"), body=body, retry_non_idempotent=true)
end

"""
Expand All @@ -135,7 +135,7 @@ datetype, reldate, mindate, maxdate.
function elink(ctx::AbstractDict=empty_context(); params...)
params = process_parameters(params, ctx)
body = HTTP.escapeuri(params)
return HTTP.request("POST", string(baseURL, "elink.fcgi"), query=body)
return HTTP.request("POST", string(baseURL, "elink.fcgi"), body=body)
end

"""
Expand Down
24 changes: 24 additions & 0 deletions test/eutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,30 @@
@test res.status == 200
res = efetch(ctx, db="protein", retmode="xml")
@test res.status == 200

# esearch then efeth for large number of ids
retmax = 1000
search_term = """(Asthma[MeSH Major Topic])
AND ("1/1/2018"[Date - Publication] :
"3000"[Date - Publication])"""
res = esearch(db = "pubmed", term = search_term,
retstart = 0, retmax = retmax, tool = "BioJulia")

#convert xml to dictionary
esearch_dict = parse_xml(String(res.body))

#get the list of ids and perfom a fetch
ids = [parse(Int64, id_node) for id_node in esearch_dict["IdList"]["Id"]]

res = efetch(db = "pubmed", tool = "BioJulia", retmode = "xml", rettype = "null", id = ids)
@test res.status == 200
@test startswith(Dict(res.headers)["Content-Type"], "text/xml")

body = parse_xml(String(res.body))

@test haskey(body, "PubmedArticle")
@test length(body["PubmedArticle"]) == retmax

end

@testset "elink" begin
Expand Down

0 comments on commit d09d6ce

Please sign in to comment.