You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python3 PDB NeighborSearch: TypeError: '<' not supported between instances of 'Residue' and 'Residue' #1356
ns.search_all(2.0, level='R') to return all pairs of residues in the NeighborSearch object that are within 2 Angstroms of each other.
Actual behaviour
Traceback (most recent call last):
File "/home/ubuntu/repos/pipeline/venv362/lib/python3.6/site-packages/doit/action.py", line 403, in execute
returned_value = self.py_callable(*self.args, **kwargs)
File "/home/ubuntu/repos/pipeline/tasks/pdb_analysis.py", line 687, in fix_ligand_overlaps
clashing_waters = ns.search_all(2.0, level='R')
File "/home/ubuntu/repos/pipeline/venv362/lib/python3.6/site-packages/Bio/PDB/NeighborSearch.py", line 128, in search_all
next_level_pair_list = self._get_unique_parent_pairs(next_level_pair_list)
File "/home/ubuntu/repos/pipeline/venv362/lib/python3.6/site-packages/Bio/PDB/NeighborSearch.py", line 65, in _get_unique_parent_pairs
elif p1 < p2:
TypeError: '<' not supported between instances of 'Residue' and 'Residue'
Object ordering is something which changed drastically from Python 2 to Python 3, and it appears there are still things missing in the PDB code for this (and missing unit test coverage).
Cross reference #1189 which is related and was fixed after Biopython 1.70 was released.
@peterjc this also breaks in 1.69 and Python 3. I don't really understand how the comparison was done before, truth be told. The private sorting methods were never called afaik, unless there is some magic somewhere.
My first guess is that we need to define __gt__ and other comparison operators for each object?
Edit
From portingguide.org: In Python 3, the cmp style of comparisons was dropped. All objects that implemented __cmp__ must be updated to implement all of the rich methods instead.
Activity
peterjc commentedon Aug 7, 2017
Object ordering is something which changed drastically from Python 2 to Python 3, and it appears there are still things missing in the PDB code for this (and missing unit test coverage).
Cross reference #1189 which is related and was fixed after Biopython 1.70 was released.
JoaoRodrigues commentedon Aug 8, 2017
Can confirm it here on an independent piece of code. I'll have a look. Thanks for assigning this Peter, and thanks @harryjubb for raising it!
JoaoRodrigues commentedon Aug 8, 2017
@peterjc this also breaks in 1.69 and Python 3. I don't really understand how the comparison was done before, truth be told. The private sorting methods were never called afaik, unless there is some magic somewhere.
My first guess is that we need to define
__gt__and other comparison operators for each object?Edit
From portingguide.org:
In Python 3, the cmp style of comparisons was dropped. All objects that implemented __cmp__ must be updated to implement all of the rich methods instead.etal commentedon Aug 8, 2017
JoaoRodrigues commentedon Aug 8, 2017
I think I fixed it. @harryjubb could you test it on your end?
peterjc commentedon Aug 9, 2017
Thanks for working on this - I agree a full implementation of sorting with tests is the best plan here 🥇
harryjubb commentedon Nov 22, 2017
Apologies for the long delay: have run a quick test and so far so good! Thanks for fixing it :), I'll keep trying it out.
peterjc commentedon Nov 22, 2017
OK, I'll close this issue now - but please do report back if you run into any problems. Thank you!