I am trying to set up a code that looks into a file with Amino Acids in it and pulls out the first amino acid (for example pulls out Ala). I want it to then search in another file with codons that match the Ala codons given. When I run the code I have set up it says that there are no matching amino acid codons in the text even though there are.
codonsinput=open("Codons.txt", "r")
aminoacidsinput=open("AminoAcids.txt", "r")
allcodons=codonsinput.readlines()
allaminoacids=aminoacidsinput.readlines()
codonsinput.seek(0)
aminoacidsinput.seek(0)
AlaName = ['Ala']
CodonsAla = ['GCU', 'GCC', 'GCA', 'GCG']
string1 = 'coding'
file1 = open("AminoAcids.txt", "r")
flag = 0
index = 0
for line in file1:
index + 1
if 'AlaName' in line:
flag = 1
break
if flag == 0:
print('AminoAcid', AlaName , 'Not Found in text')
else:
file2 = open("Codons.txt", "r")
flag = 0
index = 0
file2 = open("Codons.txt", "r")
for line in file2:
index + 1
if 'CodonsAla' in line:
flag = 1
break
if flag == 0:
print('Ala', CodonsAla , 'Not Found in AminoAcid text')
else:
print('Ala', CodonsAla , 'Found')
file1.close()
file2.close()