Skip to content

Commit

Permalink
more moltype
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegenes committed Dec 20, 2024
1 parent b63d666 commit 0c7ed1b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/sourmash/minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __getstate__(self):
# get a ksize that makes sense to the Rust layer. See #2262.
return (
self.num,
self.ksize if self.is_dna else self.ksize * 3,
self.ksize if self.is_dna or self.skipm1n3 or self.skipm2n3 else self.ksize * 3,
self.is_protein,
self.dayhoff,
self.hp,
Expand Down Expand Up @@ -481,7 +481,7 @@ def kmers_and_hashes(self, sequence, *, force=False, is_protein=False):

def add_kmer(self, kmer):
"Add a kmer into the sketch."
if self.is_dna:
if self.is_dna or self.skipm1n3 or self.skipm2n3:
if len(kmer) != self.ksize:
raise ValueError(f"kmer to add is not {self.ksize} in length")
else:
Expand Down Expand Up @@ -608,7 +608,7 @@ def skipm2n3(self):
@property
def ksize(self):
k = self._methodcall(lib.kmerminhash_ksize)
if not self.is_dna:
if not self.is_dna and not self.skipm1n3 and not self.skipm2n3:
assert k % 3 == 0
k = int(k / 3)
return k
Expand Down Expand Up @@ -1081,6 +1081,10 @@ def moltype(self): # TODO: test in minhash tests
return "dayhoff"
elif self.hp:
return "hp"
elif self.skipm1n3:
return "skipm1n3"
elif self.skipm2n3:
return "skipm2n3"
else:
return "DNA"

Expand Down

0 comments on commit 0c7ed1b

Please sign in to comment.