syncoder 0.0.1a1__tar.gz → 0.0.2a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,5 +13,6 @@ out/
13
13
  *.zip
14
14
  *.jpg
15
15
  *.bin
16
+ .pypirc
16
17
  #any actual py files are in src. anything in root is supposed to just for development.
17
18
  /*.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syncoder
3
- Version: 0.0.1a1
3
+ Version: 0.0.2a1
4
4
  Summary: A codec for DNA data storage
5
5
  Project-URL: Homepage, https://example.com/TBD
6
6
  Project-URL: Issues, https://example.com/TBD/issues
@@ -8,6 +8,9 @@ Author-email: Christopher Takahashi <cnt@uw.edu>
8
8
  License-Expression: BSD-3-Clause
9
9
  License-File: LICENSE
10
10
  Requires-Python: >=3.9
11
+ Requires-Dist: galois>=0.4
12
+ Requires-Dist: numpy>=1.20
13
+ Requires-Dist: reedsolo>=1.7
11
14
  Description-Content-Type: text/markdown
12
15
 
13
16
  # SyNCODER
@@ -2,7 +2,7 @@ name: codec-user
2
2
  channels:
3
3
  - conda-forge
4
4
  dependencies:
5
- - python=3.12
5
+ - python>=3.12
6
6
  - numpy=2.*
7
7
  - pytest
8
8
  - reedsolo=1.7.*
@@ -2,7 +2,7 @@ name: codec-dev
2
2
  channels:
3
3
  - conda-forge
4
4
  dependencies:
5
- - python=3.12
5
+ - python>=3.12
6
6
  - numpy=2.*
7
7
  - matplotlib=3.*
8
8
  - pytest
@@ -2,7 +2,7 @@ name: codec-test
2
2
  channels:
3
3
  - conda-forge
4
4
  dependencies:
5
- - python=3.12
5
+ - python>=3.12
6
6
  - numpy=2.*
7
7
  - pytest
8
8
  - reedsolo=1.7.*
@@ -1,6 +1,11 @@
1
1
  [project]
2
2
  name = "syncoder"
3
- version = "0.0.1a1"
3
+ dynamic = ["version"]
4
+ dependencies = [
5
+ "numpy>=1.20",
6
+ "galois>=0.4",
7
+ "reedsolo>=1.7"
8
+ ]
4
9
  description = "A codec for DNA data storage"
5
10
  authors = [
6
11
  { name="Christopher Takahashi", email="cnt@uw.edu" }
@@ -24,4 +29,7 @@ build-backend = "hatchling.build"
24
29
  [tool.pytest.ini_options]
25
30
  testpaths = [
26
31
  "tests"
27
- ]
32
+ ]
33
+
34
+ [tool.hatch.version]
35
+ path = "src/syncoder/__init__.py"
@@ -1,4 +1,6 @@
1
1
  from .codec import *
2
2
  from .codec import _default_b32_alphabet, _default_b32_alphabet_alt
3
3
  default_b32_alphabet = _default_b32_alphabet
4
- default_b32_alphabet_alt = _default_b32_alphabet_alt
4
+ default_b32_alphabet_alt = _default_b32_alphabet_alt
5
+
6
+ __version__ = "0.0.2a1"
@@ -142,6 +142,7 @@ class BaseNBlockCodec:
142
142
  # ^ = self.index_bits <-- in bits not bytes.
143
143
  # note: actual k remains alphabet_size-1, but the code is shorted (0 padded) to inner_n symbols.
144
144
  k = inner_n - (inner_d - 1)
145
+ self.inner_k = k
145
146
  q = self.inner_coder.field.order
146
147
 
147
148
  #number of bytes needed to store the index
@@ -248,7 +249,7 @@ class BaseNBlockCodec:
248
249
  chunk += index<<(self.data_chunk_size*8)
249
250
  index += 1
250
251
  #but.. we still need to pad out the symbol stream.
251
- chunk = _int_to_baseN(chunk,self.inner_coder.field.order,length=self.inner_coder.k)
252
+ chunk = _int_to_baseN(chunk,self.inner_coder.field.order,length=self.inner_k)
252
253
  chunks.append(chunk)
253
254
 
254
255
  #apply inner code
@@ -386,7 +387,7 @@ def b32_to_DNA_optimize(file_data:list[ArrayLike],words:list[str], alternate_wor
386
387
  mask: list of ints. 0 for word, 1 for alternate word, -1 for don't care. None for no mask.
387
388
  nmasked: number of masked words. -1 for all.
388
389
  penalty_fn: function that takes a DNA sequence and returns a score. penalty_fn(DNA_seq:str)->int
389
- """
390
+ """
390
391
  if nmasked<0: #mask all
391
392
  return [b32_to_DNA_optimize_single(x,words,alternate_words,mask,penalty_fn=penalty_fn) for x in file_data]
392
393
  else:
@@ -398,7 +399,6 @@ def b32_to_DNA_optimize(file_data:list[ArrayLike],words:list[str], alternate_wor
398
399
  def b32_to_DNA_optimize_single(strand_data:ArrayLike, words:list[str], alternate_words:list[str], mask:Union[ArrayLike,None]=None ,penalty_fn=None)->Tuple[bytes,int]:
399
400
  """
400
401
  TODO: rename to bN_to_DNA_optimize_single
401
- TODO: add mask support.
402
402
  strand_data: 1d list of integral types
403
403
  mask: list of ints. 0 for word, 1 for alternate word, -1 for don't care. None for no mask.
404
404
  """
@@ -23,12 +23,14 @@ def test_encode_decode():
23
23
 
24
24
  out_text = c.decode( coded )[0]
25
25
  assert in_text == out_text
26
+ #check inner_n is causing the correct number of bases
27
+ assert len(coded[0]) == 30
26
28
 
27
29
  def test_coded_to_bases():
28
30
  #TODO: test optimize too
29
31
 
30
32
  test_encoded_data = np.random.randint(0,32,(10,31),dtype=np.uint8)
31
- DNA_with_scores = codec.b32_to_DNA_optimize(test_encoded_data,codec._default_b32_alphabet,codec._default_b32_alphabet_alt)
33
+ DNA_with_scores = codec.b32_to_DNA_optimize(test_encoded_data,codec._default_b32_alphabet,codec._default_b32_alphabet_alt) # type: ignore
32
34
  DNA = [x[0] for x in DNA_with_scores]
33
35
  test_decoded_data = codec.dna_to_b32(DNA,codec._default_b32_alphabet,codec._default_b32_alphabet_alt)
34
36
  print(test_encoded_data.flatten())
@@ -99,7 +101,7 @@ def test_inserts():
99
101
  data_decodec,__oe,__oer,__ie = coder.decode(enc_d)
100
102
  assert data_decodec == inserted_data
101
103
 
102
- test_dna_out = codec.b32_to_DNA_optimize(enc_d,codec._default_b32_alphabet,codec._default_b32_alphabet_alt,mask=imask,nmasked=n_inserts)
104
+ test_dna_out = codec.b32_to_DNA_optimize(enc_d,codec._default_b32_alphabet,codec._default_b32_alphabet_alt,mask=imask,nmasked=n_inserts) # type: ignore
103
105
  test_dna = [x[0] for x in test_dna_out]
104
106
  for strand in test_dna[:n_inserts]:
105
107
  assert strand.decode().startswith(insert)
File without changes
File without changes