pydna 5.5.4__py3-none-any.whl → 5.5.6__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 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
@@ -48,23 +49,27 @@ functions with a lowercase letter:
48
49
  ├── amplify
49
50
  │ ├── Anneal
50
51
  │ └── pcr
52
+
51
53
  ├── assembly
52
54
  │ └── Assembly
55
+
53
56
  ├── design
54
57
  │ ├── assembly_fragments
55
58
  │ └── primer_design
56
- ├── download
57
- │ └── download_text
59
+
58
60
  ├── dseqrecord
59
61
  │ └── Dseqrecord
60
62
  ├── gel
61
63
  │ └── Gel
64
+
62
65
  ├── genbank
63
66
  │ ├── genbank
64
67
  │ └── Genbank
68
+
65
69
  ├── parsers
66
70
  │ ├── parse
67
71
  │ └── parse_primers
72
+
68
73
  └── readers
69
74
  ├── read
70
75
  └── read_primers
@@ -131,18 +136,9 @@ See this repository for a collection of
131
136
 
132
137
  """
133
138
 
134
-
135
- # from pydna.utils import open_folder as _open_folder
136
- # from pathlib import Path as _Path
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
-
139
+ from pydna._pretty import PrettyTable
140
+ from Bio.Restriction import FormattedSeq
141
+ import os
146
142
 
147
143
  __author__ = "Björn Johansson"
148
144
  __copyright__ = "Copyright 2013 - 2023 Björn Johansson"
@@ -151,113 +147,7 @@ __license__ = "BSD"
151
147
  __maintainer__ = "Björn Johansson"
152
148
  __email__ = "bjorn_johansson@bio.uminho.pt"
153
149
  __status__ = "Development" # "Production" #"Prototype"
154
- __version__ = "5.5.4"
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__)
150
+ __version__ = "5.5.6"
261
151
 
262
152
 
263
153
  class _PydnaWarning(Warning):
@@ -297,87 +187,17 @@ class _PydnaDeprecationWarning(_PydnaWarning):
297
187
  pass
298
188
 
299
189
 
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
190
  def get_env():
371
191
  """Print a an ascii table containing all environmental variables.
372
192
 
373
193
  Pydna related variables have names that starts with `pydna_`
374
194
  """
375
- _table = _PrettyTable(["Variable", "Value"])
195
+ _table = PrettyTable(["Variable", "Value"])
376
196
  # _table.set_style(_prettytable.DEFAULT)
377
197
  _table.align["Variable"] = "l" # Left align
378
198
  _table.align["Value"] = "l" # Left align
379
199
  _table.padding_width = 1 # One space between column edges and contents
380
- for k, v in sorted(_os.environ.items()):
200
+ for k, v in sorted(os.environ.items()):
381
201
  if k.lower().startswith("pydna"):
382
202
  _table.add_row([k, v])
383
203
  return _table
@@ -385,7 +205,7 @@ def get_env():
385
205
 
386
206
  def logo():
387
207
  """Ascii-art logotype of pydna."""
388
- from pydna._pretty import pretty_str as _pretty_str
208
+ from pydna._pretty import pretty_str
389
209
 
390
210
  message = f"pydna {__version__}"
391
211
  try:
@@ -395,4 +215,19 @@ def logo():
395
215
  else:
396
216
  f = Figlet()
397
217
  message = f.renderText(message)
398
- return _pretty_str(message)
218
+ return pretty_str(message)
219
+
220
+
221
+ ## Override Bio.Restriction.FormattedSeq._table
222
+
223
+
224
+ def _make_FormattedSeq_table() -> bytes:
225
+ table = bytearray(256)
226
+ upper_to_lower = ord("A") - ord("a")
227
+ for c in b"ABCDEFGHIJKLMNOPQRSTUVWXYZ": # Only allow IUPAC letters
228
+ table[c] = c # map uppercase to uppercase
229
+ table[c - upper_to_lower] = c # map lowercase to uppercase
230
+ return bytes(table)
231
+
232
+
233
+ 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 _Pt
10
- from prettytable import TableStyle as _TableStyle
11
- from copy import copy as _copy
12
- from typing import List as _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(_Pt):
22
+ class PrettyTable(Pt):
23
23
  """docstring."""
24
24
 
25
- def lol(self) -> _List[list]:
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 = _copy(self)
35
- c.set_style(_TableStyle.MARKDOWN)
34
+ c = copy(self)
35
+ c.set_style(TableStyle.MARKDOWN)
36
36
  return pretty_str(c.get_string())
@@ -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 as _collections
8
+ import collections
9
9
 
10
- dHBr = _collections.defaultdict(dict)
11
- dSBr = _collections.defaultdict(dict)
10
+ dHBr = collections.defaultdict(dict)
11
+ dSBr = collections.defaultdict(dict)
12
12
 
13
13
  dHBr[0][0] = -9100
14
14
  dSBr[0][0] = -24
pydna/all.py CHANGED
@@ -18,7 +18,7 @@ ttt
18
18
  Dseqrecord(-3)
19
19
  >>> from pydna.all import __all__
20
20
  >>> __all__
21
- ['Anneal', 'pcr', 'Assembly', 'genbank', 'Genbank', 'download_text', 'Dseqrecord',
21
+ ['Anneal', 'pcr', 'Assembly', 'genbank', 'Genbank', 'Dseqrecord',
22
22
  'Dseq', 'read', 'read_primer', 'parse', 'parse_primers', 'primer_design', 'assembly_fragments', 'eq', 'gbtext_clean']
23
23
  >>>
24
24
  """
@@ -30,20 +30,16 @@ __all__ = [
30
30
  "Assembly",
31
31
  "genbank",
32
32
  "Genbank",
33
- "download_text",
34
33
  "Dseqrecord",
35
34
  "Dseq",
36
35
  "read",
37
36
  "read_primer",
38
37
  "parse",
39
38
  "parse_primers",
40
- # "ape",
41
39
  "primer_design",
42
40
  "assembly_fragments",
43
- # "circular_assembly_fragments",
44
41
  "eq",
45
42
  "gbtext_clean",
46
- # "PrimerList",
47
43
  ]
48
44
 
49
45
 
@@ -52,20 +48,13 @@ from pydna.amplify import pcr
52
48
  from pydna.assembly import Assembly
53
49
  from pydna.genbank import genbank
54
50
  from pydna.genbank import Genbank
55
- from pydna.download import download_text
56
51
  from pydna.dseqrecord import Dseqrecord
57
52
  from pydna.dseq import Dseq
58
53
  from pydna.readers import read
59
54
  from pydna.readers import read_primer
60
55
  from pydna.parsers import parse
61
56
  from pydna.parsers import parse_primers
62
-
63
- # from pydna.editor import ape
64
57
  from pydna.design import primer_design
65
58
  from pydna.design import assembly_fragments
66
-
67
- # from pydna.design import circular_assembly_fragments
68
59
  from pydna.utils import eq
69
60
  from pydna.genbankfixer import gbtext_clean
70
-
71
- # from pydna.myprimers import PrimerList