Skip to content

Commit 4f191cc

Browse files
Revert "add download and cleanup"
This reverts commit 88d6940.
1 parent 6ffcbfc commit 4f191cc

File tree

2 files changed

+131
-145
lines changed

2 files changed

+131
-145
lines changed

src/download.jl

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ Requires an internet connection.
162162
assembly; by default downloads the PDB file.
163163
"""
164164
function downloadpdb(pdbid::AbstractString;
165-
dir::AbstractString=pwd(),
166-
format::Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat,BCIFFormat}}=PDBFormat,
167-
obsolete::Bool=false,
168-
overwrite::Bool=false,
169-
ba_number::Integer=0)
165+
dir::AbstractString=pwd(),
166+
format::Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}}=PDBFormat,
167+
obsolete::Bool=false,
168+
overwrite::Bool=false,
169+
ba_number::Integer=0)
170170
pdbid = uppercase(pdbid)
171171
# Check PDB ID is 4 characters long and only consits of alphanumeric characters
172172
if !occursin(r"^[a-zA-Z0-9]{4}$", pdbid)
@@ -198,18 +198,10 @@ function downloadpdb(pdbid::AbstractString;
198198
# Download the compressed PDB file to the temporary location
199199
@info "Downloading file from PDB: $pdbid"
200200
if ba_number == 0
201-
if format == BCIFFormat
202-
Downloads.download(
203-
"https://models.rcsb.org/$pdbid.bcif",
204-
pdbpath,
205-
)
206-
return pdbpath
207-
else
208-
Downloads.download(
209-
"http://files.rcsb.org/download/$pdbid.$(pdbextension[format]).gz",
210-
archivefilepath,
211-
)
212-
end
201+
Downloads.download(
202+
"http://files.rcsb.org/download/$pdbid.$(pdbextension[format]).gz",
203+
archivefilepath,
204+
)
213205
else
214206
if format == PDBFormat
215207
Downloads.download(
@@ -221,11 +213,6 @@ function downloadpdb(pdbid::AbstractString;
221213
"http://files.rcsb.org/download/$pdbid-assembly$ba_number.$(pdbextension[format]).gz",
222214
archivefilepath,
223215
)
224-
elseif format == BCIFFormat
225-
Downloads.download(
226-
"https://models.rcsb.org/$pdbid.bcif",
227-
archivefilepath,
228-
)
229216
else
230217
throw(ArgumentError("Biological assemblies are available in the " *
231218
"PDB and mmCIF formats only"))
@@ -243,8 +230,8 @@ function downloadpdb(pdbid::AbstractString;
243230
if !isfile(pdbpath) || filesize(pdbpath) == 0
244231
if format == PDBFormat
245232
throw(ErrorException("Error downloading file: $pdbid; some PDB entries are " *
246-
"not available as PDB format files, consider downloading " *
247-
"the mmCIF file instead"))
233+
"not available as PDB format files, consider downloading " *
234+
"the mmCIF file instead"))
248235
else
249236
throw(ErrorException("Error downloading file: $pdbid"))
250237
end
@@ -258,7 +245,7 @@ function downloadpdb(pdbid::AbstractString;
258245
return pdbpath
259246
end
260247

261-
function downloadpdb(pdbidlist::AbstractArray{<:AbstractString,1}; kwargs...)
248+
function downloadpdb(pdbidlist::AbstractArray{<:AbstractString, 1}; kwargs...)
262249
pdbpaths = String[]
263250
failedlist = String[]
264251
for pdbid in pdbidlist
@@ -304,8 +291,8 @@ Requires an internet connection.
304291
in `dir`; by default skips downloading the PDB file if it exists.
305292
"""
306293
function downloadentirepdb(; dir::AbstractString=pwd(),
307-
format::Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}}=PDBFormat,
308-
overwrite::Bool=false)
294+
format::Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}}=PDBFormat,
295+
overwrite::Bool=false)
309296
pdblist = pdbentrylist()
310297
@info "About to download $(length(pdblist)) PDB files, make sure you have enough disk space and time"
311298
@info "The function can be stopped any time and called again to resume downloading"
@@ -323,12 +310,12 @@ automatically updates the PDB files of the given `format` inside the local
323310
Requires an internet connection.
324311
"""
325312
function updatelocalpdb(; dir::AbstractString=pwd(),
326-
format::Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}}=PDBFormat)
313+
format::Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}}=PDBFormat)
327314
addedlist, modifiedlist, obsoletelist = pdbrecentchanges()
328315
# Download the newly added and modified pdb files
329316
downloadpdb(vcat(addedlist, modifiedlist), dir=dir, overwrite=true, format=format)
330317
# Set the obsolete directory to be inside dir
331-
obsolete_dir = joinpath(dir, "obsolete")
318+
obsolete_dir=joinpath(dir, "obsolete")
332319
for pdbid in obsoletelist
333320
oldfile = joinpath(dir, "$pdbid.$(pdbextension[format])")
334321
newfile = joinpath(obsolete_dir, "$pdbid.$(pdbextension[format])")
@@ -338,10 +325,10 @@ function updatelocalpdb(; dir::AbstractString=pwd(),
338325
mkpath(obsolete_dir)
339326
end
340327
mv(oldfile, newfile)
341-
# If obsolete pdb is already in the obsolete directory, inform the user and skip
328+
# If obsolete pdb is already in the obsolete directory, inform the user and skip
342329
elseif isfile(newfile)
343330
@info "PDB $pdbid is already moved to the obsolete directory"
344-
# If obsolete pdb not available in both dir and obsolete, inform the user and skip
331+
# If obsolete pdb not available in both dir and obsolete, inform the user and skip
345332
else
346333
@info "Obsolete PDB $pdbid is missing"
347334
end
@@ -365,8 +352,8 @@ Requires an internet connection.
365352
in `dir`; by default skips downloading the PDB file if it exists.
366353
"""
367354
function downloadallobsoletepdb(; obsolete_dir::AbstractString=pwd(),
368-
format::Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}}=PDBFormat,
369-
overwrite::Bool=false)
355+
format::Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}}=PDBFormat,
356+
overwrite::Bool=false)
370357
obsoletelist = pdbobsoletelist()
371358
downloadpdb(obsoletelist, dir=obsolete_dir, format=format, overwrite=overwrite)
372359
end
@@ -403,15 +390,15 @@ Requires an internet connection.
403390
Requires the STRIDE_jll.jl package to be imported if set to `true`.
404391
"""
405392
function retrievepdb(pdbid::AbstractString;
406-
dir::AbstractString=pwd(),
407-
format::Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}}=MMCIFFormat,
408-
obsolete::Bool=false,
409-
overwrite::Bool=false,
410-
ba_number::Integer=0,
411-
structure_name::AbstractString="$(uppercase(pdbid)).pdb",
412-
kwargs...)
393+
dir::AbstractString=pwd(),
394+
format::Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}}=MMCIFFormat,
395+
obsolete::Bool=false,
396+
overwrite::Bool=false,
397+
ba_number::Integer=0,
398+
structure_name::AbstractString="$(uppercase(pdbid)).pdb",
399+
kwargs...)
413400
downloadpdb(pdbid, dir=dir, format=format, obsolete=obsolete,
414-
overwrite=overwrite, ba_number=ba_number)
401+
overwrite=overwrite, ba_number=ba_number)
415402
if obsolete
416403
# If obsolete is set true, the PDB file is present in the obsolete directory inside dir
417404
dir = joinpath(dir, "obsolete")

0 commit comments

Comments
 (0)