Skip to content

Commit 196bb3e

Browse files
committed
resolved TODO comments in db.py and library.py
1 parent 3e0b0b9 commit 196bb3e

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/guidescanpy/flask/blueprints/library.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def library(
5555
frac_control: float = 0.0,
5656
append5: bool = False,
5757
):
58-
# TODO: Why is this \r\n and not just \n?
5958
genes = genes.splitlines()
6059

6160
library_info = get_library_info_by_gene(organism, genes, n_guides)
@@ -64,7 +63,6 @@ def library(
6463
results = []
6564
for i, genes in enumerate(genes_by_pool_index):
6665
n_essential_genes = round(frac_essential * len(genes))
67-
# TODO: randomize
6866
essential_genes = get_essential_genes(organism, n_essential_genes)
6967
essential_genes_library_info = get_library_info_by_gene(
7068
organism, essential_genes, n_guides
@@ -73,7 +71,6 @@ def library(
7371
n_control_guides = round(
7472
frac_control * len(genes)
7573
) # TODO: Clojure code does this, but it doesn't seem correct
76-
# TODO: randomize
7774
control_guides = get_control_guides(organism, n_control_guides)
7875

7976
for gene in genes:

src/guidescanpy/flask/db.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def create_region_query(organism, region):
9595
results = conn.execute(query, {"organism": organism, "entrez_id": region})
9696
for row in results.mappings():
9797
return_value = dict(row)
98-
# TODO: sqlite backend seems to return boolean as int
98+
9999
return_value["sense"] = bool(return_value["sense"])
100100
return return_value
101101

@@ -132,17 +132,21 @@ def get_library_info_by_gene(organism, genes, n_guides=6):
132132
def get_essential_genes(organism, n=1):
133133
conn = get_connection()
134134
query = text(
135-
"SELECT gene_symbol FROM essential_genes WHERE organism = :organism LIMIT :n"
135+
"SELECT gene_symbol FROM essential_genes WHERE organism = :organism ORDER BY RANDOM() LIMIT :n"
136136
)
137137
results = conn.execute(query, {"organism": organism, "n": n})
138-
return [r[0] for r in results] # TODO: Ugly!
138+
139+
return_value = []
140+
for row in results.mappings():
141+
return_value.append(row["gene_symbol"])
142+
return return_value
139143

140144

141145
def get_control_guides(organism, n=1):
142146
conn = get_connection()
143-
# TODO: Order by?
147+
144148
query = text(
145-
"SELECT * FROM libraries WHERE organism = :organism AND (grna_type='safe_targeting_control' OR grna_type='non_targeting_control') LIMIT :n"
149+
"SELECT * FROM libraries WHERE organism = :organism AND (grna_type='safe_targeting_control' OR grna_type='non_targeting_control') ORDER BY RANDOM() LIMIT :n"
146150
)
147151
results = conn.execute(query, {"organism": organism, "n": n})
148152
return [dict(row) for row in results.mappings()]

0 commit comments

Comments
 (0)