@@ -105,7 +105,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
105
105
db_version = None
106
106
db_name = None
107
107
check_files_exist (file_list )
108
- error_reports = []
108
+ modified_MLST_filess = []
109
109
110
110
for f in file_list :
111
111
if key_sample_name :
@@ -117,7 +117,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
117
117
if key_sample_name :
118
118
data , compare_errmsg = compare_profiles (data ,alt_profile , os .path .basename (f ))
119
119
if compare_errmsg :
120
- error_reports .append (compare_errmsg )
120
+ modified_MLST_filess .append (compare_errmsg )
121
121
# Write the a new updated JSON data back to a new file
122
122
with gzip .open ("{}/{}.gz" .format (outputdirectory , os .path .basename (f )), "wt" ) as f :
123
123
json .dump (data , f , indent = 4 )
@@ -133,7 +133,7 @@ def read_file_list(file_list, outputdirectory, perform_validation=False, key_sam
133
133
logger .critical ("Duplicate sample name detected: {}" .format (sq_data .data .sample_name ))
134
134
raise ValueError ("Attempting to merge allele profiles with the same sample name: {}" .format (sq_data .data .sample_name ))
135
135
136
- return records , error_reports
136
+ return records , modified_MLST_filess
137
137
138
138
def extract_profiles (records ):
139
139
profile = {}
@@ -225,9 +225,9 @@ def compare_profiles(mlst, sample_id, file_name):
225
225
mlst ["data" ]["profile" ] = {sample_id : profile .pop (original_key )}
226
226
mlst ["data" ]["sample_name" ] = sample_id
227
227
228
- error_report = [sample_id , keys , error_message ]
228
+ modified_MLST_file = [sample_id , keys , error_message ]
229
229
# Write the updated JSON data back to the original file
230
- return mlst , error_report
230
+ return mlst , modified_MLST_file
231
231
232
232
def run_merge (config ):
233
233
analysis_parameters = config
@@ -267,7 +267,7 @@ def run_merge(config):
267
267
268
268
#perform merge
269
269
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 )
271
271
272
272
#create profile
273
273
df = pd .DataFrame .from_dict (extract_profiles (records ), orient = 'index' )
@@ -277,9 +277,9 @@ def run_merge(config):
277
277
del (df )
278
278
run_data ['result_file' ] = os .path .join (outdir ,"profile.tsv" )
279
279
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 ]:
283
283
output_error_file = outdir + "/" + error_message [0 ] + "_error_report.csv"
284
284
with open (output_error_file , "w" , newline = "" ) as f :
285
285
writer = csv .writer (f )
0 commit comments