diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 6bfdc01..cb48f53 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -28,6 +28,3 @@ jobs: - name: Test with pytest run: | pytest - - name: Run BDD Tests - run: | - behave diff --git a/grim/algorithm/match.py b/grim/algorithm/match.py deleted file mode 100644 index a8bb16a..0000000 --- a/grim/algorithm/match.py +++ /dev/null @@ -1,16 +0,0 @@ -from grim.model.slug import SLUG - - -# SLUG match -# match the SLUG of patient with donor - - -def slug_match(patient_slug: SLUG, donor_slug: SLUG) -> bool: - """ - SLUGs are matched if they are equal to each other - - @param patient_slug: Patient SLUG - @param donor_slug: Donor SLUG - @return: bool indicating whether they match or not - """ - return patient_slug == donor_slug diff --git a/grim/conf/__init__.py b/grim/conf/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/conf/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/grim/imputation/__init__.py b/grim/imputation/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/imputation/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/grim/imputation/graph_generation/__init__.py b/grim/imputation/graph_generation/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/imputation/graph_generation/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/grim/model/allele.py b/grim/model/allele.py deleted file mode 100644 index a13b8cc..0000000 --- a/grim/model/allele.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- - -# -# grim Graph Imputation -# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 3 of the License, or (at -# your option) any later version. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -# -# > http://www.fsf.org/licensing/licenses/lgpl.html -# > http://www.opensource.org/licenses/lgpl-license.php -# - - -class Allele: - """ - A Class I allele is an allele of Locus 'HLA-A', 'HLA-B', 'HLA-C' - """ - - def __init__(self, locus: str, allele: str): - """ - Validate the Class I locus and allele first. - - @param locus: Class I Locus - @param allele: Class I Allele - """ - self.validate(locus, allele) - self.allele = allele - self.locus = locus - - def __eq__(self, other: object) -> bool: - if isinstance(other, Allele): - return self.locus == other.locus and self.allele == other.allele - return False - - def __lt__(self, other): - if isinstance(other, Allele): - return self.allele < other.allele - return False - - def __str__(self) -> str: - if self.allele.startswith("HLA-"): - return self.allele - return f"{self.locus}*{self.locus}" - - @staticmethod - def validate(locus: str, allele: str): - if locus not in ["HLA-A", "HLA-B", "HLA-C"]: - raise InvalidAllele(f"{locus} is Not a valid locus") - if "*" not in allele and ":" not in allele: - raise InvalidAllele("f{allele} is Not a valid allele") - - @classmethod - def from_fullname(cls, allele): - if not allele.startswith("HLA-"): - raise InvalidAllele(f"{allele} is not a fully-named allele") - locus = allele.split("*")[0] - return Allele(locus, allele) - - -class InvalidAllele(Exception): - def __init__(self, message: str) -> None: - self.message = message diff --git a/grim/model/slug.py b/grim/model/slug.py deleted file mode 100644 index 90f87be..0000000 --- a/grim/model/slug.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- - -# -# grim Graph Imputation -# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 3 of the License, or (at -# your option) any later version. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -# -# > http://www.fsf.org/licensing/licenses/lgpl.html -# > http://www.opensource.org/licenses/lgpl-license.php -# - -from .allele import Allele - - -class SLUG: - """ - SLUGs are Single Locus Un-phased Genotypes made up of a pair of alleles. - The alleles are lexicographically sorted. - """ - - def __init__(self, allele_1: Allele, allele_2: Allele) -> None: - """ - SLUGs are single locus genotypes with alleles in sorted order - - @param allele_1: - @param allele_2: - """ - if allele_1 < allele_2: - self.allele_1 = allele_1 - self.allele_2 = allele_2 - else: - self.allele_1 = allele_2 - self.allele_2 = allele_1 - - def __str__(self) -> str: - """ - String version of SLUG is in GL String format - - @return: gl-string format of SLUG - """ - return f"{self.allele_1}+{self.allele_2}" - - def __eq__(self, other: object) -> bool: - """ - 2 SLUGs are equal if the individual alleles are equal - to each other. - - @param other: - @return: True indicating whether 2 SLUGS are equal - """ - if isinstance(other, SLUG): - return self.allele_1 == other.allele_1 and self.allele_2 == other.allele_2 - return False - - @classmethod - def from_glstring(cls, slug): - allele_1, allele_2 = slug.split("+") - slug = SLUG(Allele.from_fullname(allele_1), Allele.from_fullname(allele_2)) - return slug diff --git a/grim/validation/__init__.py b/grim/validation/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/validation/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/grim/validation/simulation/__init__.py b/grim/validation/simulation/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/validation/simulation/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/grim/validation/simulation/data/__init__.py b/grim/validation/simulation/data/__init__.py new file mode 100644 index 0000000..cfe8889 --- /dev/null +++ b/grim/validation/simulation/data/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# +# grim Graph Imputation +# Copyright (c) 2021 Be The Match operated by National Marrow Donor Program. All Rights Reserved. +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +# +# > http://www.fsf.org/licensing/licenses/lgpl.html +# > http://www.opensource.org/licenses/lgpl-license.php +# + + +"""Top-level package for py-grim.""" + +__organization__ = "NMDP/CIBMTR Bioinformatics" diff --git a/requirements-deploy.txt b/requirements-deploy.txt index 0e1ec03..e69de29 100644 --- a/requirements-deploy.txt +++ b/requirements-deploy.txt @@ -1,2 +0,0 @@ -connexion[swagger-ui]==2.13.0 -gunicorn==20.1.0 diff --git a/requirements-dev.txt b/requirements-dev.txt index d2f222f..02e2bf4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,5 @@ -allure-behave==2.9.45 -flake8==4.0.1 +flake8==5.0.4 bump2version==1.0.1 -coverage==6.3.2 +coverage==6.4.4 wheel==0.37.1 -pre-commit==2.18.1 +pre-commit==2.20.0 diff --git a/requirements-tests.txt b/requirements-tests.txt index 77d53a7..2af4c79 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,3 +1,2 @@ pytest==7.1.2 -behave==1.2.6 PyHamcrest==2.0.3 diff --git a/setup.py b/setup.py index 2b31e49..96f2b6f 100644 --- a/setup.py +++ b/setup.py @@ -62,7 +62,15 @@ long_description_content_type="text/markdown", include_package_data=True, keywords="grim", - packages=find_packages(include=["grim"]), + packages=find_packages( + include=[ + "grim", + "grim.imputation", + "grim.imputegl", + "grim.imputation.graph_generation", + "grim.validation", + ] + ), test_suite="tests", tests_require=test_requirements, url="https://github.com/nmdp-bioinformatics/py-grim", diff --git a/tests/features/algorithm/SLUG Match.feature b/tests/features/algorithm/SLUG Match.feature deleted file mode 100644 index 4cb80df..0000000 --- a/tests/features/algorithm/SLUG Match.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Match SLUG - - SLUGs are matched if each of the alleles of one SLUG are in the other SLUG. - - Scenario Outline: Match SLUGS by allele - - Given the SLUG for patient is - And the SLUG for donor is - When we perform SLUG match patient and donor - Then they should be - - Examples: - | Patient-SLUG | Donor-SLUG | Matched | - | HLA-C*07:02+HLA-C*16:01 | HLA-C*07:02+HLA-C*16:01 | Yes | - | HLA-A*13:02+HLA-A*13:01 | HLA-A*13:02+HLA-A*30:01 | No | - | HLA-A*13:02+HLA-B*13:01 | HLA-A*13:02+HLA-A*30:01 | No | diff --git a/tests/features/definition/Class I HLA Alleles.feature b/tests/features/definition/Class I HLA Alleles.feature deleted file mode 100644 index 9c7ad99..0000000 --- a/tests/features/definition/Class I HLA Alleles.feature +++ /dev/null @@ -1,21 +0,0 @@ -Feature: SLUGs of Class I HLA Alleles - - Class I HLA Alleles are alleles on genomic loci HLA-A, HLA-B and HLA-C. - SLUGs are Single Locus Un-phased Genotypes made up of a pair of alleles. - The alleles are lexicographically sorted. - - Scenario Outline: HLA Class I Locus SLUG - - Each gene of HLA-A, HLA-B and HLA-C have a pair of alleles, one from each parent. - - Given The Locus of Gene is - And The first allele is - And The second allele is - When I create an un-phased genotype - Then I get the single locus un-phased genotype - - Examples: Valid Class I Alleles - | Locus | Allele1 | Allele2 | SLUG | - | HLA-A | HLA-A*13:02 | HLA-A*30:01 | HLA-A*13:02+HLA-A*30:01 | - | HLA-B | HLA-B*38:01 | HLA-B*07:02 | HLA-B*07:02+HLA-B*38:01 | - | HLA-C | HLA-C*07:02 | HLA-C*16:01 | HLA-C*07:02+HLA-C*16:01 | diff --git a/tests/steps/HLA_alleles.py b/tests/steps/HLA_alleles.py deleted file mode 100644 index dfbd31a..0000000 --- a/tests/steps/HLA_alleles.py +++ /dev/null @@ -1,30 +0,0 @@ -from behave import * -from hamcrest import assert_that, is_ - -from grim.model.allele import Allele -from grim.model.slug import SLUG - - -@given("The Locus of Gene is {locus}") -def step_impl(context, locus): - context.locus = locus - - -@step("The first allele is {allele1}") -def step_impl(context, allele1): - context.allele_1 = Allele(context.locus, allele1) - - -@step("The second allele is {allele2}") -def step_impl(context, allele2): - context.allele_2 = Allele(context.locus, allele2) - - -@when("I create an un-phased genotype") -def step_impl(context): - context.slug = SLUG(context.allele_1, context.allele_2) - - -@then("I get the single locus un-phased genotype {slug}") -def step_impl(context, slug): - assert_that(str(context.slug), is_(slug)) diff --git a/tests/steps/SLUG_match.py b/tests/steps/SLUG_match.py deleted file mode 100644 index 6fda209..0000000 --- a/tests/steps/SLUG_match.py +++ /dev/null @@ -1,26 +0,0 @@ -from behave import * -from hamcrest import assert_that, is_ - -from grim.algorithm.match import slug_match -from grim.model.slug import SLUG - - -@given("the SLUG for patient is {slug}") -def step_impl(context, slug): - context.patient_slug = SLUG.from_glstring(slug) - - -@step("the SLUG for donor is {slug}") -def step_impl(context, slug): - context.donor_slug = SLUG.from_glstring(slug) - - -@when("we perform SLUG match patient and donor") -def step_impl(context): - context.matched = slug_match(context.patient_slug, context.donor_slug) - - -@then("they should be {is_matched}") -def step_impl(context, is_matched): - matched = is_matched == "Yes" - assert_that(context.matched, is_(matched)) diff --git a/tests/unit/test_my_project_template.py b/tests/unit/test_grim.py similarity index 100% rename from tests/unit/test_my_project_template.py rename to tests/unit/test_grim.py