Skip to content

Commit

Permalink
Remove duplicate get_neighboring_atoms (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjrosengrant authored Oct 5, 2023
1 parent 17db4d2 commit e1a5978
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions cookbook/00_Template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,6 @@
" for targ_atom in mol.atoms:\n",
" if targ_atom.position.unpack() in near_point_set:\n",
" neighbor_atoms.append(targ_atom)\n",
" return neighbor_atoms\n",
"\n",
"\n",
"def get_neighboring_atoms(target_reference: structure.Complex, selected_atoms: list, radius=5):\n",
" \"\"\"Use KDTree to find target atoms within site_size radius of selected atoms.\n",
" \n",
" returns a list of atoms within `site_size` angstroms of the ligand.\n",
" \"\"\"\n",
" mol = next(\n",
" mol for i, mol in enumerate(target_reference.molecules)\n",
" if i == target_reference.current_frame)\n",
" ligand_positions = [atom.position.unpack() for atom in selected_atoms]\n",
" target_atoms = itertools.chain(*[ch.atoms for ch in mol.chains if not ch.name.startswith(\"H\")])\n",
" target_tree = KDTree([atom.position.unpack() for atom in target_atoms])\n",
" target_point_indices = target_tree.query_ball_point(ligand_positions, radius)\n",
" near_point_set = set()\n",
" for point_indices in target_point_indices:\n",
" for point_index in point_indices:\n",
" near_point_set.add(tuple(target_tree.data[point_index]))\n",
" neighbor_atoms = []\n",
" for targ_atom in mol.atoms:\n",
" if targ_atom.position.unpack() in near_point_set:\n",
" neighbor_atoms.append(targ_atom)\n",
" return neighbor_atoms"
]
},
Expand Down

0 comments on commit e1a5978

Please sign in to comment.