У меня есть файл с несколькими строками в формате FASTA, который я хочу разбить на части и заполнить словарь этими частями.
>piece_1
Lorem ipsum dolor sit amet
consectetur adipiscing elit. Nam a pellentesque mi.
>piece_2
Integer dignissim ultrices eros a consequat. Praesent vestibulum
>piece_3
Morbi eget sollicitudin mauris. Nunc varius felis
vitae dui congue hendrerit. Nam semper venenatis auctor.
Suspendisse potenti. Suspendisse facilisis velit vel convallis
fringilla. Duis condimentum auctor mauris eu lobortis.
Я хочу создать из текста выше словарь, содержащий все отдельные фрагменты текста с ключами >piece_1
и т. Д.
Пока мне удалось заполнить словарь всеми ключами, но я не могу сказать, как извлечь текст из файла.
f = open('Output.txt', 'r')
mydict = dict()
for index, line in enumerate(f):
if line[:1]=='>':
mydict[index] = line #instead, the key should be line with the value being the relative text.
print(line, end='')