@@ -162,11 +162,11 @@ Requires an internet connection.
162162 assembly; by default downloads the PDB file.
163163"""
164164function downloadpdb (pdbid:: AbstractString ;
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 )
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 )
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,10 +198,18 @@ 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- Downloads. download (
202- " http://files.rcsb.org/download/$pdbid .$(pdbextension[format]) .gz" ,
203- archivefilepath,
204- )
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
205213 else
206214 if format == PDBFormat
207215 Downloads. download (
@@ -213,6 +221,11 @@ function downloadpdb(pdbid::AbstractString;
213221 " http://files.rcsb.org/download/$pdbid -assembly$ba_number .$(pdbextension[format]) .gz" ,
214222 archivefilepath,
215223 )
224+ elseif format == BCIFFormat
225+ Downloads. download (
226+ " https://models.rcsb.org/$pdbid .bcif" ,
227+ archivefilepath,
228+ )
216229 else
217230 throw (ArgumentError (" Biological assemblies are available in the " *
218231 " PDB and mmCIF formats only" ))
@@ -230,8 +243,8 @@ function downloadpdb(pdbid::AbstractString;
230243 if ! isfile (pdbpath) || filesize (pdbpath) == 0
231244 if format == PDBFormat
232245 throw (ErrorException (" Error downloading file: $pdbid ; some PDB entries are " *
233- " not available as PDB format files, consider downloading " *
234- " the mmCIF file instead" ))
246+ " not available as PDB format files, consider downloading " *
247+ " the mmCIF file instead" ))
235248 else
236249 throw (ErrorException (" Error downloading file: $pdbid " ))
237250 end
@@ -245,7 +258,7 @@ function downloadpdb(pdbid::AbstractString;
245258 return pdbpath
246259end
247260
248- function downloadpdb (pdbidlist:: AbstractArray{<:AbstractString, 1} ; kwargs... )
261+ function downloadpdb (pdbidlist:: AbstractArray{<:AbstractString,1} ; kwargs... )
249262 pdbpaths = String[]
250263 failedlist = String[]
251264 for pdbid in pdbidlist
@@ -291,8 +304,8 @@ Requires an internet connection.
291304 in `dir`; by default skips downloading the PDB file if it exists.
292305"""
293306function downloadentirepdb (; dir:: AbstractString = pwd (),
294- format:: Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}} = PDBFormat,
295- overwrite:: Bool = false )
307+ format:: Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}} = PDBFormat,
308+ overwrite:: Bool = false )
296309 pdblist = pdbentrylist ()
297310 @info " About to download $(length (pdblist)) PDB files, make sure you have enough disk space and time"
298311 @info " The function can be stopped any time and called again to resume downloading"
@@ -310,12 +323,12 @@ automatically updates the PDB files of the given `format` inside the local
310323Requires an internet connection.
311324"""
312325function updatelocalpdb (; dir:: AbstractString = pwd (),
313- format:: Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}} = PDBFormat)
326+ format:: Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}} = PDBFormat)
314327 addedlist, modifiedlist, obsoletelist = pdbrecentchanges ()
315328 # Download the newly added and modified pdb files
316329 downloadpdb (vcat (addedlist, modifiedlist), dir= dir, overwrite= true , format= format)
317330 # Set the obsolete directory to be inside dir
318- obsolete_dir= joinpath (dir, " obsolete" )
331+ obsolete_dir = joinpath (dir, " obsolete" )
319332 for pdbid in obsoletelist
320333 oldfile = joinpath (dir, " $pdbid .$(pdbextension[format]) " )
321334 newfile = joinpath (obsolete_dir, " $pdbid .$(pdbextension[format]) " )
@@ -325,10 +338,10 @@ function updatelocalpdb(; dir::AbstractString=pwd(),
325338 mkpath (obsolete_dir)
326339 end
327340 mv (oldfile, newfile)
328- # If obsolete pdb is already in the obsolete directory, inform the user and skip
341+ # If obsolete pdb is already in the obsolete directory, inform the user and skip
329342 elseif isfile (newfile)
330343 @info " PDB $pdbid is already moved to the obsolete directory"
331- # If obsolete pdb not available in both dir and obsolete, inform the user and skip
344+ # If obsolete pdb not available in both dir and obsolete, inform the user and skip
332345 else
333346 @info " Obsolete PDB $pdbid is missing"
334347 end
@@ -352,8 +365,8 @@ Requires an internet connection.
352365 in `dir`; by default skips downloading the PDB file if it exists.
353366"""
354367function downloadallobsoletepdb (; obsolete_dir:: AbstractString = pwd (),
355- format:: Type{<:Union{PDBFormat, PDBXMLFormat, MMCIFFormat}} = PDBFormat,
356- overwrite:: Bool = false )
368+ format:: Type{<:Union{PDBFormat,PDBXMLFormat,MMCIFFormat}} = PDBFormat,
369+ overwrite:: Bool = false )
357370 obsoletelist = pdbobsoletelist ()
358371 downloadpdb (obsoletelist, dir= obsolete_dir, format= format, overwrite= overwrite)
359372end
@@ -390,15 +403,15 @@ Requires an internet connection.
390403 Requires the STRIDE_jll.jl package to be imported if set to `true`.
391404"""
392405function retrievepdb (pdbid:: AbstractString ;
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... )
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... )
400413 downloadpdb (pdbid, dir= dir, format= format, obsolete= obsolete,
401- overwrite= overwrite, ba_number= ba_number)
414+ overwrite= overwrite, ba_number= ba_number)
402415 if obsolete
403416 # If obsolete is set true, the PDB file is present in the obsolete directory inside dir
404417 dir = joinpath (dir, " obsolete" )
0 commit comments