Hello everybody,
Sample file:
>sp|Q6GZX2|003R_FRG3G (438 aa)
Uncharacterized protein 3R. [Frog virus 3 (isolate Goorha) (FV-3)]
MARPLLGKTSSVRRRLESLSACSIFFFLRKFCQKMASLVFLNSPVYQMSNILLTERRQVDRAMGGSDDDGVMVVALSPSD
FKTVLGSALLAVERDMVHVVPKYLQTPGILHDMLVLLTPIFGEALSVDMSGATDVMVQQIATAGFVDVDPLHSSVSWKDN
VSCPVALLAVSNAVRTMMGQPCQVTLIIDVGTQNILRDLVNLPVEMSGDLQVMAYTKDPLGKVPAVGVSVFDSGSVQKGD
AHSVGAPDGLVSFHTHPVSSAVELNYHAGWPSNVDMSSLLTMKNLMHVVVAEEGLWTMARTLSMQRLTKVLTDAEKDVMR
AAAFNLFLPLNELRVMGTKDSNNKSLKTYFEVFETFTIGALMKHSGVTPTAFVDRRWLDNTIYHMGFIPWGRDMRFVVEY
DLDGTNPFLNTVPTLMSVKRKAKIQEMFDNMVSRMVTS
2 - 9: ArpllGKT
Sample code:
def get_sequence():
try:
with open("Filename.txt") as f:
file = f.readlines()
raw_data = ''
start_reading = False
for line in file:
if line.startswith(">"):
start_reading = True
if start_reading:
raw_data += line
sequence = raw_data.split(">")
sequence = sequence[1:]
except IOError:
print('Some meaningfull message')
quit()
finally:
print(sequence[0])
print(sequence[1])
dict(sequence)
return sequence
My question is how can I convert the list sequence to a dictionary? It would be really nice if the organism is the key and the value is a list of the other data. The dict() method raises a ValueError.
This is a school assignment, so I'm not allowed to use BioPython.
Thanks in advance!
How can I post code without this messed up layout?
Above the text box you write in, there should be a number of box icons which you can use to edit the text... Highlight your code and then click the little box with the ones and zeroes in it.
Thanks! It works.