Biopython coding, sublist from list dependently by id
1
0
Entering edit mode
5.0 years ago
Xylanaser ▴ 80

Hey, I need help, I do not know how to deal with it:

list_of_ids = [aasddaw23/2-20,aasddaw23/34-50,aasddaw23/67-100,fyyrr43/67-98,fyyrr43/80-120,poipoopop34/33-200,poipoopop34/144-222]
#grouped list
result = [[aasddaw23/2-20,aasddaw23/34-50,aasddaw23/67-100],[fyyrr43/67-98,fyyrr43/80-120],[poipoopop34/33-200,poipoopop34/144-222]]

The list should be divided depending on the id on the sub-lists I'm writing a simple program for linking amino acid sequence substrings, but I've come across this problem

thanks in advance

python coding • 968 views
ADD COMMENT
2
Entering edit mode
5.0 years ago
Eric Lim ★ 2.1k

Not entirely sure the purpose of this grouped list and how Biopython plays a role here. Generally speaking, groupby is likely your friend when it comes to stuff like this.

from itertools import groupby
[[x for x in g] for k,g in groupby(sorted(list_of_ids), lambda x: x.split('/')[0])]
ADD COMMENT
0
Entering edit mode

thanks ;) works fine!

ADD REPLY

Login before adding your answer.

Traffic: 2010 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6