pydna 5.5.4__py3-none-any.whl → 5.5.5__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.
- pydna/__init__.py +24 -193
- pydna/_pretty.py +8 -8
- pydna/_thermodynamic_data.py +3 -3
- pydna/alphabet.py +995 -0
- pydna/amplicon.py +19 -24
- pydna/amplify.py +75 -95
- pydna/assembly.py +64 -81
- pydna/assembly2.py +283 -294
- pydna/codon.py +4 -4
- pydna/common_sub_strings.py +6 -8
- pydna/contig.py +203 -10
- pydna/design.py +176 -60
- pydna/download.py +6 -15
- pydna/dseq.py +1794 -718
- pydna/dseqrecord.py +170 -169
- pydna/gateway.py +6 -6
- pydna/gel.py +5 -5
- pydna/genbank.py +43 -46
- pydna/genbankfixer.py +89 -92
- pydna/ladders.py +11 -12
- pydna/oligonucleotide_hybridization.py +124 -0
- pydna/opencloning_models.py +187 -60
- pydna/parsers.py +45 -32
- pydna/primer.py +4 -4
- pydna/primer_screen.py +833 -0
- pydna/readers.py +14 -9
- pydna/seq.py +137 -47
- pydna/seqrecord.py +54 -62
- pydna/sequence_picker.py +2 -5
- pydna/sequence_regex.py +6 -6
- pydna/tm.py +17 -17
- pydna/types.py +19 -19
- pydna/utils.py +97 -75
- {pydna-5.5.4.dist-info → pydna-5.5.5.dist-info}/METADATA +8 -8
- pydna-5.5.5.dist-info/RECORD +43 -0
- {pydna-5.5.4.dist-info → pydna-5.5.5.dist-info}/WHEEL +1 -1
- pydna/conftest.py +0 -42
- pydna/genbankfile.py +0 -42
- pydna/genbankrecord.py +0 -168
- pydna/goldengate.py +0 -45
- pydna/ligate.py +0 -62
- pydna/user_cloning.py +0 -29
- pydna-5.5.4.dist-info/RECORD +0 -46
- {pydna-5.5.4.dist-info → pydna-5.5.5.dist-info}/licenses/LICENSE.txt +0 -0
pydna/__init__.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# license. Please see the LICENSE.txt file that should have been included
|
|
6
6
|
# as part of this package.
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
"""
|
|
9
10
|
:copyright: Copyright 2013-2023 by Björn Johansson. All rights reserved.
|
|
10
11
|
:license: This code is part of the pydna package, governed by the
|
|
@@ -131,18 +132,9 @@ See this repository for a collection of
|
|
|
131
132
|
|
|
132
133
|
"""
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
import os as _os
|
|
138
|
-
|
|
139
|
-
# import logging as _logging
|
|
140
|
-
# import logging.handlers as _handlers
|
|
141
|
-
# import appdirs as _appdirs
|
|
142
|
-
# import configparser as _configparser
|
|
143
|
-
# import tempfile as _tempfile
|
|
144
|
-
from pydna._pretty import PrettyTable as _PrettyTable
|
|
145
|
-
|
|
135
|
+
from pydna._pretty import PrettyTable
|
|
136
|
+
from Bio.Restriction import FormattedSeq
|
|
137
|
+
import os
|
|
146
138
|
|
|
147
139
|
__author__ = "Björn Johansson"
|
|
148
140
|
__copyright__ = "Copyright 2013 - 2023 Björn Johansson"
|
|
@@ -151,113 +143,7 @@ __license__ = "BSD"
|
|
|
151
143
|
__maintainer__ = "Björn Johansson"
|
|
152
144
|
__email__ = "bjorn_johansson@bio.uminho.pt"
|
|
153
145
|
__status__ = "Development" # "Production" #"Prototype"
|
|
154
|
-
__version__ = "5.5.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# obtain config directory from env or appdirs
|
|
158
|
-
# _os.environ["pydna_config_dir"] = _os.getenv("pydna_config_dir", _appdirs.user_config_dir("pydna"))
|
|
159
|
-
# config_dir = _Path(_os.environ["pydna_config_dir"])
|
|
160
|
-
# config_dir.mkdir(parents=True, exist_ok=True)
|
|
161
|
-
|
|
162
|
-
# set path for the pydna.ini file
|
|
163
|
-
# _ini_path = config_dir / "pydna.ini"
|
|
164
|
-
|
|
165
|
-
# define user_data_dir
|
|
166
|
-
# user_data_dir = _Path(_appdirs.user_data_dir("pydna"))
|
|
167
|
-
|
|
168
|
-
# default_ini = {
|
|
169
|
-
# "ape": "put/path/to/ape/here",
|
|
170
|
-
# "cached_funcs": "pydna.genbank.genbank.nucleotide",
|
|
171
|
-
# "data_dir": str(user_data_dir),
|
|
172
|
-
# "email": "someone@example.com",
|
|
173
|
-
# "enzymes": str(user_data_dir / "enzymes.md"),
|
|
174
|
-
# "log_dir": _appdirs.user_log_dir("pydna"),
|
|
175
|
-
# "loglevel": str(_logging.WARNING),
|
|
176
|
-
# "primers": str(user_data_dir / "primers.md"),
|
|
177
|
-
# "assembly_limit": str(10),
|
|
178
|
-
# }
|
|
179
|
-
|
|
180
|
-
# ini = default_ini.copy()
|
|
181
|
-
|
|
182
|
-
# initiate a config parser instance
|
|
183
|
-
# _parser = _configparser.ConfigParser()
|
|
184
|
-
|
|
185
|
-
# if a pydna.ini exists, it is read
|
|
186
|
-
# if _ini_path.exists():
|
|
187
|
-
# _parser.read(_ini_path)
|
|
188
|
-
# pydna related environmental variables are set
|
|
189
|
-
# from pydna.ini if they are not set already
|
|
190
|
-
# _main = _parser["main"]
|
|
191
|
-
# ini.update(_main)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
# for key, value in ini.items():
|
|
195
|
-
# _os.environ[f"pydna_{key}"] = _os.getenv(f"pydna_{key}", value)
|
|
196
|
-
|
|
197
|
-
# logdir = _Path(_os.environ["pydna_log_dir"])
|
|
198
|
-
|
|
199
|
-
# create log directory if not present
|
|
200
|
-
# logdir.mkdir(parents=True, exist_ok=True)
|
|
201
|
-
# _logmsg = "Log directory {}".format(logdir)
|
|
202
|
-
|
|
203
|
-
# create logger
|
|
204
|
-
# _logger = _logging.getLogger("pydna")
|
|
205
|
-
# _logger.setLevel(int(_os.environ["pydna_loglevel"]))
|
|
206
|
-
# _hdlr = _handlers.RotatingFileHandler(
|
|
207
|
-
# logdir / "pydna.log",
|
|
208
|
-
# mode="a",
|
|
209
|
-
# maxBytes=10 * 1024 * 1024,
|
|
210
|
-
# backupCount=10,
|
|
211
|
-
# encoding="utf-8",
|
|
212
|
-
# )
|
|
213
|
-
|
|
214
|
-
# _formatter = _logging.Formatter(("%(asctime)s %(levelname)s" " %(funcName)s %(message)s"))
|
|
215
|
-
# _hdlr.setFormatter(_formatter)
|
|
216
|
-
# _logger.addHandler(_hdlr)
|
|
217
|
-
# _logger.info(_logmsg)
|
|
218
|
-
# _logger.info("Environmental variable pydna_ape = %s", _os.environ["pydna_ape"])
|
|
219
|
-
# _logger.info("Environmental variable pydna_cached_funcs = %s", _os.environ["pydna_cached_funcs"])
|
|
220
|
-
# _logger.info("Environmental variable pydna_data_dir = %s", _os.environ["pydna_data_dir"])
|
|
221
|
-
# _logger.info("Environmental variable pydna_email = %s", _os.environ["pydna_email"])
|
|
222
|
-
# _logger.info("Environmental variable pydna_log_dir = %s", _os.environ["pydna_log_dir"])
|
|
223
|
-
# _logger.info("Environmental variable pydna_loglevel = %s", _os.environ["pydna_loglevel"])
|
|
224
|
-
# _logger.info("Environmental variable pydna_primers = %s", _os.environ["pydna_primers"])
|
|
225
|
-
# _logger.info(
|
|
226
|
-
# "Environmental variable pydna_assembly_limit = %s",
|
|
227
|
-
# _os.environ["pydna_assembly_limit"],
|
|
228
|
-
# )
|
|
229
|
-
|
|
230
|
-
# create cache directory if not present
|
|
231
|
-
|
|
232
|
-
# _Path(_os.environ["pydna_data_dir"]).mkdir(parents=True, exist_ok=True)
|
|
233
|
-
|
|
234
|
-
# find out if optional dependecies for gel module are in place
|
|
235
|
-
#
|
|
236
|
-
#
|
|
237
|
-
# def _missing_modules_for_gel():
|
|
238
|
-
# import importlib
|
|
239
|
-
# from importlib import util
|
|
240
|
-
#
|
|
241
|
-
# _missing = []
|
|
242
|
-
# for _optm in ["scipy", "PIL", "numpy", "pyparsing", "requests"]:
|
|
243
|
-
# _missing.extend([_optm] if not util.find_spec(_optm) else [])
|
|
244
|
-
# del importlib
|
|
245
|
-
# del util
|
|
246
|
-
# return _missing
|
|
247
|
-
#
|
|
248
|
-
#
|
|
249
|
-
# _missing = _missing_modules_for_gel()
|
|
250
|
-
#
|
|
251
|
-
# if _missing:
|
|
252
|
-
# _logger.warning(
|
|
253
|
-
# "gel simulation will NOT be available." " Missing modules: %s",
|
|
254
|
-
# ", ".join(_missing),
|
|
255
|
-
# )
|
|
256
|
-
# else:
|
|
257
|
-
# _logger.info("gel simulation is available," " optional dependencies were found.")
|
|
258
|
-
#
|
|
259
|
-
|
|
260
|
-
# _logger.info("__version__ = %s", __version__)
|
|
146
|
+
__version__ = "5.5.5"
|
|
261
147
|
|
|
262
148
|
|
|
263
149
|
class _PydnaWarning(Warning):
|
|
@@ -297,87 +183,17 @@ class _PydnaDeprecationWarning(_PydnaWarning):
|
|
|
297
183
|
pass
|
|
298
184
|
|
|
299
185
|
|
|
300
|
-
# def open_current_folder():
|
|
301
|
-
# """Open the current working directory.
|
|
302
|
-
|
|
303
|
-
# Opens in the default file manager. The location for this folder is
|
|
304
|
-
# given by the :func:`os.getcwd` function
|
|
305
|
-
# """
|
|
306
|
-
# return _open_folder(_os.getcwd())
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
# _logger.info("Current working directory = os.getcwd() = %s", _os.getcwd())
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
# def open_cache_folder():
|
|
313
|
-
# """Open the pydna cache folder.
|
|
314
|
-
|
|
315
|
-
# Opens in the default file manager. The location for this folder is stored
|
|
316
|
-
# in the *pydna_data_dir* environmental variable.
|
|
317
|
-
# """
|
|
318
|
-
# return _open_folder(_os.environ["pydna_data_dir"])
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
# def open_config_folder():
|
|
322
|
-
# """Open the pydna configuration folder.
|
|
323
|
-
|
|
324
|
-
# Opens in the default file manager. The location for this folder is stored
|
|
325
|
-
# in the *pydna_config_dir* environmental variable.
|
|
326
|
-
|
|
327
|
-
# The `pydna.ini` file can be edited to make pydna quicker to use.
|
|
328
|
-
# See the documentation of the :class:configparser.ConfigParser´ class.
|
|
329
|
-
|
|
330
|
-
# Below is the content of a typical `pydna.ini` file on a Linux
|
|
331
|
-
# system.
|
|
332
|
-
|
|
333
|
-
# ::
|
|
334
|
-
|
|
335
|
-
# [main]
|
|
336
|
-
# loglevel=30
|
|
337
|
-
# email=myemail@example.org
|
|
338
|
-
# data_dir=/home/user/.local/share/pydna
|
|
339
|
-
# log_dir=/home/user/.cache/pydna/log
|
|
340
|
-
# ape=tclsh /path/to/ape/AppMain.tcl
|
|
341
|
-
# cached_funcs=Genbank_nucleotide
|
|
342
|
-
# primers=/path/to/primers/PRIMERS.txt
|
|
343
|
-
# enzymes=/path/to/enzymes/RestrictionEnzymes.txt
|
|
344
|
-
|
|
345
|
-
# The email address is set to someone@example.com by default. If you change
|
|
346
|
-
# this to you own address, the :func:`pydna.genbank.genbank` function can be
|
|
347
|
-
# used to download sequences from Genbank directly without having to
|
|
348
|
-
# explicitly add the email address.
|
|
349
|
-
|
|
350
|
-
# Pydna can cache results from the following functions or methods:
|
|
351
|
-
|
|
352
|
-
# - :func:`pydna.genbank.Genbank.nucleotide` Genbank_nucleotide
|
|
353
|
-
# - :func:`pydna.amplify.Anneal` amplify_Anneal
|
|
354
|
-
# - :func:`pydna.assembly.Assembly` assembly_Assembly
|
|
355
|
-
# - :func:`pydna.download.download_text` download.download_text
|
|
356
|
-
# - :func:`pydna.dseqrecord.Dseqrecord.synced` Dseqrecord_synced
|
|
357
|
-
|
|
358
|
-
# These can be added separated by a comma to the cached_funcs entry
|
|
359
|
-
# in **pydna.ini** file or the pydna_cached_funcs environment variable.
|
|
360
|
-
|
|
361
|
-
# """
|
|
362
|
-
# return _open_folder(_os.environ["pydna_config_dir"])
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
# def open_log_folder():
|
|
366
|
-
# """docstring."""
|
|
367
|
-
# return _open_folder(_os.environ["pydna_log_dir"])
|
|
368
|
-
|
|
369
|
-
|
|
370
186
|
def get_env():
|
|
371
187
|
"""Print a an ascii table containing all environmental variables.
|
|
372
188
|
|
|
373
189
|
Pydna related variables have names that starts with `pydna_`
|
|
374
190
|
"""
|
|
375
|
-
_table =
|
|
191
|
+
_table = PrettyTable(["Variable", "Value"])
|
|
376
192
|
# _table.set_style(_prettytable.DEFAULT)
|
|
377
193
|
_table.align["Variable"] = "l" # Left align
|
|
378
194
|
_table.align["Value"] = "l" # Left align
|
|
379
195
|
_table.padding_width = 1 # One space between column edges and contents
|
|
380
|
-
for k, v in sorted(
|
|
196
|
+
for k, v in sorted(os.environ.items()):
|
|
381
197
|
if k.lower().startswith("pydna"):
|
|
382
198
|
_table.add_row([k, v])
|
|
383
199
|
return _table
|
|
@@ -385,7 +201,7 @@ def get_env():
|
|
|
385
201
|
|
|
386
202
|
def logo():
|
|
387
203
|
"""Ascii-art logotype of pydna."""
|
|
388
|
-
from pydna._pretty import pretty_str
|
|
204
|
+
from pydna._pretty import pretty_str
|
|
389
205
|
|
|
390
206
|
message = f"pydna {__version__}"
|
|
391
207
|
try:
|
|
@@ -395,4 +211,19 @@ def logo():
|
|
|
395
211
|
else:
|
|
396
212
|
f = Figlet()
|
|
397
213
|
message = f.renderText(message)
|
|
398
|
-
return
|
|
214
|
+
return pretty_str(message)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
## Override Bio.Restriction.FormattedSeq._table
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _make_FormattedSeq_table() -> bytes:
|
|
221
|
+
table = bytearray(256)
|
|
222
|
+
upper_to_lower = ord("A") - ord("a")
|
|
223
|
+
for c in b"ABCDEFGHIJKLMNOPQRSTUVWXYZ": # Only allow IUPAC letters
|
|
224
|
+
table[c] = c # map uppercase to uppercase
|
|
225
|
+
table[c - upper_to_lower] = c # map lowercase to uppercase
|
|
226
|
+
return bytes(table)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
FormattedSeq._table = _make_FormattedSeq_table()
|
pydna/_pretty.py
CHANGED
|
@@ -6,10 +6,10 @@ The pretty_str class is similar to str but has a _repr_pretty_ method
|
|
|
6
6
|
for for nicer string output in the IPython shell and Jupyter notebook.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from prettytable import PrettyTable as
|
|
10
|
-
from prettytable import TableStyle
|
|
11
|
-
from copy import copy
|
|
12
|
-
from typing import List
|
|
9
|
+
from prettytable import PrettyTable as Pt
|
|
10
|
+
from prettytable import TableStyle
|
|
11
|
+
from copy import copy
|
|
12
|
+
from typing import List
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class pretty_str(str):
|
|
@@ -19,10 +19,10 @@ class pretty_str(str):
|
|
|
19
19
|
p.text(self)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class PrettyTable(
|
|
22
|
+
class PrettyTable(Pt):
|
|
23
23
|
"""docstring."""
|
|
24
24
|
|
|
25
|
-
def lol(self) ->
|
|
25
|
+
def lol(self) -> List[list]:
|
|
26
26
|
"""docstring."""
|
|
27
27
|
return [self._field_names] + self._rows
|
|
28
28
|
|
|
@@ -31,6 +31,6 @@ class PrettyTable(_Pt):
|
|
|
31
31
|
return self.get_string()
|
|
32
32
|
|
|
33
33
|
def _repr_markdown_(self) -> pretty_str:
|
|
34
|
-
c =
|
|
35
|
-
c.set_style(
|
|
34
|
+
c = copy(self)
|
|
35
|
+
c.set_style(TableStyle.MARKDOWN)
|
|
36
36
|
return pretty_str(c.get_string())
|
pydna/_thermodynamic_data.py
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
# license. Please see the LICENSE.txt file that should have been included
|
|
6
6
|
# as part of this package.
|
|
7
7
|
|
|
8
|
-
import collections
|
|
8
|
+
import collections
|
|
9
9
|
|
|
10
|
-
dHBr =
|
|
11
|
-
dSBr =
|
|
10
|
+
dHBr = collections.defaultdict(dict)
|
|
11
|
+
dSBr = collections.defaultdict(dict)
|
|
12
12
|
|
|
13
13
|
dHBr[0][0] = -9100
|
|
14
14
|
dSBr[0][0] = -24
|