Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #96 from czbiohub/revert-89-pranathi-mp
Browse files Browse the repository at this point in the history
fix the bug in unique files of create_save_summary
  • Loading branch information
pranathivemuri authored Oct 19, 2020
2 parents db2b1b3 + 9261a19 commit fe04a91
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sencha/create_save_summary.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import csv
import itertools
import json
import os
from collections import Counter

import numpy as np
import pyarrow as pa
import pyarrow.parquet as pq
from sencha.constants_translate import (
LOW_COMPLEXITY_CATEGORIES,
PROTEIN_CODING_CATEGORIES,
Expand All @@ -29,7 +28,9 @@ def __init__(
jaccard_threshold,
coding_scores,
):
self.filenames = filenames
if type(filenames) is str:
filenames = [filenames]
self.unique_filenames = [os.path.basename(f) for f in filenames]
self.csv = csv
self.parquet = parquet
self.json_summary = json_summary
Expand Down Expand Up @@ -64,6 +65,9 @@ def maybe_write_csv(self):

def maybe_write_parquet(self):
if self.parquet:
import pyarrow as pa
import pyarrow.parquet as pq

logger.info("Writing coding scores of reads to {}".format(self.parquet))
batch = pa.RecordBatch.from_arrays(
[
Expand Down Expand Up @@ -92,7 +96,7 @@ def maybe_write_json_summary(self):

if self.coding_scores == []:
summary = {
"input_files": self.filenames,
"input_files": self.unique_filenames,
"jaccard_info": {
"count": 0,
"mean": None,
Expand Down Expand Up @@ -135,8 +139,6 @@ def generate_coding_summary(self):
translation_frame_counts,
) = self.get_n_translated_frames_per_read()

files = np.unique(self.filenames).tolist()

(
categorization_percentages,
categorization_counts,
Expand All @@ -154,7 +156,7 @@ def generate_coding_summary(self):
}

summary = {
"input_files": files,
"input_files": self.unique_filenames,
"jaccard_info": jaccard_info,
"categorization_counts": categorization_counts,
"categorization_percentages": categorization_percentages,
Expand Down

0 comments on commit fe04a91

Please sign in to comment.