python - How do I print the index of the end of an aligned sequence? -



python - How do I print the index of the end of an aligned sequence? -

i using code find seq_find located in seq_long , trying print out index in seq_long alignment ends.

seq_long="ccgacatcgtcctcaccgaccatcgtcctgcatcgtcct" seq_find="catcgtcct" matching_seq_index=[] matching_seq_range=[] matching_seq_index_end=[] x in range(len(seq_long)): search=seq_long[x:x+9] matched=[] if search==seq_find: matching_seq_index.append(x) matching_seq_index_range.append(len(search)) matching_seq_index_end.append(x:x+len(search)) else: pass print matching_seq_index

you need change:

matching_seq_index_end.append(x:x+len(search))

to:

matching_seq_index_end.append(x+len(search))

anyways much shorter version using re.finditer , list comprehension:

>>> import re >>> [m.end() m in re.finditer(seq_find, seq_long)] [13, 29, 39]

python

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -