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

problem with cut when cutsite on nucleotide zero. #51

Closed picousse closed 4 years ago

picousse commented 5 years ago

Hi, I think there is bug in the cut function when the restriction site is on the ori.

When I run the following code:

plasmid_path = "./test.gb"
test = pydna.parsers.parse([plasmid_path], ds=True)[0]
test.cut(BsaI)

I get:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-16-aadbfecceed5> in <module>
      9     logger.warning("No features found in : %s. this make selection based on rep_origin impossible." % input_seq)
     10 
---> 11 cut_seq = input_seq.cut(cutter)
     12 
     13 

/usr/local/lib/python3.7/dist-packages/pydna/dseqrecord.py in cut(self, *enzymes)
   1043             enzymes = (enzymes,)
   1044 
-> 1045         frags = self.seq.cut(enzymes)
   1046 
   1047         if not frags:

/usr/local/lib/python3.7/dist-packages/pydna/dseq.py in cut(self, *enzymes)
   1267             swl = len(self.watson)
   1268             frags = frags[1:-1]
-> 1269             newfrags = [frags.pop(0),]
   1270             while sum(len(f.watson) for f in newfrags) < swl:
   1271                 newfrags.append(frags.pop(0))

IndexError: pop from empty list

The attached file is a genbank. If I move the origin of the genbank file, there are no problems.

BjornFJohansson commented 5 years ago

Hi, ill look in to this asap. I am working on a new release 3.0 right now.

BjornFJohansson commented 5 years ago

I could not find the sequence you are referring to, so I made a short sequence containing the BsaI site in a notebook here. I could not reproduce your result. Are you sure that your sequence is set to "circular"?

picousse commented 5 years ago

oops, somehow the attach did not work.

LOCUS       Exported                  97 bp ds-DNA     circular SYN 15-MAY-2019
DEFINITION  synthetic circular DNA.
ACCESSION   .
VERSION     .
KEYWORDS    
SOURCE      synthetic DNA construct
  ORGANISM  synthetic DNA construct
REFERENCE   1  (bases 1 to 97)
  AUTHORS   Inbiose
  TITLE     Direct Submission
  JOURNAL   Exported Wednesday, May 15, 2019 from SnapGene 4.3.7
            https://www.snapgene.com
FEATURES             Location/Qualifiers
     source          1..97
                     /organism="synthetic DNA construct"
                     /mol_type="other DNA"
ORIGIN
        1 gagttgagac cgctgatagc gttactgatg atgctaagca tctgacaacg ggtctcaccc
       61 taaaaaattt atttgcttat aggcataatt atttcat
//

I'm running version 2. could that explain it? Or is it really something locally? If so, sorry for the inconvenience.

BjornFJohansson commented 5 years ago

This might be something I fixed for the new version. If you have time, I plan to release the 3.0 version tomorrow.

picousse commented 5 years ago

Awesome work, and fast reply! thanks a lot. I'll wait for the new version and test that one out.

BjornFJohansson commented 5 years ago

The 3.0.0 is out! It breaks some compatibility with the 2.03 version. There are many improvements, among them is quicker Assembly code. See if this version solves your problem.