-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhile1.java
52 lines (27 loc) · 891 Bytes
/
While1.java
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
/**
* Write a description of While1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class While1 {
public String FindGene(String dna){
int startIndex= dna.indexOf("ATG");
int currIndex=dna.indexOf("TAA",startIndex+3);
while(currIndex!=-1){
if((currIndex-startIndex)%3==0){
return dna.substring(startIndex,currIndex+3);
}
else{
currIndex= dna.indexOf("TAA",currIndex+1);
}
}
return "";
}
public void testFindGeneSimple(){
String dna="AATGCGTAATTAATCG";
System.out.println("DNA strand is " + dna);
String gene=FindGene(dna);
System.out.println("Gene is " + gene);
}
}