pydna 5.5.0__py3-none-any.whl → 5.5.2__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/assembly.py CHANGED
@@ -66,13 +66,14 @@ from typing import (
66
66
  TypedDict as _TypedDict,
67
67
  )
68
68
  import itertools as _itertools
69
- import logging as _logging
69
+
70
+ # import logging as _logging
70
71
 
71
72
  # from func_timeout import func_set_timeout
72
73
  # from wrapt_timeout_decorator import timeout
73
74
  from pydna.threading_timer_decorator_exit import exit_after
74
75
 
75
- _module_logger = _logging.getLogger("pydna." + __name__)
76
+ # _module_logger = _logging.getLogger("pydna." + __name__)
76
77
 
77
78
 
78
79
  class Assembly(object): # , metaclass=_Memoize):
@@ -239,7 +240,9 @@ class Assembly(object): # , metaclass=_Memoize):
239
240
  before = G.order()
240
241
  G.add_nodes_from(
241
242
  (node, {"order": order + od, "length": length})
242
- for od, (start, length, node) in enumerate(n for n in f["nodes"] if n[2] not in G)
243
+ for od, (start, length, node) in enumerate(
244
+ n for n in f["nodes"] if n[2] not in G
245
+ )
243
246
  )
244
247
  order += G.order() - before
245
248
 
@@ -251,7 +254,8 @@ class Assembly(object): # , metaclass=_Memoize):
251
254
  feats = [
252
255
  ft
253
256
  for ft in f["features"]
254
- if start1 <= ft.location.start and start2 + G.nodes[node2]["length"] >= ft.location.end
257
+ if start1 <= ft.location.start
258
+ and start2 + G.nodes[node2]["length"] >= ft.location.end
255
259
  ]
256
260
 
257
261
  # for feat in feats:
@@ -267,7 +271,11 @@ class Assembly(object): # , metaclass=_Memoize):
267
271
  ) # string
268
272
 
269
273
  self.G = _nx.create_empty_copy(G)
270
- self.G.add_edges_from(sorted(G.edges(data=True), key=lambda t: len(t[2].get("seq", 1)), reverse=True))
274
+ self.G.add_edges_from(
275
+ sorted(
276
+ G.edges(data=True), key=lambda t: len(t[2].get("seq", 1)), reverse=True
277
+ )
278
+ )
271
279
  self.nodemap = {**nodemap, **{nodemap[i]: i for i in nodemap}}
272
280
  self.limit = limit
273
281
  self.fragments = fragments
@@ -288,7 +296,11 @@ class Assembly(object): # , metaclass=_Memoize):
288
296
  "begin",
289
297
  node,
290
298
  piece=slice(0, start),
291
- features=[f for f in firstfragment["features"] if start + length >= f.location.end],
299
+ features=[
300
+ f
301
+ for f in firstfragment["features"]
302
+ if start + length >= f.location.end
303
+ ],
292
304
  seq=firstfragment["mixed"],
293
305
  name=firstfragment["name"],
294
306
  )
@@ -301,7 +313,11 @@ class Assembly(object): # , metaclass=_Memoize):
301
313
  "begin_rc",
302
314
  node,
303
315
  piece=slice(0, start),
304
- features=[f for f in firstfragmentrc["features"] if start + length >= f.location.end],
316
+ features=[
317
+ f
318
+ for f in firstfragmentrc["features"]
319
+ if start + length >= f.location.end
320
+ ],
305
321
  seq=firstfragmentrc["mixed"],
306
322
  name=firstfragmentrc["name"],
307
323
  )
@@ -313,7 +329,9 @@ class Assembly(object): # , metaclass=_Memoize):
313
329
  node,
314
330
  "end",
315
331
  piece=slice(start, len(lastfragment["mixed"])),
316
- features=[f for f in lastfragment["features"] if start <= f.location.start],
332
+ features=[
333
+ f for f in lastfragment["features"] if start <= f.location.start
334
+ ],
317
335
  seq=lastfragment["mixed"],
318
336
  name=lastfragment["name"],
319
337
  )
@@ -326,7 +344,9 @@ class Assembly(object): # , metaclass=_Memoize):
326
344
  node,
327
345
  "end_rc",
328
346
  piece=slice(start, len(lastfragmentrc["mixed"])),
329
- features=[f for f in lastfragmentrc["features"] if start <= f.location.start],
347
+ features=[
348
+ f for f in lastfragmentrc["features"] if start <= f.location.start
349
+ ],
330
350
  seq=lastfragmentrc["mixed"],
331
351
  name=lastfragmentrc["name"],
332
352
  )
@@ -336,9 +356,15 @@ class Assembly(object): # , metaclass=_Memoize):
336
356
  linearpaths = list(
337
357
  _itertools.chain(
338
358
  _nx.all_simple_paths(_nx.DiGraph(G), "begin", "end", cutoff=max_nodes),
339
- _nx.all_simple_paths(_nx.DiGraph(G), "begin", "end_rc", cutoff=max_nodes),
340
- _nx.all_simple_paths(_nx.DiGraph(G), "begin_rc", "end", cutoff=max_nodes),
341
- _nx.all_simple_paths(_nx.DiGraph(G), "begin_rc", "end_rc", cutoff=max_nodes),
359
+ _nx.all_simple_paths(
360
+ _nx.DiGraph(G), "begin", "end_rc", cutoff=max_nodes
361
+ ),
362
+ _nx.all_simple_paths(
363
+ _nx.DiGraph(G), "begin_rc", "end", cutoff=max_nodes
364
+ ),
365
+ _nx.all_simple_paths(
366
+ _nx.DiGraph(G), "begin_rc", "end_rc", cutoff=max_nodes
367
+ ),
342
368
  )
343
369
  )
344
370
 
@@ -412,7 +438,9 @@ class Assembly(object): # , metaclass=_Memoize):
412
438
  for (
413
439
  _,
414
440
  cp,
415
- ) in cpaths_sorted: # cpaths is a list of nodes representing a circular assembly
441
+ ) in (
442
+ cpaths_sorted
443
+ ): # cpaths is a list of nodes representing a circular assembly
416
444
  edgelol = [] # edgelol is a list of lists of all edges along cp
417
445
  cp += cp[0:1]
418
446
  for u, v in zip(cp, cp[1:]):
@@ -452,8 +480,12 @@ class Assembly(object): # , metaclass=_Memoize):
452
480
  elif f.location.end > len(ct):
453
481
  f.location = _CompoundLocation(
454
482
  (
455
- _SimpleLocation(f.location.start, _ExactPosition(len(ct))),
456
- _SimpleLocation(_ExactPosition(0), f.location.end - len(ct)),
483
+ _SimpleLocation(
484
+ f.location.start, _ExactPosition(len(ct))
485
+ ),
486
+ _SimpleLocation(
487
+ _ExactPosition(0), f.location.end - len(ct)
488
+ ),
457
489
  )
458
490
  )
459
491
 
@@ -489,7 +521,9 @@ class Assembly(object): # , metaclass=_Memoize):
489
521
  "limit(bp)..: {limit}\n"
490
522
  "G.nodes....: {nodes}\n"
491
523
  "algorithm..: {al}".format(
492
- sequences=" ".join("{}bp".format(len(x["mixed"])) for x in self.fragments),
524
+ sequences=" ".join(
525
+ "{}bp".format(len(x["mixed"])) for x in self.fragments
526
+ ),
493
527
  limit=self.limit,
494
528
  nodes=self.G.order(),
495
529
  al=self.algorithm.__name__,
@@ -529,14 +563,3 @@ class _FragmentDict(_TypedDict):
529
563
  name: str
530
564
  features: _List[_SeqFeature]
531
565
  nodes: _List[_NodeTuple]
532
-
533
-
534
- if __name__ == "__main__":
535
- import os as _os
536
-
537
- cached = _os.getenv("pydna_cached_funcs", "")
538
- _os.environ["pydna_cached_funcs"] = ""
539
- import doctest
540
-
541
- doctest.testmod(verbose=True, optionflags=doctest.ELLIPSIS)
542
- _os.environ["pydna_cached_funcs"] = cached