mev-4.0.01/source/org/tigr/microarray/mev/cgh/CGHAlgorithms/NumberOfAlterations/NumberOfAlterationsCalculator.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2  * NumberOfAlterationsCalculator.java
2 26 Feb 07 jari 3  *
2 26 Feb 07 jari 4  * Created on May 19, 2003, 1:57 AM
2 26 Feb 07 jari 5  */
2 26 Feb 07 jari 6
2 26 Feb 07 jari 7 package org.tigr.microarray.mev.cgh.CGHAlgorithms.NumberOfAlterations;
2 26 Feb 07 jari 8
2 26 Feb 07 jari 9 import java.util.Collection;
2 26 Feb 07 jari 10 import java.util.Iterator;
2 26 Feb 07 jari 11
2 26 Feb 07 jari 12 import javax.swing.tree.DefaultMutableTreeNode;
2 26 Feb 07 jari 13
2 26 Feb 07 jari 14 import org.tigr.microarray.mev.cgh.CGHDataObj.AlterationRegion;
2 26 Feb 07 jari 15 import org.tigr.microarray.mev.cgh.CGHGuiObj.AlgorithmResultsViewers.NumberOfAlterationsViewers.AlterationParametersViewer;
2 26 Feb 07 jari 16 import org.tigr.microarray.mev.cgh.CGHGuiObj.AlgorithmResultsViewers.NumberOfAlterationsViewers.NumberOfAlterationsDataModel;
2 26 Feb 07 jari 17 import org.tigr.microarray.mev.cgh.CGHGuiObj.AlgorithmResultsViewers.NumberOfAlterationsViewers.NumberOfAlterationsViewer;
2 26 Feb 07 jari 18 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmException;
2 26 Feb 07 jari 19 import org.tigr.microarray.mev.cluster.gui.ICGHCloneValueMenu;
2 26 Feb 07 jari 20 import org.tigr.microarray.mev.cluster.gui.IClusterGUI;
2 26 Feb 07 jari 21 import org.tigr.microarray.mev.cluster.gui.IData;
2 26 Feb 07 jari 22 import org.tigr.microarray.mev.cluster.gui.IFramework;
2 26 Feb 07 jari 23 import org.tigr.microarray.mev.cluster.gui.IViewer;
2 26 Feb 07 jari 24 import org.tigr.microarray.mev.cluster.gui.LeafInfo;
2 26 Feb 07 jari 25
2 26 Feb 07 jari 26 /**
2 26 Feb 07 jari 27  *
2 26 Feb 07 jari 28  * @author  Adam Margolin
2 26 Feb 07 jari 29  * @author Raktim Sinha
2 26 Feb 07 jari 30  */
2 26 Feb 07 jari 31
2 26 Feb 07 jari 32 public abstract class NumberOfAlterationsCalculator implements IClusterGUI {
2 26 Feb 07 jari 33     //making these public for now, but could switch subclasses of this class to
2 26 Feb 07 jari 34     //the same package
2 26 Feb 07 jari 35     //public CGHMultipleArrayDataFcd fcd;
2 26 Feb 07 jari 36     public IFramework framework;
2 26 Feb 07 jari 37     public IData data;
2 26 Feb 07 jari 38     public String nodeName = "";
2 26 Feb 07 jari 39
2 26 Feb 07 jari 40     /** Creates a new instance of NumberOfAlterationsCalculator */
2 26 Feb 07 jari 41     public NumberOfAlterationsCalculator() {
2 26 Feb 07 jari 42     }
2 26 Feb 07 jari 43
2 26 Feb 07 jari 44     public abstract DefaultMutableTreeNode execute(IFramework framework) throws AlgorithmException;
2 26 Feb 07 jari 45
2 26 Feb 07 jari 46     /**
2 26 Feb 07 jari 47      * NOT USED
2 26 Feb 07 jari 48      * Replaced by one below - DefaultMutableTreeNode createResultsTree(Collection results)
2 26 Feb 07 jari 49      * @param results
2 26 Feb 07 jari 50      * @return
2 26 Feb 07 jari 51      */
2 26 Feb 07 jari 52     public DefaultMutableTreeNode createResultsTree2(Collection results){
2 26 Feb 07 jari 53         DefaultMutableTreeNode root = new DefaultMutableTreeNode(nodeName);
2 26 Feb 07 jari 54         root.add(new DefaultMutableTreeNode(new LeafInfo("Parameters", createParametersViewer())));
2 26 Feb 07 jari 55         root.add(new DefaultMutableTreeNode(new LeafInfo("Results", createResultsViewer(results))));
2 26 Feb 07 jari 56         return root;
2 26 Feb 07 jari 57     }
2 26 Feb 07 jari 58
2 26 Feb 07 jari 59     /**
2 26 Feb 07 jari 60      * New method to be consistent with Mev Look & Feel
2 26 Feb 07 jari 61      * @param results
2 26 Feb 07 jari 62      * @return
2 26 Feb 07 jari 63      */
2 26 Feb 07 jari 64     public DefaultMutableTreeNode createResultsTree(Collection results){
2 26 Feb 07 jari 65         DefaultMutableTreeNode root = new DefaultMutableTreeNode(nodeName);
2 26 Feb 07 jari 66
2 26 Feb 07 jari 67         root.add(new DefaultMutableTreeNode(new LeafInfo("Results", createResultsViewer(results))));
2 26 Feb 07 jari 68         addGeneralInfo(root);
2 26 Feb 07 jari 69         return root;
2 26 Feb 07 jari 70     }
2 26 Feb 07 jari 71     
2 26 Feb 07 jari 72     /**
2 26 Feb 07 jari 73      * Raktim 4/27
2 26 Feb 07 jari 74      * Added for State Saving to capture the File used for LoadGeneList
2 26 Feb 07 jari 75      * @param results
2 26 Feb 07 jari 76      * @param file
2 26 Feb 07 jari 77      * @return
2 26 Feb 07 jari 78      */
2 26 Feb 07 jari 79     public DefaultMutableTreeNode createResultsTree(Collection results, String file){
2 26 Feb 07 jari 80         DefaultMutableTreeNode root = new DefaultMutableTreeNode(nodeName);
2 26 Feb 07 jari 81
2 26 Feb 07 jari 82         root.add(new DefaultMutableTreeNode(new LeafInfo("Results", createResultsViewer(results))));
2 26 Feb 07 jari 83         addGeneralInfo(root);
2 26 Feb 07 jari 84         return root;
2 26 Feb 07 jari 85     }
2 26 Feb 07 jari 86     
2 26 Feb 07 jari 87     public DefaultMutableTreeNode createResultsTree(Collection results, boolean addInfo){
2 26 Feb 07 jari 88         DefaultMutableTreeNode root = new DefaultMutableTreeNode(nodeName);
2 26 Feb 07 jari 89
2 26 Feb 07 jari 90         root.add(new DefaultMutableTreeNode(new LeafInfo("Results", createResultsViewer(results))));
2 26 Feb 07 jari 91         if(addInfo)
2 26 Feb 07 jari 92           addGeneralInfo(root);
2 26 Feb 07 jari 93         return root;
2 26 Feb 07 jari 94     }
2 26 Feb 07 jari 95
2 26 Feb 07 jari 96     private IViewer createResultsViewer(Collection results){
2 26 Feb 07 jari 97         AlterationRegion[] alterationRegions = new AlterationRegion[results.size()];
2 26 Feb 07 jari 98
2 26 Feb 07 jari 99         Iterator it = results.iterator();
2 26 Feb 07 jari 100         int i = 0;
2 26 Feb 07 jari 101         while(it.hasNext()){
2 26 Feb 07 jari 102             AlterationRegion alterationRegion = (AlterationRegion)it.next();
2 26 Feb 07 jari 103             alterationRegions[i++] = alterationRegion;
2 26 Feb 07 jari 104         }
2 26 Feb 07 jari 105
2 26 Feb 07 jari 106         NumberOfAlterationsDataModel dataModel = new NumberOfAlterationsDataModel();
2 26 Feb 07 jari 107         dataModel.setAlterationRegions(alterationRegions);
2 26 Feb 07 jari 108
2 26 Feb 07 jari 109         NumberOfAlterationsViewer viewer = new NumberOfAlterationsViewer();
2 26 Feb 07 jari 110         viewer.setData(framework.getData());
2 26 Feb 07 jari 111         viewer.setDataModel(dataModel);
2 26 Feb 07 jari 112
2 26 Feb 07 jari 113         return viewer;
2 26 Feb 07 jari 114     }
2 26 Feb 07 jari 115
2 26 Feb 07 jari 116     public IViewer createParametersViewer(){
2 26 Feb 07 jari 117         return new AlterationParametersViewer(framework);
2 26 Feb 07 jari 118     }
2 26 Feb 07 jari 119
2 26 Feb 07 jari 120     /**
2 26 Feb 07 jari 121      * Adds node with general iformation.
2 26 Feb 07 jari 122      */
2 26 Feb 07 jari 123     private void addGeneralInfo(DefaultMutableTreeNode root) {
2 26 Feb 07 jari 124       ICGHCloneValueMenu menu = framework.getCghCloneValueMenu();
2 26 Feb 07 jari 125       DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Information");
2 26 Feb 07 jari 126         node.add(new DefaultMutableTreeNode("Amplification Threshold: " + menu.getAmpThresh()));
2 26 Feb 07 jari 127         node.add(new DefaultMutableTreeNode("Deletion Threshold: " + menu.getDelThresh()));
2 26 Feb 07 jari 128         node.add(new DefaultMutableTreeNode("Amplification 2 Copy Threshold: " + menu.getAmpThresh2Copy()));
2 26 Feb 07 jari 129         node.add(new DefaultMutableTreeNode("Deletion 2 Copy Threshold: " + menu.getDelThresh2Copy()));
2 26 Feb 07 jari 130         root.add(node);
2 26 Feb 07 jari 131     }
2 26 Feb 07 jari 132     
2 26 Feb 07 jari 133     
2 26 Feb 07 jari 134     /**
2 26 Feb 07 jari 135      * Getter for property fcd.
2 26 Feb 07 jari 136      * @return Value of property fcd.
2 26 Feb 07 jari 137      * Not used in New Struct
2 26 Feb 07 jari 138
2 26 Feb 07 jari 139     public org.abramson.microarray.cgh.CGHFcdObj.CGHMultipleArrayDataFcd getFcd() {
2 26 Feb 07 jari 140         return fcd;
2 26 Feb 07 jari 141     }
2 26 Feb 07 jari 142     */
2 26 Feb 07 jari 143
2 26 Feb 07 jari 144     public IData getData(){
2 26 Feb 07 jari 145       return this.data;
2 26 Feb 07 jari 146     }
2 26 Feb 07 jari 147
2 26 Feb 07 jari 148     /**
2 26 Feb 07 jari 149      * Setter for property fcd.
2 26 Feb 07 jari 150      * @param fcd New value of property fcd.
2 26 Feb 07 jari 151      * Not used in New Struct
2 26 Feb 07 jari 152
2 26 Feb 07 jari 153     public void setFcd(org.abramson.microarray.cgh.CGHFcdObj.CGHMultipleArrayDataFcd fcd) {
2 26 Feb 07 jari 154         this.fcd = fcd;
2 26 Feb 07 jari 155     }
2 26 Feb 07 jari 156     */
2 26 Feb 07 jari 157
2 26 Feb 07 jari 158     public void setData(IData dat) {
2 26 Feb 07 jari 159       this.data = dat;
2 26 Feb 07 jari 160     }
2 26 Feb 07 jari 161     /** Getter for property framework.
2 26 Feb 07 jari 162      * @return Value of property framework.
2 26 Feb 07 jari 163      */
2 26 Feb 07 jari 164     public IFramework getFramework() {
2 26 Feb 07 jari 165         return framework;
2 26 Feb 07 jari 166     }
2 26 Feb 07 jari 167
2 26 Feb 07 jari 168     /** Setter for property framework.
2 26 Feb 07 jari 169      * @param framework New value of property framework.
2 26 Feb 07 jari 170      */
2 26 Feb 07 jari 171     public void setFramework(IFramework framework) {
2 26 Feb 07 jari 172         this.framework = framework;
2 26 Feb 07 jari 173     }
2 26 Feb 07 jari 174
2 26 Feb 07 jari 175 }