-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OWVolcanoPlot: general improvements, use of GeneScoring component
- Loading branch information
1 parent
6a7d577
commit 43fdb15
Showing
6 changed files
with
398 additions
and
75 deletions.
There are no files selected for viewing
Empty file.
73 changes: 73 additions & 0 deletions
73
orangecontrib/bioinformatics/tests/widgets/ow_components/test_gene_scoring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import unittest | ||
|
||
from AnyQt.QtTest import QSignalSpy | ||
|
||
from Orange.data import Table | ||
from Orange.widgets.widget import OWWidget | ||
from Orange.widgets.settings import SettingProvider | ||
from Orange.widgets.tests.base import WidgetTest | ||
from Orange.widgets.tests.utils import simulate | ||
|
||
from orangecontrib.bioinformatics.utils.statistics import score_hypergeometric_test | ||
from orangecontrib.bioinformatics.widgets.ow_components import GeneScoringComponent | ||
|
||
|
||
class MockWidget(OWWidget): | ||
name = "Mock" | ||
scoring_component = SettingProvider(GeneScoringComponent) | ||
|
||
def __init__(self): | ||
self.scoring_component = GeneScoringComponent(self, self.mainArea) | ||
|
||
|
||
class TestGeneScoringComponent(WidgetTest): | ||
def setUp(self): | ||
self.widget = MockWidget() | ||
self.component = self.widget.scoring_component | ||
|
||
def test_scoring_methods_combobox(self): | ||
combo_box_values = [ | ||
self.component.score_method_combo.itemText(i) for i in range(self.component.score_method_combo.count()) | ||
] | ||
self.assertTrue(len(combo_box_values) > 0) | ||
self.assertEqual([name for name, _ in self.component.score_methods], combo_box_values) | ||
|
||
signals_cb_emits = QSignalSpy(self.component.score_method_changed) | ||
simulate.combobox_run_through_all(self.component.score_method_combo) | ||
|
||
self.assertEqual(self.component.score_method_combo.currentIndex(), self.component.current_method_index) | ||
self.assertEqual(self.component.current_method_index, len(combo_box_values) - 1) | ||
|
||
# number of signals combobox emits should be equal to the length of available scoring methods | ||
self.assertEqual(len(combo_box_values), len(signals_cb_emits)) | ||
|
||
def test_expression_threshold_spinbox(self): | ||
# find index of item in combobox for hypergeometric test | ||
method_index, *_ = [ | ||
index | ||
for index, (name, method) in enumerate(self.component.score_methods) | ||
if method == score_hypergeometric_test | ||
] | ||
|
||
# check if spinbox appears after hypergeometric test is selected | ||
self.assertTrue(self.component.expression_threshold_box.isHidden()) | ||
simulate.combobox_activate_index(self.component.score_method_combo, method_index) | ||
self.assertFalse(self.component.expression_threshold_box.isHidden()) | ||
|
||
def test_group_values(self): | ||
self.assertIsNone(self.component.data) | ||
self.component.initialize(Table('iris')) | ||
self.assertIsNotNone(self.component.data) | ||
|
||
# we expect only one value 'iris class attribute' | ||
combo_box_value, *_ = [ | ||
self.component.group_combo.itemText(i) for i in range(self.component.group_combo.count()) | ||
] | ||
self.assertEqual(combo_box_value, 'iris') | ||
|
||
group_values = [self.component.list_widget.item(i).text() for i in range(self.component.list_widget.count())] | ||
self.assertEqual(group_values, ['Iris-setosa', 'Iris-versicolor', 'Iris-virginica']) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
orangecontrib/bioinformatics/widgets/ow_components/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .gene_scoring import GeneScoringComponent | ||
|
||
__all__ = ('GeneScoringComponent',) |
Oops, something went wrong.