diff --git a/src/sctools/bam.py b/src/sctools/bam.py index 77040de..ea3bddc 100644 --- a/src/sctools/bam.py +++ b/src/sctools/bam.py @@ -448,6 +448,7 @@ def key_generator(self) -> Callable[[pysam.AlignedSegment], Any]: class QueryNameSortOrder(AlignmentSortOrder): + """Alignment record sort order by query name.""" @staticmethod def get_sort_key(alignment: pysam.AlignedSegment) -> str: return alignment.query_name @@ -461,6 +462,7 @@ def __repr__(self) -> str: class CellMoleculeGeneQueryNameSortOrder(AlignmentSortOrder): + """Hierarchical alignment record sort order (cell barcode >= molecule barcode >= gene name >= query name).""" def __init__( self, cell_barcode_tag_key: str = consts.CELL_BARCODE_TAG_KEY, @@ -473,7 +475,7 @@ def __init__( self.molecule_barcode_tag_key = molecule_barcode_tag_key self.gene_name_tag_key = gene_name_tag_key - def get_sort_key(self, alignment: pysam.AlignedSegment) -> Tuple[str, str, str, str]: + def _get_sort_key(self, alignment: pysam.AlignedSegment) -> Tuple[str, str, str, str]: return (get_tag_or_default(alignment, self.cell_barcode_tag_key), get_tag_or_default(alignment, self.molecule_barcode_tag_key), get_tag_or_default(alignment, self.gene_name_tag_key), @@ -481,7 +483,7 @@ def get_sort_key(self, alignment: pysam.AlignedSegment) -> Tuple[str, str, str, @property def key_generator(self) -> Callable[[pysam.AlignedSegment], Tuple[str, str, str, str]]: - return self.get_sort_key + return self._get_sort_key def __repr__(self) -> str: return 'hierarchical__cell_molecule_gene_query_name'