Skip to content

Commit

Permalink
rename file and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina Bernick committed Oct 27, 2023
1 parent 0ebf127 commit 3c7e85b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions workflows/index-generation/generate_lineage_csvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def version_taxon_lineages(
num_deleted_taxa = 0

# writer for versioned output taxon lineage csv
versioned_csv_writer = csv.DictWriter(wf, fieldnames=_fieldnames + _versioning_fieldnames)
versioned_csv_writer = csv.DictWriter(
wf, fieldnames=_fieldnames + _versioning_fieldnames
)
versioned_csv_writer.writeheader()

changed_taxa_writer = csv.writer(changed_taxa)
Expand All @@ -278,7 +280,7 @@ def version_taxon_lineages(
new_taxa_writer = csv.writer(new_taxa_log)
new_taxa_writer.writerow(["taxid", "tax_name"])

# Keeping track of taxids in the non-versioned lineage file
# Keeping track of taxids in the non-versioned lineage file
# allows us to separate taxa that have been deprecated altogether
# from those that have just had their lineage changed.
non_deprecated_taxids = set()
Expand Down Expand Up @@ -344,13 +346,15 @@ def version_taxon_lineages(
versioned_csv_writer.writerow(previous_row)
num_deprecated_rows += 1
num_total_new_rows += 1
if not previous_row["taxid"] in non_deprecated_taxids and previous_row["version_end"] == previous_lineages_version:
if (
not previous_row["taxid"] in non_deprecated_taxids
and previous_row["version_end"] == previous_lineages_version
):
deleted_taxa_writer.writerow(
[previous_row["taxid"], previous_row["tax_name"]]
)
num_deleted_taxa += 1


summary_counts = (
f"Number of taxa with unchanged lineages: {num_unchanged_rows}\n"
f"Number of taxa with updated lineages: {num_updated_lineage_rows}\n"
Expand Down

0 comments on commit 3c7e85b

Please sign in to comment.