Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes in excel_generator.py #192

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 6 additions & 13 deletions bu_isciii/templates/viralrecon/RESULTS/excel_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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()


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand All @@ -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"]
Expand Down
Loading