Skip to content
This repository
Newer
Older
100644 62 lines (50 sloc) 2.079 kb
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
1 # Copyright 2009-2010 by Eric Talevich. All rights reserved.
2 # Revisions copyright 2010 by Peter Cock. All rights reserved.
3 #
4 # Converted by Eric Talevich from an older unit test copyright 2002
5 # by Thomas Hamelryck.
b1c85978 »
2012-12-04 Trim EOL whitespace (PEP8 W291, W293), batch 3.
6 #
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
7 # This code is part of the Biopython distribution and governed by its
8 # license. Please see the LICENSE file that should have been included
9 # as part of this package.
10
11 """Unit tests for those parts of the Bio.PDB module using Bio.KDTree."""
12 import unittest
13
14 try:
fd4449d5 »
2011-08-04 Tests and fix for Bug #3276, empty NeighborSearch results. Based on f…
15 from numpy import array
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
16 from numpy.random import random
17 except ImportError:
18 from Bio import MissingExternalDependencyError
9dfec356 »
2012-12-05 Zap redundant backslashes between brackets (PEP8 E502).
19 raise MissingExternalDependencyError(
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
20 "Install NumPy if you want to use Bio.PDB.")
21
22 try:
23 from Bio.KDTree import _CKDTree
24 except ImportError:
25 from Bio import MissingExternalDependencyError
9dfec356 »
2012-12-05 Zap redundant backslashes between brackets (PEP8 E502).
26 raise MissingExternalDependencyError(
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
27 "C module in Bio.KDTree not compiled")
28
29 from Bio.PDB.NeighborSearch import NeighborSearch
30
fd82a0a7 »
2012-12-06 Add blank lines where needed (PEP8 E302).
31
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
32 class NeighborTest(unittest.TestCase):
33 def test_neighbor_search(self):
34 """NeighborSearch: Find nearby randomly generated coordinates.
b1c85978 »
2012-12-04 Trim EOL whitespace (PEP8 W291, W293), batch 3.
35
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
36 Based on the self test in Bio.PDB.NeighborSearch.
37 """
38 class RandomAtom:
39 def __init__(self):
40 self.coord = 100 * random(3)
bfa8b256 »
2012-12-05 Add a blank line before and after functions (PEP8 E301).
41
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
42 def get_coord(self):
43 return self.coord
bfa8b256 »
2012-12-05 Add a blank line before and after functions (PEP8 E301).
44
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
45 for i in range(0, 20):
46 atoms = [RandomAtom() for j in range(100)]
47 ns = NeighborSearch(atoms)
48 hits = ns.search_all(5.0)
55abf4b4 »
2010-12-25 Can't compare lists to ints in Python 3
49 self.assertTrue(isinstance(hits, list), hits)
50 self.assertTrue(len(hits) >= 0, hits)
14977ce6 »
2013-10-05 Apply 2to3 ws_comma fixer (white space changes)
51 x = array([250, 250, 250]) # Far away from our random atoms
fd4449d5 »
2011-08-04 Tests and fix for Bug #3276, empty NeighborSearch results. Based on f…
52 self.assertEqual([], ns.search(x, 5.0, "A"))
53 self.assertEqual([], ns.search(x, 5.0, "R"))
54 self.assertEqual([], ns.search(x, 5.0, "C"))
55 self.assertEqual([], ns.search(x, 5.0, "M"))
56 self.assertEqual([], ns.search(x, 5.0, "S"))
57
162d02b9 »
2010-08-16 Split Bio.KDTree dependent parts of test_PDB.py into a separate file
58
59 if __name__ == '__main__':
60 runner = unittest.TextTestRunner(verbosity=2)
61 unittest.main(testRunner=runner)
Something went wrong with that request. Please try again.