Question: Write a program that Scans the DNA sequence filename from the standard input (don't print a prompt to the user). Note that the file sent
Write a program that
Scans the DNA sequence filename from the standard input (don't print a prompt to the user). Note that the file sent will be an altered version of the file you saved above.
Your project must have a class named Main in a package named ecolicounts.
Reads in the file and prints out the number of A's, C's, G's, and T's in the sequence. The format should look like #A = 1142136 #C = 1179433 #G = 1176775 #T = 1140877
I have this written down but G and T are switched and need to be like the above problem
public class Main {
public static void main(String args[]) {
try {
HashMap
Scanner inputScanner = new Scanner(in);
String fileName = inputScanner.next();
Scanner scanner = new Scanner(new File(fileName));
while (scanner.hasNext()) {
String s = scanner.next();
for (int index = 0; index < s.length(); index++) {
Character ch = s.charAt(index);
if (characterCountMap.get(ch) == null)
characterCountMap.put(ch, 0l);
characterCountMap.put(ch, characterCountMap.get(ch) + 1);
}
}
for (Character ch : characterCountMap.keySet()) {
out.println("#" + ch + " = " + characterCountMap.get(ch));
}
} catch (IOException e) {
out.println(e.getMessage());
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
