What I want to do
I have a list of almost 200 PDB entries that I need to visually inspect. Luckily, the thumbnail image displayed on the PDB website (examples with RCSB or PDBe for a well-known structure) is enough to figure out whether I want to exclude an entry for subsequent use of the resulting cleaned-up list of entries.
Now, looking up these entries one by one on the website is easy to do, but is very slow and error-prone. I need to be careful copy/pasting accession codes, and it takes a lot of time to go to my list, copy an accession code, go to the website, paste, search, and have my answer once the result page has loaded fully.
In other words, I'm lazy and I think my time would be better spent doing something more interesting than copy/pasting 200 times.
Attempt at a solution
I figured it shouldn't be too difficult to use PyMOL with a bit of scripting to automatically fetch each entry and generate a small image (faster than ray-tracing, which I don't need for this quick inspection). Here is my attempt:
pdb_entries = ['1m18', '1eqz'] # The real list has almost 200 entries, but 2 are enough to test the script for entry in pdb_entries: cmd.fetch(entry, async = 0, path = "./pdb-files") filename = "./pdb-imgs/" + entry cmd.png(filename, width = 600, dpi = 100, ray = 0, quiet = 0) cmd.delete(entry)
When I save this script as
fetch-all.py and run it from within PyMOL with the command
run fetch-all.py, the structure files are correctly downloaded in the
./pdb-files directory and images with names matching the PDB accession codes are generated in the
./pdb-imgs directory. So, it seems everything works. Except these images are just black, not showing anything of the structure.
I tried to add
cmd.show("cartoon", entry) before saving the PNG files, but it did not change anything. I also looked up the help page for
cmd.png(), thinking I was missing something, but I couldn't find anything I would be obviously missing there.
Any idea? Thank you all in advance.
Edit: I forgot to mention that this problem of black images happens with the latest PyMOL (2.2.0) and also with an older version (1.7.4).
Edit: when I run the commands inside the loop one by one at the PyMOL prompt, everything works fine, I get images correctly saved. It seems it doesn't work in the context of the loop only. I double checked the loop syntax and it looks fine to me (but I might be missing something; I don't know python very well).
Edit: I also tried
cmd.save() instead of
cmd.png(), but it did not solve the problem.