-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenomeInString.java
executable file
·57 lines (52 loc) · 1.39 KB
/
GenomeInString.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
53
54
55
56
57
public class GenomeInString{
String[] chrs;
public GenomeInString(String[] s){
chrs = new String[s.length];
chrs = s;
}
public void print(){
for(int i = 0; i< chrs.length; i++){
System.out.println("chr "+i+"\n "+chrs[i]);}
}
public int countGeneNumber(){
int result = 0;
for(int i = 0; i< chrs.length; i++){
String[] genes = splitBS(chrs[i]);
result = result+genes.length;
}
return result;
}
public void chrLength(){
String[] chrLength = new String[10000];
for(int i = 0; i< chrLength.length; i++){
chrLength[i] = "";
}
for(int i = 0; i< chrs.length; i++){
String[] genes = splitBS(chrs[i]);
chrLength[genes.length]= chrLength[genes.length]+ "\t"+ new Integer(i).toString();
}
for(int i = 0; i< chrLength.length; i++){
if(chrLength[i].equals("")==false){
System.out.println("list of chrs with "+ i+" genes"+ "\t"+chrLength[i]);
}
}
}
public String[] splitBS(String s){
String[] tmp = s.trim().split(" ");
int index = 0;
for(int i = 0; i < tmp.length; i++){
if(tmp[i].trim().equals("") ==false){
index++;
}
}
String[] result = new String[index];
index = 0;
for(int j = 0; j <tmp.length; j++){
if(tmp[j].trim().equals("") == false){
result[index] = tmp[j].trim();
index++;
}
}
return result;
}
}