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

PDB file lines read in as Models, throws "AttributeError: 'Model' object has no attribute 'decode'" #237

Open
ddcas9 opened this issue Nov 25, 2021 · 5 comments

Comments

@ddcas9
Copy link

ddcas9 commented Nov 25, 2021

In pdbfixer 1.6, 1.7 and 1.8 and openmm 7.5.1 (and 7.6 running pdbfixer 1.8), The following line:

fixer = PDBFixer(url=f'https://files.rcsb.org/download/{pdbid}.pdb')

fails with the trace (using pdbfixer 1.7 and openmm 7.5.1):

7 frames

/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2115             magic_arg_s = self.var_expand(line, stack_depth)
   2116             with self.builtin_trap:
-> 2117                 result = fn(magic_arg_s, cell)
   2118             return result
   2119 

<decorator-gen-53> in time(self, line, cell, local_ns)

/usr/local/lib/python3.7/dist-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/usr/local/lib/python3.7/dist-packages/IPython/core/magics/execution.py in time(self, line, cell, local_ns)
   1191         else:
   1192             st = clock2()
-> 1193             exec(code, glob, local_ns)
   1194             end = clock2()
   1195             out = None

<timed exec> in <module>()

/usr/local/lib/python3.7/site-packages/pdbfixer/pdbfixer.py in __init__(self, filename, pdbfile, pdbxfile, url, pdbid)
    263                 self._initializeFromPDBx(contents)
    264             else:
--> 265                 self._initializeFromPDB(StringIO(contents))
    266 
    267         # Check the structure has some atoms in it.

/usr/local/lib/python3.7/site-packages/pdbfixer/pdbfixer.py in _initializeFromPDB(self, file)
    283 
    284         structure = PdbStructure(file)
--> 285         pdb = app.PDBFile(structure)
    286         self.topology = pdb.topology
    287         self.positions = pdb.positions

/usr/local/lib/python3.7/site-packages/openmm/app/pdbfile.py in __init__(self, file, extraParticleIdentifier)

/usr/local/lib/python3.7/site-packages/openmm/app/internal/pdbstructure.py in __init__(self, input_stream, load_all_models, extraParticleIdentifier)

/usr/local/lib/python3.7/site-packages/openmm/app/internal/pdbstructure.py in _load(self, input_stream)

AttributeError: 'Model' object has no attribute 'decode'

The relevant line in _load(self, input_stream) is discussed in #81, though I don't understand where _load is called here. On line 285, a PdbStructure is passed to PDBFile, but the PdbStructure constructor isn't then called with this PdbStructure instance as an argument. Does the error actually happen on 284?

Thank you!

@ddcas9 ddcas9 changed the title PDB file lines read in as Models, then passed to a decode method, throws "AttributeError: 'Model' object has no attribute 'decode'" PDB file lines read in as Models, throws "AttributeError: 'Model' object has no attribute 'decode'" Nov 25, 2021
@peastman
Copy link
Member

I just tried the line you quoted and it worked correctly. What PDB file are you trying to load? Possibly the problem is specific to that PDB ID.

@nish-d
Copy link

nish-d commented Mar 12, 2022

fixer = PDBFixer(pdbid = '3uo4')
Facing the same error. With all PDB ids.

AttributeError                            Traceback (most recent call last)
<timed exec> in <module>

~/miniconda3/lib/python3.9/site-packages/pdbfixer/pdbfixer.py in __init__(self, filename, pdbfile, pdbxfile, url, pdbid)
    263                 self._initializeFromPDBx(contents)
    264             else:
--> 265                 self._initializeFromPDB(StringIO(contents))
    266 
    267         # Check the structure has some atoms in it.

~/miniconda3/lib/python3.9/site-packages/pdbfixer/pdbfixer.py in _initializeFromPDB(self, file)
    283 
    284         structure = PdbStructure(file)
--> 285         pdb = app.PDBFile(structure)
    286         self.topology = pdb.topology
    287         self.positions = pdb.positions

~/miniconda3/lib/python3.9/site-packages/openmm/app/pdbfile.py in __init__(self, file, extraParticleIdentifier)

~/miniconda3/lib/python3.9/site-packages/openmm/app/internal/pdbstructure.py in __init__(self, input_stream, load_all_models, extraParticleIdentifier)

~/miniconda3/lib/python3.9/site-packages/openmm/app/internal/pdbstructure.py in _load(self, input_stream)

AttributeError: 'Model' object has no attribute 'decode'

@jchodera
Copy link
Member

That's odd. I was able to get this to run on osx with openmm 7.7.0, pdbfixer 1.8.1, and python 3.9.9 on the first try:

>>> from pdbfixer import PDBFixer
>>> fixer = PDBFixer(pdbid = '3uo4')

Could you do a complete conda environment dump (conda env export)?

@nish-d
Copy link

nish-d commented Mar 13, 2022

Attaching the output for conda env export.
conda_env.txt

@peastman
Copy link
Member

You have very old versions of both PDBFixer and OpenMM. You can update them with

conda update -c conda-forge openmm pdbfixer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants