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

Related Homework Solutions

Java Programming Problem
Homework Solution
$28.00
Java
Programming
Codes
Algorithms
Computer Science
Classes
Variables
Statements
Source Files
Input
Output
Constructors
Strings
Integers
Error Handling
Class Money in Java
Homework Solution
$20.00
Java
Programming
Coding
Money
UML Diagram
Computer Science
Dollars
Cents
Parameters
Statements
Methods
Strings
Integers
Finance
Arithmetic Operations
Clustering Problems in Java
Homework Solution
$60.00
Computer Science
Java Programming
Algorithms
Clustering
K Means
Real Factors
Voronoi Diagram
Toy Problem
Brute Force
Centroids
Iterations
Statements
Variables
Java Programming Problems: Expression Trees and AVL Trees
Homework Solution
$50.00
Java
Programming
Computer Science
Expression Trees
AVL Trees
Algorithms
Input
Output
Recursive Functions
Strings
Variables
Statements
Loops
Methods
Expressions
Objects
Classes
Operators
Nodes
Numbers
Custom String Builder in Java
Homework Solution
$75.00
Java
Programming
String Builder
Algorithms
Loops
Variables
Statements
Arrays
Characters
Functions
Classes
Exception Handling
Pythagorean Theorem in Java
Homework Solution
$13.00
Computer Science
Programming
Java
Pythagorean Theorem
Mathematics
Triangles
Sides
Angles
Equations
Statements
Variables
Parameters
Methods
Get help from a qualified tutor
Live Chats