Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
146 lines (125 sloc) 6.24 KB
/* PDAP:PDTREE package for Mesquite copyright 2001-2010 P. Midford & W. MaddisonPDAP:PDTREE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.The web site for PDAP:PDTREE is http://mesquiteproject.org/pdap_mesquite/This source code and its compiled class files are free and modifiable under the terms of GNU Lesser General Public License. (http://www.gnu.org/copyleft/lesser.html)*/package mesquite.pdap.CIReport;/*~~ */import mesquite.lib.*;import mesquite.lib.characters.CharacterDistribution;import mesquite.pdap.lib.*;/* ============ a file dumper for CI files created by PDTREE (Garland et al. 1999) ============*/// CI files contain the following columns:// 1. Tip Name// 2. X Value// 3. Observed Y Value// 4. Predicted Y Value (Yhat)// 5. Lower 95% Confidence Interval// 6. Upper 95% Confidence Interval// 7. Lower 95% Prediction Interval// 8. Upper 95% Prediction Interval// 9. Lower 90% Confidence Interval//10. Upper 90% Confidence Interval//11. Lower 90% Prediction Interval//12. Upper 90% Prediction Interval/** */public class CIReport extends PDAPFileReporter { private final String STATPAKFAILURE = "No CI data generated because no RootStatPak available"; private PDAP2CTStatPak statPak; /*.................................................................................................................*/ public boolean startJob(String arguments, Object condition, boolean hiredByName) { return true; } /*...............................................................................*/ public void setStatPak(PDAPStatPak s){ if (s instanceof PDAP2CTStatPak) this.statPak = (PDAP2CTStatPak)s; else MesquiteMessage.printStackTrace("Wrong statPak passed to CIReport.setStatPak"); } /*.................................................................................................................*/ /** Always true, because an CI file always has tables. */ public boolean hasTables() { return true; } /*.................................................................................................................*/ /** * ask for formatting options * @param dataSelected boolean true to indicate saving only the selected columns of a character matrix * @param taxaSelected boolean true to indicate saving only the selected taxa * @return boolean true when button pressed? * */ public boolean getReportOptions(boolean dataSelected, boolean taxaSelected){ MesquiteInteger buttonPressed = new MesquiteInteger(1); PDAPReporterDialog reportDialog = new PDAPReporterDialog(this,containerOfModule(), "CI Report Options", buttonPressed); reportDialog.addDefaultPanels(dataSelected, taxaSelected,hasTables()); boolean ok = (reportDialog.query(dataSelected,taxaSelected,convertSpaces)==0); reportDialog.dispose(); return ok; } /*.................................................................................................................*/ /** This writes the report string to a file * @param file specifies where to write the report * @param data1 data for the first (x) trait * @param data2 data for the second (y) trait * @param tree phylogeny used * @param arguments passed throug to saveReportFile * */ public void writeReport(MesquiteFile file,CharacterDistribution data1,CharacterDistribution data2,Tree theTree, String arguments) { //todo: this should be passed scripting if (!getReportOptions(false,false)) return; final String output = reportToString(data1,data2,theTree); String name = getProject().getHomeFileName(); if (name==null) name = "untitled.ci"; else name = stripNex(name) + ".ci"; saveReportFile(output,arguments,name); } /*.................................................................................................................*/ /** This writes the report to a string, using default line break and table delimiters */ public String reportToString(CharacterDistribution data1,CharacterDistribution data2,Tree theTree) { if (statPak == null) return STATPAKFAILURE; return statPak.CIString(getLineEnding(),getTableDelimiter(),convertSpaces); } /*.................................................................................................................*/ /** This writes the report to a string, using parameters to specify line break and table delimiters */ public String reportToString(CharacterDistribution data1,CharacterDistribution data2,Tree theTree,String lineDelimiter, String columnDelimiter) { if (statPak == null) return STATPAKFAILURE; return statPak.CIString(lineDelimiter,columnDelimiter,convertSpaces); } /*.................................................................................................................*/ public String getName() { return "CI (PDAP see Garland et. al. 1999)"; } /*.................................................................................................................*/ public String getAuthors() { return "Peter Midford, Theodore Garland Jr. & Wayne Maddison"; } /*.................................................................................................................*/ public String getVersion() { return "1.15"; } /*.................................................................................................................*/ public boolean isPrerelease() { return false; } /*.................................................................................................................*/ public boolean isSubstantive(){ return false; } /*.................................................................................................................*/ /** returns an explanation of what the module does.*/ public String getExplanation() { return "Generates CI format report files as described in Garland et al. 1999" ; } /*.................................................................................................................*/ /** returns current parameters, for logging etc..*/ public String getParameters() { return "" ; }}