Skip to content

Commit 15ac8e3

Browse files
committed
fix header function
1 parent f246d28 commit 15ac8e3

File tree

4 files changed

+30
-38
lines changed

4 files changed

+30
-38
lines changed

src/barcode_calling/callers/base.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,8 @@ def __str__(self) -> str:
147147
return "%s\t%s\t%s\t%d\t%s\t%s" % (self.read_id, self._barcode, self._umi,
148148
self.BC_score, self.UMI_good, self.strand)
149149

150-
def header(self) -> str:
151-
"""Get TSV header for result output."""
152-
return BarcodeDetectionResult._header()
153-
154150
@staticmethod
155-
def _header() -> str:
151+
def header() -> str:
156152
"""Static header for class-level access."""
157153
return "#read_id\tbarcode\tUMI\tBC_score\tvalid_UMI\tstrand"
158154

@@ -219,14 +215,10 @@ def __str__(self) -> str:
219215
return (BarcodeDetectionResult.__str__(self) +
220216
"\t%d\t%d\t%d\t%d" % (self.polyT, self.primer, self.linker_start, self.linker_end))
221217

222-
def header(self) -> str:
223-
"""Get TSV header for result output."""
224-
return LinkerBarcodeDetectionResult._header()
225-
226218
@staticmethod
227-
def _header() -> str:
219+
def header() -> str:
228220
"""Static header for class-level access."""
229-
return BarcodeDetectionResult._header() + "\tpolyT_start\tprimer_end\tlinker_start\tlinker_end"
221+
return BarcodeDetectionResult.header() + "\tpolyT_start\tprimer_end\tlinker_start\tlinker_end"
230222

231223

232224
class TSOBarcodeDetectionResult(LinkerBarcodeDetectionResult):
@@ -259,16 +251,11 @@ def get_additional_attributes(self) -> List[str]:
259251
attr.append("Linker detected")
260252
if self.tso5 != -1:
261253
attr.append("TSO detected")
262-
return attr
263-
264-
def header(self) -> str:
265-
"""Get TSV header for result output."""
266-
return TSOBarcodeDetectionResult._header()
267254

268255
@staticmethod
269-
def _header() -> str:
256+
def header() -> str:
270257
"""Static header for class-level access."""
271-
return LinkerBarcodeDetectionResult._header() + "\tTSO5"
258+
return LinkerBarcodeDetectionResult.header() + "\tTSO5"
272259

273260

274261
class TenXBarcodeDetectionResult(BarcodeDetectionResult):
@@ -305,14 +292,10 @@ def __str__(self) -> str:
305292
return (BarcodeDetectionResult.__str__(self) +
306293
"\t%d\t%d" % (self.polyT, self.r1))
307294

308-
def header(self) -> str:
309-
"""Get TSV header for result output."""
310-
return TenXBarcodeDetectionResult._header()
311-
312295
@staticmethod
313-
def _header() -> str:
296+
def header() -> str:
314297
"""Static header for class-level access."""
315-
return BarcodeDetectionResult._header() + "\tpolyT_start\tR1_end"
298+
return BarcodeDetectionResult.header() + "\tpolyT_start\tR1_end"
316299

317300

318301
class SplittingBarcodeDetectionResult:
@@ -398,9 +381,10 @@ def __str__(self) -> str:
398381
"""Format all patterns as TSV lines."""
399382
return "\n".join(str(r) for r in self.detected_patterns)
400383

401-
def header(self) -> str:
384+
@staticmethod
385+
def header() -> str:
402386
"""Get TSV header for result output."""
403-
return TSOBarcodeDetectionResult._header()
387+
return TSOBarcodeDetectionResult.header()
404388

405389

406390
class ReadStats:

src/barcode_calling/callers/curio.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ def _find_barcode_umi_fwd(self, read_id: str, sequence: str) -> LinkerBarcodeDet
193193
def result_type():
194194
return LinkerBarcodeDetectionResult
195195

196-
def header(self):
197-
return self.result_type()._header()
196+
@classmethod
197+
def header(cls):
198+
return cls.result_type().header()
198199

199200

200201
class CurioIlluminaDetector:
@@ -333,5 +334,7 @@ def _find_barcode_umi_fwd(self, read_id: str, sequence: str) -> LinkerBarcodeDet
333334
def result_type():
334335
return LinkerBarcodeDetectionResult
335336

336-
def header(self):
337-
return self.result_type()._header()
337+
@classmethod
338+
def header(cls):
339+
return cls.result_type().header()
340+

src/barcode_calling/callers/stereo.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ def _find_barcode_umi_fwd(self, read_id: str, sequence: str) -> LinkerBarcodeDet
203203
def result_type():
204204
return LinkerBarcodeDetectionResult
205205

206-
def header(self):
207-
return self.result_type().header()
206+
@classmethod
207+
def header(cls):
208+
return cls.result_type().header()
208209

209210

210211
class SharedMemoryStereoBarcodeDetector(StereoBarcodeDetector):
@@ -493,8 +494,9 @@ def _find_barcode_umi_fwd(self, read_id: str, sequence: str) -> TSOBarcodeDetect
493494
def result_type():
494495
return SplittingBarcodeDetectionResult
495496

496-
def header(self):
497-
return self.result_type().header()
497+
@classmethod
498+
def header(cls):
499+
return cls.result_type().header()
498500

499501

500502
class SharedMemoryStereoSplittingBarcodeDetector(StereoSplittingBarcodeDetector):

src/barcode_calling/callers/tenx.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ def find_barcode_umi_no_polya(self, read_id: str, sequence: str) -> TenXBarcodeD
175175
def result_type():
176176
return TenXBarcodeDetectionResult
177177

178-
def header(self):
179-
return self.result_type()._header()
178+
@classmethod
179+
def header(cls):
180+
return cls.result_type().header()
181+
180182

181183
class VisiumHDBarcodeDetector:
182184
"""Visium HD spatial transcriptomics barcode detector."""
@@ -347,5 +349,6 @@ def find_barcode_umi_no_polya(self, read_id: str, sequence: str) -> TenXBarcodeD
347349
def result_type():
348350
return TenXBarcodeDetectionResult
349351

350-
def header(self):
351-
return self.result_type()._header()
352+
@classmethod
353+
def header(cls):
354+
return cls.result_type().header()

0 commit comments

Comments
 (0)