[자바 정리노트] DNA 염기 서열 분석 예제
- 카테고리 없음
- 2017. 8. 8. 14:49
/**
* Created by Gney on 2017-07-13.
*/
public class Practice {
public static void main(String[] args) {
String dna = "GATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCA"
+ "CCACGCCCGGCTAATTTTTATTTATTTATTTAAAGACAGAGTCTCACTCT"
+ "GTCACTCAGGCTAGAGTGCAGTGGCACCATCTCAGCTCACTGCAGCCTTG"
+ "ACCTCCCTGGGCTCCGGTGATTTCACCCTCCCAAGTAGCTAGGACTACAG"
+ "GCACATGCCACGACACCCAGCTAATTTTTTATTTTCTGTGAAGTCAAGGT"
+ "CTTGCTACGTTGCCCATGCTGGTATCAAACCCCTGGGCTCAATCAATCCT"
+ "TCCACCTCAGCCTCCCCAAGTATTGGGGTTACAGGCATGAGCTACCACAC"
+ "TCAGCCCTAGCCTACTTGAAACGTGTTCAGAGCATTTAAGTTACCCTACA"
+ "GTTGGGCAAAGTCATCTAACACAAAGCCCTTTTTATAGTAATAAAATGTT"
+ "GTATATCTCATGTGATTTATTGAATATTGTTACTGAAAGTGAGAAACAGC"
+ "ATGGTTGCATGAAAGGAGGCACAGTCGAGCCAGGCACAGCCTGGGCGCAG"
+ "AGCGAGACTCAAAAAAAGAAAAGGCCAGGCGCACTGGCTCACGCCTGTAA"
+ "TCCCAGCATTTCGGGAGGCTGAGGCGGGTGGATCACCTGAGGTCAGGAGT"
+ "TCAAGACCAGCCTAGCCAACATGGTGAAACCCCGTCTCTACTAAAATACA"
+ "AAAATTAACCGGGCGTGATGGCAGGTGCCTGTAATCCCAGCTACTTGGGA"
+ "GGCTGAGGCAGGAGAATCGCTTGAACCAGGAGGCGGAGGTTGCAGGGAGC"
+ "CAAGATGGCGCCACTGCACTCCAGCCTGGGCGATAGAGTGAGACTCCGTC"
+ "TCAGAAAAAAAAGAAAAGAAACGAGGCACAGTCGCATGCACATGTAGTCC"
+ "CAGTTACTTGAGAGGCTAAGGCAGGAGGATCTCTTGAGCCCAAGAGTTTG"
+ "AGTCCAGCCTGAACAACATAGCAAGACATCATCTCTAAAATTTAAAAAAG"
+ "GGCCGGGCACAGTGGCTCACACCTGTAATCCCAGCACTTTGGGAGGTGGA"
+ "GGTGGGTAGATCACCTGACGTCAGGAGTTGGAAACCAGCCTGGCTAACAT";
char[] charArray = dna.toCharArray();
char[] current = new char[4];
int cnt1=0;
int cnt2=0;
int cnt3=0;
for (int i = 0; i < charArray.length - 3; i++) {
for (int j = 0; j < current.length; j++) {
current[j] = charArray[i + j];
}
String stringFromCharArr = new String(current);
switch(stringFromCharArr) {
case "TAGG":
cnt1++;
break;
case "CCAG":
cnt2++;
break;
case "AGCC":
cnt3++;
break;
}
}
System.out.println("TAGG: " + cnt1);
System.out.println("CCAG: " + cnt2);
System.out.println("AGCC: " + cnt3);
}
}
이 글을 공유하기