fls-bioinformatics-core / auto_process_ngs

Scripts and utilities for automatic processing & management of Illumina NGS sequencing data.
Other
9 stars 6 forks source link

Enable '__repr__' method on QCProtocol class & recover instances from 'repr' string #844

Closed pjbriggs closed 1 year ago

pjbriggs commented 1 year ago

Implements the __repr__ built-in on the QCProtocol class in qc/protocols, to produce a specification string.

A new function parse_protocol_spec can break down the specification string to provide the arguments required to recover the parent instance, for example:

>>> p = QCProtocol(...)
>>> args = parse_protocol_spec(repr(p))
>>> q = QCProtocol(**args)

Alternatively a new classmethod from_specification of the QCProtocol class can create an instance directly from a protocol specification string, for example:

>>> p = QCProtocol(...)
>>> q = QCProtocol.from_specification(repr(p))

The PR also implements the __eq__ built-in on QCProtocol, so it's possible to check if two instances are equivalent.