Skip to content

Commit 9d941e9

Browse files
committed
switch PDB downloads from ftp to https
1 parent a863102 commit 9d941e9

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/download.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export
99
downloadallobsoletepdb,
1010
retrievepdb
1111

12+
const pdb_download_prefix = "https://files.wwpdb.org/pub/pdb"
13+
1214
"""
1315
pdbentrylist()
1416
@@ -21,7 +23,7 @@ function pdbentrylist()
2123
@info "Fetching the list of all PDB entries from the RCSB server"
2224
tempfilepath = tempname()
2325
try
24-
Downloads.download("ftp://ftp.wwpdb.org/pub/pdb/derived_data/index/entries.idx", tempfilepath)
26+
Downloads.download("$pdb_download_prefix/derived_data/index/entries.idx", tempfilepath)
2527
open(tempfilepath) do input
2628
reading = false
2729
for line in eachline(input)
@@ -53,7 +55,7 @@ end
5355
Obtain the list of Protein Data Bank (PDB) entries from a RCSB weekly status
5456
file by specifying its URL.
5557
56-
An example URL is ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/added.pdb.
58+
An example URL is $pdb_download_prefix/pub/pdb/data/status/latest/added.pdb.
5759
Requires an internet connection.
5860
"""
5961
function pdbstatuslist(url::AbstractString)
@@ -92,9 +94,9 @@ Obtain three lists giving the added, modified and obsolete Protein Data Bank
9294
Requires an internet connection.
9395
"""
9496
function pdbrecentchanges()
95-
addedlist = pdbstatuslist("ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/added.pdb")
96-
modifiedlist = pdbstatuslist("ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/modified.pdb")
97-
obsoletelist = pdbstatuslist("ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/obsolete.pdb")
97+
addedlist = pdbstatuslist("$pdb_download_prefix/data/status/latest/added.pdb")
98+
modifiedlist = pdbstatuslist("$pdb_download_prefix/data/status/latest/modified.pdb")
99+
obsoletelist = pdbstatuslist("$pdb_download_prefix/data/status/latest/obsolete.pdb")
98100
return addedlist, modifiedlist, obsoletelist
99101
end
100102

@@ -111,7 +113,7 @@ function pdbobsoletelist()
111113
@info "Fetching the list of all obsolete PDB entries from the RCSB server"
112114
tempfilepath = tempname()
113115
try
114-
Downloads.download("ftp://ftp.wwpdb.org/pub/pdb/data/status/obsolete.dat", tempfilepath)
116+
Downloads.download("$pdb_download_prefix/data/status/obsolete.dat", tempfilepath)
115117
open(tempfilepath) do input
116118
for line in eachline(input)
117119
# Check if its an obsolete pdb entry and not headers

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ BioSequences = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
66
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
77
DSSP_jll = "74334e00-59ce-546d-b517-81f3b7e1d491"
88
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
9+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
910
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
1011
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1112
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

test/runtests.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using MetaGraphs
1414
using RecipesBase
1515
using STRIDE_jll
1616

17+
using Downloads
1718
using LinearAlgebra
1819
using Test
1920

@@ -49,7 +50,8 @@ using BioStructures:
4950
tokenizecifstructure,
5051
formatmmcifcol,
5152
requiresnewline,
52-
requiresquote
53+
requiresquote,
54+
pdb_download_prefix
5355

5456
# Get the path to BioFmtSpecimens and download it if required
5557
fmtdir = BioCore.Testing.get_bio_fmt_specimens("master", false)
@@ -90,12 +92,9 @@ Aqua.test_all(BioStructures; ambiguities=(recursive=false))
9092
@test length(pdbentrylist()) > 100000
9193

9294
# This may be empty on a given date so we just check it has the correct type
93-
@test isa(pdbstatuslist("ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/added.pdb"), Vector{String})
95+
@test isa(pdbstatuslist("$pdb_download_prefix/data/status/latest/added.pdb"), Vector{String})
9496
# Invalid URL
95-
# The error type changes from ErrorException to ProcessFailedException in Julia v1.2
96-
# therefore we check for the more general Exception type
97-
# This also applies to two examples below
98-
@test_throws Exception pdbstatuslist("ftp://ftp.wwpdb.org/pub/pdb/data/status/latest/dummy.pdb")
97+
@test_throws RequestError pdbstatuslist("$pdb_download_prefix/data/status/latest/dummy.pdb")
9998

10099
addedlist, modifiedlist, obsoletelist = pdbrecentchanges()
101100

@@ -104,13 +103,13 @@ Aqua.test_all(BioStructures; ambiguities=(recursive=false))
104103
# Invalid PDB ID format
105104
@test_throws ArgumentError downloadpdb("1a df")
106105
# Valid PDB ID format but PDB does not exist
107-
@test_throws Exception downloadpdb("no1e", dir=temp_dir)
106+
@test_throws RequestError downloadpdb("no1e", dir=temp_dir)
108107
# Invalid file format
109108
@test_throws TypeError downloadpdb("1alw", dir=temp_dir, format=String)
110109
# Biological assembly not available in PDBXML and MMTF
111110
@test_throws ArgumentError downloadpdb("1alw", dir=temp_dir, format=PDBXMLFormat, ba_number=1)
112111
# Invalid BA number for this PDB entry
113-
@test_throws Exception downloadpdb("1alw", dir=temp_dir, format=MMCIFFormat, ba_number=10)
112+
@test_throws RequestError downloadpdb("1alw", dir=temp_dir, format=MMCIFFormat, ba_number=10)
114113
# Test if downloadpdb returns the path to the downloaded file
115114
@test isfile(downloadpdb("1crn", dir=temp_dir))
116115

0 commit comments

Comments
 (0)