Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BarcodeHandler.from_file: Pass down parameters #25

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
}
}