Hi, I've just started out with Python and I've been stuck on this problem for a few hours now trying to parse a file into a certain format..
I am trying to create a list in a list out of a list.
I currently have this list;
['MPNRRRCKLSTAISTVATLAIASPCAYFLVYEPTASAKPAAKHYEFKQAASIADLPGEVLDAISQGLSQFGINL', 'MQLVDRVRGAVTGMSRRLVVGAVGAALVSGLVGAVGGTATAGAFSRPGLPVEYLQVPSPSMGRSELPGWLQA', 'etc']
What I am trying to make is a list of each item, with the first 40 individual characters in the strings as items, while translating them into an int for example; M = 1.43, P=1.53, I want to be able to have each item as an individual list before putting them into one together because I want to add another value(1/0) on the end of the lists, and in the end put all these items back into a list like this;
[[1.43,'0.00','1.53','1.42','8.90', '1'],[1.43,'0.00','1.53','1.42','8.90', '0'],[1.43,'0.00','1.53','1.42','8.90', '0']]
My current code:
converted = []
seq= ['MPNRRRCKLSTAISTVATLAIASPCAYFLVYEPTASAKPAAKHYEFKQAASIADLPGEVLDAISQGLSQFGINL', 'MQLVDRVRGAVTGMSRRLVVGAVGAALVSGLVGAVGGTATAGAFSRPGLPVEYLQVPSPSMGRSELPGWLQA','GLVGLAGGAATAGAFSRPGLPVEYLQVPSPSMGRDIKVQFQSGGNNSPAVYLLDGLRAQDDYNGWDINTPAFEWACGKAGCQTYKWETFLTSELPQWLSANRAVKPTGSAAIGLSMAGSSAMILAAYHPQQFIYAGSLSALL']
polarity = { 'A': 0.000, 'R': 52.000, 'N': 3.380, 'D': 49.700, 'C': 1.480,
'Q': 3.530, 'E': 49.900, 'G': 0.000, 'H': 51.600, 'I': 0.130,
'L': 0.130, 'K': 49.500, 'M': 1.430, 'F': 0.350, 'P': 1.580,
'S': 1.670, 'T': 1.660, 'W': 2.100, 'Y': 1.610, 'V': 0.130,
}
for x in seq:
seq2 = x[0:39]
for y in seq2:
converted.append(polarity[y])
I've already tried a different approach before but I keep getting stuck.
I hope you guys can help me out!