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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ ENV/
*.txt
*.pickle
*.zip

# BDD Testing
testing/
!test-requirements.txt
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ Install from PyPi

pip install py-ard

Testing

-------
To run behavior-driven development (BDD) tests locally via the behave framework,
you'll need to set up a virtual environment.

.. code-block::
# Virtual environment setup
python3 -m venv testing
source testing/bin/activate
pip install --upgrade pip
pip install -r test-requirements.txt

# Running Behave and all BDD tests
behave

Example
-------
Expand Down
7 changes: 7 additions & 0 deletions behave.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[behave]
paths=tests
format=pretty
show_snippets=false

; Development
stop=true
3 changes: 3 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
behave==1.2.6
pandas==0.25.1
PyHamcrest==2.0.2
4 changes: 4 additions & 0 deletions tests/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pyard import ARD

def before_all(context):
context.ard = ARD(verbose=True)
23 changes: 23 additions & 0 deletions tests/features/allele.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature: Alleles

Scenario Outline:

Given the allele as <Allele>
When reducing on the <Level> level
Then the reduced allele is found to be <Redux Allele>

Examples:
| Allele | Level | Redux Allele |
| A*01:01:01 | G | A*01:01:01G |
| A*01:01:01 | lg | A*01:01g |
| A*01:01:01 | lgx | A*01:01 |

| HLA-A*01:01:01 | G | HLA-A*01:01:01G |
| HLA-A*01:01:01 | lg | HLA-A*01:01g |
| HLA-A*01:01:01 | lgx | HLA-A*01:01 |

| DRB1*14:05:01 | lgx | DRB1*14:05 |
| DRB1*14:05:01 | lg | DRB1*14:05g |

| DRB1*14:06:01 | lgx | DRB1*14:06 |
| DRB1*14:06:01 | lg | DRB1*14:06g |
21 changes: 21 additions & 0 deletions tests/features/glstring.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: GL (Genotype List) Strings

Scenario Outline:

Given the allele as <Allele>
When reducing on the <Level> level (ambiguous)
Then the reduced allele is found to be <Redux Allele>

Examples:
| Allele | Level | Redux Allele |
| A*01:01:01:01+A*01:01:01:01 | G | A*01:01:01G+A*01:01:01G |
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | G | HLA-A*01:01:01G+HLA-A*01:01:01G |
| A*01:01:01:01+A*01:01:01:01 | lg | A*01:01g+A*01:01g |
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | lg | HLA-A*01:01g+HLA-A*01:01g |
| A*01:01:01:01+A*01:01:01:01 | lgx | A*01:01+A*01:01 |
| HLA-A*01:01:01:01+HLA-A*01:01:01:01 | lgx | HLA-A*01:01+HLA-A*01:01 |
| A*01:01+A*01:01^B*07:02+B*07:02 | G | A*01:01:01G+A*01:01:01G^B*07:02:01G+B*07:02:01G |
| A*01:01+A*01:01^B*07:02+B*07:02 | lg | A*01:01g+A*01:01g^B*07:02g+B*07:02g |
| A*01:01~B*07:02+A*01:01~B*07:02 | G | A*01:01:01G~B*07:02:01G+A*01:01:01G~B*07:02:01G |
| A*01:01~B*07:02+A*01:01~B*07:02 | lg | A*01:01g~B*07:02g+A*01:01g~B*07:02g |
| A*01:01~B*07:02+A*01:01~B*07:02\|A*02:01~B*07:02+A*02:01~B*07:02 | lg | A*01:01g~B*07:02g+A*01:01g~B*07:02g\|A*02:01g~B*07:02g+A*02:01g~B*07:02g |
14 changes: 14 additions & 0 deletions tests/features/mac.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: MAC (Multiple Allele Code)

Scenario Outline:

Given the allele as <Allele>
When reducing on the <Level> level (ambiguous)
Then the reduced allele is found to be <Redux Allele>

Examples:
| Allele | Level | Redux Allele |
| A*01:AB | G | A*01:01:01G/A*01:02 |
| A*01:AB | lgx | A*01:01/A*01:02 |
| HLA-A*01:AB | G | HLA-A*01:01:01G/HLA-A*01:02 |
| HLA-A*01:AB | lgx | HLA-A*01:01/HLA-A*01:02 |
12 changes: 12 additions & 0 deletions tests/features/p_g_group.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: P and G Groups

Scenario Outline:

Given the allele as <Allele>
When reducing on the <Level> level (ambiguous)
Then the reduced allele is found to be <Redux Allele>

Examples:
| Allele | Level | Redux Allele |
| A*02:01P | lgx | A*02:01 |
| A*02:01:01G | lgx | A*02:01 |
19 changes: 19 additions & 0 deletions tests/steps/redux_allele.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from hamcrest import assert_that, is_

@given('the allele as {allele}')
def step_impl(context, allele):
context.allele = allele

@when('reducing on the {level} level')
def step_impl(context, level):
context.level = level
context.redux_allele = context.ard.redux(context.allele, level)

@when('reducing on the {level} level (ambiguous)')
def step_impl(context, level):
context.level = level
context.redux_allele = context.ard.redux_gl(context.allele, level)

@then('the reduced allele is found to be {redux_allele}')
def step_impl(context, redux_allele):
assert_that(context.redux_allele, is_(redux_allele))