I have a string of characters and a list of characters. I wish to create a dictionary in which the keys are the characters as and the values are the list, only without the key character.
A string of characters:
sequence = 'ATGCG' The list:
bases = ['C', 'T', 'A', 'G'] The resulting dictionary would be:
{'A': ['C', 'T', 'G'], 'T': ['C', 'A', 'G'], 'G': ['C', 'T', 'A'], 'C': ['T', 'A', 'G'], 'G': ['C', 'T', 'A'], } I tried using the following code but got a list of 4 items:
variations = {current_base: [base for base in bases if current_base != base] for current_base in sequence} I'd love to get ideas regarding what I'm doing wrong. Thanks.