def calculate_asa(atoms, probe, n_sphere_point=960): """ Returns list of accessible surface areas of the atoms, using the probe and atom radius to define the surface. """ sphere_points = generate_sphere_points(n_sphere_point) points = np.array([ [a.pos.x, a.pos.y, a.pos.z] for a in atoms ]) #, dtype=np.float16) radii = np.array([a.radius for a in atoms]) #, dtype=np.float16) const = 4.0 * math.pi / len(sphere_points) test_point = Vector3d() areas = [] for i, atom_i in enumerate(atoms): neighbor_indices = find_neighbor_indices(points, radii, probe, i) n_neighbor = len(neighbor_indices) j_closest_neighbor = 0 radius = probe + atom_i.radius n_accessible_point = 0 for point in sphere_points: is_accessible = True test_point.x = point[0]*radius + atom_i.pos.x test_point.y = point[1]*radius + atom_i.pos.y test_point.z = point[2]*radius + atom_i.pos.z cycled_indices = range(j_closest_neighbor, n_neighbor) cycled_indices.extend(range(j_closest_neighbor)) for j in cycled_indices: atom_j = atoms[neighbor_indices[j]] r = atom_j.radius + probe diff_sq = pos_distance_sq(atom_j.pos, test_point) if diff_sq < r*r: j_closest_neighbor = j is_accessible = False break if is_accessible: n_accessible_point += 1 area = const*n_accessible_point*radius*radius areas.append(area) return areas
def calculate_asa(atoms, probe, n_sphere_point=960): """ Returns list of accessible surface areas of the atoms, using the probe and atom radius to define the surface. """ sphere_points = generate_sphere_points(n_sphere_point) const = 4.0 * math.pi / len(sphere_points) test_point = Vector3d() areas = [] for i, atom_i in enumerate(atoms): neighbor_indices = find_neighbor_indices(atoms, probe, i) n_neighbor = len(neighbor_indices) j_closest_neighbor = 0 radius = probe + atom_i.radius n_accessible_point = 0 for point in sphere_points: is_accessible = True test_point.x = point[0] * radius + atom_i.pos.x test_point.y = point[1] * radius + atom_i.pos.y test_point.z = point[2] * radius + atom_i.pos.z cycled_indices = range(j_closest_neighbor, n_neighbor) cycled_indices.extend(range(j_closest_neighbor)) for j in cycled_indices: atom_j = atoms[neighbor_indices[j]] r = atom_j.radius + probe diff_sq = pos_distance_sq(atom_j.pos, test_point) if diff_sq < r * r: j_closest_neighbor = j is_accessible = False break if is_accessible: n_accessible_point += 1 area = const * n_accessible_point * radius * radius areas.append(area) return areas