spacr.qt.widgets.barcode_regex

Interactive editor for sequencing barcode regular expressions.

Barcode regexes are not filename regexes. The sequencing pipeline requires three specifically named capture groups (columnID, grna and rowID), so the generic filename-regex editor cannot validate this field. This module keeps the compact settings row while providing a focused dialog that compiles the expression and previews its captures against a pasted read.

Classes

BarcodeRegexDialog

Edit and test a barcode regex against a representative read.

BarcodeRegexResult

Validation result shown by the inline field and test dialog.

BarcodeRegexWidget

Compact settings-row field with inline validation and a test dialog.

Functions

evaluate_barcode_regex(→ BarcodeRegexResult)

Compile a barcode regex and optionally apply it to one sequence.

Module Contents

class spacr.qt.widgets.barcode_regex.BarcodeRegexDialog(initial_regex: str = '', parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Edit and test a barcode regex against a representative read.

Parameters:
  • initial_regex – the expression to open with. Empty opens the field empty; the dialog proposes nothing until the user tests a read.

  • parent – parent widget.

Build the barcode-regex tester.

Sized in scaled pixels rather than raw ones: a size set from Python does not grow with the stylesheet’s font size, and at the 200% scale the prose inside wrapped to more height than the window had.

Parameters:
  • initial_regex – the pattern to open with; empty uses spaCR’s default.

  • parent – parent widget, or None.

class spacr.qt.widgets.barcode_regex.BarcodeRegexResult[source]

Validation result shown by the inline field and test dialog.

Parameters:
  • valid – whether the pattern (and the sample, when one was given) passed.

  • message – one-line explanation to show beside the field.

  • captures – the columnID, grna and rowID values the sample produced; empty when no sample was matched.

class spacr.qt.widgets.barcode_regex.BarcodeRegexWidget(value: str = '', parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

Compact settings-row field with inline validation and a test dialog.

Parameters:
  • value – the regular expression already saved. Empty opens the field empty rather than with a suggestion, so a blank setting stays blank until the user or the test dialog fills it.

  • parent – parent widget.

Build the inline regex field with its verdict mark and Test button.

Parameters:
  • value – the pattern to start with.

  • parent – parent widget, or None.

get_value()[source]

Return the edited regex, or None for a blank field.

set_value(value) → None[source]

Replace the current regex and immediately refresh validation.

Parameters:

value – the regex text; None clears the field, anything else is converted with str.

spacr.qt.widgets.barcode_regex.evaluate_barcode_regex(pattern: str, sample: str = '') → BarcodeRegexResult[source]

Compile a barcode regex and optionally apply it to one sequence.

A usable mapping expression must define every named group consumed by spacr.sequencing. When a sample is supplied it must also match and produce a non-empty value for each required group.

Parameters:
  • pattern – the regular expression, stripped of surrounding whitespace; it must define the named groups columnID, grna and rowID.

  • sample – an optional read to match from its start with re.match; all whitespace is removed first, and empty skips the match.