Skip to content

Commit

Permalink
cell name method extracted to common 10x superclass
Browse files Browse the repository at this point in the history
  • Loading branch information
lchorbadjiev committed May 28, 2020
1 parent f861dda commit 0d9b34a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
10 changes: 5 additions & 5 deletions sgains/pipelines/extract_10x_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def __init__(self, config):
self.genome = Genome(self.config)
assert self.genome is not None

@staticmethod
def _cell_name(cell_id):
cell_name = f"C{cell_id:0>8}"
return cell_name


class Extract10xPipeline(Base10xPipeline):

Expand Down Expand Up @@ -108,11 +113,6 @@ def _process_segment(self, segment, region):
self._write_to_fastq(barcode, segment, records)
cell_records[barcode] = []

@staticmethod
def _cell_name(cell_id):
cell_name = f"C{cell_id:0>8}"
return cell_name

def _cell_segment_filename(self, cell_id, segment):
cell_name = self._cell_name(cell_id)
segment_name = f"{segment:0>8}"
Expand Down
23 changes: 0 additions & 23 deletions sgains/pipelines/varbin_10x_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ def split_bins(self, bins_step, bins_region=None):
for chrom, start, end in regions
]

# @staticmethod
# def compress_reads(reads):
# if not reads:
# return None
# df = pd.DataFrame(reads, columns=['cell_id', 'chrom', 'pos'])
# buff = BytesIO()
# df.to_feather(buff)

# return str(buff.getbuffer(), encoding='latin1')

@staticmethod
def _cell_name(cell_id):
cell_name = f"C{cell_id:0>8}"
return cell_name

def _cell_reads_dirname(self, cell_id):
cell_name = self._cell_name(cell_id)
dirname = os.path.join(
Expand Down Expand Up @@ -160,14 +145,6 @@ def load_reads(self, cell_id):
result_df = result_df.sort_values(by=["cell_id", "chrom", "pos"])
return result_df

# @staticmethod
# def decompress_reads(data):
# if data is None:
# return None
# buff = BytesIO(bytes(data, encoding='latin1'))
# df = pd.read_feather(buff)
# return df

Read = namedtuple('Read', ['cell_id', 'chrom', 'pos'])

def process_region_reads(self, region, region_index):
Expand Down

0 comments on commit 0d9b34a

Please sign in to comment.