Ejemplo n.º 1
0
def data_page():
    bcs = OrderedDict([("Data", None)])
    title = "Data"
    from cendr import build
    strain_listing = strain.select().filter(
        strain.isotype != None).order_by(strain.isotype).execute()
    return render_template('data.html', **locals())
Ejemplo n.º 2
0
def statistics():
    title = "Site Statistics"
    bcs = OrderedDict([("About", url_for("about")), ("Statistics", None)])

    # Number of reports
    n_reports = report.select().count()
    n_traits = trait.select().count()
    n_significant_mappings = mapping.select().count()
    n_distinct_strains = strain.select(strain.strain).distinct().count()
    n_distinct_isotypes = strain.select(strain.isotype).filter(strain.isotype != None).distinct().count()

    # Collection dates
    collection_dates = list(strain.select().filter(
        strain.isotype != None, strain.isolation_date != None).order_by(strain.isolation_date).execute())

    return render_template('statistics.html', **locals())
Ejemplo n.º 3
0
def download_script(filetype):
    strain_listing = strain.select().filter(
        strain.isotype != None).order_by(strain.isotype).execute()
    download_page = render_template('download_script.sh', **locals())
    response = make_response(download_page)
    response.headers["Content-Type"] = "text/plain"
    return response
Ejemplo n.º 4
0
def about():
	# About us Page - directs to other pages.
    title = "About"
    bcs = OrderedDict([("About", None)])
    strain_listing = list(strain.select().filter(strain.isotype.is_null() == False)
        .filter(strain.latitude.is_null() == False).execute())
    strain_listing = json.dumps([x.__dict__["_data"] for x in strain_listing], default=json_serial)
    return render_template('about.html', **locals())
Ejemplo n.º 5
0
def map_page():
    title = "Global Strain Map"
    bcs = OrderedDict([("Strain", url_for("strain_listing_page")), ("Global-Strain-Map", "")])
    strain_list_dicts = []
    strain_listing = list(strain.select().filter(strain.reference_strain == True)
        .filter(strain.latitude.is_null() == False).execute())
    strain_listing = json.dumps([x.__dict__["_data"] for x in strain_listing], default=json_serial)
    return render_template('map.html', **locals())
Ejemplo n.º 6
0
 def get(self, isotype_name):
     """
         Return all strains within an isotype.
     """
     strain_data = list(strain.select(
         strain.strain).filter(strain.isotype == isotype_name).execute())
     response = [x.strain for x in strain_data]
     return jsonify(response)
Ejemplo n.º 7
0
 def get(self):
     """
         Return information for all strains.
     """
     strain_data = list(strain.select(
         *PEEWEE_FIELDS_LIST).tuples().execute())
     response = [OrderedDict(zip(FIELDS, x)) for x in strain_data]
     return jsonify(response)
Ejemplo n.º 8
0
 def get(self, strain_name):
     """
         Return information for an individual strain.
     """
     strain_data = list(strain.select(
         *PEEWEE_FIELDS_LIST).filter(strain.strain == strain_name)
                             .tuples()
                             .execute())
     response = OrderedDict(zip(FIELDS, strain_data[0]))
     print response, "RESPONSE"
     return jsonify(response)
Ejemplo n.º 9
0
def strain_metadata():
    strain_listing = list(strain.select().filter(
        strain.isotype != None).tuples().execute())
    def generate():
        yield '\t'.join(strain._meta.sorted_field_names[1:21]) + "\n"
        for row in strain_listing:
            row = list(row)
            for k, f in enumerate(row):
                if type(f) == unicode:
                    row[k] = f.encode('ascii', 'ignore')
            yield '\t'.join(map(str, row[1:21])) + "\n"
    return Response(generate(), mimetype="text/tab-separated-values")
Ejemplo n.º 10
0
def browser(chrom = "III", start = 11746923, end = 11750250, tracks="mh"):
    bcs = OrderedDict([("Data", "/data"), ("Browser", None)])
    title = "Browser"
    
    putative_impact = {'l': 'LOW', 'm':'MODERATE', 'h': 'HIGH'}
    var_eff = [putative_impact[x] if x else '' for x in tracks]
    putative_impact_items = putative_impact.items()
    
    from cendr import build
    
    isotype_listing = list(strain.select(strain.isotype).distinct().filter(
                                    strain.isotype != None).order_by(strain.isotype).dicts().execute())
    isotypes = [x["isotype"] for x in isotype_listing]
    
    return render_template('browser.html', **locals())
Ejemplo n.º 11
0
def strain_listing_page():
    bcs = OrderedDict([("Strain", None)])
    title = "Strain Catalog"

    if 'warning' in request.args:
        warning = request.args["warning"]

    strain_listing = strain.select(strain.strain,
                                   strain.reference_strain,
                                   strain.isotype,
                                   strain.previous_names,
                                   strain.set_1,
                                   strain.set_2,
                                   strain.set_3,
                                   strain.set_4,
                                   strain.set_divergent).filter(strain.isotype != None).order_by(strain.isotype).execute()
    return render_template('strain_catalog.html', **locals())
Ejemplo n.º 12
0
def gwa():
    title = "Perform Mapping"
    bcs = OrderedDict([("Perform-Mapping", None)])

    # Generate list of allowable strains
    query = (
        strain.select(strain.strain, strain.isotype, strain.previous_names)
        .filter(strain.isotype.is_null() == False)
        .execute()
    )
    qresults = list(itertools.chain(*[[x.strain, x.isotype, x.previous_names] for x in query]))
    qresults = set([x for x in qresults if x != None])
    qresults = list(itertools.chain(*[x.split("|") for x in qresults]))

    embargo_release = (datetime.now(pytz.timezone("America/Chicago")) + relativedelta(years=1)).strftime("%m/%d/%Y")

    strain_list = json.dumps(qresults)
    return render_template("gwa.html", **locals())
Ejemplo n.º 13
0
def fetch_geo_gt(chrom, pos):
    """
        Fetch genotypes with strain geographic information
    """
    gt = get_gt(chrom, pos)
    strain_locations = list(strain.select(strain.isotype,
                                          strain.latitude,
                                          strain.longitude)
                .filter(strain.latitude != None)
                .distinct().dicts().execute())
    strain_locations = {x["isotype"]: x for x in strain_locations}
    for i in gt:
        if i["SAMPLE"] in strain_locations and i["GT"] in ["0/0", "1/1"]:
            gts = {"TGT": i["TGT"], "GT": i["GT"]}
            strain_locations[i["SAMPLE"]].update(gts)
        else:
            if i["SAMPLE"] in strain_locations:
                del strain_locations[i["SAMPLE"]]
    return strain_locations.values()