I'm making Calculator for Peptide monoisotopic and have some problems that I cannot solve.
import re
aminoacid = {
"I": "C6H13NO2",
"L": "C6H13NO2",
"K": "C6H14N2O2",
"M": "C5H11NO2S",
"F": "C9H11NO2",
"T": "C4H9NO3",
"W": "C11H12N2O2",
"V": "C5H11NO2",
"R": "C6H14N4O2",
"H": "C6H9N3O2",
"A": "C3H7NO2",
"N": "C4H8N2O3",
"D": "C4H7NO4",
"C": "C3H7NO2S",
"E": "C5H9NO4",
"Q": "C5H10N2O3",
"G": "C2H5NO2",
"P": "C5H9NO2",
"S": "C3H7NO3",
"Y": "C9H11NO3"
}
acid = input('Sequence: ')
s = re.findall('([A-Z][a-z]?)([0-9]*)', formula)
monoisotopic = {'S': 31.972, 'C': 12.0000, 'H': 1.0078, 'O': 15.9949, 'N': 14.0031}
weight = 0
for elem, count in s:
#For singular elements
if count=='':
count = 1
weight = weight + int(count) * monoisotopic[elem]
print('[M + H]+ : ', weight-(len(acid)-1)*18.0105+1.0078)
print('# of amino acids : ', len(acid))
If I put single amino acid like "A", it works well. But when I put sequences like "AILWNG", the program cannot recognize it. How can I make this program to recognize two or more amino acids?