Part 2: CovidMutation.java
public class CovidMutation {...}
You are recruited to another research lab at UCSD because of your exceptional work in helping create a new vaccine. This lab is on the forefront of a COVID-19 cure using an antibody treatment. This antibody treatment works by mutilating the genome sequence of the COVID-19 virus such that the nucleotides formed by this mutilated sequence turn the virus into a clump of molecules that is easily broken down by white blood cells. The research lab has a genome sequence simulator that takes in a string of nucleobases (Adenine, Guanine, Thymine, Cytosine, Uracil) and simulates the DNA/RNA chain of that potential organism and its characteristics. The lab has found that they can control the antibodies to specifically reverse every k (some integer) nucleobases of the virus. In order to produce this treatment with the greatest efficacy possible, the research lab must find some k that has the highest rate of weakening the COVID-19 virus.
Task
public class CovidMutation {
...
public static void main(String[] args);
...
}
Given some genome sequence, we want to find the output if we did this k-reversing. Since this technique might be used in the future, we will allow it to work for any string and hope the researchers pass in a valid genome sequence for now. Our application should be able to take any string and any integer k and reverse every k-sized chunk of the string. We will implement this in the main() method of the CovidMutation class in the CovidMutation.java file.
Input
We will read user input from System.in using a Scanner (remember to import it). After a user runs java CovidMutation, they will then type the input to our program. For this assignment, you can safely assume that this input will come as a single line of characters followed by an integer on the next line. The first line will be the string to k-reverse (all you need to know is that it is a string of characters) and the integer k in the next line will represent the "chunk size."
Output
After checking the inputs, we will print some output to System.out. This printout will always be a single string followed by a single newline character. In the case of invalid inputs (see below), print out the original input string (the string from the first line of input). In the case of valid inputs, print out the k-reversed version of the input string. If the length of the string is not divisible by k then you should reverse all characters in the remainder of the string after the last full chunk. If the given k is greater than the length of string, you should completely reverse the entire string (this is a special case of the case described in the previous sentence). Note that this means that the output should always have the same length as the input string.
Implementation
Valid Inputs
The first line will be any string (i.e., possibly composed of characters other than A, C, T, and G). The integer in the second line must be at least 1 to be valid.
Testing
You can use the same procedure as for Part 1. The only difference will be that the second line of your input file will contain the integer representing the chunk size.
Sample Test Case
Case 1
Input: sequence = ACGTAAGCA ; k = 3
Output: GCAAATACG (the k chunk size given is 3 which means we will reverse every 3 nucleotides. This gives ACG|TAA|GCA, if we are to reverse each chunk we will have GCA|AAT|ACG.)
Case 2
Input: sequence = ACGTAAGCA ; k = 7
Output: GAATGCAAC (the k chunk size given is 7 which means we will reverse every 7 nucleotides. This gives ACGTAAG|CA, if we are to reverse the first full chunk we will have GAATGCA. If there is a remainder left that is smaller than the k given, it should be fully reversed. In this case we have 2 nucleobases (CA) left and those should be reversed to result in GAATGCA|AC.)
Style
Coding style is an important part of ensuring readability and maintainability of your code. Namely, there are a few things you must have in each file/class/method:
File headers
Class headers
Method headers
Inline comments
Proper indentation (do not intermingle spaces and tabs for indentation)
Descriptive variable names
No magic numbersa
Reasonably short methods (if you have implemented each method according to specification in this write-up, you’re fine)
Lines shorter than 80 characters (note, tabs will be counted as 4 characters toward this limit. It is a good idea to set your tab width/size to be 4. A good way to check is using the command grep -n '.\{81,\}' *.java in the directory with your files, but note that this won't necessarily take tabulation into account appropriately.)
Javadoc conventions (@param, @return tags, /** header comments */, etc.)
A full style guide can be found here. If you need any clarifications, feel free to ask on Edstem.
Submission:
Turning in your code
Submit all of the following files to Gradescope by Tuesday, July 12 @ 11:59PM PST
CovidGenomeAnalysis.java
CovidMutation.java
When submitting, please wait until the autograder finishes running and read the output. Your code must compile in the autograder in order to receive proper partial credit. Make sure that you have followed the General Notes to ensure that the autograder can run.