Question

Question #2 A DNA molecule can be specified using a string of the characters , ‘g a, t. Each of these characters represen

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#codons.py
import itertools,random
#method that generates 64 possible codes for atcg
def get_codons():
   codons = []
   for p in itertools.product('atcg',repeat = 3):
       codons.append("".join(p))
   return codons

#method that returns the count of each valid codon in the given file
def codon_dict(file_name):
   #open file
   inp = open(file_name,"r")
   #split() method without any argument splits the string at white space i.e a space , a tab or a new line
   #to handle uppercase codons , all the text read is converted to lower case
   data = inp.read().strip().lower().split()
   #get codons
   codons = get_codons()
   #create an empty dictionary
   c_dict = {}
   #for each valid codon in generated from get_codons() method
   for code in codons:
       #get the count of the code
       count = data.count(code)
       #if it is > 0
       if(count > 0):
           #create a key in dictionary
           c_dict[code] = count
   #finally return the dictionary
   return c_dict

#call codon_dict()
c_dict = codon_dict("inp.txt")
print("Count of Codons")
for key, value in c_dict.items():
   print(key, value)
#sample input and output screenshot is inserted
#inp.txt

ACT cta AAG CCC AGA CGT ATC GAT CGT GGG TGC
tga TGC CGA TCC ggt tac GGC TGA gtg acc
GTA CAC GGA GGT aga GGT cat tag GGC agc
TTT AAC GCT CTT CAT aga GGC CTC tac tat
GAT tat ata tag gtg AGG aag agg AGG gtt
tcc CGT ccg cca gga TCG aac TGG CTC ATC
CCT TTA CCG TTG TCT TCC ACT TTG TCA aat
TCA AGT TAG tcg TAC CGT CCT AGC TAT CGT
gac cag cag CAT ATC ccg ATA cgg ACA gat
TCC TGA CTT tac TCT aaa agc TTC caa asldj
tc jsdlkj 123 dkdl akd
skdkd djd
djdkjd
ount of Codons C:\Windows SYSTEM32\cmd.exe ag 2 ta 2 tc 3 ct 2 ga 3 gt 1 9g 3 at 3 ag 3 ta 1 tt 1 tc 1 tg 2 ca 2 ct 2 cc 4 cg File Edit earch View Document Project Build Iools Help New Open codons.py X inp.tbtX ave Save All Revert CloseBack Forward Co

Add a comment
Know the answer?
Add Answer to:
Question #2 A DNA molecule can be specified using a string of the characters , ‘g...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • project-8a Write a function named count_letters that takes as a parameter a string and returns a...

    project-8a Write a function named count_letters that takes as a parameter a string and returns a dictionary that tabulates how many of each letter is in that string. The string can contain characters other than letters, but only the letters should be counted. The string could even be the empty string. Lower-case and upper-case versions of a letter should be part of the same count. The keys of the dictionary should be the upper-case letters. If a letter does not...

  • Write a program in java to read a string object consisting 300 characters or more using...

    Write a program in java to read a string object consisting 300 characters or more using index input Stream reader. The program should perform following operations. The String must have proper words and all kind of characters.(Use String class methods). a, Determine the length of the string count the number of letters in the strings , count the number of numeric object d. Calculate the number of special character e. Compute the ratio of the numeric to the total f....

  • C++ Help Task B: Translation While a nucleotide is the basic unit of information, three nucleotid...

    C++ Help Task B: Translation While a nucleotide is the basic unit of information, three nucleotides, or codon, is the basic unit of storage. The reason for this is that each gene codes for a protein, and all proteins are made from 20 amino acids. Recall that there are 4 different bases that make up dna. Thus, three bases can encode for 4x4x4 = 64 different symbols. Two base pairs can only encode for 4x4 = 16 symbols, which is...

  • Using python Question 13 (20 points) Write a function named Linestats that finds the number of...

    Using python Question 13 (20 points) Write a function named Linestats that finds the number of consonant and vowel letters on each line of a file and writes those statistics to a corresponding line of a new file, separated by a space. Definitions: A vowel letter is one of a, e, i, o, u, along with the corresponding uppercase letters..A consonant letter is not a vowel letter. The function linestats takes two parameters: 1. inFile, a string, the name of...

  • From the Tony Gaddis text, the chapter on C-String and Class String: String Length: Write a...

    From the Tony Gaddis text, the chapter on C-String and Class String: String Length: Write a Function that passes in a C-String and using a pointer determine the number of chars in the string.                                           Data:   “This is a test string for string length” Prt String Backwards: Write a Function that passes in a C-String and prints the string backwards.      Data: “This is a test string for string backwards” replaceSubstring: Write a Function that accepts three C-Strings – str1,...

  • Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can...

    Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can be solved in one post so I posted the other on another question so please check them out as well :) Here is the questions in this assignment: Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...

  • WE ARE USING PYTHON TO COMPLETE THIS ASSIGNMENT :) THANK YOU! In this programming assignment, you...

    WE ARE USING PYTHON TO COMPLETE THIS ASSIGNMENT :) THANK YOU! In this programming assignment, you will write functions to encrypt and decrypt messages using simple substitution ciphers. Your solution MUST include: a function called encode that takes two parameters: key, a 26-character long string that identifies the ciphertext mapping for each letter of the alphabet, in order; plaintext, a string of unspecified length that represents the message to be encoded. encode will return a string representing the ciphertext. a...

  • Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string"...

    Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...

  • This is for C++ Write a program that reads in a sequence of characters entered by...

    This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...

  • 1 Overview and Background Many of the assignments in this course will introduce you to topics in ...

    1 Overview and Background Many of the assignments in this course will introduce you to topics in computational biology. You do not need to know anything about biology to do these assignments other than what is contained in the description itself. The objective of each assignment is for you to acquire certain particular skills or knowledge, and the choice of topic is independent of that objective. Sometimes the topics will be related to computational problems in biology, chemistry, or physics,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT