Biopython.KDTree库中的“search”和所有其他方法将输出为“None”,尽管KDTree已成功创建

Biopython.KDTree库中的“search”和所有其他方法将输出为“None”,尽管KDTree已成功创建,python,bioinformatics,biopython,kdtree,Python,Bioinformatics,Biopython,Kdtree,以下是我的代码片段,用于创建KDTree并搜索以给定中心为半径的点: 代码段: threed_array = np.array(my_list, np.float_) atom_kdtree.set_coords(threed_array) try: print(atom_kdtree.built) print(atom_kdtree.search(threed_array[1], 100.00000000)) except Exception, err: prin

以下是我的代码片段,用于创建KDTree并搜索以给定中心为半径的点:

代码段:

threed_array = np.array(my_list, np.float_)
atom_kdtree.set_coords(threed_array)

try:

    print(atom_kdtree.built)
    print(atom_kdtree.search(threed_array[1], 100.00000000))

except Exception, err:
    print traceback.format_exc()
    print sys.exc_info()[0]
输出:

1
None
my_list是三维空间中点的坐标列表。三维数组是numpy nd数组

因此,KDTree.builded将输出作为“1”“搜索”给出“无”。我是否错过了构建KDTree的任何步骤?

问题是atom_KDTree.search不返回任何内容,它只执行搜索

你必须进行搜索,然后询问问题点。即

my_list = ([0, 0, 0], 
           [1, 1, 1], 
           [3, 3, 3]) 

threed_array = np.array(my_list, np.float_)
atom_kdtree = KDTree(3)
atom_kdtree.set_coords(threed_array)

# The search is done here. Every point within a radious < 2 from [0, 0, 0].
atom_kdtree.search(threed_array[0], 2.00000000)

# Here we print the points
print(atom_kdtree.get_indices())
print(atom_kdtree.get_radii())
也就是说:点0和1与点0、0、0的距离在radious<2范围内,与该点的距离为0和1.73205078。点3、3、3最远,因此未显示

[0 1]
[ 0.          1.73205078]