-
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.
- Loading branch information
Showing
5 changed files
with
145 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,69 @@ | ||
import os | ||
from argparse import ArgumentParser | ||
|
||
from ebi_eva_common_pyutils.logger import logging_config | ||
|
||
from cli import SUB_CLI_CONFIG_FILE | ||
from cli.docker_validator import DockerValidator, docker_path, container_image | ||
from cli.submit import StudySubmitter | ||
from cli.writable_config import WritableConfig | ||
|
||
VALIDATION_OUTPUT_DIR = "validation_output" | ||
VALIDATE = 'validate' | ||
SUBMIT = 'submit' | ||
RESUME = 'resume' | ||
|
||
logging_config.add_stdout_handler() | ||
|
||
|
||
def get_docker_validator(vcf_files_mapping, output_dir, metadata_json, metadata_xlsx, | ||
arg_container, arg_docker, sub_config): | ||
docker = arg_docker or docker_path | ||
container = arg_container or container_image | ||
validation_output_dir = os.path.join(output_dir, VALIDATION_OUTPUT_DIR) | ||
return DockerValidator(vcf_files_mapping, validation_output_dir, metadata_json, metadata_xlsx, | ||
container, docker, sub_config) | ||
|
||
|
||
if __name__ == "__main__": | ||
argparse = ArgumentParser(description='EVA Submission CLI') | ||
argparse.add_argument('--submission-dir', required=True, type=str, | ||
help='Full path to the submission directory where all submission info is/will be stored') | ||
argparse.add_argument('--resume', action='store_true', default=False, help='resume an existing submission') | ||
args = argparse.parse_args() | ||
|
||
logging_config.add_stdout_handler() | ||
|
||
submitter = StudySubmitter() | ||
if args.resume: | ||
submitter.upload_submission(args.submission_dir) | ||
else: | ||
submitter.submit(args.submission_dir) | ||
argparser = ArgumentParser(description='EVA SUB CLI - to validate and submit a submission') | ||
argparser.add_argument('--task', required=True, choices=[VALIDATE, SUBMIT, RESUME], | ||
help='Select a task to perform') | ||
argparser.add_argument('--submission_dir', required=True, type=str, | ||
help='Full path to the directory where all processing will be done and submission info is/will be stored') | ||
argparser.add_argument("--docker_path", help="Full path to the docker installation, " | ||
"not required if docker is available on path", required=False) | ||
argparser.add_argument("--container_name", help="Name of the docker container", required=False) | ||
argparser.add_argument("--vcf_files_mapping", required=False, | ||
help="csv file with the mappings for vcf files, fasta and assembly report") | ||
group = argparser.add_mutually_exclusive_group(required=False) | ||
group.add_argument("--metadata_json", | ||
help="Json file that describe the project, analysis, samples and files") | ||
group.add_argument("--metadata_xlsx", | ||
help="Excel spreadsheet that describe the project, analysis, samples and files") | ||
|
||
args = argparser.parse_args() | ||
|
||
# load config | ||
config_file_path = os.path.join(args.submission_dir, SUB_CLI_CONFIG_FILE) | ||
sub_config = WritableConfig(config_file_path) | ||
|
||
if args.task == RESUME: | ||
submitter = StudySubmitter(args.submission_dir, submission_config=sub_config) | ||
submitter.upload_submission() | ||
|
||
if args.task == VALIDATE or args.task == SUBMIT: | ||
if not args.vcf_files_mapping: | ||
raise Exception(f"Please provide csv file with the mappings of vcf files using --vcf_files_mapping") | ||
if not args.metadata_json and not args.metadata_xlsx: | ||
raise Exception(f"Please provide the file that describes the project, analysis, samples and files " | ||
f"using either --metadata_json or --metadata_xlsx") | ||
docker_validator = get_docker_validator(args.vcf_files_mapping, args.submission_dir, args.metadata_json, | ||
args.metadata_xlsx, args.container_name, args.docker_path, sub_config) | ||
docker_validator.validate() | ||
docker_validator.create_reports() | ||
|
||
if args.task == SUBMIT: | ||
docker_validator.update_config_with_validation_result() | ||
submitter = StudySubmitter(args.submission_dir) | ||
submitter.submit(args.submission_dir, submission_config=sub_config) |
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