Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Giuseppe Costanzi
ciao giorgio, temo che a breve dovro' studiarmelo grazie per la segnalazione On Sun, Nov 26, 2017 at 11:34 AM, Giorgio Zoppi wrote: > Io userei el automa di aho corasick. > In Bioinformatics si usa tanto. >

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Giuseppe Costanzi
ciao Christian, che dire... spettacolare; On Sun, Nov 26, 2017 at 11:25 AM, Christian Barra wrote: > In pseudo code > > seq = "ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT" > ...: > ...: def finder(seq, target): > ...: len_target = len(target)

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Giorgio Zoppi
Io userei el automa di aho corasick. In Bioinformatics si usa tanto. http://carshen.github.io/data-structures/algorithms/2014/04/07/aho-corasick-implementation-in-python.html 2017-11-26 10:20 GMT+01:00 Giuseppe Costanzi : > salve a tutti, > > ho una sequenza del tipo

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Christian Barra
In pseudo code seq = "ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT" ...: ...: def finder(seq, target): ...: len_target = len(target) ...: i = 0 ...: while i+len_target < len(seq): ...: yield seq[i:i+len_target], i ...: i += 1

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Giuseppe Costanzi
ciao federico, il secondo metodo mi piace, tra l' altro ho notato che itera solo 22 volte mentre il mio 28. in pratica vai a blocchi di lunghezza uguale al target invece di andare una base alla volta. bello, mi piace questa soluzione. grazie 2017-11-26 11:06 GMT+01:00 Federico Cerchiari

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Federico Cerchiari
Ciao Giuseppe, per trovare la posizione di un oggetto in una sequenza (lista, stringa o altro) puoi usare il metodo '.index' delle liste: dna_seq = 'ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT' target = 'GAATTCT' target_position = dna_seq.index(target) + 1 print('lunghezza

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Giuseppe Costanzi
ciao carlo, si, interessante ma vorrei iterare la sequenza mano a mano, stavo pensando a qualcosa tipo next(iterator, default) grazie comunque On Sun, Nov 26, 2017 at 10:30 AM, Carlo Miron wrote: > On Sun, Nov 26, 2017 at 10:20 AM, Giuseppe Costanzi >

Re: [Python] Iterare una sequenza

2017-11-26 Per discussione Carlo Miron
On Sun, Nov 26, 2017 at 10:20 AM, Giuseppe Costanzi wrote: > ho una sequenza del tipo > ACTGATCGATTACGTATAGTAGAATTCTATCATACATATATATCGATGCGTTCAT > scorrendola devo trovare una sequenza target GAATTC > ACTGATCGATTACGTATAGTA "GAATTC" TATCATACATATATATCGATGCGTTCAT >

[Python] Iterare una sequenza

2017-11-26 Per discussione Giuseppe Costanzi
salve a tutti, 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