forked from aidanvanleuven/cs321-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneBankSearch.java
More file actions
53 lines (44 loc) · 1.15 KB
/
GeneBankSearch.java
File metadata and controls
53 lines (44 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class GeneBankSearch {
public static void main(String[] args) {
boolean cache = false;
File btree;
File qFile;
int cacheSize = 0;
BTree tree;
//Parse command line arguments
if(args.length < 3 || args.length > 4) {
printUsage();
System.exit(1);
}
int tmp = Integer.parseInt(args[0]);
if(tmp == 1) {
cache = true;
}
if(args.length == 4) {
cacheSize = Integer.parseInt(args[3]);
}
btree = new File(args[1]);
qFile = new File(args[2]);
tree = new BTree(btree, cache, cacheSize);
tree.printTree();
try {
Scanner q = new Scanner(qFile);
while(q.hasNextLine()) {
String sequence = q.nextLine();
long key = TreeObject.sequenceToLong(sequence);
int frequency = tree.search(key);
sequence = sequence.toLowerCase();
System.out.println(sequence + ": " + frequency);
}
q.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public static void printUsage() {
System.out.println("java GeneBankSearch <0/1(no/with Cache)> <btree file> <query file> [<cache size>]");
}
}