Skip to content

Commit

Permalink
Additional fixes for the comparison with previous counts
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Jul 3, 2024
1 parent a179f7c commit 39a9a59
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ def _write_per_taxonomy_counts(self, session):
else:
prev_count_for_taxonomy = None
for rs_type in taxonomy_counts.get(taxonomy_id):
count_prev = 0
if prev_count_for_taxonomy:
count_new = taxonomy_counts.get(taxonomy_id).get(rs_type) - getattr(prev_count_for_taxonomy,
self._type_to_column(rs_type))
else:
count_new = 0
count_prev = getattr(prev_count_for_taxonomy, self._type_to_column(rs_type))

count_new = taxonomy_counts.get(taxonomy_id).get(rs_type) - count_prev
setattr(taxonomy_row, self._type_to_column(rs_type), taxonomy_counts.get(taxonomy_id).get(rs_type))
setattr(taxonomy_row, self._type_to_column(rs_type, is_new=True), count_new)
session.add(taxonomy_row)
Expand Down Expand Up @@ -333,11 +333,10 @@ def _write_per_assembly_counts(self, session):
else:
prev_count_for_assembly = None
for rs_type in assembly_counts.get(assembly):
count_prev = 0
if prev_count_for_assembly:
count_new = assembly_counts.get(assembly).get(rs_type) - getattr(prev_count_for_assembly,
self._type_to_column(rs_type))
else:
count_new = 0
count_prev = getattr(prev_count_for_assembly, self._type_to_column(rs_type))
count_new = assembly_counts.get(assembly).get(rs_type) -count_prev
setattr(assembly_row, self._type_to_column(rs_type), assembly_counts.get(assembly).get(rs_type))
setattr(assembly_row, self._type_to_column(rs_type, is_new=True), count_new)
session.add(assembly_row)
Expand Down Expand Up @@ -374,11 +373,11 @@ def _write_per_taxonomy_and_assembly_counts(self, session):
else:
prev_count_for_taxonomy_assembly = None
for rs_type in species_assembly_counts.get((taxonomy, assembly)):
count_prev = 0
if prev_count_for_taxonomy_assembly:
count_new = species_assembly_counts.get((taxonomy, assembly)).get(rs_type) - \
getattr(prev_count_for_taxonomy_assembly, self._type_to_column(rs_type))
else:
count_new = 0
count_prev = getattr(prev_count_for_taxonomy_assembly, self._type_to_column(rs_type))

count_new = species_assembly_counts.get((taxonomy, assembly)).get(rs_type) - count_prev
setattr(taxonomy_assembly_row, self._type_to_column(rs_type),
species_assembly_counts.get((taxonomy, assembly)).get(rs_type))
setattr(taxonomy_assembly_row, self._type_to_column(rs_type, is_new=True), count_new)
Expand Down Expand Up @@ -475,7 +474,6 @@ def generate_per_assembly_counts(self):
for count_dict in count_groups
if count_dict['assembly'] is assembly_accession and count_dict['idtype'] is rstype
]))

assembly_annotations[assembly_accession]['release_folder'] = assembly_accession
return assembly_counts, assembly_annotations

Expand All @@ -490,7 +488,11 @@ def generate_per_taxonomy_and_assembly_counts(self):
species_assembly_annotations[(taxonomy, assembly)] = {'release_folder': None}
# All count_dict have the same count in a group
species_assembly_counts[(taxonomy, assembly)][rstype] += count_groups[0]['count']
species_assembly_annotations[(taxonomy, assembly)]['release_folder'] = release_folder_map[taxonomy] + '/' + assembly
if assembly != 'Unmapped':
species_assembly_annotations[(taxonomy, assembly)]['release_folder'] = \
release_folder_map[taxonomy] + '/' + assembly
else:
species_assembly_annotations[(taxonomy, assembly)]['release_folder'] = release_folder_map[taxonomy]
return species_assembly_counts, species_assembly_annotations

def detect_inconsistent_types(self):
Expand Down

0 comments on commit 39a9a59

Please sign in to comment.