Write another method for the class called. It should construct and return a new from the consensus characters for each c

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write another method for the class called. It should construct and return a new from the consensus characters for each c

Post by answerhappygod »

Write Another Method For The Class Called It Should Construct And Return A New From The Consensus Characters For Each C 1
Write Another Method For The Class Called It Should Construct And Return A New From The Consensus Characters For Each C 1 (32.14 KiB) Viewed 19 times
Write another method for the class called. It should construct and return a new from the consensus characters for each column in an alignment. You are recommended to repeatedly call getConsensusForColumn in your implementation. Note that the returned sequence should be composed from the same alphabet as the alignment, except you should allow for gaps to appear in the consensus. Alignment getConsensus Sequence To test your code, use the following sequences and check your consensus sequence using Coder Quiz: seqi Sequence (name="Seql", sequence="AGFDTVTTAISYSL-YLVTNPNVQKKIQ", alphabet=Pr otein_Alphabet, gappy=True) seq2 = Sequence (name="Seq2", sequence="AGFDTITTAISWSL-YLVMNPRIQKKIQ", alphabet=Pr otein_Alphabet, cappy=True) seq3 Sequence (name="Seq3", sequence="AGFDTVT-A-SWSLMYLVMNPRVQRKIQ", alphabet=Pr otein_Alphabet, gappy=True) seq4 Sequence (name="Seq4", sequence="AGFDTVT-A-SWSLMYLVTNPRVQRKIQ“, alphabet=Pr otein_Alphabet, rappy=True) seq5 Sequence (name="Seq5", sequence="AGFDTVT-AISYSLMYLVTNPGVQRKIQ", alphabet=Pr otein_Alphabet, gappy=True) test_aln Alignment([seqi, seq2, seq3, seq4, seq5]) print("My consensus:", test_aln. getConsensus () Question 3a : Submit the consensus sequence that is produced by the getConsensus function for the five sequences above. Question 3b : Submit a file containing the code you developed for your implementation of getConsensus.
def getConsensusForColumn (self, colidx): syment = {} for seq in self. seqs: mysym = seq[colidx] try: #Attempt to execute the code in the below block syment[mysym] += 1 except: #If the above block of code throws any kind of error, #eg. a dictionary key error, execute the below block of code syment [mysym] 1 consensus = None Maxcnt = 0 for mysym in syment: if syment[mysym] > maxcnt: maxcnt = syment (mysyn] consensus = my sym return consensus
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply