Commit eeedb0bb authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-sc/cľonedb-with-indexes-depending-on-user' into 'dev'

Cľonedb with indexes depending on user

See merge request !266
parents 5740d20b b9c8df56
Pipeline #40759 failed with stages
in 5 minutes and 35 seconds
...@@ -313,12 +313,26 @@ Database.prototype = { ...@@ -313,12 +313,26 @@ Database.prototype = {
data: "sequences="+windows.join()+"&sample_set_id="+self.m.sample_set_id, data: "sequences="+windows.join()+"&sample_set_id="+self.m.sample_set_id,
xhrFields: {withCredentials: true}, xhrFields: {withCredentials: true},
success: function (result) { success: function (result) {
try {
res = jQuery.parseJSON(result);
result = res;
} catch (err) {}
self.connected = true; self.connected = true;
for (var i = 0; i < kept_clones.length; i++) { if (typeof result.success !== 'undefined' && result.success == 'false') {
self.m.clones[kept_clones[i]].seg.clonedb = processCloneDBContents(result[i]); console.log({
} "type": "flash",
m.shouldRefresh() "msg": result.message,
m.update() "priority": 2
});
self.connected = false;
} else {
for (var i = 0; i < kept_clones.length; i++) {
self.m.clones[kept_clones[i]].seg.clonedb = processCloneDBContents(result[i]);
}
m.shouldRefresh()
m.update()
}
}, },
error: function() { error: function() {
self.connected = false; self.connected = false;
......
...@@ -6,6 +6,8 @@ import os ...@@ -6,6 +6,8 @@ import os
import sys import sys
import imp import imp
from controller_utils import error_message
if request.env.http_origin: if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true' response.headers['Access-Control-Allow-Credentials'] = 'true'
...@@ -23,7 +25,7 @@ def index(): ...@@ -23,7 +25,7 @@ def index():
if request.vars['sequences'] == None or request.vars['sequences'] == ''\ if request.vars['sequences'] == None or request.vars['sequences'] == ''\
or request.vars['sample_set_id'] == None: or request.vars['sample_set_id'] == None:
return response.json({'error': 'Malformed request'}) return error_message('Malformed request')
return search_clonedb(request.vars['sequences'].split(','), int(request.vars['sample_set_id'])) return search_clonedb(request.vars['sequences'].split(','), int(request.vars['sample_set_id']))
...@@ -33,11 +35,17 @@ def search_clonedb(sequences, sample_set_id): ...@@ -33,11 +35,17 @@ def search_clonedb(sequences, sample_set_id):
clonedb = imp.load_source('clonedb', defs.DIR_CLONEDB+os.path.sep+'clonedb.py') clonedb = imp.load_source('clonedb', defs.DIR_CLONEDB+os.path.sep+'clonedb.py')
results = [] results = []
parent_group = get_default_creation_group(auth)[1]
for sequence in sequences: for sequence in sequences:
options = clonedb.build_grep_clones_options({'sequence': sequence+' -sample_set:%d' % sample_set_id}) options = clonedb.build_grep_clones_options({'sequence': sequence+' -sample_set:%d' % sample_set_id,
'index': 'clonedb_{}'.format(parent_group)})
args = grep_clones.parser.parse_args(options) args = grep_clones.parser.parse_args(options)
log.debug(args) try:
occurrences = grep_clones.launch_search(args) occurrences = grep_clones.launch_search(args)
except ValueError:
return error_message('Are you sure your account has an enabled CloneDB?')
except Exception as e:
return error_message(e.message)
for occ in occurrences: for occ in occurrences:
if 'tags' in occ and 'sample_set' in occ['tags']: if 'tags' in occ and 'sample_set' in occ['tags']:
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]))
......
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