Week 9 Discussion

.docx

School

University of Maryland Global Campus (UMGC) *

*We aren’t endorsed by this school

Course

617

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by DeanGullMaster970

Contains unread posts What is meant by a dictionary in Python? And why are they useful? A Dictionary can be described as an object that stores a collection of data. Dictionaries are useful because it can be used to retrieve a specific value by using the key associated with it. After reading chapter 8 of the text book, and checking out the lecture notes, do the following exercise: Write a program that asks a user for a gene ID or accession number and returns the sequence that corresponds to that gene. Use a dictionary to accomplish this. Get the genes and their sequences from NCBI and create the dictionary so that the key = gene ID and value = sequence. Handle the case where the gene ID is not found in the dictionary. # Create dictionary of gene sequences gene_sequences = { "BRCA1": "GTGATCCGCTCACCTTGACCTCCCAAAGTGCTGGGATTAAAGGCA TGAGCCACTGTGCCCCGCCAGGAAA", "BRCA2": "GTGGCGCGAGCTTCTGAAACTAGGCGGCAGAGGCGGAGCCGCT GTGGCACTGCTGCGCCTCTGCTGCGCC", "CDKN2B-AS1": "AGCTACATCCGTCACCTGACACGGCCCTACCAGGAACAGCCGCG CTCCCGCGGATTCTGGTGCTGCTCGC", "MLH1": "GAAGAGACCCAGCAACCCACAGAGTTGAGAAATTTGACTGGCATT CAAGCTGTCCAATCAATAGCTGCCG", "CCAT2": "CCGAGGTGATCAGGTGGACTTTCCTGGATGTTCTGGGTCTTGACC TGATTGCTGAAAAATGAATACAAAT", "PRNCR1": "AAATCTCAGCCTCCCACTCCCATATTTACAGTTTGATTAGGGAGG CACATTTAGATATGCAGTGATAATT", }
# Function to search for a gene sequence based on gene ID def find_gene_sequence(gene_id): if gene_id in gene_sequences: return gene_sequences[gene_id] else: return "Gene ID not found" # Main program loop while True: user_input = input("Enter a gene ID or accession number (type 'stop' to exit): ") if user_input.lower() == "stop": print("Stopped program.") break sequence = find_gene_sequence(user_input) print(f"Sequence for {user_input}: {sequence}")
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help