예제 #1
0
def get_gene_list(direction, extraction_id):
    """Returns gene list in plain text file based on gene signature ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    gene_list = _get_gene_list_by_direction(gene_signature, int(direction))
    gene_list_str = file_manager.get_file_contents_as_string(gene_list)
    response = Response(gene_list_str, mimetype='text/plain')
    return response
예제 #2
0
def get_gene_list(direction, extraction_id):
    """Returns gene list in plain text file based on gene signature ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    gene_list = _get_gene_list_by_direction(gene_signature, int(direction))
    gene_list_str = file_manager.get_file_contents_as_string(gene_list)
    response = Response(gene_list_str, mimetype='text/plain')
    return response
예제 #3
0
def get_extraction(extraction_id):
    """Handles GET request based on extraction ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    if gene_signature is None:
        return jsonify(
            {'error': 'No gene signatures with ID %s found' % extraction_id})
    else:
        return jsonify(gene_signature.serialize)
예제 #4
0
def perform_hierarchical_clustering(extraction_id):
    """Performs hierarchical clustering on a SOFT file.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    link = clustergrammer.from_soft_file(gene_signature)
    link = link + '&preview=true'
    return render_template('pages/clustergrammer.html',
                           clustergrammer_link=link,
                           results_url=config.RESULTS_URL,
                           extraction_id=gene_signature.extraction_id)
예제 #5
0
def get_extraction(extraction_id):
    """Handles GET request based on extraction ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    if gene_signature is None:
        return jsonify({
            'error': 'No gene signatures with ID %s found' % extraction_id
        })
    else:
        return jsonify(gene_signature.serialize)
예제 #6
0
def perform_hierarchical_clustering(extraction_id):
    """Performs hierarchical clustering on a SOFT file.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    link = clustergrammer.from_soft_file(gene_signature)
    link = link + '&preview=true'
    return render_template('pages/clustergrammer.html',
                           clustergrammer_link=link,
                           results_url=config.RESULTS_URL,
                           extraction_id=gene_signature.extraction_id)
예제 #7
0
def perform_soft_file_pca(extraction_id):
    """Performs PCA on a SOFT file, referenced by extraction_id.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    if gene_signature:
        pca_data = pca.from_soft_file(gene_signature.soft_file)
        pca_json = json.dumps(pca_data)
        return render_template('pages/pca.html',
                               pca_data=pca_json,
                               results_url=config.RESULTS_URL,
                               extraction_id=gene_signature.extraction_id)
예제 #8
0
def get_soft_file(extraction_id):
    """Returns SOFT file in plain text file based on gene signature ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    soft_file = gene_signature.soft_file.actual_text_file
    soft_file_str = ''
    for line in soft_file:
        print(line)
        soft_file_str += line
    response = Response(soft_file_str, mimetype='text/plain')
    return response
예제 #9
0
def get_soft_file(extraction_id):
    """Returns SOFT file in plain text file based on gene signature ID.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    soft_file = gene_signature.soft_file.actual_text_file
    soft_file_str = ''
    for line in soft_file:
        print line
        soft_file_str += line
    response = Response(soft_file_str, mimetype='text/plain')
    return response
예제 #10
0
def edit_result():
    """Edits gene signature, removing fields that are empty and adding new ones.
    """
    extraction_id = request.form.get('extraction_id')
    gene_signature = database.get_gene_signature(extraction_id)

    for opt_meta in gene_signature.optional_metadata:
        value = request.form.get(opt_meta.name)
        if not value:
            database.delete_object(opt_meta)
            continue
        opt_meta.value = value
        database.update_object(opt_meta)

    # Generate a new optional metadata field is requested.
    new_meta_name = request.form.get('new_metadata_name')
    new_meta_value = request.form.get('new_metadata_value')
    if new_meta_name and new_meta_value:
        new_opt_meta = OptionalMetadata(new_meta_name, new_meta_value)
        gene_signature.optional_metadata.append(new_opt_meta)
        database.update_object(gene_signature)

    # Update existing tags.
    tag_names = request_utils.get_param_as_list(request.form, 'tags')
    for tag in gene_signature.tags:
        if tag.name not in tag_names:
            database.delete_object(tag)
        else:
            tag_names.remove(tag.name)
    database.update_object(gene_signature)

    # Create any new tags. Note that any leftover tags are new ones.
    if len(tag_names) > 0:
        for tag_name in tag_names:
            tag = Tag(tag_name)
            gene_signature.tags.append(tag)
        database.update_object(gene_signature)

    return redirect(
        url_for('results_page.view_result', extraction_id=extraction_id))
예제 #11
0
def edit_result():
    """Edits gene signature, removing fields that are empty and adding new ones.
    """
    extraction_id = request.form.get('extraction_id')
    gene_signature = database.get_gene_signature(extraction_id)

    for opt_meta in gene_signature.optional_metadata:
        value = request.form.get(opt_meta.name)
        if not value:
            database.delete_object(opt_meta)
            continue
        opt_meta.value = value
        database.update_object(opt_meta)

    # Generate a new optional metadata field is requested.
    new_meta_name = request.form.get('new_metadata_name')
    new_meta_value = request.form.get('new_metadata_value')
    if new_meta_name and new_meta_value:
        new_opt_meta = OptionalMetadata(new_meta_name, new_meta_value)
        gene_signature.optional_metadata.append(new_opt_meta)
        database.update_object(gene_signature)

    # Update existing tags.
    tag_names = request_utils.get_param_as_list(request.form, 'tags')
    for tag in gene_signature.tags:
        if tag.name not in tag_names:
            database.delete_object(tag)
        else:
            tag_names.remove(tag.name)
    database.update_object(gene_signature)

    # Create any new tags. Note that any leftover tags are new ones.
    if len(tag_names) > 0:
        for tag_name in tag_names:
            tag = Tag(tag_name)
            gene_signature.tags.append(tag)
        database.update_object(gene_signature)

    return redirect(url_for('results_page.view_result',
                            extraction_id=extraction_id))
예제 #12
0
def view_result(extraction_id):
    """Renders extracted gene signature and associated metadata.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    if gene_signature is None:
        return render_template('pages/404.html')
    gene_signature = _process_extraction_for_view(gene_signature)

    use_crowdsourcing = False
    for tag in gene_signature.tags:
        if tag.name in CROWDSOURCING_TAGS:
            use_crowdsourcing = True

    if gene_signature.soft_file and gene_signature.soft_file.samples:
        show_viz = True
    else:
        show_viz = False

    if current_user.is_authenticated and current_user.name == 'admin':
        show_admin_controls = True
        tag_names = [t.name for t in gene_signature.tags]
    else:
        show_admin_controls = False
        tag_names = None

    if gene_signature.is_from_geo:
        return render_template('pages/results.html',
                               show_admin_controls=show_admin_controls,
                               tag_names=json.dumps(tag_names),
                               gene_signature=gene_signature,
                               show_viz=show_viz,
                               use_crowdsourcing=use_crowdsourcing)
    else:
        return render_template('pages/results-not-from-geo.html',
                               show_admin_controls=show_admin_controls,
                               tag_names=json.dumps(tag_names),
                               gene_signature=gene_signature)
예제 #13
0
def view_result(extraction_id):
    """Renders extracted gene signature and associated metadata.
    """
    gene_signature = database.get_gene_signature(extraction_id)
    if gene_signature is None:
        return render_template('pages/404.html')
    gene_signature = _process_extraction_for_view(gene_signature)

    use_crowdsourcing = False
    for tag in gene_signature.tags:
        if tag.name in CROWDSOURCING_TAGS:
            use_crowdsourcing = True

    if gene_signature.soft_file and gene_signature.soft_file.samples:
        show_viz = True
    else:
        show_viz = False

    if current_user.is_authenticated and current_user.name == 'admin':
        show_admin_controls = True
        tag_names = [t.name for t in gene_signature.tags]
    else:
        show_admin_controls = False
        tag_names = None

    if gene_signature.is_from_geo:
        return render_template('pages/results.html',
                               show_admin_controls=show_admin_controls,
                               tag_names=json.dumps(tag_names),
                               gene_signature=gene_signature,
                               show_viz=show_viz,
                               use_crowdsourcing=use_crowdsourcing)
    else:
        return render_template('pages/results-not-from-geo.html',
                               show_admin_controls=show_admin_controls,
                               tag_names=json.dumps(tag_names),
                               gene_signature=gene_signature)