module Bio.PDB.Structure.Neighbours(makeOctree,
findInRadius, findNearest,
AtomOctree(..))
where
import qualified Data.Octree as Oct
import Bio.PDB.Structure
import Bio.PDB.Iterable
import Data.Vector.V3
type AtomOctree = Oct.Octree Atom
extract :: Atom -> (Oct.Vector3, Atom)
extract (at@(Atom { coord = cvec,
atSerial = ser ,
element = elt })) = (cvec, at)
makeOctree :: Iterable a Atom => a -> AtomOctree
makeOctree = Oct.fromList . Prelude.map extract . itfoldr (:) []
findInRadius :: AtomOctree -> Double -> Vector3 -> [(Vector3, Atom)]
findInRadius = Oct.withinRange
findNearest :: AtomOctree -> Vector3 -> Maybe (Vector3, Atom)
findNearest = Oct.nearest