Skip to content

Commit

Permalink
Merge pull request #25 from mschilli87/barcodehandler-from_file-kwargs
Browse files Browse the repository at this point in the history
`BarcodeHandler.from_file`: Pass down parameters
  • Loading branch information
arogozhnikov authored Feb 27, 2024
2 parents 900e58c + 84ebb6b commit 88a4d3e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions demuxalot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ def get_barcode_index(self, read: pysam.AlignedRead) -> Optional[int]:
return self.barcode2index.get(barcode, None)

@staticmethod
def from_file(barcodes_filename):
def from_file(barcodes_filename, **kwargs):
"""
:param barcodes_filename: path to barcodes.csv or barcodes.csv.gz where each line is a barcode
:param **kwargs: optional additional keyword arguments to pass down to BarcodeHandler.__init__
"""
barcodes = pd.read_csv(barcodes_filename, header=None)[0].values
return BarcodeHandler(barcodes)
return BarcodeHandler(barcodes, **kwargs)

def filter_to_rg_value(self, rg_value):
""" Create a copy of this handler with only barcodes specific to one original file described by RG tag """
Expand Down Expand Up @@ -292,4 +293,4 @@ def _compute_qualities(probs: pd.DataFrame, barcode2possible_donors: dict):
"logloss": np.mean(loglosses),
"accuracy": np.mean(is_correct),
"error rate": 1 - np.mean(is_correct),
}
}

0 comments on commit 88a4d3e

Please sign in to comment.