Skip to content

Commit

Permalink
added "possible overhangs feature"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulko committed Dec 14, 2018
1 parent 3a12354 commit 9c81cf9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion goldenhinges/OverhangsSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class OverhangsSelector:
forbidden_overhang
List of all forbidden overhangs.
possible_overhangs
List of a few overhangs the collection should be chosen from.
time_limit
Time in seconds after which the solvers should stop if no solution
Expand All @@ -46,7 +49,8 @@ class OverhangsSelector:
"""

def __init__(self, gc_min=0, gc_max=1, differences=1, overhangs_size=4,
forbidden_overhangs=(), forbidden_pairs=(), time_limit=None,
forbidden_overhangs=(), forbidden_pairs=(),
possible_overhangs=None, time_limit=None,
external_overhangs=(), progress_logger='bar'):
"""Initialize the object (see class description)."""

Expand All @@ -66,6 +70,9 @@ def progress_logger(**k):
forbidden_overhangs = list(set(
list(forbidden_overhangs) + [reverse_complement(o)
for o in forbidden_overhangs]))
if possible_overhangs is not None:
forbidden_overhangs += [o for o in self.all_overhangs
if o not in possible_overhangs]
for o1 in self.all_overhangs:
reverse = reverse_complement(o1)
if any([(sequences_differences(o1, o2) < self.differences) or
Expand Down
2 changes: 1 addition & 1 deletion goldenhinges/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def write_report_for_cutting_solution(solution, target, sequence,
ax.set_title("Selected overhangs", loc="left",
fontdict=dict(weight='bold', fontsize=13))
ax.figure.set_size_inches((max(8, 0.7*len(o)), 2))
ax.set_ylim(ymax=ax.get_ylim()[1] + 2)
ax.set_ylim(top=ax.get_ylim()[1] + 2)

xx = [x for (a, b) in edited_segments for x in range(a, b)]
ax.plot(xx, [0 for x in xx], marker='o', c='r', lw=0,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
version=__version__,
author='Zulko',
description='DNA overhangs design for Golden Gate etc.',
url='https://github.com/Edinburgh-Genome-Foundry/goldenhinges',
url='https://github.com/Edinburgh-Genome-Foundry/GoldenHinges',
long_description=open('pypi-readme.rst').read(),
license='see LICENSE.txt',
keywords="DNA assembly overhangs constraint-programming synthetic-biology",
Expand Down
8 changes: 8 additions & 0 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def test_generate_overhangs_collection2():
assert sequences_differences(o1, o2) >= 2
assert sequences_differences(o1, reverse_complement(o2)) >= 2

def test_generate_overhangs_collection_with_possible():
selector = OverhangsSelector(gc_min=0.25, gc_max=0.75,
differences=1,
possible_overhangs=['ATTC', 'AAAA', 'GAAT',
'CTCA'],
time_limit=2)
collection = selector.generate_overhangs_set()
assert len(collection) == 2

def test_cut_sequence_into_similar_lengths(data):
def invalid_overhang(overhang):
Expand Down

0 comments on commit 9c81cf9

Please sign in to comment.