Using non-PDB Universe: "AttributeError: 'Topology' object has no attribute 'altLocs'"
Mishakolok opened this issue · 4 comments
Hello, I've encountered a problem when I tried supplying MDAnalysis Universe generated from a GROMACS trajectory with a '.gro' extension as an argument to the SpinLabel() function.
---> 11 SL1 = xl.SpinLabel('R1M', site=34, protein=compl, sample = 10000, dihedral_sigmas = np.inf)
12 saveLabel(path = path_to_folder,SL = SL1)
13 spins = mda.Universe(path_to_folder + "label_conformations.pdb")
File c:\Anaconda\envs\spins\lib\site-packages\chilife-0.1-py3.10.egg\chilife\SpinLabel.py:36, in SpinLabel.__init__(self, label, site, protein, chain, rotlib, **kwargs)
33 if not kwargs.get('minimize', False):
34 kwargs.setdefault("eval_clash", True)
---> 36 super().__init__(label, site, protein=protein, chain=chain, rotlib=rotlib, **kwargs)
38 self.label = label
40 # Parse spin delocalization information
File c:\Anaconda\envs\spins\lib\site-packages\chilife-0.1-py3.10.egg\chilife\RotamerEnsemble.py:235, in RotamerEnsemble.__init__(self, res, site, protein, chain, rotlib, **kwargs)
232 self.eps = chilife.get_lj_eps(self.atom_types[self.side_chain_idx])
234 if hasattr(self.protein, "atoms") and isinstance(self.protein.atoms, (mda.AtomGroup, chilife.MolecularSystem)):
--> 235 self.protein_setup()
236 resname = self.protein.atoms[self.clash_ignore_idx[0]].resname
237 self.nataa = chilife.nataa_codes.get(resname, resname)
File c:\Anaconda\envs\spins\lib\site-packages\chilife-0.1-py3.10.egg\chilife\SpinLabel.py:68, in SpinLabel.protein_setup(self)
66 def protein_setup(self):
...
--> 609 nmattr = getattr(group.universe._topology, self.field)
611 matches = [] # list of passing indices
612 # iterate through set of known atom names, check which pass
AttributeError: 'Topology' object has no attribute altLocs
It seems like this attribute has no functional meaning in terms of the spin labeling. However, apparently one of the functions tries to call it nonetheless.
I easily fixed it by adding
traj.add_TopologyAttr('altLocs',np.full(len(traj.atoms),''))
where "traj" is my Universe. After that everything worked perfectly.
Thank you for posting this @Mishakolok. I will fix this as soon as I can. Please be aware that chilife.SpinLabel
only labels the active frame, not the whole trajectory. There is a SpinLabelTraj
object but it is not yet fully supported.
Thank you for posting this @Mishakolok. I will fix this as soon as I can. Please be aware that
chilife.SpinLabel
only labels the active frame, not the whole trajectory. There is aSpinLabelTraj
object but it is not yet fully supported.
Thank you! Yes, I am aware of that, so I just label each frame in the trajectory. It's not really fast but it works well enough for me.
@Mishakolok yes, unfortunately, any method involving sampling will be slower, but if you can sacrifice a little accuracy the rotamer library method is a lot faster. If your trajectory is long enough it may not make that much of a difference.