This repository was archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeObject.java
More file actions
84 lines (72 loc) · 1.46 KB
/
TreeObject.java
File metadata and controls
84 lines (72 loc) · 1.46 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.io.Serializable;
/**
* Creates the tree object that contains the key and freq
* @author thomasreinking
*
*/
public class TreeObject implements Serializable {
private int freq;
private long key;
private static int seqLength = 0;
/**
* Creates a tree object with a given frequency and key
* Could be used for when a duplicate is found.
*/
public TreeObject(long key, int freq) {
this.freq = freq;
this.key = key;
}
/**
* Creates a tree object with only the key
* Used for when no duplicates is found
* @param key
*/
public TreeObject(long key) {
this.key = key;
freq = 1;
}
/**
* Increases the freq count
*/
public void increaseFreq() {
freq++;
}
/**
* Returns the freq of the object
*/
public int getFreq() {
return freq;
}
/**
* Returns the key of
* @return
*/
public long getKey() {
return key;
}
@Override
public String toString() {
String str = convertKey() + ": " + freq;
return str;
}
public void setSeqLen(int n) {
seqLength = n;
}
private String convertKey() {
String subString = "";
for (int i = 1; i <= seqLength; i++) {
long geneBit = (key & (3L << (seqLength - i) * 2));
geneBit = geneBit >> (seqLength - i) * 2;
if (geneBit == 0) { //00
subString += "a";
} else if (geneBit == 1) { //01
subString += "c";
} else if (geneBit == 2) { //10
subString += "g";
} else if (geneBit == 3) { //11
subString += "t";
}
}
return subString;
}
}