View Javadoc
1   /*** PerWellDataAnalyzer.java - part of the MirkE (say murky) application for colormetric analysis emphesizing 
2   kinetics.
3   
4   this will be removed when Siva's analysis system is in place (had to perform an analysis for monthly report)
5   
6   Created by: Scott Menor on 1 Februrary, 2005.
7   
8   Copyright (c) 2004 Arizona State University - Cancer Research Institute. All rights reserved.
9   
10  MirkE is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14  
15  MirkE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19  
20  You should have received a copy of the GNU General Public License
21  along with MirkE; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
23  */
24  package edu.asu.cri.MirkE.util;
25  
26  import java.util.Iterator;
27  
28  import edu.asu.cri.MirkE.MirkE;
29  import edu.asu.cri.MirkE.dataStructures.DataSet;
30  import edu.asu.cri.MirkE.exceptions.MirkEApplicationException;
31  
32  /***
33   * @author smenor
34   *
35   */
36  public class PerWellDataAnalyzer extends DataAnalyzer {
37      
38      private MirkE mirke = null;
39      
40      /*** preferred constructor
41       * @param mirke
42       */
43      public PerWellDataAnalyzer(MirkE mirke) {
44          this.mirke = mirke;
45      }
46      
47      /***
48       * @throws MirkEApplicationException
49       * 
50       */
51      public void computeAndDisplayPerWellMeans() throws MirkEApplicationException {
52          DataSet dataSet = this.mirke.getDataSet();
53          dataSet.computePlateDimensions();
54          
55          java.util.Set observables = dataSet.getObservables();
56          java.util.Set plateIdentifiers = dataSet.getPlateIdentifiers();
57          
58          int numberOfRows = dataSet.getNumberOfRows();
59          int numberOfColumns = dataSet.getNumberOfColumns();
60          
61          System.out.print("data file \t");
62          
63          for (int rowNumber=0;rowNumber<numberOfRows;rowNumber++) {
64              String rowLabel = dataSet.rowNumberToLabel(rowNumber);
65              
66              for (int columnNumber=1;columnNumber<=numberOfColumns;columnNumber++) {
67                  
68                  Iterator observableIterator = observables.iterator();
69                  while (observableIterator.hasNext()) {
70                      String observableName = observableIterator.next().toString();
71                      
72                      System.out.print("" + rowLabel + "" + columnNumber + " " + observableName + "\t"); // TODO - use stringbuffer explicitly?
73                    //  System.out.print(" (+-) \t"); // TODO - use stringbuffer explicitly?
74                  }
75              }
76          }
77          
78          System.out.println();
79          
80          Iterator plateIdentifierIterator = plateIdentifiers.iterator();
81          while (plateIdentifierIterator.hasNext()) {
82              String plateIdentifier = plateIdentifierIterator.next().toString();
83              
84              System.out.print(plateIdentifier +"\t");
85  
86              for (int rowNumber=0;rowNumber<numberOfRows;rowNumber++) {
87                  String rowLabel = dataSet.rowNumberToLabel(rowNumber);
88                  
89                  for (int columnNumber=1;columnNumber<=numberOfColumns;columnNumber++) {
90                      
91                      Iterator observableIterator = observables.iterator();
92                      while (observableIterator.hasNext()) {
93                          String observableName = observableIterator.next().toString();
94                          
95                          double meanValue = 0;
96                          
97                          java.util.List plateWellDataPointMeanValueList = null;
98                          
99                          {
100                             String query = "select avg(p.observedValue) from PlateWellDataPoint p where p.plateRow='"+rowLabel+"' and " +
101                             "p.plateColumn = '"+columnNumber+"' and p.plateIdentifier='"+plateIdentifier+"' and " +
102                             "p.observableName = '"+observableName+"'";
103                             
104                             plateWellDataPointMeanValueList = dataSet.find(query);
105                         }
106                         
107                         if (plateWellDataPointMeanValueList.size()==1) {
108                             Double meanValueDouble = (Double)plateWellDataPointMeanValueList.get(0);
109                             if (meanValueDouble != null) {
110                                 meanValue = meanValueDouble.doubleValue();
111                             } else {
112                                 // TODO - handle this (Double.NaN?)
113                             }
114                             
115                         } else {
116                             if (plateWellDataPointMeanValueList.size()>0) {
117                                 // TODO - throw an exceptionSystem.out.print("" + plateWellDataPointMeanValueList.size());
118                             }
119                             
120                             // no matches - should value be Double.NaN? 
121                         }
122                         
123                         /*java.util.List plateWellDataPointList = null;
124                         
125                         {
126                             String query = "select p.observedValue from PlateWellDataPoint p where p.plateRow='"+rowLabel+"' and " +
127                             "p.plateColumn = '"+columnNumber+"' and p.plateIdentifier='"+plateIdentifier+"' and " +
128                             "p.observableName = '"+observableName+"'";
129                             
130                             plateWellDataPointList =  dataSet.find(query);
131                         }*/
132                         
133                         //double standardDeviation = stdevFromListAndMean(plateWellDataPointList, meanValue);
134                         
135                                 
136                         System.out.print(meanValue + "\t");//+ standardDeviation + "\t");
137                     }
138                 }
139             }
140             System.out.println();
141         }
142     }
143 }