<p>So this was the code I used and it worked (as far as I could see) and refers to point 2 of @jgreener's advice and was based on the comment by @marcin</p>
<pre><code>python
pdb_lists = ['3LZG', '6HJN'] # lots more pdbs
for x in pdb_lists:
    cmd.fetch(x, type='pdb')
    cmd.select(x)
    cmd.save(x + '.pdb', x)
    cmd.delete(x)
cmd.quit()
python end
</code></pre>
<p>There are some Bio SE members who have serious skills in Pymol scripting, and constructive critique would be very welcome.</p>

CC BY-SA 4.0
2019-09-09T13:23:22.250Z
2020-12-20T10:39:25.147Z
2020-12-20T10:39:25.147Z
M__
<p>To expand on the comment by marcin:</p>

<ol>
<li><code>fetch</code> downloads files in mmCIF format by default (<a href="https://pymolwiki.org/index.php/Fetch" rel="noreferrer">https://pymolwiki.org/index.php/Fetch</a>). Not all PDB entries have PDB format files, e.g. due to too many chains. Presumably this is why the change was made, though mmCIF files tend to be larger and hence download slower.</li>
<li>When calling <code>save</code> with the <code>.pdb</code> file extension the structure is converted to PDB format. Perhaps the converter uses the SEQRES records to define the sequence, and hence gives bad files when there are some residues not resolved.</li>
</ol>

<p>To correct it you could try:</p>

<ol>
<li>Saving as <code>.cif</code> and reading in with the Biopython mmCIF parser.</li>
<li>Providing the <code>type=pdb</code> argument to <code>fetch</code>, which will force PDB format downloads. Some PDB files may not be available.</li>
<li>Don't do it in PyMol and instead use the Biopython structure downloader (<a href="http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc187" rel="noreferrer">http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc187</a>).</li>
</ol>

<p>Also, if download speed is limiting you then consider using the MMTF file format, which is a binary format and hence smaller. Biopython can read in and write out MMTF files.</p>

CC BY-SA 4.0
2019-09-07T23:55:45.137Z
Thanks point 2 was exactly how I solved the issue (and it worked). Let me look at the Biopython solution. I looked in detail at MMTF but it that appeared more aimed at pdb->MMTF.
M__
CC BY-SA 4.0
2019-09-07T20:21:02.967Z
2019-09-07T20:21:02.967Z
jgreener
<p>I automated a PDB download using a Pymol script (below)</p>
<pre><code>python
pdb_lists = ['3LZG', '6HJN'] # lots more pdbs
for x in pdb_lists:
    cmd.fetch(x)
    cmd.select(x)
    cmd.save(x + '.pdb', x)
    cmd.delete(x)
cmd.quit()
python end
</code></pre>
<p>When the script is run within Pymol it pulls down a collection of pdbs, however this flopped when I  plugged it through a Biopython PDB parser, but was okay when I manually downloaded the same pdb file from RCSB.org</p>
<p>A manual downloaded PDB was perfect, meaning the amino acids which cannot be observed by X-ray crystalography (e.g. they not sufficiently stationary) were recognised as being absent from the parser (resulting in a protein ~390 amino acids), but the Pymol scripted download contained all amino acid residues, i.e. even those which couldn't be observed in the X-ray (resulting in a protein of ~440 amino acid residues). Any ideas why the script resulted in a pdb that flopped and how to correct it?</p>

CC BY-SA 4.0
2019-09-07T17:19:54.440Z
In PyMol 1.8+ fetch downloads mmcif files by default. Your script must convert mmCIF to pdb, that's why the result differs from a pdb file downloaded directly from wwPDB.
marcin
<python><phylogenetics><phylogeny><pdb><pymol>
PDB file downloading: pymol automation vs. manual
# PDB file downloading: pymol automation vs. manual

(Asked by: username_0 on 2019-09-07)

I automated a PDB download using a Pymol script (below)
python
pdb_lists = ['3LZG', '6HJN'] # lots more pdbs
for x in pdb_lists:
    cmd.fetch(x)
    cmd.select(x)
    cmd.save(x + '.pdb', x)
    cmd.delete(x)
cmd.quit()
python end

When the script is run within Pymol it pulls down a collection of pdbs, however this flopped when I  plugged it through a Biopython PDB parser, but was okay when I manually downloaded the same pdb file from RCSB.org
A manual downloaded PDB was perfect, meaning the amino acids which cannot be observed by X-ray crystalography (e.g. they not sufficiently stationary) were recognised as being absent from the parser (resulting in a protein ~390 amino acids), but the Pymol scripted download contained all amino acid residues, i.e. even those which couldn't be observed in the X-ray (resulting in a protein of ~440 amino acid residues). Any ideas why the script resulted in a pdb that flopped and how to correct it?

**Tags:** python, phylogenetics, phylogeny, pdb, pymol
> **Comments:**
> **username_1**: In PyMol 1.8+ fetch downloads mmcif files by default. Your script must convert mmCIF to pdb, that's why the result differs from a pdb file downloaded directly from wwPDB.  

---

## 2 answers

### Answer by username_2 on 2019-09-07. Score: 5 | Accepted answer

To expand on the comment by marcin:

1. `fetch` downloads files in mmCIF format by default (<https://pymolwiki.org/index.php/Fetch>). Not all PDB entries have PDB format files, e.g. due to too many chains. Presumably this is why the change was made, though mmCIF files tend to be larger and hence download slower.
2. When calling `save` with the `.pdb` file extension the structure is converted to PDB format. Perhaps the converter uses the SEQRES records to define the sequence, and hence gives bad files when there are some residues not resolved.

To correct it you could try:

1. Saving as `.cif` and reading in with the Biopython mmCIF parser.
2. Providing the `type=pdb` argument to `fetch`, which will force PDB format downloads. Some PDB files may not be available.
3. Don't do it in PyMol and instead use the Biopython structure downloader (<http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc187>).

Also, if download speed is limiting you then consider using the MMTF file format, which is a binary format and hence smaller. Biopython can read in and write out MMTF files.

> **Comments:**
> **username_0**: Thanks point 2 was exactly how I solved the issue (and it worked). Let me look at the Biopython solution. I looked in detail at MMTF but it that appeared more aimed at pdb->MMTF.  

---

### Answer by username_0 on 2019-09-09. Score: 1

So this was the code I used and it worked (as far as I could see) and refers to point 2 of @jgreener's advice and was based on the comment by @marcin
python
pdb_lists = ['3LZG', '6HJN'] # lots more pdbs
for x in pdb_lists:
    cmd.fetch(x, type='pdb')
    cmd.select(x)
    cmd.save(x + '.pdb', x)
    cmd.delete(x)
cmd.quit()
python end

There are some Bio SE members who have serious skills in Pymol scripting, and constructive critique would be very welcome.


---

