BjornFJohansson / pydna

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

Agarose gel simulation does not work with fragments less than 75 bp #97

Open kcorreia opened 1 year ago

kcorreia commented 1 year ago

` from pydna.ladders import PennStateLadder from pydna.gel import gel from pydna.dseqrecord import Dseqrecord

sample_1 = [Dseqrecord('A'1000),Dseqrecord('A'80),Dseqrecord('A'50)] sample_2 = [Dseqrecord('A'1000),Dseqrecord('A'*80)]

gel( [PennStateLadder, sample_1 ])

Traceback (most recent call last): File "", line 1, in File "/Users/kcorreia/opt/anaconda3/lib/python3.8/site-packages/pydna/gel.py", line 70, in gel for y in range(int(y1), int(y2)): ValueError: cannot convert float NaN to integer

gel( [PennStateLadder, sample_2 ]) <PIL.Image.Image image mode=RGB size=180x600 at 0x7F8E88447CD0> `

Didn't test the exact cutoff but it looks like between 70-75 bp.

BjornFJohansson commented 1 year ago

@kcorreia and thanks for taking your time to report this.

The default interpolator goes down to 75 bp. It is based on the data from the GeneRuler_1kb_plus list in the ladders.py module. There is another one called HI_LO_DNA_MARKER that goes down to 50 bp.

If you need even smaller ones, you need to make a list yourself, which is very easy. Get a gel image with bands that cover you use case, make a similar list but with the new sizes and Rf values calculated from the gel with a screen ruler (https://www.rapidtables.com/web/tools/pixel-ruler.html) or gimp.

from pydna.gel import gel, interpolator

from pydna.ladders import HI_LO_DNA_MARKER

gel([ HI_LO_DNA_MARKER,[pcr_prod]], interpolator=interpolator(HI_LO_DNA_MARKER))

Perhaps you can tell me about your use case? Are you going to need less than 50 bp?

You can copy this google spreadsheet in order to make your own ladder. https://docs.google.com/spreadsheets/d/1vN0y75ibxPrG6yJQjq1uF2FXP0L-qGSn_fzInUHeTs4/edit?usp=sharing Ill be happy to include it in next pydna release.

kcorreia commented 1 year ago

I don't really need an image of bands of less than 75 or 50bp as those can be hard to see on a real gel anyway. At a minimum would be nice to raise an Exception about the size restriction.

I digest linear fragment and plasmid sequences and want to see what it looks like on a virtual gel. That way I can compare it with an actual gel, rather than reading a fragment list size and visualizing it on a real gel as I have done for many years.

As of now, I filter the fragment list so that only fragments longer than 75bp are shown on the virtual gel.

BjornFJohansson commented 1 year ago

OK, I suppose a filter could be added to avoid the somewhat mysterious error message. Ill get around to fix this in the next release.