Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permit atomic input to deformAtoms #1983

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
17 changes: 7 additions & 10 deletions prody/dynamics/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ def deformAtoms(atoms, mode, rmsd=None, replace=False, scale=None):
generate a coordinate set with given RMSD distance to the active coordinate
set."""

if not isinstance(atoms, AtomGroup):
raise TypeError('atoms must be an AtomGroup, not {0}'
if not isinstance(atoms, Atomic):
raise TypeError('atoms must be an Atomic object, not {0}'
.format(type(atoms)))
if not isinstance(mode, VectorBase):
raise TypeError('mode must be a Mode or Vector instance, '
Expand All @@ -280,15 +280,12 @@ def deformAtoms(atoms, mode, rmsd=None, replace=False, scale=None):
rmsd = float(rmsd)
# rmsd = ( ((scalar * array)**2).sum() / n_atoms )**0.5
scalar = (atoms.numAtoms() * rmsd**2 / (array**2).sum())**0.5
scale *= scalar
LOGGER.info('Mode is scaled by {0}.'.format(scalar))
if replace is False:
atoms.addCoordset(atoms.getCoords() + array * scalar * scale)
else:
atoms.setCoords(atoms.getCoords() + array * scalar * scale)

if replace is False:
atoms.addCoordset(atoms.getCoords() + array * scale)
else:
if replace is False:
atoms.addCoordset(atoms.getCoords() + array * scale)
else:
atoms.setCoords(atoms.getCoords() + array * scale)
atoms.setCoords(atoms.getCoords() + array * scale)


7 changes: 5 additions & 2 deletions prody/proteins/cifheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,11 @@ def _getReference(lines):
except:
continue
if what == 'AUTH':
surname, initials = value.split(',')
author = initials+surname
try:
surname, initials = value.split(',')
author = initials+surname
except ValueError:
author = value
authors.append(author.strip().upper())

ref['authors'] = authors
Expand Down
7 changes: 5 additions & 2 deletions prody/proteins/localpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,15 @@ def fetchPDB(*pdb, **kwargs):
if len(pdb) == 1 and isinstance(pdb[0], list):
pdb = pdb[0]

identifiers = checkIdentifiers(*pdb)

folder = kwargs.get('folder', '.')
compressed = kwargs.get('compressed')
format_ = kwargs.get('format', 'pdb')

if format_ != 'emd':
identifiers = checkIdentifiers(*pdb)
else:
identifiers = pdb

# check *folder* specified by the user, usually pwd ('.')
filedict = findPDBFiles(folder, compressed=compressed,
format=format_)
Expand Down
6 changes: 4 additions & 2 deletions prody/proteins/pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ def _parsePDB(pdb, **kwargs):
if filename is None:
try:
LOGGER.warn("Trying to parse mmCIF file instead")
chain = kwargs.pop('chain', chain)
return parseMMCIF(pdb+chain, **kwargs)
except:
except OSError:
try:
LOGGER.warn("Trying to parse EMD file instead")
chain = kwargs.pop('chain', chain)
return parseEMD(pdb+chain, **kwargs)
except:
raise IOError('PDB file for {0} could not be downloaded.'
raise IOError('PDB file for {0} could not be parsed.'
.format(pdb))
pdb = filename
if title is None:
Expand Down
22 changes: 20 additions & 2 deletions prody/proteins/wwpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,22 @@ def fetchPDBviaHTTP(*pdb, **kwargs):
output_folder = kwargs.pop('folder', None)
compressed = bool(kwargs.pop('compressed', True))

extension = '.pdb'
format = kwargs.get('format', 'pdb')
noatom = bool(kwargs.pop('noatom', False))
if format == 'pdb':
extension = '.pdb'
elif format == 'xml':
if noatom:
extension = '-noatom.xml'
else:
extension = '.xml'
elif format == 'cif':
extension = '.cif'
elif format == 'emd' or format == 'map':
extension = '.map'
else:
raise ValueError(repr(format) + ' is not valid format')

local_folder = pathPDBFolder()
if local_folder:
local_folder, is_divided = local_folder
Expand Down Expand Up @@ -294,7 +309,10 @@ def fetchPDBviaHTTP(*pdb, **kwargs):
filenames.append(None)
continue
try:
handle = openURL(getURL(pdb))
url = getURL(pdb)
if kwargs.get('format', 'pdb') != 'pdb':
url = url.replace('.pdb', extension)
handle = openURL(url)
except Exception as err:
LOGGER.warn('{0} download failed ({1}).'.format(pdb, str(err)))
failure += 1
Expand Down
15 changes: 3 additions & 12 deletions prody/tests/proteins/test_wwpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
LOGGER.verbosity = 'none'


class TestFTP(unittest.TestCase):
class TestHTTP(unittest.TestCase):

def setUp(self):

self.pdb = ['1ubi', '1aar', 'arg', 1234]
self.fns = []
self.len = [683, 1218, None, None]
self.fetch = fetchPDBviaFTP
self.protocol = 'FTP'
self.fetch = fetchPDBviaHTTP
self.protocol = 'HTTP'


@dec.slow
Expand Down Expand Up @@ -69,12 +69,3 @@ def tearDown(self):
pass
except:
pass

class TestHTTP(TestFTP):

def setUp(self):

TestFTP.setUp(self)
self.fetch = fetchPDBviaHTTP
self.protocol = 'HTTP'

Loading