Question
You will create an class that will work alongside the server to search Chromosome 1 of the human genome. At construction this class will open
You will create an class that will work alongside the server to search Chromosome 1 of the human genome. At construction this class will open the Chromosome file specified and read it into a single long string that it maintains. It will also provide a method that takes a string as its input and it will output a List
Example Constructor: public GenomeSearcher(Path file)
Example Method:public List
Tip 1: The Chromosome file has the dna separated with ' ' characters. We don't want that. There are many ways to remove it, but one is to use a StringBuilder to append each line you read from the file:
StringBuilder sb = new StringBuilder();
String s;
while((s = br.readLine()) != null) {
sb.append(s);
}
The variable br is the BufferedReader being used to read the file. This reads the lines one at a time and appends them all together into one giant genome string. Note that this string will not be visible in the debugger due to its immense size. I recommend just printing out a subsection (like indices 10,000 to 11,000) to test that you are reading it in correctly.
Tip 2: Use the .indexOf() method of strings to do an substring search. This method can take two parameters, the string you want it to search for and the index you want it to start from. This method returns -1 if the substring is not found, so you can use that result as well to exit your loop.
To put this process into pseudocode:
1.index = 0
2.while(index >= 0)
a.index = chromosome1.indexOf(substring,index+1)
b.if(index >= 0)
i.list.add(index)
Tip 3: The genome contains a mixture of upper and lower case DNA which we are going to ignore. I would recommend when you read the chromosome data in, make everything upper case. Similarly, when you read in a string to search for, make it upper case as well. This can be done easily with the .toUpperCase() function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started