BjornFJohansson / pydna

Clone with Python! Data structures for double stranded DNA & simulation of homologous recombination, Gibson assembly, cut & paste cloning.
Other
166 stars 45 forks source link

Dseqrecord: error transferring features when cutting a plasmid open #180

Closed manulera closed 9 months ago

manulera commented 10 months ago

Hi @BjornFJohansson I noticed this when making further tests for the cuts. My implementation makes the exact same mistake, but the code below is with current pydna code. Will make a fix for this in the new implementation, but wanted to document it somewhere.

cc: @hiyama341 (maybe related to the error in the transfer of features that you mentioned)

The example below uses the following circular sequence with 4 features:

In the image below, the overhang of EcoRI is highlighted with the selector

Screenshot 2024-01-19 at 12 42 11

The expected behaviour would be that when you cut with EcoRI, you would end up with something like this:

Screenshot 2024-01-19 at 12 40 43

However, the result gives wrong coordinates for left_side and keeps throughout when it should not (see print of the script).

from Bio.Restriction import EcoRI
from pydna.dseqrecord import Dseqrecord
from Bio.SeqFeature import SeqFeature, SimpleLocation

seq = Dseqrecord("acgtGAATTCaatt", circular=True)
seq.features.append(SeqFeature(SimpleLocation(5, 9), id='full_overlap', type='CDS', qualifiers={'label': 'full_overlap'}))
seq.features.append(SeqFeature(SimpleLocation(3, 9), id='left_side', type='CDS', qualifiers={'label': 'left_side'}))
seq.features.append(SeqFeature(SimpleLocation(5, 10), id='right_side', type='CDS', qualifiers={'label': 'right_side'}))
seq.features.append(SeqFeature(SimpleLocation(3, 10), id='throughout', type='CDS', qualifiers={'label': 'throughout'}))

open_seq = seq.cut(EcoRI)[0]

print(*open_seq.features, sep='\n')
print(open_seq.seq.__repr__())

Prints:

type: CDS
location: [0:4]
id: full_overlap
qualifiers:
    Key: label, Value: full_overlap

type: CDS
location: join{[0:4], [12:14]}
id: left_side
qualifiers:
    Key: label, Value: left_side

type: CDS
location: [0:5]
id: right_side
qualifiers:
    Key: label, Value: right_side

type: CDS
location: join{[0:5], [12:14]}
id: throughout
qualifiers:
    Key: label, Value: throughout

Dseq(-18)
AATTCaattacgtG
    GttaatgcaCTTAA