예제 #1
0
def from_table(form):
    raw_table = pd.read_csv(form.input_file.data,
                            delimiter='\t',
                            comment='#',
                            header=0,
                            index_col=0).dropna(how='all')
    root = models.Tree.objects().get(source=form.target.data)['tree']
    nodes = tree.get_nodes(root)
    entry_to_layer = dict(map(lambda x: (x['entry'], x['layer']), nodes))

    profile = []
    for entry in raw_table.index:
        profile.append({
            'entry': entry,
            'layer': analysis.get_layer(entry, entry_to_layer),
            'values': [raw_table.ix[entry].tolist()]
        })
    colors = []
    if form.color_file.data:
        colors = pd.read_csv(form.color_file.data, header=None,
                             delimiter='\t').as_matrix().tolist()
    utcnow = datetime.datetime.utcnow()
    return models.Profile(
        profile_id=uuid.uuid4(),
        profile=profile,
        series=['Raw'],
        columns=[raw_table.columns.tolist()],
        colors=colors,
        target=form.target.data,
        description=form.description.data,
        added_at=utcnow,
        expire_at=utcnow +
        datetime.timedelta(days=app.config['FUNCTREE_PROFILE_TTL_DAYS']),
        private=form.private.data).save().profile_id
예제 #2
0
def from_json(form):
    raw_data = json.load(form.input_file.data)
    utcnow = datetime.datetime.utcnow()
    return models.Profile(
        profile_id=uuid.uuid4(),
        profile=raw_data[0]['profile'],
        series=raw_data[0]['series'],
        columns=raw_data[0]['columns'],
        colors=raw_data[0]['colors'],
        target=form.target.data,
        description=form.description.data,
        added_at=utcnow,
        expire_at=utcnow +
        datetime.timedelta(days=app.config['FUNCTREE_PROFILE_TTL_DAYS']),
        private=form.private.data).save().profile_id
예제 #3
0
def route_init_profiles():
    f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/data/example/profile.json'), 'r')
    input_data = json.load(f)[0]
    models.Profile.objects.all().delete()
    models.Profile(
        profile_id=uuid.uuid4(),
        profile=input_data['profile'],
        series=input_data['series'],
        columns=input_data['columns'],
        target=input_data['target'],
        description=input_data['description'],
        added_at=datetime.datetime.utcnow(),
        expire_at=datetime.datetime(2101, 1, 1),
        private=False,
        locked=True
    ).save()
    return flask.redirect(flask.url_for('route_admin'))
예제 #4
0
def from_table(form):
    result = calc_coverages(f=form.input_file.data, target=form.target.data)
    colors = []
    if form.color_file.data:
        colors = pd.read_csv(form.color_file.data, header=None,
                             delimiter='\t').as_matrix().tolist()
    utcnow = datetime.datetime.utcnow()
    return models.Profile(
        profile_id=uuid.uuid4(),
        profile=result['profile'],
        series=result['series'],
        columns=result['columns'],
        colors=colors,
        target=form.target.data,
        description=form.description.data,
        added_at=utcnow,
        expire_at=utcnow +
        datetime.timedelta(days=app.config['FUNCTREE_PROFILE_TTL_DAYS']),
        private=form.private.data).save().profile_id