You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/primitive_obsession.md
+16-18
Original file line number
Diff line number
Diff line change
@@ -41,8 +41,8 @@ def read_in_gene(read, genome):
41
41
for chrom in genome:
42
42
if chrom[0] == read[0]:
43
43
for gene in chrom[2]:
44
-
starts_in = gene[1][1] <= read[1] < gene[1][2]
45
-
ends_in = gene[1][1] < read[2] <= gene[1][2]
44
+
starts_in = gene[1][1] <= read[1] <= gene[1][2]
45
+
ends_in = gene[1][1] <= read[2] <= gene[1][2]
46
46
same_sign = gene[1][3] == read[3]
47
47
if starts_in or ends_in:
48
48
returnTrue
@@ -51,7 +51,7 @@ def read_in_gene(read, genome):
51
51
52
52
> The code in this post was tested under python 3.10.4
53
53
54
-
We define a genome as a complex nested structure of built-in types (list, tuple, str, int). Then we write a function which will check whether an input read falls on a gene from a given genome.
54
+
We define a genome as a complex nested structure of built-in types (list, tuple, str, int). Then we write a function which will check whether an input read falls on a gene from a given genome. All intervals are 0-based and open.
55
55
56
56
Even with intuitive variable names (`gene` and not `g`) it takes a lot of mental effort to understand the nesting, and translate the numeric indices (e.g. `gene[1][1]`) into their meaning 🪆. This can make the code harder to understand and maintain.
57
57
@@ -129,7 +129,7 @@ from typing import Literal, NamedTuple, Optional
129
129
130
130
131
131
classInterval(NamedTuple):
132
-
"""An optionally stranded genomic interval."""
132
+
"""An optionally stranded, 0-based, open genomic interval."""
0 commit comments