Skip to content

Add selftest for Bio.PDB.NeighborSearch - #1366

Closed
souravsingh wants to merge 10 commits into
biopython:masterfrom
souravsingh:add-test
Closed

souravsingh wants to merge 10 commits into
biopython:masterfrom
souravsingh:add-test

Conversation

@souravsingh

Copy link
Copy Markdown
Contributor

This pull request addresses issue #820

I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.

I am happy to be thanked by name in the NEWS.rst and
CONTRIB.rst files.

I have read the CONTRIBUTING.rst file and understand that AppVeyor and
TravisCI will be used to confirm the Biopython unit tests and flake8 style
checks pass with these changes.

Comment thread Tests/test_PDB_NeighborSearch.py Outdated
@@ -0,0 +1,26 @@
# Copyright 2017 by Peter Cock. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't my work.

The original test was written by Thomas Hamelryck (CVS username nisse) in Dec 2002, see https://github.com/souravsingh/biopython/commit/b9996bf27c6c69e22ce1c78a18f5285ebf8b3fe0

I would suggest:

# Copyright 2017 by Peter Cock.  All rights reserved.
# Based on code Copyright 2002 by Thomas Hamelryck.  All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my mistake - I copy-pasted this but meant to put your name here.

Also I think it would be reasonable to dual license this file, so:

# Copyright 2017 by Sourav Singh.  All rights reserved.
# Based on code Copyright 2002 by Thomas Hamelryck.  All rights reserved.
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.

Comment thread Tests/test_PDB_NeighborSearch.py Outdated
al = [Atom() for j in range(100)]
ns = NeighborSearch(al)
for i in range(0, 6):
for i in [0, 1, 2, 3, 4, 5, 6]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use range(7) which gives 0, 1, 2, 3, 4, 5 ,6?

@peterjc

peterjc commented Aug 22, 2017

Copy link
Copy Markdown
Member

The tests are all failing on TravisCI (AppVeyor timed out during a download), eg

======================================================================
FAIL: test_NeighborSearch (test_PDB_NeighborSearch.NeighborSearchTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/biopython/biopython/Tests/test_PDB_NeighborSearch.py", line 27, in test_NeighborSearch
    self.assertEqual(i, len(ns.search_all(5.0)))
AssertionError: 0 != 5
----------------------------------------------------------------------

@souravsingh

Copy link
Copy Markdown
Contributor Author

@peterjc The original self-test gives the following output-

Found 3
Found 4
Found 5
Found 1
Found 4
Found 3
Found 4
Found 5
Found 1
Found 5
Found 1
Found 1
Found 3
Found 1
Found 1
Found 2
Found 4
Found 2
Found 2
Found 3

I believe the range won't work for testing such an output.

@peterjc

peterjc commented Aug 23, 2017

Copy link
Copy Markdown
Member

Perhaps something like this then if we expect between 1 and 5 hits?:

self.assertTrue(1 <= len(ns.search_all(5.0)) <= 5)

@souravsingh

Copy link
Copy Markdown
Contributor Author

@peterjc The tests are failing for Windows due to the KDTree module not compiled.

@peterjc

peterjc commented Aug 28, 2017 •

Copy link
Copy Markdown
Member

Well spotted. There are two issues here, first this test should be skipped if KDTree is not available, like:

test_KDTree ... skipping. C module in Bio.KDTree not compiled

That is done using the following snippet of code in test_KDTree.py,

try:
    from Bio.KDTree import _CKDTree
    del _CKDTree
except ImportError:
    from Bio import MissingExternalDependencyError
    raise MissingExternalDependencyError(
            "C module in Bio.KDTree not compiled")

Second, this points at something wrong in the AppVeyor configuration which I had not noticed until you spotted it.... logged as #1378. Thank you!

@souravsingh

Copy link
Copy Markdown
Contributor Author

There is a test written for NeighborSearch which is written here-

class NeighborTest(unittest.TestCase):
, but it is itself based on the self-test

@peterjc

peterjc commented Aug 28, 2017

Copy link
Copy Markdown
Member

Well spotted. OK, for this pull request you can just remove the self-test from Bio/PDB/NeighborSearch.py since a version of it already exists in Tests/test_PDB_KDTree.py

However, based on Eric's comments it would be great to open another pull request to improve that test in Tests/test_PDB_KDTree.py to use a fixed list of atom coordinates.

@souravsingh

Copy link
Copy Markdown
Contributor Author

Closing the PR in favor of a new PR

@souravsingh
souravsingh deleted the add-test branch August 28, 2017 15:25
@peterjc

peterjc commented Feb 27, 2019

Copy link
Copy Markdown
Member

Did you work on a new branch? I don't see another pull request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants