-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3704dde
commit 1d09603
Showing
2 changed files
with
35 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
import sqlite3 | ||
from sqlite3 import Error | ||
from pathlib import Path | ||
|
||
|
||
class CoronaryRefHomo: | ||
|
||
rsid_map = {} | ||
rsid_map:dict[str, dict] = {} | ||
|
||
def init(self, reporter, sql_insert): | ||
def init(self, reporter, sql_insert:str) -> None: | ||
self.parent = reporter | ||
self.sql_insert = sql_insert | ||
|
||
|
||
def setup(self): | ||
sql = "SELECT rsID, Risk_allele FROM coronary_disease WHERE Ref_allele = Risk_allele" | ||
def setup(self) -> None: | ||
sql:str = "SELECT rsID, Risk_allele FROM coronary_disease WHERE Ref_allele = Risk_allele" | ||
self.parent.coronary_cursor.execute(sql) | ||
rows = self.parent.coronary_cursor.fetchall() | ||
rows:list = self.parent.coronary_cursor.fetchall() | ||
for rsid, risk_allele in rows: | ||
self.rsid_map[rsid] = {'exist':True, 'risk':risk_allele} | ||
|
||
|
||
def process_row(self, row): | ||
rsid = str(row['dbsnp__rsid']) | ||
rsid:str = str(row['dbsnp__rsid']) | ||
if rsid == '': | ||
return | ||
|
||
if not rsid.startswith('rs'): | ||
rsid = "rs"+rsid | ||
|
||
item = self.rsid_map.get(rsid) | ||
item:dict = self.rsid_map.get(rsid) | ||
if item: | ||
self.rsid_map[rsid]['exist'] = False | ||
|
||
|
||
def end(self): | ||
def end(self) -> None: | ||
for rsid in self.rsid_map: | ||
if self.rsid_map[rsid]['exist']: | ||
risk = self.rsid_map[rsid]['risk'] | ||
risk:str = self.rsid_map[rsid]['risk'] | ||
risk = risk+risk | ||
|
||
query = "SELECT Risk_allele, Gene, Genotype, Conclusion, Weight, PMID, Population, GWAS_study_design, P_value " \ | ||
query:str = "SELECT Risk_allele, Gene, Genotype, Conclusion, Weight, PMID, Population, GWAS_study_design, P_value " \ | ||
f"FROM coronary_disease WHERE rsID = '{rsid}' AND Genotype = '{risk}';" | ||
|
||
self.parent.coronary_cursor.execute(query) | ||
row = self.parent.coronary_cursor.fetchone() | ||
row:list = self.parent.coronary_cursor.fetchone() | ||
if row: | ||
task = (rsid, row[1], row[0], row[0]+"/"+row[0], row[3], row[4], row[5], row[6], row[7], row[8], | ||
task:tuple = (rsid, row[1], row[0], row[0]+"/"+row[0], row[3], row[4], row[5], row[6], row[7], row[8], | ||
self.parent.get_color(row[4], 0.6)) | ||
self.parent.longevity_cursor.execute(self.sql_insert, task) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters