[Python] Iterare una sequenza

Carlo Miron miron a python.it
Dom 26 Nov 2017 10:30:53 CET


On Sun, Nov 26, 2017 at 10:20 AM, Giuseppe Costanzi
<giuseppecostanzi a gmail.com> wrote:

> ho una sequenza del tipo
> ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT
> scorrendola devo trovare una sequenza target GAATTC
> ACTGATCGATTACGTATAGTA  "GAATTC"  TATCATACATATATATCGATGCGTTCAT
> quindi dividere la sequenza da G, la prima lettera della sequenza target,
> e calcolarmi la lunghezza dei due frammenti risultanti
> ACTGATCGATTACGTATAGTAG
> e di questa
> GAATTCTATCATACATATATATCGATGCGTTCAT

qualcosa tipo

>>> seq = "ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT"
>>> target = "GAATTCT"
>>> first, second = seq.split(target, 1)
>>> first += target[1]
>>> second = target[1:] + second
>>> len(first), len(second)
(22, 33)

?
㎝

-- 
|:**THE 🍺-WARE LICENSE** *(Revision ㊷)*:
| <miron@🐍.it> wrote this mail. As long as you retain this
| notice you can do whatever you want with this stuff.
| If we meet some day, and you think this stuff is worth it,
| you can buy me a 🍺 in return. —㎝


Maggiori informazioni sulla lista Python