Skip to content

Commit

Permalink
nested with
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewprzh committed Aug 2, 2024
1 parent 7e55e93 commit e35a0b0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/long_read_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,23 +363,23 @@ def dump_ungrouped(self, all_features):
f.write("__usable\t%d\n" % self.reads_for_tpm)

def dump_grouped(self, all_features, all_groups):
with (self.get_output_file_handler() as output_file,
self.get_linear_output_file_handler() as linear_output_file):
assert linear_output_file is not None

output_file.write(self.format_header(all_groups))
linear_output_file.write("#feature_id\tgroup_id\tcount\n")
for feature_id in all_features:
row_count = 0
for group_id in self.feature_counter[feature_id].data.keys():
count = self.feature_counter[feature_id].data[group_id]
linear_output_file.write("%s\t%s\t%.2f\n" % (feature_id, self.ordered_groups[group_id], count))
row_count += count
if not self.output_zeroes and row_count == 0:
continue
count_values = [self.feature_counter[feature_id].get(self.group_numeric_ids[group_id]) for group_id in
all_groups]
output_file.write("%s\t%s\n" % (feature_id, "\t".join(["%.2f" % c for c in count_values])))
with self.get_output_file_handler() as output_file:
with self.get_linear_output_file_handler() as linear_output_file:
assert linear_output_file is not None

output_file.write(self.format_header(all_groups))
linear_output_file.write("#feature_id\tgroup_id\tcount\n")
for feature_id in all_features:
row_count = 0
for group_id in self.feature_counter[feature_id].data.keys():
count = self.feature_counter[feature_id].data[group_id]
linear_output_file.write("%s\t%s\t%.2f\n" % (feature_id, self.ordered_groups[group_id], count))
row_count += count
if not self.output_zeroes and row_count == 0:
continue
count_values = [self.feature_counter[feature_id].get(self.group_numeric_ids[group_id]) for group_id in
all_groups]
output_file.write("%s\t%s\n" % (feature_id, "\t".join(["%.2f" % c for c in count_values])))

def convert_counts_to_tpm(self, normalization_str=NormalizationMethod.simple.name):
normalization = NormalizationMethod[normalization_str]
Expand Down

0 comments on commit e35a0b0

Please sign in to comment.