Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing H2 jar as internal dependency. Fixes #291 #292

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions src/pheval/cli_pheval_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,15 @@ def benchmark_comparison(
This is the path where the phenotypic database folder will be written out.""",
type=Path,
)
@click.option(
"--h2-jar",
required=True,
metavar="h2-jar",
help="""H2 JAR file. JAR required to run H2 Database. e.g h2.jar""",
type=Path,
)
def semsim_to_exomiserdb_command(
input_file: Path, object_prefix: str, subject_prefix: str, db_path: Path
input_file: Path, object_prefix: str, subject_prefix: str, db_path: Path, h2_jar: Path
):
"""ingests semsim file into exomiser phenotypic database

Expand All @@ -531,8 +538,9 @@ def semsim_to_exomiserdb_command(
object_prefix (str): object prefix. e.g. MP
subject_prefix (str): subject prefix e.g HP
db_path (Path): Exomiser Phenotypic Database Folder Path. (e.g. /exomiser_folder/2209_phenotype/2209_phenotype/)
h2_jar (Path): H2 JAR file. JAR required to run H2 Database. e.g h2.jar
"""
semsim_to_exomiserdb(input_file, object_prefix, subject_prefix, db_path)
semsim_to_exomiserdb(input_file, object_prefix, subject_prefix, db_path, h2_jar)


@click.command()
Expand Down
7 changes: 3 additions & 4 deletions src/pheval/infra/exomiserdb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: cp936 -*-
import logging as log
import os
from pathlib import Path

import jaydebeapi
Expand All @@ -15,7 +14,7 @@ class DBConnector:
def __init__(
self, jar: Path, driver: str, server: str, database: str, user: str, password: str
):
self.jar = jar
self.jar = str(jar)
self.driver = driver
self.server = server
self.database = database
Expand Down Expand Up @@ -61,10 +60,10 @@ def get_cursor(cls) -> jaydebeapi.Cursor:


class ExomiserDB:
def __init__(self, db_path: Path):
def __init__(self, db_path: Path, h2_jar: Path):
try:
self.connector = DBConnector( # noqa
jar=os.path.join(os.path.dirname(__file__), "../../../lib/h2-1.4.199.jar"),
jar=h2_jar,
driver="org.h2.Driver",
server=f"jdbc:h2:{db_path}",
user="sa",
Expand Down
7 changes: 5 additions & 2 deletions src/pheval/utils/exomiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
from pheval.infra.exomiserdb import ExomiserDB


def semsim_to_exomiserdb(input_path: Path, object_prefix: str, subject_prefix: str, db_path: Path):
def semsim_to_exomiserdb(
input_path: Path, object_prefix: str, subject_prefix: str, db_path: Path, h2_jar: Path
):
"""ingests semsim file into exomiser phenotypic database

Args:
input_path (Path): semsim input file. e.g phenio-plus-hp-mp.0.semsimian.tsv
object_prefix (str): object prefix. e.g. MP
subject_prefix (str): subject prefix e.g HP
db_path (Path): Exomiser Phenotypic Database Folder Path. (e.g. /exomiser_folder/2209_phenotype/2209_phenotype/)
h2_jar (Path): H2 JAR file. JAR required to run H2 Database. e.g h2.jar
"""
exomiserdb = ExomiserDB(db_path)
exomiserdb = ExomiserDB(db_path, h2_jar)
exomiserdb.import_from_semsim_file(input_path, object_prefix, subject_prefix)
File renamed without changes.
4 changes: 3 additions & 1 deletion tests/test_exomiser_db_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pheval.utils.exomiser import semsim_to_exomiserdb

PHENO_FOLDER = os.path.abspath("./testdata/phenotype/2302_phenotype")
H2_JAR = os.path.abspath("./tests/lib/h2-1.4.199.jar")


class TestExomiserDBIngestion(unittest.TestCase):
Expand All @@ -17,7 +18,7 @@ def tearDown(self):
_clean_db()

def select_data(self, query: str):
edb = ExomiserDB(f"{PHENO_FOLDER}/2302_phenotype_test")
edb = ExomiserDB(f"{PHENO_FOLDER}/2302_phenotype_test", H2_JAR)
with edb.connector as cnn:
conn = DBConnection(cnn)
cursor = conn.get_cursor()
Expand All @@ -36,6 +37,7 @@ def test_semsim_to_exomiserdb(self):
object_prefix="MP",
subject_prefix="HP",
db_path=f"{PHENO_FOLDER}/2302_phenotype_test",
h2_jar=H2_JAR,
)
new_res = self.select_data(query)
self.assertEqual(len(new_res), 9)
Expand Down
Loading