forked from samuell/gccontent-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gc.java
32 lines (24 loc) · 903 Bytes
/
gc.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
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class gc {
/*
* https://github.com/pditommaso/gccontent-benchmark
*/
public static void main(String... args) throws IOException {
BufferedReader stream = new BufferedReader(new FileReader("../chry_multiplied.fa"));
int[] value = new int[256];
value['A'] = value['T'] = value['G'] = value['C'] =0;
String line;
while( (line=stream.readLine())!= null ) {
if( line.charAt(0)=='>' )
continue;
for( int i=0; i<line.length(); i++ ) {
value[line.charAt(i)]++;
}
}
int totalBaseCount = value['A'] + value['T'] + value['G'] + value['C'];
int gcCount = value['G'] + value['C'];
System.out.println((float)gcCount / (float)totalBaseCount * 100);
}
}