-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSequence.java
More file actions
59 lines (51 loc) · 1.44 KB
/
Sequence.java
File metadata and controls
59 lines (51 loc) · 1.44 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
package Assignment_1;
/**
* Created by Sebastian on 23.10.2016.
* Saves sequence and computes some information about the sequence
*/
class Sequence {
private String name;
private String sequence;
private int length;
private int lengthWithoutHyphen;
Sequence(String name, String sequence) {
this.name = name;
this.sequence = sequence;
this.length = sequence.length();
this.lengthWithoutHyphen = this.length;
for (int i = 0; i < this.length; i++) {
switch (sequence.charAt(i)) {
case 'A':
Nucleotide.A++;
break;
case 'U':
Nucleotide.U++;
break;
case 'C':
Nucleotide.C++;
break;
case 'G':
Nucleotide.G++;
break;
case '-':
Nucleotide.Hyphen++;
this.lengthWithoutHyphen--;
break;
default:
System.err.println("Error while reading sequence, unexpected character");
}
}
}
public String getName() {
return name;
}
public String getSequence() {
return sequence;
}
public int getLength() {
return length;
}
public int getLengthWithoutHyphen() {
return lengthWithoutHyphen;
}
}