We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 606e240 commit e124676Copy full SHA for e124676
pyensembl/search.py
@@ -0,0 +1,20 @@
1
+"""
2
+Helper functions for searching over collections of PyEnsembl objects
3
4
+
5
+def find_nearest_locus(start, end, loci):
6
+ """
7
+ Finds nearest locus (object with method `distance_to_interval`) to the
8
+ interval defined by the given `start` and `end` positions.
9
+ Returns the distance to that locus, along with the locus object itself.
10
11
+ best_distance = float("inf")
12
+ best_locus = None
13
+ for locus in loci:
14
+ distance = locus.distance_to_interval(start, end)
15
16
+ if best_distance > distance:
17
+ best_distance = distance
18
+ best_locus = locus
19
20
+ return best_distance, best_locus
0 commit comments