Subject Computer Science Java Programming

Question

The information content of the molecule DNA can be represented in computer programs as a sequence of the letters A, C, G, and T. As DNA is passed down from generation to generation, the sequence of letters is usually faithfully replicated, but sometimes errors occur either during replication or in the course of a lifetime, so that the sequence has changed. If an error occurs in a germ cell line and is passed on to progeny, this is termed a mutation. The accumulation of mutations over generations helps to drive evolution.
Write a program to simulation mutation by starting with an input sequence of letters of arbitrary length up to a maximum of 80 and then for 25 generations randomly choose one letter for mutation. There should be an equal probability for a letter to be chosen, and an equal probability for which of the four letters it could become.
Your program should print the original sequence, and then the 25 resulting sequences. If it should happen that two adjacent sequences are identical, you should print an asterisk at the end of the second of the two sequences.
At the end of the output, you should print an asterisk below the column of any letter that did not change during the course of the simulation.
An example run of the program should appear like this:
$ java Student
Enter a DNA sequence up to 80 bp:
ATTCGGCTA
ATTCGGCTA
ATCCGGCTA
ATCCGTCTA
ATCCGTCTA *
...ATCCGTCTT
AACCGTCTT
AATCGTCTT
* ** **
You should not print the ellipses, of course, but rather the entire 26 lines of output.
Use an array of characters for this program. Do not use ArrayLists or strings. Write methods as necessary, and follow all the rules of the style guide.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;


public class Mutation {

public static void mutationSimulation(char[] sequence)
{
int size = sequence.length;
boolean[] change = new boolean[size];
for(int i = 0 ;i < 0; i++)
change[i] = false;
char[] letters = {'A', 'C', 'G', 'T'};
System.out.println(sequence);
for(int i = 0; i < 25; i++)
{
int position = (int)(Math.random()*size);...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$13.00

or $1 if you
register a new account!

Related Homework Solutions

Interactive Command-Line Game in Java
Homework Solution
$50.00
Java
Programming
Coding
Game Development
Computer Science
Zork
Colossal Cave Adventure
Command Line
Maps
2D Grid
Win
Lose
Classes
OOP
Methods
Fields
String Values
Integers
Statements
Accounting Problems Using Java
Homework Solution
$45.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Interest Rates
Account Balance
Display Messages
Compounding Interest
Strings
Dates
Analysis
Matrix Problem in Java
Homework Solution
$13.00
Java
Programming
Coding
Computer Science
Matrix
Diagonals
Input File
Output File
Integers
Loops
Conditions
Statements
Swapping Numbers
Random Values
Variables
Get help from a qualified tutor
Live Chats