diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd336a7..59cd25c6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ Code contributions to the hotfix: - Brought back `PASS_ONLY` to exometrio's `exomiser_configfile.yml` - [#187](https://github.com/BU-ISCIII/buisciii-tools/pull/187) - Added new template for bacterial assembly. Allowing for short, long and hybrid assembly. - [#190](https://github.com/BU-ISCIII/buisciii-tools/pull/190) - renamed some variables in create-summary_report from viralrecon template as their name was misleading and fixed a small typo in regex finding in excel_generator.py +- [#192](https://github.com/BU-ISCIII/buisciii-tools/pull/192) - Small changes in excel_generator.py to automatically merge pangolin/nextclade tables when more than 1 reference is found ### Modules diff --git a/bu_isciii/templates/viralrecon/RESULTS/excel_generator.py b/bu_isciii/templates/viralrecon/RESULTS/excel_generator.py index c9243324..b33c761c 100755 --- a/bu_isciii/templates/viralrecon/RESULTS/excel_generator.py +++ b/bu_isciii/templates/viralrecon/RESULTS/excel_generator.py @@ -4,8 +4,8 @@ from typing import List, Dict # conda activate viralrecon_report -"""Usage: python excel_generator.py ./reference.tmp""" -"""Single csv to excel Usage: python excel_generator.py -s csv_file.csv""" +"""Standard usage: python excel_generator.py -r ./reference.tmp""" +"""Single csv to excel usage: python excel_generator.py -s csv_file.csv""" parser = argparse.ArgumentParser( description="Generate excel files from viralrecon results" ) @@ -22,14 +22,6 @@ default="", help="Transform a single csv file to excel format. Omit rest of processes", ) -parser.add_argument( - "-l", - "--merge_lineage_files", - type=str, - default="", - help="Merge pangolin and nextclade lineage tables", -) - args = parser.parse_args() @@ -112,7 +104,7 @@ def excel_generator(csv_files: List[str]): except pd.errors.EmptyDataError: print("Could not parse table from ", str(file)) continue - table.drop(["index"], axis=1, errors="ignore") + table = table.drop(["index"], axis=1, errors="ignore") table.to_excel(output_name, index=False) return @@ -143,7 +135,7 @@ def main(args): ref: str("ref_samples/samples_" + ref + ".tmp") for ref in references } - if args.merge_lineage_files: + if len(references) > 1: # Merge pangolin and nextclade csv files separatedly and create excel files for them merge_lineage_tables(reference_folders, samples_ref_files) for reference, folder in reference_folders.items(): @@ -162,7 +154,8 @@ def main(args): csvs_in_folder=variants_tables, merged_csv_name="variants_long_table.csv" ) except FileNotFoundError as e: - print("Not variants_long_table found for ", str(e)) + print(str(e)) + print("Merged variants_long_table.csv might be empty") # Create excel files for individual tables valid_extensions = [".csv", ".tsv", ".tab"]