What would be the total size of all PDB files in RCSB?
Can I traverse/enumerate them one at a time using a Python script without downloading all of them to my local disk?
If YES, what would be the Python script like?
Bioinformatics Stack Exchange is a question and answer site for researchers, developers, students, teachers, and end users interested in bioinformatics. It only takes a minute to sign up.
Sign up to join this communityThe page https://www.wwpdb.org/ftp/pdb-ftp-sites gives the addresses of interest. PDB has an FTP site downloadable via rsync and the latter has a dry run mode.
rsync --port=33444 -rlpt -v -z --dry-run --stats rsync.rcsb.org::ftp_data/structures/divided/pdb/
You get a bunch of folders names and the following:
Number of files: 182479
Number of files transferred: 0
Total file size: 38382243431 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 3777395
File list generation time: 52.909 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 16
Total bytes received: 3777651
sent 16 bytes received 3777651 bytes 66861.36 bytes/sec
total size is 38382243431 speedup is 10160.30
So there are 182,479 *.ent.gz in various folders. The total is 38,382,243,431 bytes, which is 38 GB, so not too much. In Python it is easy to iterate across gzip files with the gzip module, so uncompressing them is generally a thing to avoid as it will bloat up greatly. The problem arise when dealing with the density maps, which do take up a lot of space...
The PDBe is easier to for downloading things than the RCSB PDB and the API are much more comprehensive.
Given a list of PDB codes one could
pdbcode : str = '👾👾👾👾'
import requests
r = requests.get(f'https://www.ebi.ac.uk/pdbe/entry-files/download/pdb{pdbcode.lower()}.ent', stream=True)
assert r.status_code == 200, f'something ({r.status_code} is wrong: {r.text}'
pdb_code = r.text
Not Python, but you can do this with BioStructures.jl in Julia:
using BioStructures
pdblist = pdbentrylist()
for pdbid in pdblist
# Download a file and delete it after use
downloadpdb(pdbid, format=MMCIF) do fp
s = read(fp, MMCIF)
# Do something with the file, e.g. print the cysteine fraction
nres = countresidues(s, standardselector)
if nres > 0
frac = countresidues(s, standardselector, x -> resname(x) == "CYS") / nres
println(pdbid, " ", round(frac; digits=2))
end
end
end
If you want to get all the PDB entries you should use the mmCIF format, though it does lead to larger file sizes.