import sys
import isca_me_util

# config file
DATA_DIR = '../conf'
CONFIG = os.path.join(DATA_DIR, '.isca_config')
STD_FIELD_FILE = os.path.join(DATA_DIR, 'standard_field.ini')
RECENT_REVIEW_HTML = "recent_review.html"

if __name__ == "__main__":

    gene_symbol_hash = {}
    (user, passwd) = isca_me_util.ParseLoginConfig(CONFIG)
    jira = isca_me_util.JiraConnect(user, passwd)
    ISCA_dict = isca_me_util.GetFieldDict(STD_FIELD_FILE, 'ISCA')
    issue_list = isca_me_util.GetIssuesByJQL(jira, 'filter=13642 ORDER BY updated DESC',
                                             sys.stdout)

    FH_HTML = open(RECENT_REVIEW_HTML, 'w')
    print("<h3>Genes/Regions Recently Reviewed</h3>", file=FH_HTML)
    print("<table data-jig=\"ncbigrid\">", file=FH_HTML)
    print("\t<thead>\n\t<tr>", file=FH_HTML)
    print("\t<th>Gene/Region name</th>", file=FH_HTML)
    print("\t<th class=\"score_col\">Haploinsufficiency score</th>", file=FH_HTML)
    print("\t<th class=\"score_col\">Triplosensitivity score</th>", file=FH_HTML)
    print("\t<th>Date reviewed</th>", file=FH_HTML)
    print("\t</tr>\n\t</thead>", file=FH_HTML)
    print("\t<tbody>", file=FH_HTML)

    for issue in issue_list:
        try:
            name, href_prefix = '', ''
import sys
import os
import isca_me_util

# config file
DATA_DIR = '../conf'
CONFIG = os.path.join(DATA_DIR, '.isca_config')
STD_FIELD_FILE = os.path.join(DATA_DIR, 'standard_field.ini')
# filter id
FILTER_ID = 10632

if __name__ == "__main__":
    (user, passwd) = isca_me_util.ParseLoginConfig(CONFIG)
    jira = isca_me_util.JiraConnect(user, passwd)
    ISCA_dict = isca_me_util.GetFieldDict(STD_FIELD_FILE, 'ISCA')
    issue_list = isca_me_util.GetIssuesByJQL(jira, 'filter=' + str(FILTER_ID),
                                             sys.stdout)

    ret_list = []
    gene_loc_dict, region_loc_dict = {}, {}
    region_name_dict = {}
    designated_fields = [
        'Resolution', 'Status', 'GRCh38 Genome Position', 'Type', 'Summary',
        'ISCA Haploinsufficiency score', 'ISCA Triplosensitivity score',
        'OMIM Link', 'ExAC pLI score'
    ]
    for issue in issue_list:
        try:
            value_dict = isca_me_util.IssueEntries(issue, ISCA_dict,
                                                   designated_fields)

            # gene tickect does not have region name
DATA_DIR = '../conf'
CONFIG = os.path.join(DATA_DIR, '.isca_config')
STD_FIELD_FILE = os.path.join(DATA_DIR, 'standard_field.ini')
REGION_OUT_HTML = "pathogenic_region_body.html"

if __name__ == "__main__":

    gene_symbol_hash = {}
    (user, passwd) = isca_me_util.ParseLoginConfig(CONFIG)
    jira = isca_me_util.JiraConnect(user, passwd)
    ISCA_dict = isca_me_util.GetFieldDict(STD_FIELD_FILE, 'ISCA')
    #query_str = ('project = ISCA AND issuetype in (\"ISCA Region Curation\") '
    #             'AND labels in (\"nstd45pathogenic\") ')
    #query_str = ('filter = 14035 AND project = ISCA AND labels = Recurrent ORDER BY cf[10202] ASC')
    query_str = ('filter=14035')
    issue_list = isca_me_util.GetIssuesByJQL(jira, query_str, sys.stdout)
    designated_fields = [
        'ISCA Region Name', 'ISCA Haploinsufficiency score',
        'ISCA Triplosensitivity score', 'GRCh37 Genome Position', 'Components',
        'Status', 'Resolution'
    ]

    FH_HTML = open(REGION_OUT_HTML, 'w')
    for issue in issue_list:
        try:
            value_dict = isca_me_util.IssueEntries(issue, ISCA_dict,
                                                   designated_fields)
            region_name = value_dict['ISCA Region Name']
            gain_score = value_dict['ISCA Triplosensitivity score']
            loss_score = value_dict['ISCA Haploinsufficiency score']
            genome_pos = value_dict['GRCh37 Genome Position']