Ejemplo n.º 1
0
def comparisonpage(organism, transcriptome):
    global user_short_passed
    user_short_passed = False
    global local
    try:
        print local
    except:
        local = False
    try:
        user = current_user.name
    except:
        user = None
    organism = str(organism)
    connection = sqlite3.connect('{}/trips.sqlite'.format(config.SCRIPT_LOC))
    connection.text_factory = str
    cursor = connection.cursor()
    cursor.execute(
        "SELECT gwips_clade,gwips_organism,gwips_database,default_transcript from organisms WHERE organism_name = '{}';"
        .format(organism))
    result = (cursor.fetchone())
    gwips_clade = result[0]
    gwips_org = result[1]
    gwips_db = result[2]
    gwips_info = {
        "organism": gwips_org,
        "clade": gwips_clade,
        "database": gwips_db
    }
    default_tran = result[3]
    studyinfo_dict = fetch_study_info(organism)
    user_file_dict = {}
    if str(request.args.get('files')) != "None":
        colors = str(request.args.get('files')).split("_")
        for filelist in colors:
            all_items = filelist.split(",")
            files = []
            for item in all_items:
                if "#" in item:
                    color = item
                else:
                    files.append(item)
            user_file_dict[color] = files

    user_label_dict = {}
    if str(request.args.get('labels')) != "None":
        colors = str(request.args.get('labels')).split("_")
        for label in colors:
            all_items = label.split(",")
            for item in all_items:
                if "#" in item:
                    color = item
                else:
                    label = item
            user_label_dict[color] = label

    html_args = {
        "user_short": str(request.args.get('short')),
        "user_file_dict": user_file_dict,
        "user_label_dict": user_label_dict,
        "transcript": str(request.args.get('transcript')),
        "minread": str(request.args.get('minread')),
        "maxread": str(request.args.get('maxread')),
        "hili_start": str(request.args.get('hili_start')),
        "hili_stop": str(request.args.get('hili_stop')),
        "ambig": str(request.args.get('ambig')),
        "cov": str(request.args.get('cov')),
        "normalize": str(request.args.get('normalize')),
        "transcriptome": str(transcriptome)
    }

    accepted_studies = fetch_studies(user, organism, transcriptome)
    file_id_to_name_dict, accepted_studies, accepted_files, seq_types = fetch_files(
        accepted_studies)

    connection.close()
    return render_template('index_compare.html',
                           studies_dict=accepted_studies,
                           accepted_files=accepted_files,
                           gwips_info=gwips_info,
                           gwips_clade=gwips_clade,
                           gwips_org=gwips_org,
                           gwips_db=gwips_db,
                           organism=organism,
                           transcriptome=transcriptome,
                           default_tran=default_tran,
                           local=local,
                           html_args=html_args,
                           file_id_to_name_dict=file_id_to_name_dict,
                           studyinfo_dict=studyinfo_dict,
                           seq_types=seq_types)
def interactiveplotpage(organism, transcriptome):
    global user_short_passed
    user_short_passed = True
    global local
    try:
        print local
    except:
        local = False
    try:
        user = current_user.name
    except:
        user = None
    organism = str(organism)

    accepted_studies = fetch_studies(user, organism, transcriptome)
    file_id_to_name_dict, accepted_studies, accepted_files, seq_types = fetch_files(
        accepted_studies)
    connection = sqlite3.connect('{}/trips.sqlite'.format(config.SCRIPT_LOC))
    connection.text_factory = str
    cursor = connection.cursor()

    cursor.execute(
        "SELECT gwips_clade,gwips_organism,gwips_database,default_transcript from organisms WHERE organism_name = '{}' and transcriptome_list = '{}';"
        .format(organism, transcriptome))
    result = (cursor.fetchone())
    gwips_clade = result[0]
    gwips_org = result[1]
    gwips_db = result[2]
    gwips_info = {
        "organism": gwips_org,
        "clade": gwips_clade,
        "database": gwips_db
    }
    default_tran = result[3]
    studyinfo_dict = fetch_study_info(organism)
    user_transcript = request.args.get('tran')
    user_readscore = request.args.get('rs')
    user_hili = request.args.get('hili')
    user_generate_shorturl = request.args.get('genshort')
    user_files = request.args.get('files')
    user_minread = request.args.get('minread')
    user_maxread = request.args.get('maxread')
    user_dir = request.args.get('dir')
    user_line_graph = request.args.get('lg')
    user_ambig = request.args.get('ambig')
    user_cov = request.args.get('cov')
    user_nuc = request.args.get('nuc')
    user_short = request.args.get('short')
    user_crd = request.args.get('crd')

    if user_files != None:
        user_files = user_files.split(",")
        user_files = [str(x) for x in user_files]
    else:
        user_files = []

    user_ribo_studies = request.args.get('ribo_studies')
    if user_ribo_studies != None:
        user_ribo_studies = user_ribo_studies.split(",")
        user_ribo_studies = [str(x) for x in user_ribo_studies]
    else:
        user_ribo_studies = []
    user_rna_studies = request.args.get('rna_studies')
    if user_rna_studies != None:
        user_rna_studies = user_rna_studies.split(",")
        user_rna_studies = [str(x) for x in user_rna_studies]
    else:
        user_rna_studies = []

    if user_generate_shorturl == "F":
        user_generate_shorturl = False
    else:
        user_generate_shorturl = True

    user_hili_starts = []
    user_hili_stops = []
    try:
        for item in user_hili.split(","):
            user_hili_starts.append(int(item.split("_")[0]))
            user_hili_stops.append(int(item.split("_")[1]))
    except:
        user_hili_start = None
        user_hili_stop = None

    try:
        user_minread = int(user_minread)
        user_maxread = int(user_maxread)
    except:
        user_minread = None
        user_maxread = None
    advanced = 'True'
    connection.close()
    return render_template('index.html',
                           gwips_info=gwips_info,
                           gwips_clade=gwips_clade,
                           gwips_org=gwips_org,
                           gwips_db=gwips_db,
                           organism=organism,
                           transcriptome=transcriptome,
                           default_tran=default_tran,
                           user_transcript=user_transcript,
                           user_readscore=user_readscore,
                           user_hili_starts=user_hili_starts,
                           user_hili_stops=user_hili_stops,
                           local=local,
                           studies_dict=accepted_studies,
                           accepted_files=accepted_files,
                           user_files=user_files,
                           user_ribo_studies=user_ribo_studies,
                           user_rna_studies=user_rna_studies,
                           user_minread=user_minread,
                           user_maxread=user_maxread,
                           user_dir=user_dir,
                           user_line_graph=user_line_graph,
                           user_ambig=user_ambig,
                           user_cov=user_cov,
                           user_nuc=user_nuc,
                           user_short=user_short,
                           user_crd=user_crd,
                           studyinfo_dict=studyinfo_dict,
                           advanced=advanced,
                           seq_types=seq_types)