Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ matplotlib
numpy
pandas
parmed
plotly==3.5.0
plotly>=3.5.0
requests
scipy>=1.1.0
scikit-learn
2 changes: 1 addition & 1 deletion src/lib/components/Ideogram.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {omit} from 'ramda';
* datasets for organisms such as human, mouse, and any other
* eukaryote. The Ideogram component can be used to compare
* homologous features between chromosomes, and depict
* haploid, diploid, aneuploidy genomes. It can also display
* haploid, diploid, aneuploid genomes. It can also display
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Words like these make me remember why I switched my major from biochem 🤣

* annotations on genomic data using histograms and overlays.
*
* Reference: https://eweitz.github.io/ideogram/
Expand Down
49 changes: 28 additions & 21 deletions tests/test_ideogram.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import json
import os

from pytest_dash.wait_for import (
wait_for_element_by_css_selector,
wait_for_element_by_id,
Expand All @@ -14,14 +15,12 @@
COMPONENT_REACT_BASE
)

# TODO by merging https://github.com/plotly/dash-bio/pull/201

# these tests are written for the locked version v1.4.1
# NOTE These tests were written to work with dependency `ideogram` v1.4.1:
# git+https://github.com/eweitz/ideogram.git#7d9b2ab91b91ef35db93bdeb529d4760de63292f
# if the version in package-lock.json is different and some of the test fails it might be due
# to changes from the author of https://github.com/eweitz/ideogram. For example, currently in the
# version v1.5.1 test_orientation fails because "chromosome-set-container" was renamed to
# "chromosome-set" which result in a timeout of the _wait_for function
# This version is locked in `package-lock.json`. If that changed and some of the tests failed,
# it might be due to changes in https://github.com/eweitz/ideogram. For example, test_orientation
# fails with version v1.5.1 because "chromosome-set-container" was renamed to "chromosome-set"
# (which results in the wait_for function timing out without finding the element).

# define app name once
APP_NAME = os.path.basename(__file__).replace('test_', '').replace('.py', '').replace('_', '-')
Expand Down Expand Up @@ -80,7 +79,7 @@ def ideogram_test_props_callback(


def test_chr_height(dash_threaded):
"""Test change maximal height of the chromosome."""
"""Test change of chromosome maximal height."""

prop_type = 'float'

Expand Down Expand Up @@ -227,16 +226,16 @@ def assert_callback(prop_value, nclicks, input_value):
driver = dash_threaded.driver

# assert 22 chromosomes + X and Y chromosomes
num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome'))
assert num_chromosoms == 24
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason that you changed these? (I'm just wondering if it somehow speeds things up, or ensures that we have a result before trying to test the assertion)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is to standardize the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both reasons: standardize and get elements before taking their length (for possible debugging too).

assert len(chromosomes) == 24

# trigger a change of the component prop
btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME))
btn.click()

# assert doubling of the 22 chromosomes + X and Y chromosomes
num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome'))
assert num_chromosoms == 46
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
assert len(chromosomes) == 46


def test_chromosomes(dash_threaded):
Expand Down Expand Up @@ -266,13 +265,17 @@ def assert_callback(prop_value, nclicks, input_value):

driver = dash_threaded.driver

# assert 22 chromosomes + X and Y chromosomes
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
assert len(chromosomes) == 24

# trigger a change of the component prop
btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME))
btn.click()

# assert the set of chromosomes contains 3 chromosomes
num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome'))
assert num_chromosoms == 3
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
assert len(chromosomes) == 3


def test_chromosomes_wrong_input(dash_threaded):
Expand Down Expand Up @@ -302,13 +305,17 @@ def assert_callback(prop_value, nclicks, input_value):

driver = dash_threaded.driver

# assert 22 chromosomes + X and Y chromosomes
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
assert len(chromosomes) == 24

# trigger a change of the component prop
btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME))
btn.click()

# assert the set of chromosomes contains 2 chromosomes
num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome'))
assert num_chromosoms == 2
chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome')
assert len(chromosomes) == 2


def test_brush(dash_threaded):
Expand Down Expand Up @@ -396,7 +403,7 @@ def assert_callback(prop_value, nclicks, input_value):

# assert the presence of bands' labels
labels = driver.find_elements_by_class_name('bandLabel')
assert len(labels) != 0
assert len(labels) > 0


def test_show_chromosome_labels(dash_threaded):
Expand Down Expand Up @@ -435,8 +442,8 @@ def assert_callback(prop_value, nclicks, input_value):
btn.click()

# assert the presence of chromosomes' labels
num_labels = len(wait_for_elements_by_css_selector(driver, '.chrLabel'))
assert num_labels != 0
labels = wait_for_elements_by_css_selector(driver, '.chrLabel')
assert len(labels) > 0


def test_sex(dash_threaded):
Expand Down Expand Up @@ -629,7 +636,7 @@ def assert_callback(prop_value, nclicks, input_value):

# assert the presence of homology region
regions = wait_for_elements_by_css_selector(driver, '.syntenicRegion')
assert len(regions) != 0
assert len(regions) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed? I guess it makes sense, since the length of a list cannot be negative, but I'm not sure this change affects performance or functionality. (Correct me if I'm wrong!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't affect performance or functionality, but if ever a length was negative, I would want to catch it!! Well, I'm for writing the meaningful version directly (we expect this length to be positive, so let's write it, it's easier on the reader too).



def test_full_chromosome_labels(dash_threaded):
Expand Down