Skip to content

Commit

Permalink
fusion PCR kind of works
Browse files Browse the repository at this point in the history
  • Loading branch information
BjornFJohansson committed Dec 19, 2023
1 parent 4cd555f commit 222d643
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
40 changes: 31 additions & 9 deletions src/pydna/fusionpcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ def anneal(x, y, limit=limit):
new = Dseqrecord(Dseq(a.seq.watson, b.seq.crick, ovhg=-s1))
new.features = copy(a.features)
new.features.extend([f._shift(s1) for f in b.features])
new.parents = b, a # Setting a new property dynamically
new.left = b # Setting a new property dynamically
new.right = a # Setting a new property dynamically
elif s1 == 0:
new = Dseqrecord(Dseq(b.seq.watson, a.seq.crick, ovhg=-s2))
new.features = copy(b.features)
new.features.extend([f._shift(s2) for f in a.features])
new.parents = b, a # Setting a new property dynamically
new.left = a # Setting a new property dynamically
new.right = b # Setting a new property dynamically
return new

argument = fragments
for arg in argument:
arg.left = None
arg.right = None
newfragments = []
while True:
for a, b in combinations(fragments, 2):
Expand All @@ -50,15 +55,32 @@ def anneal(x, y, limit=limit):
newfragments = []
else:
break

return [x for x in fragments if x not in argument]


if __name__ == "__main__":
import os as _os
def list_parts(fusion_pcr_fragment):
stack = [fusion_pcr_fragment]
processed = []

while stack:
obj = stack.pop()
try:
a, b = obj.right, obj.left
except AttributeError:
pass
else:
stack.extend((a, b))
processed.append(obj)

parts = [x for x in processed[::-1] if x]

msg = "---\n\n"

cached = _os.getenv("pydna_cached_funcs", "")
_os.environ["pydna_cached_funcs"] = ""
import doctest
for part in parts:
if hasattr(part, "anneal"):
msg += repr(part.anneal) + "\n\n"
msg += f"{part.name}\n{part.seq.watson}\n{part.seq.crick[::-1]}\n\n---\n\n"
msg += repr(part.seq) + "\n\n"

doctest.testmod(verbose=True, optionflags=(doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE))
_os.environ["pydna_cached_funcs"] = cached
return msg
27 changes: 12 additions & 15 deletions tests/test_module_fusionpcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,18 @@ def test_fusionpcr3():
assert eq(result, r)


# from Bio.SeqFeature import SeqFeature, SimpleLocation
# x = Dseqrecord(Dseq("tctggtcaagctgaagggtattc"),
# features=[SeqFeature(SimpleLocation(5, 10, strand=1),
# type="misc_feature")])
# y = Dseqrecord(Dseq("tattcgtacacagatg"),
# features=[SeqFeature(SimpleLocation(5, 10, strand=1),
# type="misc_feature")])
# z = Dseqrecord(Dseq("acagatgacgtgt"),
# features=[SeqFeature(SimpleLocation(5, 10, strand=1),
# type="misc_feature")])


# seqtuples = [ (x, y, z)]
# for arg in seqtuples:
# result = fuse_by_pcr(arg, limit=5).pop()
from Bio.SeqFeature import SeqFeature, SimpleLocation

x = Dseqrecord(
Dseq("tctggtcaagctgaagggtattc"), features=[SeqFeature(SimpleLocation(5, 10, strand=1), type="misc_feature")]
)
y = Dseqrecord(Dseq("tattcgtacacagatg"), features=[SeqFeature(SimpleLocation(5, 10, strand=1), type="misc_feature")])
z = Dseqrecord(Dseq("acagatgacgtgt"), features=[SeqFeature(SimpleLocation(5, 10, strand=1), type="misc_feature")])


seqtuples = [(x, y, z)]
for arg in seqtuples:
result = fuse_by_pcr(arg, limit=5).pop()


if __name__ == "__main__":
Expand Down

0 comments on commit 222d643

Please sign in to comment.