[Biopython-dev] Extending test_PDB.py coverage?

Peter biopython at maubp.freeserve.co.uk
Tue Jul 6 15:03:32 UTC 2010


Hi all,

I've been running the unit tests with the Python 3 warnings enabled (this
needs either Python 2.6 or Python 2.7), e.g.

python2.6 -3 run_tests.py
python2.6 -3 run_tests.py test_PDB.py
python2.6 -3 test_PDB.py

There is a harmless glitch with test_1_warning in this mode (because it isn't
expecting all the extra warnings).

I was getting some DeprecationWarning messages about using "k in d"
rather than d.has_key(k), which I fixed:
http://github.com/biopython/biopython/commit/9b508b6a6391ac9d379a74cbb3cca1127e3c7aba

Looking at the Bio/PDB/*.py files there are still quite a few more examples
of has_key being used - but these are not being picked up by the unit tests:

AbstractPropertyMap.py:    def has_key(self, id):
AbstractPropertyMap.py:            >>> if map.has_key((chain_id, res_id)):
AbstractPropertyMap.py:        return self.property_dict.has_key(translated_id)
DSSP.py:    print d.has_key(('A', 1))
Entity.py:        return self.child_dict.has_key(id)
Entity.py:        return self.child_dict.has_key(id)
FragmentMapper.py:    def has_key(self, res):
FragmentMapper.py:        return self.fd.has_key(res)
FragmentMapper.py:        if fm.has_key(r):
MMCIFParser.py:        if mmcif_dict.has_key("_atom_site.auth_seq_id"):
NACCESS.py:                if naccess_dict.has_key((chain_id, res_id)):
NACCESS.py:                    if self.naccess_atom_dict.has_key(full_id):
Residue.py:        if _atom_name_dict.has_key(name1):
Residue.py:        if _atom_name_dict.has_key(name2):
Selection.py:        if not d.has_key(i):

While we could just fix the has_key usage, this would be a good point to
first extend the unit coverage - just in case we break something.

Some of these like DSSP and NACCESS are wrappers for command line
tools, so new files test_PDB_DSSP.py and test_PDB_NACCESS.py would
be sensible which can check for and run the tool if installed.

Others like the Residue, Entity and Selection modules should be more
straight forward to add directly to test_PDB.py itself.

Are there any volunteers?

Thanks,

Peter



More information about the Biopython-dev mailing list