Skip to content

Example Codes Fail #188

@kylezhang1011

Description

@kylezhang1011

I'm running Python 3.12.7 locally on my computer and using the latest version of chiLife (1.1.4). In Example 4, some lines of codes returned an error instead of the results presented in the example.

T109R3A = xl.SpinLabel('R3A', 109, T4L, rotlib='R3A_rotlib.npz')
T109NBA = xl.SpinLabel('NBA', 109, T4L, rotlib='NBA')
T109GD3 = xl.SpinLabel('GD3', 109, T4L, sample=5000)

The error returned is:

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/MDAnalysis/core/universe.py:743: UserWarning: Reader has no dt information, set to 1.0 ps
  dt=self.trajectory.ts.dt * step,

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/chilife/protein_utils.py:148: RuntimeWarning: invalid value encountered in divide
  b1 /= np.linalg.norm(b1, axis=-1)[:, None]

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/MDAnalysis/core/universe.py:743: UserWarning: Reader has no dt information, set to 1.0 ps
  dt=self.trajectory.ts.dt * step,

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/chilife/protein_utils.py:148: RuntimeWarning: invalid value encountered in divide
  b1 /= np.linalg.norm(b1, axis=-1)[:, None]

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/MDAnalysis/core/universe.py:743: UserWarning: Reader has no dt information, set to 1.0 ps
  dt=self.trajectory.ts.dt * step,

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/chilife/protein_utils.py:148: RuntimeWarning: invalid value encountered in divide
  b1 /= np.linalg.norm(b1, axis=-1)[:, None]

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[3], line 35
     22 xl.create_library('GD3', 'GD3/GD3_Ensemble.pdb', 
     23                   dihedral_atoms=[['N', 'CA', 'CB', 'SG'],
     24                                   ['CA', 'CB', 'SG', 'C18'],
   (...)
     28                   spin_atoms='Gd1',
     29                   weights=weights)
     34 T4L = xl.fetch('2lzm')
---> 35 T109R3A = xl.SpinLabel('R3A', 109, T4L, rotlib='R3A_rotlib.npz')
     36 #T109NBA = xl.SpinLabel('NBA', 109, T4L, rotlib='NBA')
     37 #T109GD3 = xl.SpinLabel('GD3', 109, T4L, sample=5000)
     39 xl.save(T109R3A, T109NBA, T109GD3, T4L)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/SpinLabel.py:33, in SpinLabel.__init__(self, label, site, protein, chain, rotlib, **kwargs)
     30 if not kwargs.get('minimize', False):
     31     kwargs.setdefault("eval_clash", True)
---> 33 super().__init__(label, site, protein=protein, chain=chain, rotlib=rotlib, **kwargs)
     35 self.label = label
     37 # Parse spin delocalization information

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:191, in RotamerEnsemble.__init__(self, res, site, protein, chain, rotlib, **kwargs)
    188 if self.chain not in ('A', None):
    189     self.name += f"_{self.chain}"
--> 191 self.update(no_lib=True)
    193 # Store atom information as atom objects
    194 self.atoms = [
    195     FreeAtom(name, atype, idx, self.res, self.site, coord)
    196     for idx, (coord, atype, name) in enumerate(
    197         zip(self._coords[0], self.atom_types, self.atom_names)
    198     )
    199 ]

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:435, in RotamerEnsemble.update(self, no_lib)
    432     self.weights = self._weights.copy()
    434 if self.protein is not None:
--> 435     self.protein_setup()
    436 else:
    437     self.ICs_to_site(self.origin, self.mx)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:440, in RotamerEnsemble.protein_setup(self)
    439 def protein_setup(self):
--> 440     self.to_site()
    442     # Get weight of current or closest rotamer
    443     clash_ignore_idx = self.protein.select_atoms(f"resid {self.site} and segid {self.chain}").ix

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:622, in RotamerEnsemble.to_site(self, site_pos)
    619 cmx = ori_mx @ mx
    621 self._coords = np.einsum("ijk,kl->ijl", self._coords, cmx) + ori
--> 622 self.ICs_to_site(ori, mx)
    623 if self._match_backbone:
    624     self.backbone_to_site()

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:642, in RotamerEnsemble.ICs_to_site(self, cori, cmx)
    639 m2m3 = self.ic_mx @ self.mx
    640 op = {}
--> 642 new_mx = self.internal_coords.chain_operators[0]["mx"] @ m2m3
    643 new_ori = (self.internal_coords.chain_operators[0]["ori"] - self.ic_ori) @ m2m3 + self.origin
    644 op[0] = {"mx": new_mx, "ori": new_ori}

KeyError: 0

This issue was also found in Example 5:

SL1_repack = xl.SpinLabel.from_trajectory(traj, 124, burn_in=5000, spin_atoms=SL1.spin_atoms)
SL2_repack = xl.SpinLabel.from_trajectory(traj, 281, burn_in=5000, spin_atoms=SL2.spin_atoms)

The error returned is:

KeyError                                  Traceback (most recent call last)
Cell In[2], line 10
      3 SL2 = xl.SpinLabel('R1M', 281, mbp)
      5 traj, dE = xl.repack(mbp, SL1, SL2,
      6                      repetitions=10000, temp=298,
      7                      off_rotamer=True,
      8                      repack_radius=10)
---> 10 SL1_repack = xl.SpinLabel.from_trajectory(traj, 124, burn_in=5000, spin_atoms=SL1.spin_atoms)
     11 SL2_repack = xl.SpinLabel.from_trajectory(traj, 281, burn_in=5000, spin_atoms=SL2.spin_atoms)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:406, in RotamerEnsemble.from_trajectory(cls, traj, site, chain, energy, burn_in, **kwargs)
    404 kwargs.setdefault('eval_clash', False)
    405 kwargs.setdefault('_match_backbone', False)
--> 406 return cls(resname, site, chain=chain, rotlib=lib, **kwargs)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/SpinLabel.py:33, in SpinLabel.__init__(self, label, site, protein, chain, rotlib, **kwargs)
     30 if not kwargs.get('minimize', False):
     31     kwargs.setdefault("eval_clash", True)
---> 33 super().__init__(label, site, protein=protein, chain=chain, rotlib=rotlib, **kwargs)
     35 self.label = label
     37 # Parse spin delocalization information

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:191, in RotamerEnsemble.__init__(self, res, site, protein, chain, rotlib, **kwargs)
    188 if self.chain not in ('A', None):
    189     self.name += f"_{self.chain}"
--> 191 self.update(no_lib=True)
    193 # Store atom information as atom objects
    194 self.atoms = [
    195     FreeAtom(name, atype, idx, self.res, self.site, coord)
    196     for idx, (coord, atype, name) in enumerate(
    197         zip(self._coords[0], self.atom_types, self.atom_names)
    198     )
    199 ]

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:437, in RotamerEnsemble.update(self, no_lib)
    435     self.protein_setup()
    436 else:
--> 437     self.ICs_to_site(self.origin, self.mx)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:642, in RotamerEnsemble.ICs_to_site(self, cori, cmx)
    639 m2m3 = self.ic_mx @ self.mx
    640 op = {}
--> 642 new_mx = self.internal_coords.chain_operators[0]["mx"] @ m2m3
    643 new_ori = (self.internal_coords.chain_operators[0]["ori"] - self.ic_ori) @ m2m3 + self.origin
    644 op[0] = {"mx": new_mx, "ori": new_ori}

KeyError: 0
neighbors = [xl.RotamerEnsemble.from_trajectory(traj, resi, burn_in=5000) for resi in resis]
neighbors = [resi for resi in neighbors if len(resi) > 1]

The error returned is:

WARNING:py.warnings:/opt/anaconda3/lib/python3.12/site-packages/chilife/protein_utils.py:148: RuntimeWarning: invalid value encountered in divide
  b1 /= np.linalg.norm(b1, axis=-1)[:, None]

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[5], line 4
      1 resis = [res.resnum for res in mbp.select_atoms('(not resname ALA GLY HOH) and around 14 resnum 124').residues] + \
      2         [res.resnum for res in mbp.select_atoms('(not resname ALA GLY HOH) and around 14 resnum 281').residues]
----> 4 neighbors = [xl.RotamerEnsemble.from_trajectory(traj, resi, burn_in=5000) for resi in resis]
      5 neighbors = [resi for resi in neighbors if len(resi) > 1]

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:406, in RotamerEnsemble.from_trajectory(cls, traj, site, chain, energy, burn_in, **kwargs)
    404 kwargs.setdefault('eval_clash', False)
    405 kwargs.setdefault('_match_backbone', False)
--> 406 return cls(resname, site, chain=chain, rotlib=lib, **kwargs)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:191, in RotamerEnsemble.__init__(self, res, site, protein, chain, rotlib, **kwargs)
    188 if self.chain not in ('A', None):
    189     self.name += f"_{self.chain}"
--> 191 self.update(no_lib=True)
    193 # Store atom information as atom objects
    194 self.atoms = [
    195     FreeAtom(name, atype, idx, self.res, self.site, coord)
    196     for idx, (coord, atype, name) in enumerate(
    197         zip(self._coords[0], self.atom_types, self.atom_names)
    198     )
    199 ]

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:437, in RotamerEnsemble.update(self, no_lib)
    435     self.protein_setup()
    436 else:
--> 437     self.ICs_to_site(self.origin, self.mx)

File /opt/anaconda3/lib/python3.12/site-packages/chilife/RotamerEnsemble.py:642, in RotamerEnsemble.ICs_to_site(self, cori, cmx)
    639 m2m3 = self.ic_mx @ self.mx
    640 op = {}
--> 642 new_mx = self.internal_coords.chain_operators[0]["mx"] @ m2m3
    643 new_ori = (self.internal_coords.chain_operators[0]["ori"] - self.ic_ori) @ m2m3 + self.origin
    644 op[0] = {"mx": new_mx, "ori": new_ori}

KeyError: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions