Skip to content

Extension of Kmer class to return numeric indices for each nucleotide #5

Description

@ghuls

Extension of Kmer class to return numeric indices for each nucleotide:

@extend
class Kmer:
    def nucleotide_indices(self) -> List[int]:
        """
        Get nucleotide indices for each nucleotide position in the Kmer.

        The nucleotide index for a nucleotide corresponds with the position in "ACGT".
        """
        nuc_idx = List[int](k)
        x = self.x
        i = k - 1
        while i >= 0:
            nuc_idx.append(int(x & UInt[2*k](3)))
            x >>= UInt[2*k](2)
            i -= 1
        nuc_idx.reverse()
        return nuc_idx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions