Allora, ho una funzione che restituisce un generatore:
la funzione è richiamata dal main in questo modo:codice:read_sequences{ ... ... ... yield Sequence(name, sequence, qualities) }
quello che si vuole fare è iterare tutte le read di reader e per ognuna dividere a metà i 3 parametri name, sequence e qualities, salvando le due metà in due nuove stringhe. Quindi nel main dopo la funzione invocata ho messo:codice:reader = read_sequences(parametri vari)
tuttavia mi da il seguente errore:codice:for read in reader: # split the name in two and add the number half = len(read.name) /2 first.name = read.name[:half] first.name += '/1' second.name = read.name[half+1:] second.name += '/2' # split the read in two half = len(read.sequence) /2 first.sequence = read.sequence[:half] second.sequence = read.sequence[half+1:] # split the quality in two half = len(read.quality) /2 first.quality = read.quality[:half] second.quality = read.quality[half+1:]
line 691, in main
first.name = read.name[:half]
TypeError: slice indices must be integers or None or have an __index__ method
Come mai? (premetto che ho incluso string se può servire)

Rispondi quotando