-
Notifications
You must be signed in to change notification settings - Fork 70
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
TypeError in resid.py #13
Comments
Hi, Thanks for providing your code snippet and the full error log, that's really helpful. Could you try the following commands: pmol = plf.Molecule.from_mda(prot)
lmol = plf.Molecule.from_mda(tyr) One of the two should fail (or maybe both). Depending on if it's ag = prot # or tyr, whichever is failing
for r in ag.residues:
print(r.resname, r.resid, getattr(r, "chainID", ""), getattr(r, "segid", "")) This last command should help in identifying if it's just a residue missing a resnum/chain or if it's something else. |
Thanks so much for your quick suggestion. I ran the commands you mentioned and while the first worked for 'tyr', it did not work for 'prot' and gave the same TypeError in residue.py as I mentioned before. After running your second set of commands on the 'prot' that failed, I see no missing residue numbers or chains, they are all printed as expected. I've now focused my search to only a part of the protein and not the entirety of it and this works completely fine so for my current purposes it works but there does seem to be an issue when the whole protein is used - I have tried it with other .tpr files as well and the same issue arises. |
I think I identified where the problem comes from: can you confirm that one of the residues in your protein has a resnumber of 0? For some reason I was converting this to None, which causes the issue you mentioned. I'll publish a fix very soon! |
Yes, that's correct - the resnumbers begin with 0. Once I exclude that first residue everything works fine so that is most likely what is happening. Thank you! |
### Added - LigNetwork: an interaction diagram with atomistic details for the ligand and residue-level details for the protein, fully interactive in a browser/notebook, inspired from LigPlot (PR #19) - `fp.generate`: a method to get the IFP between two `prolif.Molecule` objects (PR #19) ### Changed - Default residue name and number: `UNK` and `0` are now the default values if `None` or `''` is given - The Hydrophobic interaction now uses `+0` (no charge) instead of `!$([+{1-},-{1-}])` (not negatively or positively charged) for part of its SMARTS pattern (PR #19) - Moved the `return_atoms` parameter from the `run` methods to `to_dataframe` to avoid recalculating the IFP if one wants to display it with atomic details (PR #19) - Changed the values returned by `fp.bitvector_atoms`: the atom indices have been separated in two lists, one for the ligand and one for the protein (PR #19) ### Deprecated ### Removed ### Fixed - Residues with a resnumber of `0` are not converted to `None` anymore (Issue #13)
When running fp.run, a consistent TypeError is given out in the resid.py code: '<' not supported between instances of 'NoneType' and 'int'
File types: .tpr, .xtc
Python: 3.8
Code below run on jupyter notebook:
import MDAnalysis as mda
import prolif as plf
u = mda.Universe('5jty_TCN.tpr','5jty_TCN_fit.xtc')
tyr = u.select_atoms("resid 139 and resname TYR")
prot = u.select_atoms("protein and not group tyr", tyr=tyr)
tyr, prot
fp = plf.Fingerprint(["HBDonor", "HBAcceptor", "PiStacking", "PiCation", "CationPi", "Anionic", "Cationic"])
fp.run(u.trajectory[::1000], tyr, prot)
Error:
`TypeError Traceback (most recent call last)
in
6 tyr, prot
7 fp = plf.Fingerprint(["HBDonor", "HBAcceptor", "PiStacking", "PiCation", "CationPi", "Anionic", "Cationic"])
----> 8 fp.run(u.trajectory[::1000], tyr, prot)
~/anaconda3/envs/proLIF/lib/python3.8/site-packages/prolif/fingerprint.py in run(self, traj, lig, prot, residues, return_atoms, progress)
277 ifp = []
278 for ts in iterator:
--> 279 prot_mol = Molecule.from_mda(prot)
280 lig_mol = Molecule.from_mda(lig)
281 data = {"Frame": ts.frame}
~/anaconda3/envs/proLIF/lib/python3.8/site-packages/prolif/molecule.py in from_mda(cls, obj, selection, **kwargs)
114 ag = obj.select_atoms(selection) if selection else obj.atoms
115 mol = mda_to_rdkit(ag, **kwargs)
--> 116 return cls(mol)
117
118 @classmethod
~/anaconda3/envs/proLIF/lib/python3.8/site-packages/prolif/molecule.py in init(self, mol)
77 residues = split_mol_by_residues(self)
78 residues = [Residue(mol) for mol in residues]
---> 79 residues.sort(key=attrgetter("resid"))
80 self.residues = ResidueGroup(residues)
81
~/anaconda3/envs/proLIF/lib/python3.8/site-packages/prolif/residue.py in lt(self, other)
49
50 def lt(self, other):
---> 51 return (self.chain, self.number) < (other.chain, other.number)
52
53 @classmethod
TypeError: '<' not supported between instances of 'NoneType' and 'int'
`
Thanks!
The text was updated successfully, but these errors were encountered: