I'm trying to create a dictionary by running through a for loop where it would have a description of a bacteria and the key being its DNA sequence. The only problem is that my variable cannot store multiple dataset and it just overwrites the first dataset, thus giving me only one output for my dictionary.
#reads a fasta file and seperates the description and dna sequences
for line in resistance_read:
if line.startswith(">"):
description = line
else:
sequence = line
#trying to get the output from the for loop and into the dictionary
bacteria_dict = {description:sequence}
Output:
line3description
dna3sequence
However, with the following code below, I am able to get all the outputs
for line in resistance_read:
if line.startswith(">"):
print line
else:
print line
Output:
line1description
line2description
line3description
dna1sequence
dna2sequence
dna3sequence