pybiolib 1.1.1632__py3-none-any.whl → 1.1.1641__py3-none-any.whl
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.
- biolib/utils/seq_util.py +19 -2
- {pybiolib-1.1.1632.dist-info → pybiolib-1.1.1641.dist-info}/METADATA +1 -1
- {pybiolib-1.1.1632.dist-info → pybiolib-1.1.1641.dist-info}/RECORD +6 -6
- {pybiolib-1.1.1632.dist-info → pybiolib-1.1.1641.dist-info}/LICENSE +0 -0
- {pybiolib-1.1.1632.dist-info → pybiolib-1.1.1641.dist-info}/WHEEL +0 -0
- {pybiolib-1.1.1632.dist-info → pybiolib-1.1.1641.dist-info}/entry_points.txt +0 -0
biolib/utils/seq_util.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
import re
|
2
|
+
from biolib.typing_utils import List, Optional, Dict
|
2
3
|
|
3
4
|
allowed_sequence_chars = set("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.")
|
4
5
|
def find_invalid_sequence_characters(sequence):
|
@@ -6,11 +7,24 @@ def find_invalid_sequence_characters(sequence):
|
|
6
7
|
return invalid_chars
|
7
8
|
|
8
9
|
class SeqUtilRecord:
|
9
|
-
def __init__(self,
|
10
|
+
def __init__(self,
|
11
|
+
sequence: str,
|
12
|
+
sequence_id: str,
|
13
|
+
description: Optional['str'],
|
14
|
+
properties: Optional[Dict[str, str]] = None):
|
10
15
|
self.sequence = sequence
|
11
16
|
self.id = sequence_id # pylint: disable=invalid-name
|
12
17
|
self.description = description
|
13
18
|
|
19
|
+
if properties:
|
20
|
+
disallowed_pattern = re.compile(r"[=\[\]\n]")
|
21
|
+
for key, value in properties.items():
|
22
|
+
assert not bool(disallowed_pattern.search(key)), "Key cannot contain characters =[] and newline"
|
23
|
+
assert not bool(disallowed_pattern.search(value)), "Value cannot contain characters =[] and newline"
|
24
|
+
self.properties = properties
|
25
|
+
else:
|
26
|
+
self.properties = {}
|
27
|
+
|
14
28
|
def __repr__(self) -> str:
|
15
29
|
return f'{self.__class__.__name__} ({self.id})'
|
16
30
|
|
@@ -78,5 +92,8 @@ class SeqUtil:
|
|
78
92
|
with open(file_name, mode='w') as file_handle:
|
79
93
|
for record in records:
|
80
94
|
optional_description = f' {record.description}' if record.description else ''
|
95
|
+
if record.properties:
|
96
|
+
for key, value in record.properties.items():
|
97
|
+
optional_description += f' [{key}={value}]'
|
81
98
|
sequence = '\n'.join(record.sequence[i:i + 80] for i in range(0, len(record.sequence), 80))
|
82
99
|
file_handle.write(f'>{record.id}{optional_description}\n{sequence}\n')
|
@@ -99,10 +99,10 @@ biolib/utils/__init__.py,sha256=RxXoO8sLfmv5UIdkYAX7p5K03UUIUzss_A5vtb8CLlw,6897
|
|
99
99
|
biolib/utils/app_uri.py,sha256=hOFsTQfA7QbyQyg9ItGdD8VDWBJw0vYMqzLdSiJXmqQ,1857
|
100
100
|
biolib/utils/cache_state.py,sha256=BFrZlV4XZIueIFzAFiPidX4hmwADKY5Y5ZuqlerF5l0,3060
|
101
101
|
biolib/utils/multipart_uploader.py,sha256=PEorMsTNg5f72e3Y-KA3LrI-F6EAnsD9vENV-5EuiX0,9896
|
102
|
-
biolib/utils/seq_util.py,sha256=
|
102
|
+
biolib/utils/seq_util.py,sha256=7EwBNJ0yFAfX1lTOwf5IpcbjdNZ8u0TeHf8gW9n28IA,4019
|
103
103
|
biolib/utils/zip/remote_zip.py,sha256=NCdUnVbGCv7SfXCI-yVU-is_OnyWmLAnVpIdSvo-W4k,23500
|
104
|
-
pybiolib-1.1.
|
105
|
-
pybiolib-1.1.
|
106
|
-
pybiolib-1.1.
|
107
|
-
pybiolib-1.1.
|
108
|
-
pybiolib-1.1.
|
104
|
+
pybiolib-1.1.1641.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
105
|
+
pybiolib-1.1.1641.dist-info/METADATA,sha256=QAbbPvjHwCp16EXECXjNiVJalta7-_lvrSjrFuF2COw,1543
|
106
|
+
pybiolib-1.1.1641.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
107
|
+
pybiolib-1.1.1641.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
108
|
+
pybiolib-1.1.1641.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|