Skip to content

Commit 580c272

Browse files
committed
Renamed variables related to profile mismatch
1 parent 1d7ae8f commit 580c272

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

locidex/merge.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
105105
db_version = None
106106
db_name = None
107107
check_files_exist(file_list)
108-
error_reports = []
108+
modified_MLST_filess = []
109109

110110
for f in file_list:
111111
if key_sample_name:
@@ -117,7 +117,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
117117
if key_sample_name:
118118
data, compare_errmsg = compare_profiles(data,alt_profile, os.path.basename(f))
119119
if compare_errmsg:
120-
error_reports.append(compare_errmsg)
120+
modified_MLST_filess.append(compare_errmsg)
121121
# Write the a new updated JSON data back to a new file
122122
with gzip.open("{}/{}.gz".format(outputdirectory, os.path.basename(f)), "wt") as f:
123123
json.dump(data, f, indent=4)
@@ -133,7 +133,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
133133
logger.critical("Duplicate sample name detected: {}".format(sq_data.data.sample_name))
134134
raise ValueError("Attempting to merge allele profiles with the same sample name: {}".format(sq_data.data.sample_name))
135135

136-
return records, error_reports
136+
return records, modified_MLST_filess
137137

138138
def extract_profiles(records):
139139
profile = {}
@@ -225,9 +225,9 @@ def compare_profiles(mlst, sample_id, file_name):
225225
mlst["data"]["profile"] = {sample_id: profile.pop(original_key)}
226226
mlst["data"]["sample_name"] = sample_id
227227

228-
error_report = [sample_id, keys, error_message]
228+
modified_MLST_file = [sample_id, keys, error_message]
229229
# Write the updated JSON data back to the original file
230-
return mlst, error_report
230+
return mlst, modified_MLST_file
231231

232232
def run_merge(config):
233233
analysis_parameters = config
@@ -267,7 +267,7 @@ def run_merge(config):
267267

268268
#perform merge
269269
file_list = get_file_list(input_files)
270-
records, compare_error = read_file_list(file_list, outdir, perform_validation=validate_db, key_sample_name=sample_dict)
270+
records, modified_MLST_file_list = read_file_list(file_list, outdir, perform_validation=validate_db, key_sample_name=sample_dict)
271271

272272
#create profile
273273
df = pd.DataFrame.from_dict(extract_profiles(records), orient='index')
@@ -277,9 +277,9 @@ def run_merge(config):
277277
del(df)
278278
run_data['result_file'] = os.path.join(outdir,"profile.tsv")
279279

280-
#Write error messages for profile mismatch (compare_profiles())
281-
for error_message in compare_error:
282-
if error_message[2]:
280+
#Write report of all the MLST files with profile mismatch and how MLST profiles with mismatch were modified
281+
for report_message in modified_MLST_file_list:
282+
if report_message[2]:
283283
output_error_file = outdir + "/" + error_message[0] + "_error_report.csv"
284284
with open(output_error_file, "w", newline="") as f:
285285
writer = csv.writer(f)

0 commit comments

Comments
 (0)