Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Oct 24, 2023
1 parent 31b2c42 commit 42aa503
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
13 changes: 10 additions & 3 deletions bin/samples_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ def read_metadata_json(json_file):
)


def resolve_vcf_file_location(vcf_files, files_per_analysis):
def associate_vcf_path_with_analysis(vcf_files, files_per_analysis):
"""
Match the files names associated with analysis provided in the metadata with the file path given on the command
line.
:param vcf_files the list of full path to the vcf files
:param files_per_analysis: dictionary of the analysis and their associated VCF file names
:returns dictionary of analysis and their associated vcf file path
"""
result_files_per_analysis = dict()
for analysis in files_per_analysis:
result_files_per_analysis[analysis] = []
Expand Down Expand Up @@ -137,8 +144,8 @@ def check_sample_name_concordance(metadata_json, vcf_files, output_yaml):
found in the VCF files
"""
samples_per_analysis, files_per_analysis = read_metadata_json(metadata_json)
files_per_analysis = resolve_vcf_file_location(vcf_files, files_per_analysis)
overall_differences, results_per_analysis_alias = compare_all_analysis(samples_per_analysis, files_per_analysis)
file_path_per_analysis = associate_vcf_path_with_analysis(vcf_files, files_per_analysis)
overall_differences, results_per_analysis_alias = compare_all_analysis(samples_per_analysis, file_path_per_analysis)
write_result_yaml(output_yaml, overall_differences, results_per_analysis_alias)


Expand Down
32 changes: 13 additions & 19 deletions eva_sub_cli/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,19 @@ def _collect_validation_workflow_results(self, ):
self._write_spreadsheet_validation_results()

@lru_cache
def _vcf_check_log(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
def _vcf_check_log(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'vcf_format', vcf_name + '.vcf_format.log')
)

@lru_cache
def _vcf_check_text_report(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
def _vcf_check_text_report(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'vcf_format', vcf_name + '.*.txt')
)

@lru_cache
def _vcf_check_db_report(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
def _vcf_check_db_report(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'vcf_format', vcf_name + '.*.db')
)
Expand All @@ -182,9 +179,9 @@ def _collect_vcf_check_results(self,):
for vcf_file in self.vcf_files:
vcf_name = os.path.basename(vcf_file)

vcf_check_log = self._vcf_check_log(vcf_file)
vcf_check_text_report = self._vcf_check_text_report(vcf_file)
vcf_check_db_report = self._vcf_check_db_report(vcf_file)
vcf_check_log = self._vcf_check_log(vcf_name)
vcf_check_text_report = self._vcf_check_text_report(vcf_name)
vcf_check_db_report = self._vcf_check_db_report(vcf_name)

if vcf_check_log and vcf_check_text_report and vcf_check_db_report:
valid, warning_count, error_count, critical_count, error_list, critical_list = self.parse_vcf_check_report(vcf_check_text_report)
Expand All @@ -201,22 +198,19 @@ def _collect_vcf_check_results(self,):
}

@lru_cache
def _assembly_check_log(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
def _assembly_check_log(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'assembly_check', vcf_name + '.assembly_check.log')
)
@lru_cache
def _assembly_check_valid_vcf(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
def _assembly_check_valid_vcf(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'assembly_check', vcf_name + '.valid_assembly_report*')
)

@lru_cache
def _assembly_check_text_report(self, vcf_file):
vcf_name = os.path.basename(vcf_file)
return resolve_single_file_path(
def _assembly_check_text_report(self, vcf_name):
return resolve_single_file_path(
os.path.join(self.output_dir, 'assembly_check', vcf_name + '*text_assembly_report*')
)

Expand All @@ -226,9 +220,9 @@ def _collect_assembly_check_results(self):
for vcf_file in self.vcf_files:
vcf_name = os.path.basename(vcf_file)

assembly_check_log = self._assembly_check_log(vcf_file)
assembly_check_valid_vcf = self._assembly_check_valid_vcf(vcf_file)
assembly_check_text_report = self._assembly_check_text_report(vcf_file)
assembly_check_log = self._assembly_check_log(vcf_name)
assembly_check_valid_vcf = self._assembly_check_valid_vcf(vcf_name)
assembly_check_text_report = self._assembly_check_text_report(vcf_name)

if assembly_check_log and assembly_check_valid_vcf and assembly_check_text_report:
error_list_from_log, nb_error_from_log, match, total = \
Expand Down

0 comments on commit 42aa503

Please sign in to comment.