Skip to content

Commit

Permalink
[pdb.pdb2traj] increase buffer size
Browse files Browse the repository at this point in the history
The whole pdb file wasn't downloading from response in Linux,
but it did on MacOS, although they have the same buffer size (?)
  • Loading branch information
gph82 committed Oct 26, 2023
1 parent 1a64e50 commit 73cfe64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mdciao/pdb/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
from mdtraj import load_pdb as _load_pdb
from tempfile import NamedTemporaryFile as _NamedTemporaryFile
from shutil import copy as _copy, copyfileobj as _copyfileobj
try:
from shutil import COPY_BUFSIZE as _COPY_BUFSIZE
except ImportError:
_COPY_BUFSIZE = 256 * 64 #py37 shutil has this buffersize hard-coded

from urllib.error import HTTPError as _HTTPError, URLError as _URLError
from urllib.request import urlopen as _urlopen
Expand Down Expand Up @@ -135,7 +139,7 @@ def pdb2traj(code,
with _urlopen(url1) as response:
if response.status == 200:
with _NamedTemporaryFile(delete=True) as tmp_file:
_copyfileobj(response, tmp_file)
_copyfileobj(response, tmp_file, length=_COPY_BUFSIZE*2)
geom = _load_pdb(tmp_file.name)
if filename is not None:
print_v("Saving to %s..." % filename, end="", flush=True)
Expand Down

0 comments on commit 73cfe64

Please sign in to comment.