Exemple #1
0
def isotype_page(isotype_name, release=config['DATASET_RELEASE']):
    """
        Isotype page
    """
    isotype = query_strains(isotype_name=isotype_name)
    if not isotype:
        abort(404)

    # Fetch isotype images
    photos = list_release_files(f"photos/isolation/{isotype_name}")
    photo_set = {}
    for row in photos:
        if 'thumb' not in row:
            strains = basename(row).replace(".jpg", "").split("_")[1:]
            photo_set[row.replace(".jpg", ".thumb.jpg")] = strains

    # High impact variants
    logger.info(release)

    VARS = {
        "title": f"Isotype {isotype_name}",
        "isotype": isotype,
        "isotype_name": isotype_name,
        "isotype_ref_strain": [x for x in isotype if x.isotype_ref_strain][0],
        "strain_json_output": dump_json(isotype),
        "photo_set": photo_set
    }
    return render_template('strain/isotype.html', **VARS)
Exemple #2
0
def map_page():
    """
        Global strain map shows the locations of all wild isolates
        within the SQLite database.
    """
    VARS = {
        'title': "Global Strain Map",
        'strain_listing': dump_json(get_strains(known_origin=True))
    }
    return render_template('strain/global_strain_map.html', **VARS)
def store_item(kind, name, **kwargs):
    ds = google_datastore()
    try:
        exclude = kwargs.pop('exclude_from_indexes')
    except KeyError:
        exclude = False
    if exclude:
        m = datastore.Entity(key=ds.key(kind, name), exclude_from_indexes=exclude)
    else:
        m = datastore.Entity(key=ds.key(kind, name))
    for key, value in kwargs.items():
        if isinstance(value, dict):
            m[key] = 'JSON:' + dump_json(value)
        else:
            m[key] = value
    ds.put(m)
def isotype_page(isotype_name):
    """
        Isotype page
    """
    isotype = query_strains(isotype_name=isotype_name)
    if not isotype:
        abort(404)

    # Fetch isotype images
    photos = list_release_files(f"photos/isolation/{isotype_name}")
    photo_set = {}
    for row in photos:
        if 'thumb' not in row:
            strains = basename(row).replace(".jpg", "").split("_")[1:]
            photo_set[row.replace(".jpg", ".thumb.jpg")] = strains

    # High impact variants
    soft_variant = requests.get(
        f"https://storage.googleapis.com/elegansvariation.org/releases/{DATASET_RELEASE}/variation/sample_summary/soft.isotype_summary.json"
    ).json()
    hard_variant = requests.get(
        f"https://storage.googleapis.com/elegansvariation.org/releases/{DATASET_RELEASE}/variation/sample_summary/hard.isotype_summary.json"
    ).json()

    soft_variant = [x for x in soft_variant if x['isotype'] == isotype_name][0]
    hard_variant = [x for x in hard_variant if x['isotype'] == isotype_name][0]

    VARS = {
        "title": isotype_name,
        "isotype": isotype,
        "isotype_name": isotype_name,
        "reference_strain": [x for x in isotype if x.reference_strain][0],
        "strain_json_output": dump_json(isotype),
        "photo_set": photo_set,
        "soft_variant": soft_variant,
        "hard_variant": hard_variant
    }
    return render_template('strain/strain.html', **VARS)