-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from apriltuesday/EVA-3225
EVA-3225 - Add native execution for validation and refactor
- Loading branch information
Showing
16 changed files
with
164 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import subprocess | ||
|
||
from ebi_eva_common_pyutils.command_utils import run_command_with_output | ||
from ebi_eva_common_pyutils.logger import logging_config | ||
|
||
from eva_sub_cli.validators.validator import Validator | ||
|
||
logger = logging_config.get_logger(__name__) | ||
|
||
|
||
class NativeValidator(Validator): | ||
|
||
def __init__(self, mapping_file, output_dir, metadata_json=None, metadata_xlsx=None, | ||
vcf_validator_path='vcf_validator', assembly_checker_path='vcf_assembly_checker', | ||
biovalidator_path='biovalidator', submission_config=None): | ||
super().__init__(mapping_file, output_dir, metadata_json=metadata_json, metadata_xlsx=metadata_xlsx, | ||
submission_config=submission_config) | ||
self.vcf_validator_path = vcf_validator_path | ||
self.assembly_checker_path = assembly_checker_path | ||
self.biovalidator_path = biovalidator_path | ||
|
||
def _validate(self): | ||
self.run_validator() | ||
|
||
def run_validator(self): | ||
self.verify_executables_installed() | ||
try: | ||
command = self.get_validation_cmd() | ||
run_command_with_output("Run Validation using Nextflow", command) | ||
except subprocess.CalledProcessError as ex: | ||
logger.error(ex) | ||
|
||
def get_validation_cmd(self): | ||
if self.metadata_xlsx and not self.metadata_json: | ||
metadata_flag = f"--metadata_xlsx {self.metadata_xlsx}" | ||
else: | ||
metadata_flag = f"--metadata_json {self.metadata_json}" | ||
path_to_workflow = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | ||
'nextflow/validation.nf') | ||
return ( | ||
f"nextflow run {path_to_workflow} " | ||
f"--vcf_files_mapping {self.mapping_file} " | ||
f"{metadata_flag} " | ||
f"--output_dir {self.output_dir} " | ||
f"--executable.vcf_validator {self.vcf_validator_path} " | ||
f"--executable.vcf_assembly_checker {self.assembly_checker_path} " | ||
f"--executable.biovalidator {self.biovalidator_path}" | ||
) | ||
|
||
def verify_executables_installed(self): | ||
for name, path in [('vcf-validator', self.vcf_validator_path), | ||
('vcf-assembly-checker', self.assembly_checker_path), | ||
('biovalidator', self.biovalidator_path)]: | ||
try: | ||
run_command_with_output( | ||
f"Check {name} is installed and available on the path", | ||
f"{path} --version" | ||
) | ||
except subprocess.CalledProcessError as ex: | ||
logger.error(ex) | ||
raise RuntimeError(f"Please make sure {name} ({path}) is installed and available on the path") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.