This is what I am given:
In this exercise we want to simulate the effects of mutations on a DNA string (with at most 1000 characters). For simplicity we will only consider a selected subset of chromosomal mutations. We would simulate the following (simplified) mutations:
Amplification (amp) : this inserts a duplicate copy of the specified region beside it;
Deletion (del) : this deletes the selected region;
Inversion (inv) : this reverses the orientation of the specified region.
The first line of the input consists of a string (with at most 1000 characters) that denotes the DNA sequence. The second line consists of a positive integer n denoting the number of mutations. The next n lines specify the mutations, each on a single line.
Each line representing a mutation consists of (1) the mutation command (which can be amp, del, or inv), (2) the start index (inclusive), and (3) the end index (inclusive). The first character in the DNA sequence has index 0. All commands are in lower case.
For example "amp 2 4" on "AGCTAGATT" results in "AGCTACTAGATT" as CTA is duplicated. The duplicated part is marked in blue for your reference.
The following is always true about the input and the DNA at every point of time:
There will always be a command, followed by a space, followed by an integer value (denoting the start index), followed by a space, followed by an integer value (denoting the end index).
There is always only a single space between the command and the start index.
There is always only a single space between the start index and the end index.
All indices are inclusive.
The start index is always smaller or equal to the end index.
All DNA strings will consist only of 4 possible characters (in uppercase) which are 'A', 'T', 'C', 'G'.
The number of commands is always exactly equals to n.
The length of a DNA string will always be at least 1 and at most 1000 at any point of time.
The input mutation commands are always in lower case.
The mutations have been greatly simplified and you should model your mutations only in the descriptions given here.
The output consists of a single line containing the modified string.
It is a must to work on character array.
And the skeleton i'm provided with:
public class Mutations
public static void main(String args)
Scanner stdIn = new Scanner(System.in);
String dna = stdIn.nextLine();
int count = stdIn.nextInt(); // number of mutation commands
int dnaLength = dna.length();
char dnaArray = new char;
for (int i = 0; i < dna.length(); i++)
dnaArray[i] = dna.charAt(i);
* Type your code here.
* Make sure you remember to update the dnaLength variable!
* We cannot simply use the dnaArray because it has a length of 1000.
* Therefore we should only take a substring of its proper length.
String output = new String(dnaArray);
output = output.substring(0, dnaLength);