diff --git a/eva_submission/__init__.py b/eva_submission/__init__.py index 21229749..cadd355d 100644 --- a/eva_submission/__init__.py +++ b/eva_submission/__init__.py @@ -1,4 +1,8 @@ import os +import eva_submission + ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # This is your Project Root -MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) # This is the module Root + +NEXTFLOW_DIR = os.path.join(os.path.dirname(os.path.abspath(eva_submission.__file__)), 'nextflow') +ETC_DIR = os.path.join(os.path.dirname(os.path.abspath(eva_submission.__file__)), 'etc') diff --git a/eva_submission/eload_brokering.py b/eva_submission/eload_brokering.py index 2f9063ef..4e78a7b0 100644 --- a/eva_submission/eload_brokering.py +++ b/eva_submission/eload_brokering.py @@ -6,7 +6,7 @@ from ebi_eva_common_pyutils import command_utils from ebi_eva_common_pyutils.config import cfg -from eva_submission import ROOT_DIR +from eva_submission import ROOT_DIR, NEXTFLOW_DIR from eva_submission.ENA_submission.upload_to_ENA import ENAUploader from eva_submission.biosamples_submission import SampleMetadataSubmitter from eva_submission.eload_submission import Eload @@ -94,7 +94,7 @@ def _run_brokering_prep_workflow(self): brokering_config_file = os.path.join(self.eload_dir, 'brokering_config_file.yaml') with open(brokering_config_file, 'w') as open_file: yaml.safe_dump(brokering_config, open_file) - validation_script = os.path.join(ROOT_DIR, 'nextflow', 'prepare_brokering.nf') + validation_script = os.path.join(NEXTFLOW_DIR, 'prepare_brokering.nf') try: command_utils.run_command_with_output( 'Nextflow brokering preparation process', diff --git a/eva_submission/eload_ingestion.py b/eva_submission/eload_ingestion.py index 59acd9bc..dee2c6fb 100644 --- a/eva_submission/eload_ingestion.py +++ b/eva_submission/eload_ingestion.py @@ -12,7 +12,7 @@ from ebi_eva_common_pyutils.pg_utils import get_all_results_for_query, execute_query import pymongo -from eva_submission import ROOT_DIR +from eva_submission import NEXTFLOW_DIR from eva_submission.assembly_taxonomy_insertion import insert_new_assembly_and_taxonomy from eva_submission.eload_submission import Eload from eva_submission.eload_utils import get_metadata_conn, get_mongo_creds, get_accession_pg_creds @@ -246,7 +246,7 @@ def run_accession_workflow(self): accession_config_file = os.path.join(self.project_dir, 'accession_config_file.yaml') with open(accession_config_file, 'w') as open_file: yaml.safe_dump(accession_config, open_file) - accession_script = os.path.join(ROOT_DIR, 'nextflow', 'accession.nf') + accession_script = os.path.join(NEXTFLOW_DIR, 'accession.nf') try: command_utils.run_command_with_output( 'Nextflow Accessioning process', @@ -296,7 +296,7 @@ def run_variant_load_workflow(self): load_config_file = os.path.join(self.project_dir, 'load_config_file.yaml') with open(load_config_file, 'w') as open_file: yaml.safe_dump(load_config, open_file) - variant_load_script = os.path.join(ROOT_DIR, 'nextflow', 'variant_load.nf') + variant_load_script = os.path.join(NEXTFLOW_DIR, 'variant_load.nf') try: command_utils.run_command_with_output( 'Nextflow Variant Load process', diff --git a/eva_submission/eload_validation.py b/eva_submission/eload_validation.py index a603afbc..94c9c921 100755 --- a/eva_submission/eload_validation.py +++ b/eva_submission/eload_validation.py @@ -7,7 +7,7 @@ from ebi_eva_common_pyutils import command_utils from ebi_eva_common_pyutils.config import cfg -from eva_submission import ROOT_DIR +from eva_submission import NEXTFLOW_DIR from eva_submission.eload_submission import Eload from eva_submission.eload_utils import resolve_single_file_path from eva_submission.samples_checker import compare_spreadsheet_and_vcf @@ -130,7 +130,7 @@ def _run_validation_workflow(self): validation_confg_file = os.path.join(self.eload_dir, 'validation_confg_file.yaml') with open(validation_confg_file, 'w') as open_file: yaml.safe_dump(validation_config, open_file) - validation_script = os.path.join(ROOT_DIR, 'nextflow', 'validation.nf') + validation_script = os.path.join(NEXTFLOW_DIR, 'validation.nf') try: command_utils.run_command_with_output( 'Nextflow Validation process', diff --git a/etc/eva_project_conf.yaml b/eva_submission/etc/eva_project_conf.yaml similarity index 100% rename from etc/eva_project_conf.yaml rename to eva_submission/etc/eva_project_conf.yaml diff --git a/etc/eva_project_validation.yaml b/eva_submission/etc/eva_project_validation.yaml similarity index 100% rename from etc/eva_project_validation.yaml rename to eva_submission/etc/eva_project_validation.yaml diff --git a/etc/example_submission_config.yaml b/eva_submission/etc/example_submission_config.yaml similarity index 100% rename from etc/example_submission_config.yaml rename to eva_submission/etc/example_submission_config.yaml diff --git a/nextflow/accession.nf b/eva_submission/nextflow/accession.nf similarity index 100% rename from nextflow/accession.nf rename to eva_submission/nextflow/accession.nf diff --git a/nextflow/prepare_brokering.nf b/eva_submission/nextflow/prepare_brokering.nf similarity index 100% rename from nextflow/prepare_brokering.nf rename to eva_submission/nextflow/prepare_brokering.nf diff --git a/nextflow/validation.nf b/eva_submission/nextflow/validation.nf similarity index 100% rename from nextflow/validation.nf rename to eva_submission/nextflow/validation.nf diff --git a/nextflow/variant_load.nf b/eva_submission/nextflow/variant_load.nf similarity index 100% rename from nextflow/variant_load.nf rename to eva_submission/nextflow/variant_load.nf diff --git a/eva_submission/xlsx/xlsx_parser_eva.py b/eva_submission/xlsx/xlsx_parser_eva.py index 818d75c4..b3f7ed51 100644 --- a/eva_submission/xlsx/xlsx_parser_eva.py +++ b/eva_submission/xlsx/xlsx_parser_eva.py @@ -18,14 +18,14 @@ from cached_property import cached_property from ebi_eva_common_pyutils.logger import AppLogger -from eva_submission import ROOT_DIR +from eva_submission import ETC_DIR from eva_submission.xlsx.xlsx_parser import XlsxReader, XlsxWriter class EvaXlsxReader(AppLogger): def __init__(self, metadata_file): - conf = os.path.join(ROOT_DIR, 'etc', 'eva_project_conf.yaml') + conf = os.path.join(ETC_DIR, 'eva_project_conf.yaml') self.reader = XlsxReader(metadata_file, conf) self.metadata_file=metadata_file @@ -97,7 +97,7 @@ def files_per_analysis(self): class EvaXlsxWriter(AppLogger): def __init__(self, metadata_source, metadata_dest=None): - conf = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'etc', 'eva_project_conf.yaml') + conf = os.path.join(ETC_DIR, 'eva_project_conf.yaml') self.writer = XlsxWriter(metadata_source, conf) self.metadata_source = metadata_source if metadata_dest: diff --git a/eva_submission/xlsx/xlsx_validation.py b/eva_submission/xlsx/xlsx_validation.py index 6c082794..e1b37d22 100644 --- a/eva_submission/xlsx/xlsx_validation.py +++ b/eva_submission/xlsx/xlsx_validation.py @@ -7,7 +7,7 @@ from ebi_eva_common_pyutils.variation.assembly_utils import retrieve_genbank_assembly_accessions_from_ncbi from requests import HTTPError -from eva_submission import ROOT_DIR +from eva_submission import ETC_DIR from eva_submission.eload_utils import cast_list from eva_submission.xlsx.xlsx_parser_eva import EvaXlsxReader @@ -33,7 +33,7 @@ def cerberus_validation(self): Leverage cerberus validation to check the format of the metadata. This function adds error statements to the errors attribute """ - config_file = os.path.join(ROOT_DIR, 'etc', 'eva_project_validation.yaml') + config_file = os.path.join(ETC_DIR, 'eva_project_validation.yaml') with open(config_file) as open_file: validation_schema = yaml.safe_load(open_file) validator = Validator(validation_schema) diff --git a/setup.py b/setup.py index 652fabbf..9a96fa03 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,8 @@ setup( name='eva_submission', packages=['eva_submission', 'eva_submission.ENA_submission', 'eva_submission.xlsx'], - version='0.5.6', + package_data={'eva_submission': ['nextflow/*', 'etc/*']}, + version='0.5.7', license='Apache', description='EBI EVA - submission processing tools', url='https://github.com/EBIVariation/eva-submission', diff --git a/tests/test_eload_brokering.py b/tests/test_eload_brokering.py index 2c1dbf60..71a9f4e7 100644 --- a/tests/test_eload_brokering.py +++ b/tests/test_eload_brokering.py @@ -6,7 +6,7 @@ from ebi_eva_common_pyutils.config import cfg -from eva_submission import ROOT_DIR +from eva_submission import NEXTFLOW_DIR from eva_submission.biosamples_submission import SampleMetadataSubmitter from eva_submission.eload_brokering import EloadBrokering from eva_submission.eload_submission import Eload @@ -68,7 +68,7 @@ def test_run_brokering_prep_workflow(self): 'nextflow': 'path_to_nextflow' } temp_dir = 'temporary_directory' - nf_script = os.path.join(ROOT_DIR, 'nextflow', 'prepare_brokering.nf') + nf_script = os.path.join(NEXTFLOW_DIR, 'prepare_brokering.nf') config_file = os.path.join(self.eload.eload_dir, 'brokering_config_file.yaml') with patch('eva_submission.eload_brokering.command_utils.run_command_with_output') as m_execute, \