Commit 107f04ed authored by Anze Vavpetic's avatar Anze Vavpetic

Merge branch 'bioinformatics' into dev

parents 9ec20e5b 593ec48a
......@@ -36,4 +36,18 @@ def select_subgroups(request, input_dict, output_dict, widget):
'widget' : widget,
'model_name' : sd_rules.algorithmName,
'subgroups' : subgroups
def table_from_sets(request, input_dict, output_dict, widget):
Makes a table with the given sets of examples as the classes.
@author: Anze Vavpetic, 2012
tables = input_dict['data']
return render(request, 'interactions/table_from_sets.html', {
'widget' : widget,
'class_name' : 'class name',
'class_values' : ['class%d' % i for i in range(len(tables))],
'replace' : True
\ No newline at end of file
......@@ -78,10 +78,48 @@ def select_subgroups_finished(postdata, input_dict, output_dict):
def query_with_subgroups(input_dict):
data = input_dict['data']
sd_rules = input_dict['rules']
full_set = set([ex for ex in data])
subset = set()
for rule in sd_rules.rules:
subset = subset.union(rule.filter(data))
subset_table =
remaining_table =
for ex in subset:
return {'data' : subset_table}
for ex in full_set.difference(subset):
return {'data' : subset_table, 'remaining_data' : remaining_table}
def table_from_sets(input_dict):
return {'merged_data' : None}
def table_from_sets_finished(postdata, input_dict, output_dict):
tables = input_dict['data']
widget_id = postdata['widget_id'][0]
class_name = str(postdata['class_name'+widget_id][0])
class_values = [str(postdata['class'+str(i)+widget_id][0]) for i in range(len(tables))]
replace = postdata.get('replace'+widget_id, [False])[0]
class_var = Orange.feature.Discrete(class_name, values = class_values)
class_table =[class_var]))
# Check if the domains are the same
domain = tables[0].domain
for table in tables:
if table.domain.variables != domain.variables:
print table.domain, domain
raise Exception('The domains of tables do not match!')
for i, table in enumerate(tables):
for ex in table:
class_table.append(, [class_values[i]]))
# All examples
examples =[0])
for table in tables[1:]:
old_table = examples
if replace:
if not examples.domain.classVar:
raise Exception('No class variable present.')
old_domain = list(examples.domain)
old_table =, examples.domain), examples)
return {'merged_data' :[old_table, class_table])}
......@@ -9,13 +9,13 @@
{% for param, info in parameters_info.items %}
<label for="{{param}}{{}}">{{info.1}}</label><input type="number" id="{{param}}{{}}" name="{{param}}{{}}" value="{{info.0}}"/>
{% endfor %}
<input type="hidden" name="widget_id" value="{{}}">
<label for="class{{}}">Class</label>
<select id="class{{}}" name="class{{}}">
{% for class in classValues %}
<option value="{{class}}">{{class}}</option>
{% endfor %}
<input type="hidden" name="widget_id" value="{{}}">
<script type="text/javascript">
var all_parameters = {{all_parameters|safe}};
<div id="widgetinteract-{{}}" rel="{{}}" class="widgetinteractdialog" title="{{}} interaction" width="400" height="300">
<label for="class_name{{}}">New class attribute name</label>
<input type="text" name="class_name{{}}" value="{{class_name}}"/>
{% for class_val in class_values %}
<label for="{{class_val}}{{}}">Class label for set on signal #{{forloop.counter}}</label>
<input type="text" name="{{class_val}}{{}}" value="{{class_val}}"/>
{% endfor %}
<input type="checkbox" name="replace{{}}" value="{{replace}}"/>
<label for="replace{{}}">Replace existing class</label>
<input type="hidden" name="widget_id" value="{{}}">
<script type="text/javascript">
\ No newline at end of file
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