slentzen
September 28th, 2008, 08:28 AM
I am trying to solve an exercise where I have to lad a fasta file containing headers starting with >Protein_name, followed by some peoptide sequence.
By using regular expressions, and loops, I have gotten to the point where my list is on the form ['header1','seq1',headern+1',seqn+1']. The list will always have an even number of elements, in the order given above.
Now I should convert the list to a dictionary, where the header files are the keyes, and the respetive sequence strings the values. But I am hitting my head against a wall on how to do this.
Maybe someone can guide me a little on my way towards a solution?
My first idea was to maybe to try with a while loop that first checks that " while list%2 == 0 and len(list)!=0:" the idea that the first part with the modulus operater ensures that the previous formatting has proceeded correctly, and the last part that the loop stops correctly when the extraction is done.
But from there on, I am low on ideas.
Hope anyone here can give me some advice.
Thanks - Slentzen
By using regular expressions, and loops, I have gotten to the point where my list is on the form ['header1','seq1',headern+1',seqn+1']. The list will always have an even number of elements, in the order given above.
Now I should convert the list to a dictionary, where the header files are the keyes, and the respetive sequence strings the values. But I am hitting my head against a wall on how to do this.
Maybe someone can guide me a little on my way towards a solution?
My first idea was to maybe to try with a while loop that first checks that " while list%2 == 0 and len(list)!=0:" the idea that the first part with the modulus operater ensures that the previous formatting has proceeded correctly, and the last part that the loop stops correctly when the extraction is done.
But from there on, I am low on ideas.
Hope anyone here can give me some advice.
Thanks - Slentzen