Skip to content

Commit

Permalink
changed what Dseq.__str__ returns to the ascii decoded ._data proerty…
Browse files Browse the repository at this point in the history
… instead of the full_sequence. This way I hope to write dsiupac code
  • Loading branch information
BjornFJohansson committed Jan 26, 2025
1 parent 811b73c commit 4740475
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/pydna/dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,14 @@ class Dseq(_Seq):
Coercing to string
>>> str(a)
>>> str(a.full_sequence)
'ggggtttcccc'
Coercing to string containing dsIUPAC code.
>>> str(a)
'qqqqtttiiii'
A Dseq object can be longer that either the watson or crick strands.
::
Expand Down Expand Up @@ -637,7 +642,7 @@ def translate(self, *args, **kwargs): # TODO: discuss this
return obj.translate(*args, **kwargs)

def __str__(self):
return self.full_sequence._data.decode("ascii")
return self._data.decode("ascii") # self.full_sequence._data.decode("ascii")

# def __getitem__(self, sl: slice) -> "Dseq":
# """Returns a subsequence. This method is used by the slice notation"""
Expand Down
8 changes: 4 additions & 4 deletions tests/test_module_dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_pair():
def test_dsiupac():
from pydna.dseq import Dseq

assert str(Dseq("PEXIaaaQFZJ")) == "GATCaaaGATC"
assert str(Dseq("QFZJaaaPEXI")) == "GATCaaaGATC"
assert str(Dseq("PEXIaaaQFZJ")) == "PEXIaaaQFZJ"
assert str(Dseq("QFZJaaaPEXI")) == "QFZJaaaPEXI"


def test_cut1():
Expand Down Expand Up @@ -1415,9 +1415,9 @@ def test_new():
from Bio.Restriction import KpnI, Acc65I, BsaI, XmaI, SmaI, BamHI

fiveoh = Dseq("PEXIaaaQFZJ")
assert str(fiveoh + fiveoh) == "GATCaaaGATCaaaGATC"
assert str(fiveoh + fiveoh) == "PEXIaaaGATCaaaQFZJ"
threeoh = Dseq("QFZJQtttPEXIP")
assert str(threeoh + threeoh) == "GATCGtttGATCGtttGATCG"
assert str(threeoh + threeoh) == "QFZJQtttGATCGtttPEXIP"

assert repr(Dseq("AIXEP") + Dseq("JZFQA")) == "Dseq(-6)\nACTAGA\nTGATCT"

Expand Down
2 changes: 1 addition & 1 deletion tests/test_module_dseqrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def test_initialization():
assert dsr.seq.crick == "taaa"
assert dsr.circular == False
assert dsr.seq.circular == False
assert str(dsr.seq) == "attta"
assert str(dsr.seq) == "etttf"

dsr = Dseqrecord(ds, circular=True)

Expand Down

0 comments on commit 4740475

Please sign in to comment.