Commit a93b02af authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-s/2933-tags-in-clonedb' into 'dev'

Tags in clonedb

Closes #2933

See merge request !292
parents 2a263ddf c6730089
Pipeline #41179 passed with stages
in 4 minutes and 31 seconds
...@@ -335,7 +335,7 @@ Database.prototype = { ...@@ -335,7 +335,7 @@ Database.prototype = {
self.connected = false; self.connected = false;
} else { } else {
for (var i = 0; i < kept_clones.length; i++) { for (var i = 0; i < kept_clones.length; i++) {
self.m.clones[kept_clones[i]].seg.clonedb = processCloneDBContents(result[i]); self.m.clones[kept_clones[i]].seg.clonedb = processCloneDBContents(result[i], self.m);
} }
m.shouldRefresh() m.shouldRefresh()
m.update() m.update()
......
...@@ -51,18 +51,22 @@ def search_clonedb(sequences, sample_set_id): ...@@ -51,18 +51,22 @@ def search_clonedb(sequences, sample_set_id):
info = get_info_of_viewable_sample_set([int(sample_id) for sample_id in occ['tags']['sample_set']], int(occ['tags']['config_id'][0])) info = get_info_of_viewable_sample_set([int(sample_id) for sample_id in occ['tags']['sample_set']], int(occ['tags']['config_id'][0]))
occ['tags']['sample_set_viewable'] = info['viewable'] occ['tags']['sample_set_viewable'] = info['viewable']
occ['tags']['sample_set_name'] = info['name'] occ['tags']['sample_set_name'] = info['name']
occ['tags']['sample_tags'] = info['sample_tags']
config_db = db.config[occ['tags']['config_id'][0]] config_db = db.config[occ['tags']['config_id'][0]]
occ['tags']['config_name'] = [config_db.name if config_db else None] occ['tags']['config_name'] = [config_db.name if config_db else None]
results.append(occurrences) results.append(occurrences)
return response.json(results) return response.json(results)
def get_info_of_viewable_sample_set(sample_sets, config): def get_info_of_viewable_sample_set(sample_sets, config):
info = {'viewable': [], 'name': []} info = {'viewable': [], 'name': [], 'sample_tags': []}
for sample_id in sample_sets: for sample_id in sample_sets:
viewable = auth.can_view_sample_set(sample_id, auth.user) viewable = auth.can_view_sample_set(sample_id, auth.user)
info['viewable'].append(viewable) info['viewable'].append(viewable)
if viewable: if viewable:
info['name'].append(get_sample_name(sample_id)) info['name'].append(get_sample_name(sample_id))
tags = get_sample_set_tags(sample_id)
for row in tags:
info['sample_tags'].append("#" + row.name)
else: else:
info['name'].append(None) info['name'].append(None)
return info return info
...@@ -138,3 +138,13 @@ def get_public_group_id(group_ids): ...@@ -138,3 +138,13 @@ def get_public_group_id(group_ids):
if (len(public_group) > 0 and public_group[0].id not in group_ids): if (len(public_group) > 0 and public_group[0].id not in group_ids):
return public_group[0].id return public_group[0].id
return -1 return -1
def get_sample_set_tags(sample_id):
sample_set = db.sample_set[sample_id]
sample_type = sample_set.sample_type
table = db(db[sample_type].sample_set_id == sample_id).select()
for row in table:
tag_ref = db((row.id == db.tag_ref.record_id)
& (db.tag_ref.table_name == sample_type)
& (db.tag_ref.tag_id == db.tag.id)).select(db.tag.name)
return tag_ref
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment