Commit 0ea6a11f authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

Merge branch 'feature-sc/4219-config-par-groupe' into 'dev'

Resolve "Avoir un classement par groupe des config proposées"

Closes #4219

See merge request !627
parents 402bb118 f1df48e3
Pipeline #135112 failed with stages
in 8 minutes and 56 seconds
......@@ -18,6 +18,7 @@ def index():
query = db((auth.vidjil_accessible_query(PermissionEnum.read_config.value, db.config) | auth.vidjil_accessible_query(PermissionEnum.admin_config.value, db.config) ) ).select(orderby=~db.config.name)
used_query = db(db.results_file.config_id > 0).select(db.results_file.config_id, distinct=True)
used_configs = [row.config_id for row in used_query]
classification = db( (db.classification) ).select()
mes = u"Access config list"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': -1, 'table_name': 'config'})
......@@ -25,12 +26,14 @@ def index():
return dict(message=T('Configs'),
query=query,
used_configs=used_configs,
classification=classification,
isAdmin = auth.is_admin())
def add():
if (auth.can_create_config()):
return dict(message=T('Add config'))
classification = db( (db.classification) ).select()
return dict(message=T('Add config'), classification=classification)
return error_message(ACCESS_DENIED)
......@@ -45,13 +48,20 @@ def add_form():
if request.vars[field] == "" :
error += field+" needed, "
## test if classification id exist
classification = db(db.classification.id == request.vars["config_classification"]).select()
if len(classification) == 0:
error += "classification id don't exist, "
if error=="" :
config_id = db.config.insert(name=request.vars['config_name'],
info=request.vars['config_info'],
command=request.vars['config_command'],
fuse_command=request.vars['config_fuse_command'],
program=request.vars['config_program']
program=request.vars['config_program'],
classification=request.vars['config_classification']
)
user_group = None
......@@ -83,8 +93,9 @@ def add_form():
def edit():
if (auth.can_modify_config(request.vars['id'])):
mes = u"Load config edit form"
classification = db( (db.classification) ).select()
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return dict(message=T('edit config'))
return dict(message=T('edit config'), classification=classification)
return error_message(ACCESS_DENIED)
......@@ -98,6 +109,11 @@ def edit_form():
for field in required_fields:
if request.vars[field] == "" :
error += field+" needed, "
## test if classification id exist
classification = db(db.classification.id == request.vars["config_classification"]).select()
if len(classification) == 0:
error += "classification id don't exist, "
if error=="" :
......@@ -105,7 +121,8 @@ def edit_form():
info=request.vars['config_info'],
command=request.vars['config_command'],
fuse_command=request.vars['config_fuse_command'],
program=request.vars['config_program']
program=request.vars['config_program'],
classification=request.vars['config_classification']
)
res = {"redirect": "config/index",
......
......@@ -4,6 +4,7 @@ import vidjil_utils
import time
import json
from vidjilparser import VidjilParser
from collections import defaultdict
import operator
import math
......@@ -129,7 +130,9 @@ def index():
pre_process_list = {}
for row in query_pre_process:
pre_process_list[row.id] = row.name
classification = getConfigsByClassification()
log.info('sample_set (%s)' % request.vars["id"], extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "sample_set"})
......@@ -148,6 +151,7 @@ def index():
analysis_filename = analysis_filename,
sample_type = db.sample_set[request.vars["id"]].sample_type,
config=config,
classification=classification,
tag_decorator=tag_decorator)
## return a list of generic sample_sets
......@@ -262,6 +266,8 @@ def stats():
else:
result = sorted(result, key = lambda row : row.id, reverse=not reverse)
classification = getConfigsByClassification()
result = helper.filter(search, result)
log.info("%s stat list %s" % (request.vars["type"], search), extra={'user_id': auth.user.id,
'record_id': None,
......@@ -273,6 +279,7 @@ def stats():
helper = helper,
group_ids = group_ids,
isAdmin = isAdmin,
classification=classification,
reverse = False)
def result_files():
......@@ -679,13 +686,34 @@ def custom():
log.info("load compare list", extra={'user_id': auth.user.id, 'record_id': None, 'table_name': "results_file"})
log.debug("sample_set/custom (%.3fs) %s" % (time.time()-start, search))
classification = getConfigsByClassification()
return dict(query=query,
config_id=config_id,
config=config,
helper=helper,
tag_decorator=tag_decorator,
classification=classification,
group_ids=group_ids)
def getConfigsByClassification():
""" Return list of available and auth config, classed by classification values """
i = 0
classification = defaultdict( lambda: {"info":"", "name":"", "configs":[]} )
if auth.can_process_sample_set(request.vars['id']) :
for class_elt in db( (db.classification)).select(orderby=db.classification.id):
configs = db( (db.config.classification == class_elt.id) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db.config) | auth.vidjil_accessible_query(PermissionEnum.admin.value, db.config) ) ).select(orderby=db.config.id)
if len(configs): # don't show empty optgroup
classification["%02d_%s" % (i, class_elt)]["name"] = class_elt.name
classification["%02d_%s" % (i, class_elt)]["info"] = class_elt.info
classification["%02d_%s" % (i, class_elt)]["configs"] = configs
i += 1
classification["%02d_noclass" % i]["name"] = "–"
classification["%02d_noclass" % i]["info"] = ""
classification["%02d_noclass" % i]["configs"] = db( (db.config.classification == None) & (auth.vidjil_accessible_query(PermissionEnum.read.value, db.config) | auth.vidjil_accessible_query(PermissionEnum.admin.value, db.config) ) ).select(orderby=db.config.id)
return classification
def getStatHeaders():
m = StatDecorator()
s = SetsDecorator()
......
......@@ -197,13 +197,18 @@ db.define_table('sequence_file',
db.define_table('classification',
Field('name', 'string'),
Field('info','text'))
db.define_table('config',
Field('name', 'string'),
Field('program', 'string'),
Field('command', 'string'),
Field('fuse_command', 'string'),
Field('info','text'))
Field('info','text'),
Field('classification', 'reference classification', ondelete='SET NULL'))
db.define_table('results_file',
......
......@@ -619,6 +619,30 @@ def init_db_helper(db, auth, force=False, admin_email="plop@plop.com", admin_pas
db.auth_membership.insert(user_id=id_first_user, group_id=id_sa_group)
db.auth_membership.insert(user_id=id_first_user, group_id=id_public_group)
### Base config classification
db.classification.insert(
name = 'Vidjil-algo',
info = 'Vidjil-algo'
)
db.classification.insert(
name = 'Sub groups',
info = 'Sub groups'
)
db.classification.insert(
name = 'Other germlines',
info = 'Other germlines'
)
db.classification.insert(
name = 'Other species',
info = 'Other species'
)
db.classification.insert(
name = 'Experimentals',
info = 'Experimentals'
)
## base Vidjil configs
db.config.insert(
......@@ -626,42 +650,48 @@ def init_db_helper(db, auth, force=False, admin_email="plop@plop.com", admin_pas
program = 'vidjil',
command = '-c clones -3 -z 100 -r 1 -g germline/homo-sapiens.g -e 1 -2 -d -w 50 -U ',
fuse_command = '-t 100',
info = 'Same as the default "multi+inc+xxx" (multi-locus, with some incomplete/unusual/unexpected recombinations), and extract analyzed reads in the "out" temporary directory.'
info = 'Same as the default "multi+inc+xxx" (multi-locus, with some incomplete/unusual/unexpected recombinations), and extract analyzed reads in the "out" temporary directory.',
classification = 1
)
db.config.insert(
name = 'multi+inc+xxx',
program = 'vidjil',
command = '-c clones -3 -z 100 -r 1 -g germline/homo-sapiens.g -e 1 -2 -d -w 50 ',
fuse_command = '-t 100',
info = 'multi-locus, with some incomplete/unusual/unexpected recombinations'
info = 'multi-locus, with some incomplete/unusual/unexpected recombinations',
classification = 1
)
db.config.insert(
name = 'multi+inc',
program = 'vidjil',
command = '-c clones -3 -z 100 -r 1 -g germline/homo-sapiens.g -e 1 -w 50 ',
fuse_command = '-t 100',
info = 'multi-locus, with some incomplete/unusual recombinations'
info = 'multi-locus, with some incomplete/unusual recombinations',
classification = 1
)
db.config.insert(
name = 'multi',
program = 'vidjil',
command = '-c clones -3 -z 100 -r 1 -g germline/homo-sapiens.g:IGH,IGK,IGL,TRA,TRB,TRG,TRD -e 1 -d -w 50 ',
fuse_command = '-t 100',
info = 'multi-locus, only complete recombinations'
info = 'multi-locus, only complete recombinations',
classification = 2
)
db.config.insert(
name = 'TRG',
program = 'vidjil',
command = '-c clones -3 -z 100 -r 1 -g germline/homo-sapiens.g:TRG ',
fuse_command = '-t 100',
info = 'TRG, VgJg'
info = 'TRG, VgJg',
classification = 2
)
db.config.insert(
name = 'IGH',
program = 'vidjil',
command = '-c clones -w 60 -d -3 -z 100 -r 1 -g germline/homo-sapiens.g:IGH ',
fuse_command = '-t 100',
info = 'IGH, Vh(Dh)Jh'
info = 'IGH, Vh(Dh)Jh',
classification = 2
)
## permission
......
......@@ -265,7 +265,10 @@ class TestSample < ServerTest
def test_run
table = go_to_set_by_tag "#set_assoc_0"
$b.select_list(:id => "choose_config").select("2")
config_list = $b.select_list(:id => "choose_config")
assert ( config_list.optgroup(:label => "Vidjil-algo").exist? ), "optgroup is present in configlist"
config_list.select("2")
Watir::Wait.until(timeout: 30) {$b.execute_script("return jQuery.active") == 0}
samples_table = $b.table(:id => "table")
......
......@@ -61,12 +61,16 @@ class ConfigController(unittest.TestCase):
def test2AddForm1(self):
# Add a testing classification
db.classification.insert(name="test_class", info="test_class_info")
#test valid request
request.vars['config_name'] = test_config_name
request.vars['config_info'] = " plop"
request.vars['config_command'] = " -plop"
request.vars['config_fuse_command'] = " -plop"
request.vars['config_program'] = " plop.cpp"
request.vars['config_classification'] = 1
resp = add_form()
self.assertTrue( len(db( db.config.name == test_config_name ).select()) == 1 , "fail to insert a new config")
......@@ -84,6 +88,7 @@ class ConfigController(unittest.TestCase):
request.vars["id"] = id_config
request.vars['config_name'] = test_config_name
request.vars['config_info'] = "plup"
request.vars['config_classification'] = 1
resp = edit_form()
self.assertTrue( db.config[id_config].info == "plup" , "fail to edit config info")
......
......@@ -8,6 +8,15 @@
<td > <input class="string" id="config_name" name="config_name" type="text" value=""> </td>
<td > </td>
</tr>
<tr>
<td> <label for="config_classification" id="config_classification__label">classification: </label> </td>
<td><select id="config_classification" name="config_classification">
{{for class_elt in classification: }}
<option value="{{=class_elt.id}}" title="{{=class_elt.info}}">{{=class_elt.name}}</option>
{{pass}}
</select></td>
<td> </td>
</tr>
<tr>
<td> <label for="config_program" id="config_program__label">Program: </label> </td>
<td><select id="config_program" name="config_program">
......
......@@ -13,6 +13,15 @@ info = db.config[request.vars["id"]]
<td > <input class="string" id="config_name" name="config_name" type="text" value="{{=info.name}}"> </td>
<td > </td>
</tr>
<tr>
<td> <label for="config_classification" id="config_classification__label">classification: </label> </td>
<td><select id="config_classification" name="config_classification">
{{for class_elt in classification: }}
<option value="{{=class_elt.id}}" {{if class_elt.id == info.classification:}}selected="selected"{{pass}} title="{{=class_elt.info}}">{{=class_elt.name}}</option>
{{pass}}
</select></td>
<td> </td>
</tr>
<tr>
<td> <label for="config_program" id="config_program__label">Program: </label> </td>
<td><select id="config_program" name="config_program">
......
......@@ -3,12 +3,15 @@
{{('message' in globals())}}
{{if 'message' in globals():}}
<h3>{{=message}}</h3>
<div id="db_table_container">
<table class="db_table" id="table">
<thead>
<tr><td class="column_50"></td>
<td class="column2"> classification </td>
<td class="column2"> name </td>
<td class="column1"> program </td>
<td> command </td>
......@@ -25,6 +28,17 @@
for row in query :}}
<tr>
<td> {{=row.id }} </td>
{{ found = False }}
{{for class_elt in classification: }}
{{ if class_elt.id == row.classification: }}
<td title="{{ =class_elt.name}}">{{=class_elt.name}}</td>
{{ found = True }}
{{pass}}
{{pass}}
{{ if not found: }}
<td title="Not defined">Not defined</td>
{{pass}}
<td> {{=row.name }} </td>
<td> {{=row.program }} </td>
<td> {{=row.command }} </td>
......
......@@ -35,10 +35,15 @@
'custom_list' : db.getListInput('custom_result[]'),
'id' : '{{='' if request.vars["id"] is None else request.vars["id"]}}' })">
<option value="-1" {{if not config :}}selected{{pass}}> --- </option>
{{for row in db((auth.vidjil_accessible_query(PermissionEnum.read_config.value, db.config) | auth.accessible_query(PermissionEnum.admin_config.value, db.config) ) ).select(orderby=~db.config.name) :}}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} >
{{=row.name}}
</option>
{{ for class_name in classification.keys(): }}
{{ class_elt = classification[class_name] }}
<optgroup label="{{ =class_elt['name'] }}" title="{{ =class_elt['info'] }}">
{{ for row in class_elt['configs']: }}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} title="{{=row.info}}" >
{{=row.name}}
</option>
{{pass}}
</optgroup>
{{pass}}
</select>
</span>
......
......@@ -21,10 +21,15 @@
<span>
<select id="choose_config" name="config" onchange="db.call('sample_set/index', {'id' :'{{=request.vars['id']}}', 'config_id' : this.value})">
<option value="-1" {{if not config :}}selected{{pass}}> --- </option>
{{for row in db((auth.vidjil_accessible_query(PermissionEnum.read.value, db.config) | auth.vidjil_accessible_query(PermissionEnum.admin.value, db.config) ) ).select(orderby=~db.config.name) :}}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} title="{{=row.info}}" >
{{=row.name}}
</option>
{{ for class_name in classification.keys(): }}
{{ class_elt = classification[class_name] }}
<optgroup label="{{ =class_elt['name'] }}" title="{{ =class_elt['info'] }}">
{{ for row in class_elt['configs']: }}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} title="{{=row.info}}" >
{{=row.name}}
</option>
{{pass}}
</optgroup>
{{pass}}
</select>
</span>
......@@ -34,10 +39,7 @@
</div>
......
......@@ -21,10 +21,15 @@
<span>
<select id="choose_config" name="config" onchange="db.updateStatsButton()">
<option value="-1" selected> --- </option>
{{for row in db((auth.vidjil_accessible_query(PermissionEnum.read.value, db.config) | auth.vidjil_accessible_query(PermissionEnum.admin.value, db.config) ) ).select(orderby=~db.config.name) :}}
<option value="{{=row.id }}" title="{{=row.info}}" >
{{=row.name}}
</option>
{{ for class_name in classification.keys(): }}
{{ class_elt = classification[class_name] }}
<optgroup label="{{ =class_elt['name'] }}" title="{{ =class_elt['info'] }}">
{{ for row in class_elt['configs']: }}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} title="{{=row.info}}" >
{{=row.name}}
</option>
{{pass}}
</optgroup>
{{pass}}
</select>
</span>
......
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