22
22
public class ClassifierSequence extends Sequence {
23
23
private boolean reverse = false ;
24
24
private Integer goodWordCount = null ; // the number of words with only valid bases
25
-
25
+ private int [] wordIndexArr = null ;
26
26
/**
27
27
* Creates new ParsedSequence.
28
28
*/
29
- public ClassifierSequence (Sequence seq ) {
29
+ public ClassifierSequence (Sequence seq ) throws IOException {
30
30
this (seq .getSeqName (), seq .getDesc (), seq .getSeqString ());
31
31
}
32
32
33
- public ClassifierSequence (String seqName , String desc , String seqString ) {
33
+ public ClassifierSequence (String seqName , String desc , String seqString ) throws IOException {
34
34
super (seqName , desc , SeqUtils .getUnalignedSeqString (seqString ));
35
+ /**
36
+ * Fetches every overlapping word from the sequence string, changes each
37
+ * word to integer format and saves in an array.
38
+ */
39
+ GoodWordIterator iterator = new GoodWordIterator (this .getSeqString ());
40
+ this .wordIndexArr = iterator .getWordArr ();
41
+ this .goodWordCount = wordIndexArr .length ;
35
42
}
36
43
37
44
/**
@@ -41,6 +48,9 @@ protected void setSeqString(String s) {
41
48
seqString = s ;
42
49
}
43
50
51
+ public int [] getWordIndexArr (){
52
+ return this .wordIndexArr ;
53
+ }
44
54
/**
45
55
* Returns true if the sequence string is a minus strand.
46
56
*/
@@ -52,31 +62,16 @@ public boolean isReverse() {
52
62
* Returns a Sequence object whose sequence string is the reverse complement
53
63
* of the current rRNA sequence string.
54
64
*/
55
- public ClassifierSequence getReversedSeq () {
65
+ public ClassifierSequence getReversedSeq () throws IOException {
56
66
ClassifierSequence retval = new ClassifierSequence (seqName , desc , IUBUtilities .reverseComplement (seqString ));
57
67
retval .reverse = true ;
58
68
return retval ;
59
69
}
60
70
61
- /**
62
- * Fetches every overlapping word from the sequence string, changes each
63
- * word to integer format and saves in an array.
64
- */
65
- public int [] createWordIndexArr () throws IOException {
66
- GoodWordIterator iterator = new GoodWordIterator (this .getSeqString ());
67
- int [] wordIndexArr = iterator .getWordArr ();
68
-
69
- this .goodWordCount = wordIndexArr .length ;
70
- return wordIndexArr ;
71
- }
72
-
73
71
/**
74
72
* Returns the number of words with valid bases.
75
73
*/
76
- public int getGoodWordCount () throws IOException {
77
- if (goodWordCount == null ) {
78
- this .createWordIndexArr ();
79
- }
74
+ public int getGoodWordCount () {
80
75
return goodWordCount ;
81
76
}
82
77
}
0 commit comments