Skip to content
1 change: 1 addition & 0 deletions prody/proteins/cifheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ def _getPolymers(lines, **kwargs):
polymers = dict()

entities = defaultdict(list)
longSeq = kwargs.get('longSeq', False)

# SEQRES block
items1 = parseSTARSection(lines, '_entity_poly', report=False)
Expand Down
2 changes: 1 addition & 1 deletion prody/proteins/localpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def fetchPDB(*pdb, **kwargs):
'specify another folder'.format(folder))

if compressed is not None and not compressed:
filedict = findPDBFiles(folder, compressed=True)
filedict = findPDBFiles(folder, compressed=True, format=format_)
not_found, decompress = [], not_found
for i, pdb in decompress:
if pdb in filedict:
Expand Down
6 changes: 5 additions & 1 deletion prody/proteins/wwpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,14 @@ def fetchPDBviaHTTP(*pdb, **kwargs):
try:
url = getURL(pdb)
if format != 'pdb':
url = url.replace('.pdb', extension)
if url.find('.pdb') != -1:
url = url.replace('.pdb', extension)
elif url.find('.ent') != -1:
url = url.replace('.ent', extension)

if url.find('divided/pdb') != -1:
url = url.replace('divided/pdb', 'divided/' + long_format)

handle = openURL(url)
except Exception as err:
if not _isExtendedPDBID(pdb):
Expand Down
14 changes: 13 additions & 1 deletion prody/tests/proteins/test_ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ def testLongChainArgument(self):
self.no_pdb['segment_SX0_atoms'],
'parseMMCIF failed to parse correct number of atoms '
'when segment SX0 is specified')


def testSkipPDBs(self):
"""Test outcome of valid and invalid *segment* arguments."""

pdb = self.altlocs['pdb']
_ = parsePDB(pdb)
_ = parseMMCIF(pdb)

def testUniteChainsArgument(self):
"""Test outcome of valid and invalid *segment* arguments."""

Expand Down Expand Up @@ -468,6 +475,11 @@ def testAltlocAllMultiModels(self):
self.assertEqual(ag.numCoordsets(), self.multi['models'],
'parsePDB failed to parse correct number of coordsets ({0}) with altloc "all"'.format(self.multi['models']))

def testLongSeqFix(self):
"""Test the outcome of parsing 3o21 from id, which failed previously."""

_ = parseMMCIF('3o21')

def testStopScipion(self):
"""Test number of coordinate sets and atoms for PyMOL CIF file with altloc='all'."""

Expand Down
10 changes: 10 additions & 0 deletions prody/utilities/pathtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ def gunzip(filename, outname=None):
else:
outname = filename

# Quick gzip magic number check
with open(filename, 'rb') as f:
magic = f.read(2)
if magic != b'\x1f\x8b':
raise ValueError(f"File {filename} is not a valid gzip file")

inp = gzip_open(filename, 'rb')
data = inp.read()
inp.close()
Expand All @@ -224,6 +230,10 @@ def gunzip(filename, outname=None):
out.close()
return outname
else:
# filename is a buffer, so check directly without opening
if filename[:2] != b'\x1f\x8b':
raise ValueError("Buffer is not gzipped or is invalid content")

result = None
try:
from StringIO import StringIO
Expand Down
Loading