Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Proteins and DNA are the basic building blocks of life. A protein is a sequence of amino acids of which there are 2 0 different

Proteins and DNA are the basic building blocks of life. A protein is a sequence of
amino acids of which there are 20 different kinds. DNA is made up of nucleic
acids. There are four nucleic acids, abbreviated with the letters A, C, G, and T. A
sequence of three nucleic acids make up a codon (e.g., AAT, GCT, TAC). Each
codon corresponds to one of the twenty amino acids.
You are to write a program called TranslateCodons.java (put into the package
ds2) that does the following:
- Read in the file data/codonto3letteraa.txt already provided which specifies
the mapping from DNA codons to the amino acids. Using one of the symbol
table implementations in algs4, build a symbol table where the key is a
three-letter codon (made up of the letters A, C, G, or T) and the value is the
three-letter abbreviation for an amino acid (for example, "Ala", "Leu"). For
example, the codon "TTA" should have the value "Leu", the codon "TAA"
should have the value "Stp".
- Read in another file data/smallsequences.txt where each line consists of a
species name (which may include spaces), a tab character, and a DNA
sequence whose length is a multiple of 3. For each line read in, print four
lines:
1. the species name
2. the DNA sequence broken into three-letter groups (i.e., codons)
separated by whitespaces
3. the three-letter amino acid codes corresponding to the codons in the
DNA sequence separated by whitespaces
4. a blank line
For example, if the input line is:
Ailuropoda melanoleuca ATGTTCATTAACCGATGACTGTTTTCCACCAAA
your program should print:
Ailuropoda melanoleuca
ATG TTC ATT AAC CGA TGA CTG TTT TCC ACC AAA
Met Phe Ile Asn Arg Stp Leu Phe Ser Thr Lys
Notice that it is okay to have a trailing whitespace in the second and third line
that you print out.
Reading input from file
The names for the files that you read from should be specified as two separate
arguments from the command line, where the first argument points to the
location of the file codonto3letteraa.txt and the second argument points to the
location of the file containing the species names and DNA sequences. For
example, one may run your program as follows:
java ds2.TranslateCodons data/codonto3letteraa.txt
data/smallsequences.txt
This means that in your java code, the first filepath is stored in the variable
args[0] and the second filepath is stored in the variable args[1]. You should
create two different objects of Algs4.In for reading the two files.
Do not hardcode the file path in your codes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions