-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart1.java
34 lines (34 loc) · 1.11 KB
/
part1.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
/**
* This is my first practice in bioinfrmatics.
*
* @author (Atheer)
* @version (v1 - 10/9/2020)
*/
public class part1 {
String findSimpleGene(String DNA) {
String result = "No DNA";
int startDNA = DNA.indexOf("ATG");
if (startDNA != -1) {
int stopDNA = DNA.indexOf("TAA", startDNA + 3);
if (stopDNA != -1) {
if ((startDNA-stopDNA)%3==0){
result = "";
result = DNA.substring(startDNA, stopDNA + 3);
}
}
}
return result;
}
void testSimpleGene (){
String dna1 ="AAATTTAAA";
String dna2 ="ATGAAATTT";
String dna3 ="AAATTT";
String dna4 ="ATGAATTAAA";
String dna5 ="ATGAATTTAAA";
System.out.println("The result of dna1: " + findSimpleGene(dna1));
System.out.println("The result of dna2: " + findSimpleGene(dna2));
System.out.println("The result of dna3: " + findSimpleGene(dna3));
System.out.println("The result of dna4: " + findSimpleGene(dna4));
System.out.println("The result of dna5: " + findSimpleGene(dna5));
}
}