my problem follows:
dnaSequence = file2.readline()
for key in nucleotides:
keys = " ".join(key)
value = re.search(f"(?:({key}){{2,}}|({key}))", dnaSequence)
value = int(len(value.group(0)) / len(key))
STRs = {key: value}
print(STRs)
I have to solve this problem by reading a file with a unknow DNA chain, and using a regex to find the biggest repetitions of nucleotides sequences inside that chain. Something such as AAGT, AGTC, TTTTTTTCT, and so on. The above code gave me the following result:
{'AGATC': 4}
{'AATG': 1}
{'TATC': 5}
The dictionary key is the nucleotides chain that I have to look up for. The numbers(values) are the number of times that those nucleotides repeat yourselves consecutively. So, just for enlightening, the first result means my regex found AGATCAGATCAGATCAGATC in a long DNA chain in the file.
And I was expecting for {'AGATC': 4, 'AATG': 1, 'TATC': 5}. How can I merge these 3 different values in one single dictionary?