Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Karmazin committed Dec 12, 2022
0 parents commit b1fbda8
Show file tree
Hide file tree
Showing 5 changed files with 860 additions and 0 deletions.
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions longevity2reporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Longevity2 reporter (pre alpha version) display your genome analysis related to longevity and disease risks

It consist now of 3 parts:
* Longevitymap report, show your longevity-related rsid and their influence.
* Cancer report, show cancer risks.
* Drug report, show how your genome influences drug effects.
* Coranary disease report, lists snps that influence on chanses to have coranary disease.
* Prs report, have poligenic risk scores.

It deppends on annotators: dbsnp, clinvar, omim, ncbigene, pubmed, gnomad, vcfinfo.
91 changes: 91 additions & 0 deletions longevity2reporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import json

from cravat.cravat_report import CravatReport
import sys
import datetime
import re
import csv
import zipfile
from pathlib import Path
import sqlite3
from mako.template import Template

class Reporter(CravatReport):

def __init__(self, args):
super().__init__(args)
self.savepath = args['savepath']


async def run(self):
self.setup()
self.write_data()
self.end()
pass


def setup(self):
self.input_database_path = f'{self.savepath}_longevity.sqlite'
self.db_conn = sqlite3.connect(self.input_database_path)
self.db_cursor = self.db_conn.cursor()
outpath = f'{self.savepath}.longevity2.html'
self.outfile = open(outpath, 'w', encoding='utf-8')
cur_path = str(Path(__file__).parent)
self.template = Template(filename=str(Path(__file__).parent)+"/template.html")


def write_table(self, name, json_fields = [], sort_field = "", sort_revers = False):
try:
sort_sql = ""
if sort_field != "":
sort_sql = " ORDER BY " + sort_field
if sort_revers:
sort_sql = sort_sql+" DESC"
else:
sort_sql = sort_sql+" ASC"

self.db_cursor.execute("SELECT * FROM "+name+sort_sql)
rows = self.db_cursor.fetchall()
res = []

for row in rows:
tmp = {}
for i, item in enumerate(self.db_cursor.description):
if item[0] in json_fields:
lst = json.loads(row[i])
if len(lst) == 0:
tmp[item[0]] = ""
else:
tmp[item[0]] = lst[0]
else:
tmp[item[0]] = row[i]
res.append(tmp)
self.data[name] = res
except Exception as e:
print("Warning:", e)


def write_data(self):
# self.data = {"test1":[1,2,3], "test2":["aa", "bbb", "cccc"]}
self.data = {}
self.write_table("prs", [], "id", True)
self.write_table("longevitymap", ["conflicted_rows", "description"], "weight", False)
self.write_table("cancer", [], "id", True)
self.write_table("coronary", [], "weight", False)
self.write_table("drugs", [], "id", True)


def end(self):
self.outfile.write(self.template.render(data=self.data))
self.outfile.close()
return Path(self.outfile.name).resolve()


### Don't edit anything below here ###
def main():
reporter = Reporter(sys.argv)
reporter.run()


if __name__ == '__main__':
main()
32 changes: 32 additions & 0 deletions longevity2reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
title: Longevity2
version: 0.3.0
type: reporter
description: Create report with longevity ralated information (pre alpha version). It deppends on postagregators .
output_filename_schema:
- '{run_name}.longevity2.html'
developer:
name: DNA-seq
organization: DNA-seq
email: karmazinalex@gmail.com
website: https://github.com/dna-seq/opencravat-longevity
citation: ''
requires:
- just_cancer
- just_coronary
- just_drugs
- just_longevitymap
- just_prs
tags:
- input/output
- reporters
- longevity
data_version: 0.1.3
release_note:
0.1.0: initial version
0.1.1: added prs support
0.1.2: bugfix rsid for prs, template improved
0.1.3: added Coronary arthery disease sub reporter, fixed bugs in prs sub report
0.1.4: in coranary sub report added color signaling and sorted by weight results
0.1.5: fixed bug in column acces for new version of oakvar
0.2.0: changed to fit new oakvar, not compatible with previuse versions of oak var
0.3.0: rebuilded reporter for new version of oakvar and postagregators
Loading

0 comments on commit b1fbda8

Please sign in to comment.