Debian Codegraph @

current/dna/Matrix.java

raw symbols SCIP
1 package dna;
2 import java.util.HashMap;
3 import java.util.Set;
4
5 import fileIO.MatrixFile;
6
7
8 public class Matrix {
9
10
11 public Matrix(float[][] g, int pre, String nm){
12 grid=g;
13 prefix=pre;
14 name=nm;
15 }
16
17 public float[][] subGrid(int prefixLength, int length){
18 float[][] r=new float[length][];
19 int start=prefix-prefixLength;
20 for(int i=0; i<length; i++){
21 r[i]=grid[i+start].clone();
22 }
23 return r;
24 }
25
26 public float[][] grid;
27 public int prefix;
28 public String name;
29
30
31
32
33 private static HashMap<String, Matrix> table=null;
34
35 public static Set<?> keys(){return table.keySet();}
36
37 public static Matrix get(String s){
38 if(table==null){
39 table=new HashMap<String, Matrix>(64);
40 // fillTable("matrices.txt");
41 // fillTable("matrices2.txt");
42
43 // fillTable("matrixN1.txt");
44 // fillTable("matrixN2.txt");
45 // fillTable("matrixN3.txt");
46 // fillTable("matrixN4.txt");
47
48 fillTable("matrix_build37_N1.txt");
49 fillTable("matrix_build37_N2.txt");
50 fillTable("matrix_build37_N3.txt");
51 // fillTable("matrix_build37_N4.txt");
52
53
54
55 // fillTable("asmGstart_sept9.txt");
56 // fillTable("asmEstart_sept9.txt");
57 // fillTable("asmTRstart_sept9.txt");
58 // fillTable("asmGstop_sept9.txt");
59 // fillTable("asmEstop_sept9.txt");
60 // fillTable("asmTRstop_sept9.txt");
61 // fillTable("asmEstop_sept16.txt");
62
63 // fillTable("SplicePercentiles_b37_Sept16.txt");
64 fillTable("SplicePercentiles_b37_Nov24.txt");
65
66 }
67 Matrix m=table.get(s);
68
69 // assert(table.containsKey(s)) : "\nCan't find "+s+" in\n\n"+table.keySet()+"\n";
70 // assert(m!=null) : "\nValue for "+s+" is null\n";
71
72 if(!table.containsKey(s) || m==null){
73 if(!table.containsKey(s)){throw new RuntimeException("Can't find "+s+" in\n\n"+table.keySet()+"\n");}
74 if(m==null){throw new RuntimeException("\nValue for "+s+" is null");}
75 }
76
77
78 return m;
79 }
80
81 private static void fillTable(String fname){
82 MatrixFile mf=new MatrixFile(fname);
83 Matrix mat=mf.nextMatrix();
84 while(mat!=null){
85 // System.out.println("Adding "+mat.name);
86 table.put(mat.name, mat);
87 table.put(mat.name.toLowerCase(), mat);
88 mat=mf.nextMatrix();
89 }
90 mf.close();
91 }
92
93 }