Skip to content

Commit

Permalink
add reviewer sugestions BU-ISCIII#258
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-VM committed Apr 9, 2024
1 parent bdbb1d3 commit d7799a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 14 additions & 5 deletions relecov_tools/assets/pipeline_utils/viralrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,26 @@ def convert_to_json(self, samp_dict):
j_list = []
# Grab date from filename
result_regex = re.search(
"variants_long_table_(.*).csv", os.path.basename(self.file_path)
"variants_long_table(?:_\d{8})?\.csv", os.path.basename(self.file_path)
)
stderr.print(result_regex.group(0))
if result_regex is None:
log.error("Analysis date not found in filename, aborting")
stderr.print(
"[red]Error: filename must include analysis date in format YYYYMMDD"
"[EROR]\tWARN: Couldn't find variants long table file. Expected file name is:\n\t" +
"variants_long_table.csv or variants_long_table_YYYYMMDD.csv. Aborting..."
)
stderr.print("[red]e.g. variants_long_table_20220830.csv")
sys.exit(1)
else:
date_regex = re.search(r"(\d{8})", result_regex.group())
if date_regex is not None:
analysis_date = date_regex
stderr.print(f"[green]\tDate {analysis_date.group()} found in {self.file_path}")
else:
analysis_date = "Not Provided [GENEPIO:0001668]"
stderr.print(f"[yellow]\tWARN:No analysis date found in long table: {self.file_path}")

for key, values in samp_dict.items():
j_dict = {"sample_name": key, "analysis_date": result_regex.group(1)}
j_dict = {"sample_name": key, "analysis_date": analysis_date.group()}
j_dict["variants"] = values
j_list.append(j_dict)
return j_list
Expand Down
4 changes: 2 additions & 2 deletions relecov_tools/conf/bioinfo_config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"viralrecon": {
"mapping_stats": {
"fn": "mapping_illumina_stats.tab",
"fn": "mapping_illumina_stats(?:_\\d{8})?\\.tab",
"sample_col_idx": 5,
"header_row_idx": 1,
"required": true,
Expand Down Expand Up @@ -37,7 +37,7 @@
}
},
"variants_long_table": {
"fn": "variants_long_table(?:_\\d{8})?\\.csv$",
"fn": "variants_long_table(?:_\\d{8})?\\.csv",
"sample_col_idx": 1,
"header_row_idx": 1,
"required": true,
Expand Down

0 comments on commit d7799a3

Please sign in to comment.