BjornFJohansson / pydna

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

_multiply_circular fails with splitted features #41

Closed santirdnd closed 7 years ago

santirdnd commented 7 years ago

Hello, When trying to use the products of an Anneal instance, _multiply_circular fails, presumably, if the sequence has a feature splitted along the sequence origin (as with NZ_CP009685.1 or NZ_CP014225.1).

A simple way to reproduce with ipython:

In [1]: from pydna.readers import read

In [2]: from pydna.amplify import Anneal

In [3]: dseq_file = 'NZ_CP014225.1.gbk'

In [4]: primer_f = read('>primer.f\nAACGCTATTCGCCAGCTTGC', ds=False)

In [5]: primer_r = read('>primer.r\nTCTCCCCATACCGTACGCTA', ds=False)

In [6]: PCR_output = Anneal((primer_f, primer_r), read(dseq_file))

In [7]: print(PCR_output.products)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-7-1f84db735bfe> in <module>()
----> 1 print(PCR_output.products)

/Users/santirdnd/anaconda/envs/bio3-env/lib/python3.5/site-packages/pydna/amplify.py in products(self)
    295 
    296                 elif self.template.circular:
--> 297                     tmpl = self.template._multiply_circular(3)
    298                     tmpl = tmpl[fp.position-fp._fp+len(self.template):rp.position+rp._fp+len(self.template)]
    299                 else:

/Users/santirdnd/anaconda/envs/bio3-env/lib/python3.5/site-packages/pydna/dseqrecord.py in _multiply_circular(self, multiplier)
   1166                 j=0
   1167                 while (j+1)<=len(new_feature.location.parts):
-> 1168                     if new_feature.location.parts[j].end == len(self) and new_feature.location.parts[j+1].start==0:
   1169                         new_feature.location.parts[j] = _FeatureLocation(new_feature.location.parts[j].start,
   1170                                                                         new_feature.location.parts[j].end+len(new_feature.location.parts[j+1]))

IndexError: list index out of range
BjornFJohansson commented 7 years ago

Thank you for your input, I will take a look at this tonight.

BjornFJohansson commented 7 years ago

I can confirm this bug https://gist.github.com/BjornFJohansson/8438a9033fd79eff71eef740bcf4641b

BjornFJohansson commented 7 years ago

I have pinned down the problem. Ill have a solution tomorrow and a new bugfix alpha release.

BjornFJohansson commented 7 years ago

This bug should be fixed as of 2.0.0a4 Please reopen this bug if not.

santirdnd commented 7 years ago

Thanks, it's working great!

BjornFJohansson commented 7 years ago

Good to hear, open another issue if you have more problems/questions/comments.