/** Called to alter data in all cells */ public boolean operateOnData(CharacterData data) { if (!(data instanceof ContinuousData)) return false; ContinuousData cData = (ContinuousData) data; int numItems = cData.getNumItems(); String[] items = new String[numItems]; for (int i = 0; i < items.length; i++) { if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)"; else items[i] = cData.getItemName(i); } int d = ListDialog.queryList( containerOfModule(), "Rename item", "Rename item:", MesquiteString.helpString, items, 0); if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false; else { String s = MesquiteString.queryString( containerOfModule(), "Rename Item", "New name for " + items[d], items[d]); if (StringUtil.blank(s)) return false; cData.setItemReference(d, NameReference.getNameReference(s)); return true; } }
/*.................................................................................................................*/ boolean checkUsernamePassword(boolean tellUserAboutCipres) { if (StringUtil.blank(username) || StringUtil.blank(password)) { MesquiteBoolean answer = new MesquiteBoolean(false); MesquiteString usernameString = new MesquiteString(); if (username != null) usernameString.setValue(username); MesquiteString passwordString = new MesquiteString(); if (password != null) passwordString.setValue(password); String help = "You will need an account on the CIPRes REST system to use this service. To register, go to https://www.phylo.org/restusers/register.action"; new UserNamePasswordDialog( ownerModule.containerOfModule(), "Sign in to CIPRes", help, "", "Username", "Password", answer, usernameString, passwordString); if (answer.getValue()) { username = usernameString.getValue(); password = passwordString.getValue(); } ownerModule.storePreferences(); } boolean success = StringUtil.notEmpty(username) && StringUtil.notEmpty(password); if (!success && tellUserAboutCipres) { MesquiteMessage.discreetNotifyUser( "Use of the CIPRes service requires an account with CIPRes's REST service. Go to https://www.phylo.org/restusers/register.action to register for an account"); } return success; }
/** This method simply lists the tools available */ public void listTools(HttpClient httpclient) { Document cipresResponseDoc = cipresQuery(httpclient, baseURL + "/tool", "tools"); if (cipresResponseDoc != null) { String elementName = "tool"; List tools = cipresResponseDoc.getRootElement().elements(elementName); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { // let's get a count as to how many tools there are. Element nextTool = (Element) iter.next(); count++; } String[] toolName = new String[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); String name = nextTool.elementText("toolId"); if (!StringUtil.blank(name) && count < toolName.length) { ownerModule.logln(name); } name = nextTool.elementText("toolName"); if (!StringUtil.blank(name) && count < toolName.length) { ownerModule.logln(" " + name); } count++; } } }
/** * Gets background color for cell for row ic. Override it if you want to change the color from the * default. */ public Color getBackgroundColorOfCell(int it, boolean selected) { if (observedStates == null) { doCalcs(); if (observedStates == null) return null; } if (observedStates.getParentData() != null) { captureCharacterDataFromObservedStates(); Associable tInfo = data.getTaxaInfo(false); NameReference genBankColor = NameReference.getNameReference("genbankcolor"); Object obj = tInfo.getAssociatedObject(genBankColor, it); // not saved to file if (obj instanceof Color) return (Color) obj; } if (bits == null || it < 0 || it > bits.getSize()) return null; String note = getNote(it); if (selected) { if (bits.isBitOn(it)) return ColorDistribution.darkGreen; else return ColorDistribution.darkRed; } else if (bits.isBitOn(it)) { if (StringUtil.blank(note)) return ColorDistribution.veryLightGreen; if (!(note.equalsIgnoreCase("x"))) return ColorDistribution.lightGreenYellowish; return ColorDistribution.lightGreenYellow; } else { if (StringUtil.blank(note)) return ColorDistribution.brown; if (!(note.equalsIgnoreCase("x"))) { return Color.red; } return ColorDistribution.lightRed; } }
public void processCompletedOutputFiles(String[] outputFilePaths) { if (outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1])) { ZephyrUtil.copyLogFile(this, "TNT", outputFilePaths[1]); } if (outputFilePaths.length > 2 && !StringUtil.blank(outputFilePaths[2])) { ZephyrUtil.copyOutputText(this, outputFilePaths[2], commands); } }
/** monitors the run. */ public boolean monitorAndCleanUpShell() { lastModified = null; boolean stillGoing = true; if (outputFilePaths != null) { lastModified = new long[outputFilePaths.length]; LongArray.deassignArray(lastModified); } if (!StringUtil.blank( runningFilePath)) // is file at runningFilePath; watch for its disappearance while (MesquiteFile.fileExists(runningFilePath) && stillGoing) { processOutputFiles(); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { MesquiteMessage.notifyProgrammer( "InterruptedException in shell script executed by " + name); return false; } stillGoing = watcher == null || watcher.continueShellProcess(proc); } if (outputFileProcessor != null) outputFileProcessor.processCompletedOutputFiles(outputFilePaths); return true; }
/*................................................................................................*/ private boolean hireFillers(String directoryPath) { String[] files = directory.list(); String treePath; for (int i = 0; i < files.length; i++) { if (files[i] != null) { String fileLowerCase = files[i].toLowerCase(); if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) { treePath = directoryPath + MesquiteFile.fileSeparator + files[i]; File treeFile = new File(treePath); String treeFileName = treeFile.getName(); if (StringUtil.blank(treeFileName)) { return false; } TreeBlockFiller newFiller; newFiller = (TreeBlockFiller) hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath); if (newFiller != null) { if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath) && ((SampleOneTreeFromFile) newFiller).processFile()) { fillerTasks.addElement(newFiller); } else Debugg.println( "Filler " + i + " processFile = " + ((SampleOneTreeFromFile) newFiller).processFile()); } } } } return true; }
/*................................................................................................*/ public boolean startJob(String arguments, Object condition, boolean hiredByName) { addMenuItem("Directory for Sample Trees From Directory...", makeCommand("setDirPath", this)); fillerTasks = new Vector(); if (!MesquiteThread .isScripting()) { // enclosed in conditional to avoid hiring query when opening file; should // be handled by snapshot/doCommand when file is opened. String directoryPath = MesquiteFile.chooseDirectory( "Choose directory containing tree files:", previousDirectory); // MesquiteFile.saveFileAsDialog("Base name for files (files will // be named <name>1.nex, <name>2.nex, etc.)", baseName); if (StringUtil.blank(directoryPath)) { // TODO: clean this up? return false; } else { directory = new File(directoryPath); previousDirectory = directory.getParent(); if (directory.exists() && directory.isDirectory()) { return hireFillers(directoryPath); } } } return true; // Add something to make sure directory paths are set up correctly, when not // scripting... }
public String[] getJobURLs(Document cipresResponseDoc) { String elementName = "jobstatus"; Element jobs = cipresResponseDoc.getRootElement().element("jobs"); if (jobs == null) return null; List tools = jobs.elements("jobstatus"); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); count++; } String[] url = new String[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextJob = (Element) iter.next(); if (nextJob != null) { Element selfUriElement = nextJob.element("selfUri"); if (selfUriElement != null) { String jobURL = selfUriElement.elementText("url"); if (!StringUtil.blank(jobURL) && count < url.length) { url[count] = jobURL; } } count++; } } return url; }
/*.................................................................................................................*/ public boolean downloadWorkingResults( HttpClient httpclient, String jobURL, String rootDir, String fileName, boolean onlyNewOrModified) { if (StringUtil.blank(fileName)) return false; String workingUri = getWorkingDirectory(jobURL); if (StringUtil.notEmpty(workingUri)) { Document cipresResponseDoc = cipresQuery(httpclient, workingUri, "workingdir"); if (cipresResponseDoc != null) { CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc); if (cipresJobFiles == null || cipresJobFiles.length == 0) { return false; } for (int job = 0; job < cipresJobFiles.length; job++) { if (fileName.equalsIgnoreCase(cipresJobFiles[job].getFileName()) && (!onlyNewOrModified || fileNewOrModified(previousCipresJobFiles, cipresJobFiles, job))) cipresDownload( httpclient, cipresJobFiles[job].getDownloadURL(), rootDir + cipresJobFiles[job].getFileName()); } previousCipresJobFiles = cipresJobFiles.clone(); return true; } } return false; }
/** * this is the primary method that sends a query to the CIPRes REST service. It expects to receive * an XML file, which it returns in Document if the root tag matc hes xmlRootTag */ public Document cipresQuery(HttpClient httpclient, String URL, String xmlRootTag) { if (StringUtil.blank(URL)) return null; try { HttpGet httpget = new HttpGet(URL); httpget.addHeader("cipres-appkey", CIPRESkey); try { HttpResponse response = httpclient.execute(httpget); HttpEntity responseEntity = response.getEntity(); InputStream instream = responseEntity.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(instream)); String line = ""; StringBuffer sb = new StringBuffer(); while ((line = br.readLine()) != null) { sb.append(line + StringUtil.lineEnding()); } Document cipresResponseDoc = loadXMLFile(xmlRootTag, sb.toString()); if (cipresResponseDoc != null && verbose) { ownerModule.logln(sb.toString()); } if (cipresResponseDoc == null) { Document errorDoc = loadXMLFile(sb.toString()); if (errorDoc != null) reportError(errorDoc, "Error in communicating with CIPRes", true); } EntityUtils.consume(response.getEntity()); return cipresResponseDoc; } catch (IOException e) { Debugg.printStackTrace(e); } catch (Exception e) { Debugg.printStackTrace(e); } } catch (Exception e) { Debugg.printStackTrace(e); } return null; }
/** * This method returns a Document from the contents of the XML file as contained in the String * xmlFile, with no restriction as to the root element. */ public Document loadXMLFile(String xmlFile) { if (!StringUtil.blank(xmlFile)) { Document CipresDoc = XMLUtil.getDocumentFromString(xmlFile); return CipresDoc; } return null; }
/** * This processes information about the files contained in either the results or working directory * of a job. */ public CipresJobFile[] processFilesDocument(Document cipresResponseDoc) { Element jobfiles = cipresResponseDoc.getRootElement().element("jobfiles"); if (jobfiles == null) return null; List tools = jobfiles.elements("jobfile"); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); count++; } if (count == 0) return null; CipresJobFile[] cipresJobFile = new CipresJobFile[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextJob = (Element) iter.next(); if (nextJob != null) { if (cipresJobFile[count] == null) cipresJobFile[count] = new CipresJobFile(); Element jobFileElement = nextJob.element("downloadUri"); String fileInfo = null; if (jobFileElement != null) { fileInfo = jobFileElement.elementText("url"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setDownloadURL(fileInfo); } fileInfo = jobFileElement.elementText("title"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setDownloadTitle(fileInfo); } } fileInfo = nextJob.elementText("dateModified"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setLastModified(fileInfo); } fileInfo = nextJob.elementText("filename"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setFileName(fileInfo); } fileInfo = nextJob.elementText("length"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setLength(MesquiteLong.fromString(fileInfo)); } count++; } } return cipresJobFile; }
/*..........................................MContinuousStates................*/ public int userQueryItem(String message, MesquiteModule module) { int numItems = getNumItems(); String[] items = new String[numItems]; for (int i = 0; i < items.length; i++) { if (StringUtil.blank(getItemName(i))) items[i] = "(unnamed)"; else items[i] = getItemName(i); } return ListDialog.queryList( module.containerOfModule(), "Select item", message, MesquiteString.helpString, items, 0); }
/** * A request for the MesquiteModule to perform a command. It is passed two strings, the name of * the command and the arguments. This should be overridden by any module that wants to respond to * a command. */ public Object doCommand(String commandName, String arguments, CommandChecker checker) { if (checker.compare(MesquiteModule.class, null, null, commandName, "paint")) { MesquiteInteger io = new MesquiteInteger(0); int column = MesquiteInteger.fromString(arguments, io); int row = MesquiteInteger.fromString(arguments, io); if (MesquiteInteger.isCombinable(row)) { if (!MesquiteLong.isCombinable(currentColor)) removeColor(row, true); else setColor(row, (int) currentColor); } } else if (checker.compare( this.getClass(), "Sets the color to be used to paint cells", "[name of color]", commandName, "setColor")) { int bc = ColorDistribution.standardColorNames.indexOf(parser.getFirstToken(arguments)); if (bc >= 0 && MesquiteLong.isCombinable(bc)) { removeColor.setValue(false); currentColor = bc; savedColor = bc; colorString = "Color " + ColorDistribution.standardColorNames.getValue(bc); } } else if (checker.compare( this.getClass(), "Sets the color of selected taxa", "[name of color]", commandName, "setColorSelected")) { int bc = ColorDistribution.standardColorNames.indexOf(parser.getFirstToken(arguments)); if (bc >= 0 && MesquiteLong.isCombinable(bc)) { for (int it = 0; it < taxa.getNumTaxa(); it++) if (taxa.getSelected(it)) setColor(it, bc); } } else if (checker.compare( this.getClass(), "Removes color from all the cells", null, commandName, "removeAllColor")) { removeAllColor(true); } else if (checker.compare( this.getClass(), "Sets the paint brush so that it removes colors from any cells touched", null, commandName, "removeColor")) { if (StringUtil.blank(arguments)) removeColor.setValue(!removeColor.getValue()); else removeColor.toggleValue(parser.getFirstToken(arguments)); if (removeColor.getValue()) { colorString = "Remove color"; currentColor = MesquiteLong.unassigned; } else { colorString = "Color " + ColorDistribution.standardColorNames.getValue((int) currentColor); currentColor = savedColor; } } else return super.doCommand(commandName, arguments, checker); return null; }
/** * executes a shell script at "scriptPath". If runningFilePath is not blank and not null, then * Mesquite will create a file there that will serve as a flag to Mesquite that the script is * running. */ public boolean executeInShell() { proc = null; try { ShellScriptUtil.setScriptFileToBeExecutable(scriptPath); if (!StringUtil.blank(runningFilePath)) { if (StringUtil.blank(runningFileMessage)) MesquiteFile.putFileContents(runningFilePath, "Script running...", true); else MesquiteFile.putFileContents(runningFilePath, runningFileMessage, true); if (appendRemoveCommand && MesquiteFile.fileExists(runningFilePath)) MesquiteFile.appendFileContents( scriptPath, StringUtil.lineEnding() + ShellScriptUtil.getRemoveCommand(runningFilePath), true); // append remove command to guarantee that the runningFile is deleted // +StringUtil.lineEnding()+ShellScriptUtil.getExitCommand() } proc = ShellScriptUtil.executeScript(scriptPath, visibleTerminal); } catch (IOException e) { MesquiteMessage.warnProgrammer("IOException in shell script executed by " + name); return false; } return true; }
/*.................................................................................................................*/ public boolean monitorAndCleanUpShell(String jobURL) { boolean stillGoing = true; if (!checkUsernamePassword(true)) { return false; } lastModified = null; if (outputFilePaths != null) { lastModified = new long[outputFilePaths.length]; LongArray.deassignArray(lastModified); } String status = ""; while (!jobCompleted(jobURL) && stillGoing) { if (StringUtil.blank(status)) ownerModule.logln( "CIPRes Job Status: " + getJobStatus(jobURL) + " (" + StringUtil.getDateTime() + ")"); // if (jobSubmitted(jobURL)) // processOutputFiles(); try { Thread.sleep(minPollIntervalSeconds * 1000); } catch (InterruptedException e) { MesquiteMessage.notifyProgrammer("InterruptedException in CIPRes monitoring"); return false; } stillGoing = watcher == null || watcher.continueShellProcess(null); String newStatus = getJobStatus(jobURL); if (newStatus != null && !newStatus.equalsIgnoreCase(status)) { ownerModule.logln( "CIPRes Job Status: " + newStatus + " (" + StringUtil.getDateTime() + ")"); status = newStatus; } else ownerModule.log("."); if (newStatus != null && newStatus.equalsIgnoreCase("SUBMITTED")) { // job is running processOutputFiles(jobURL); } } ownerModule.logln("CIPRes job completed."); if (outputFileProcessor != null) { if (rootDir != null) { ownerModule.logln("About to download results from CIPRes."); if (downloadResults(jobURL, rootDir, false)) outputFileProcessor.processCompletedOutputFiles(outputFilePaths); else return false; } } return true; }
public ShellScriptRunner( String scriptPath, String runningFilePath, String runningFileMessage, boolean appendRemoveCommand, String name, String[] outputFilePaths, OutputFileProcessor outputFileProcessor, ShellScriptWatcher watcher, boolean visibleTerminal) { this.scriptPath = scriptPath; this.runningFilePath = runningFilePath; if (runningFilePath == null && !StringUtil.blank(scriptPath)) this.runningFilePath = ShellScriptUtil.getDefaultRunningFilePath(); this.runningFileMessage = runningFileMessage; this.appendRemoveCommand = appendRemoveCommand; this.name = name; this.outputFilePaths = outputFilePaths; this.outputFileProcessor = outputFileProcessor; this.watcher = watcher; this.visibleTerminal = visibleTerminal; }
boolean showOptions() { MesquiteInteger buttonPressed = new MesquiteInteger(1); ExtensibleDialog queryDialog = new ExtensibleDialog(containerOfModule(), "Reinterpret Node Labels", buttonPressed); queryDialog.addLargeOrSmallTextLabel( "Some programs write information as node labels; e.g. MrBayes writes posterior probabilities as if they were the names of clades (= node labels)." + "\nHere you can reintepret such information."); // name for information (e.g., "posteriorProbability", "bootstrapFrequency") queryDialog.addLabel( "Name for information? (e.g., \"posteriorProbability\", \"bootstrapFrequency\")", Label.LEFT); TextField nameField = queryDialog.addTextField(name, 30); queryDialog.addHorizontalLine(2); // where to attach queryDialog.addLabel("Applies to branch or node?", Label.LEFT); String[] where = new String[] { "Information applies to branch (e.g., posterior probability, bootstrap frequency)", "Information applies to node (e.g., clade name)" }; RadioButtons whereButtons = queryDialog.addRadioButtons(where, 0); queryDialog.addLabel( "(This determines how the information will behave when the tree is rerooted.)", Label.LEFT); queryDialog.addHorizontalLine(2); // how to treat queryDialog.addLabel("Number or text?", Label.LEFT); String[] what = new String[] { "Treat as number (e.g., posterior probability)", "Treat as text (e.g., clade name)" }; RadioButtons whatButtons = queryDialog.addRadioButtons(what, 0); queryDialog.addHorizontalLine(2); // delete internal node labels after reinterpreting? Checkbox delete = queryDialog.addCheckBox("Delete internal node labels after reinterpreting?", deleteAfter); queryDialog.addHorizontalLine(2); queryDialog.completeAndShowDialog(true); boolean ok = (queryDialog.query() == 0); if (ok) { if (StringUtil.blank(nameField.getText())) { ok = false; alert("A name must be entered for the information"); } else { name = nameField.getText(); nameRef = NameReference.getNameReference(name); appliesToBranch = whereButtons.getValue() == 0; isNumber = whatButtons.getValue() == 0; deleteAfter = delete.getState(); } } queryDialog.dispose(); return ok; }
public void runFilesAvailable(int fileNum) { String[] logFileNames = getLogFileNames(); if ((progIndicator != null && progIndicator.isAborted()) || logFileNames == null) return; String[] outputFilePaths = new String[logFileNames.length]; outputFilePaths[fileNum] = externalProcRunner.getOutputFilePath(logFileNames[fileNum]); String filePath = outputFilePaths[fileNum]; if (fileNum == 0 && outputFilePaths.length > 0 && !StringUtil.blank(outputFilePaths[0]) && !bootstrapOrJackknife()) { // tree file if (ownerModule instanceof NewTreeProcessor) { String treeFilePath = filePath; if (taxa != null) { TaxaSelectionSet outgroupSet = (TaxaSelectionSet) taxa.getSpecsSet(outgroupTaxSetString, TaxaSelectionSet.class); ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, outgroupSet); } else ((NewTreeProcessor) ownerModule).newTreeAvailable(treeFilePath, null); } } else if (fileNum == 1 && outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1]) && !bootstrapOrJackknife()) { // log file if (MesquiteFile.fileExists(filePath)) { String s = MesquiteFile.getFileLastContents(filePath); if (!StringUtil.blank(s)) if (progIndicator != null) { parser.setString(s); String rep = parser.getFirstToken(); // generation number logln(""); if (MesquiteInteger.isNumber(rep)) { int numReps = MesquiteInteger.fromString(rep) + 1; progIndicator.setText( "Replicate: " + numReps); // + ", ln L = " + parser.getNextToken()); if (bootstrapOrJackknife()) { logln("Replicate " + numReps + " of " + bootstrapreps); } logln("Replicate " + numReps + " of " + totalNumHits); progIndicator.spin(); double timePerRep = 0; if (MesquiteInteger.isCombinable(numReps) && numReps > 0) { timePerRep = timer.timeSinceVeryStartInSeconds() / numReps; // this is time per rep } int timeLeft = 0; if (bootstrapOrJackknife()) { timeLeft = (int) ((bootstrapreps - numReps) * timePerRep); } else { String token = parser.getNextToken(); // algorithm token = parser.getNextToken(); // Tree token = parser.getNextToken(); // Score String best = parser.getNextToken(); // Best logln(" Score " + token + "; best found so far " + best); timeLeft = (int) ((totalNumHits - numReps) * timePerRep); } logln( " Running time so far " + StringUtil.secondsToHHMMSS((int) timer.timeSinceVeryStartInSeconds()) + ", approximate time remaining " + StringUtil.secondsToHHMMSS(timeLeft)); } } count++; } else if (MesquiteTrunk.debugMode) logln("*** File does not exist (" + filePath + ") ***"); } }
/** for those permitting editing, indicates user has edited to incoming string. */ public void setString(int row, String s) { if (StringUtil.blank(s)) setNote(row, null); else if (s.equalsIgnoreCase("Yes") || s.equalsIgnoreCase("No Data")) return; else setNote(row, s); }
/*.................................................................................................................*/ public Object doCommand(String commandName, String arguments, CommandChecker checker) { if (checker.compare( this.getClass(), "Returns the matrix source", null, commandName, "getMatrixSource")) { return matrixSourceTask; } else if (checker.compare( this.getClass(), "Copies the data for selected taxon", null, commandName, "copyData")) { if (observedStates == null) return null; CharacterData data = observedStates.getParentData(); if (data == null) return null; int it = MesquiteInteger.fromString(parser.getFirstToken(arguments)); if (MesquiteInteger.isCombinable(it)) { StringBuffer sb = new StringBuffer(); data.copyDataFromRowIntoBuffer(it, sb); if (StringUtil.notEmpty(sb.toString())) { localCopyDataClipboard = sb.toString(); localCopyData = data; localCopyDataTaxon = data.getTaxa().getTaxonName(it); } else { localCopyDataClipboard = null; localCopyData = null; localCopyDataTaxon = null; } } return null; } else if (checker.compare( this.getClass(), "Pastes the data for selected taxon", null, commandName, "pasteData")) { if (observedStates == null) return null; CharacterData data = observedStates.getParentData(); if (data == null) return null; int it = MesquiteInteger.fromString(parser.getFirstToken(arguments)); if (MesquiteInteger.isCombinable(it) && StringUtil.notEmpty(localCopyDataClipboard)) { data.pasteDataFromStringIntoTaxon(it, localCopyDataClipboard); } return null; } else if (checker.compare( this.getClass(), "Pastes the data for selected taxon", null, commandName, "deleteDataTouched")) { if (observedStates == null) return null; CharacterData data = observedStates.getParentData(); if (data == null) return null; int it = MesquiteInteger.fromString(parser.getFirstToken(arguments)); Debugg.println("prepare to delete row: " + it); if (MesquiteInteger.isCombinable(it)) { if (!AlertDialog.query( containerOfModule(), "Delete Data?", "Are you sure you want to delete the data for taxon " + data.getTaxa().getTaxonName(it) + " in the matrix \"" + data.getName() + "\"", "No", "Yes")) { zapData(data, it); } } return null; } else if (checker.compare( this.getClass(), "Deletes the data for selected taxa", null, commandName, "deleteData")) { if (observedStates == null) return null; captureCharacterDataFromObservedStates(); if (data == null) return null; if (!AlertDialog.query( containerOfModule(), "Delete Data?", "Are you sure you want to delete the data for these taxa in the matrix \"" + data.getName() + "\"", "No", "Yes")) zapData(data); return null; } else if (checker.compare( this.getClass(), "deleteds () and anything between", null, commandName, "deletePrepended")) { if (observedStates == null || taxa == null) return null; boolean anySelected = taxa.anySelected(); int myColumn = -1; if (getEmployer() instanceof ListModule) { myColumn = ((ListModule) getEmployer()).getMyColumn(this); if (table != null) anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn); } for (int it = 0; it < taxa.getNumTaxa(); it++) { if ((!anySelected || selected(taxa, it, myColumn))) { String note = getNote(it); while (!StringUtil.blank(note) && note.indexOf("(") >= 0) { int start = note.indexOf("("); int end = note.indexOf(")"); String firstBit = ""; if (start > 0) firstBit = note.substring(0, start); note = firstBit + note.substring(end + 1, note.length()); } setNote(it, note); } } outputInvalid(); parametersChanged(); return null; } else if (checker.compare(this.getClass(), "deletes *", null, commandName, "deleteStar")) { if (observedStates == null || taxa == null) return null; boolean anySelected = taxa.anySelected(); int myColumn = -1; if (getEmployer() instanceof ListModule) { myColumn = ((ListModule) getEmployer()).getMyColumn(this); if (table != null) anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn); } for (int it = 0; it < taxa.getNumTaxa(); it++) { if ((!anySelected || selected(taxa, it, myColumn))) { String note = getNote(it); while (!StringUtil.blank(note) && note.indexOf("*") >= 0) { int start = note.indexOf("*"); String firstBit = ""; if (start > 0) firstBit = note.substring(0, start); note = firstBit + note.substring(start + 1, note.length()); } setNote(it, note); } } outputInvalid(); parametersChanged(); return null; } else if (checker.compare( this.getClass(), "Prepends to the note the sequence length (including N\'s and ?\'s) for the selected taxa", null, commandName, "prependLength")) { if (observedStates == null || taxa == null) return null; boolean anySelected = taxa.anySelected(); int myColumn = -1; if (getEmployer() instanceof ListModule) { myColumn = ((ListModule) getEmployer()).getMyColumn(this); if (table != null) anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn); } for (int it = 0; it < taxa.getNumTaxa(); it++) { if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) { String note = getNote(it); if (StringUtil.blank(note)) note = "(" + sequenceLength(it) + ")"; else note = "(" + sequenceLength(it) + ") " + note; setNote(it, note); } } outputInvalid(); parametersChanged(); return null; } else if (checker.compare( this.getClass(), "Prepends to the note the number of non-missing sites (not including N\'s and ?\'s) for the selected taxa", null, commandName, "prependNumSites")) { if (observedStates == null || taxa == null) return null; boolean anySelected = taxa.anySelected(); int myColumn = -1; if (getEmployer() instanceof ListModule) { myColumn = ((ListModule) getEmployer()).getMyColumn(this); if (table != null) anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn); } for (int it = 0; it < taxa.getNumTaxa(); it++) { if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) { String note = getNote(it); if (StringUtil.blank(note)) note = "(" + numSites(it) + ")"; else note = "(" + numSites(it) + ") " + note; setNote(it, note); } } outputInvalid(); parametersChanged(); return null; } else if (checker.compare( this.getClass(), "Deletes the notes for the selected taxa", null, commandName, "deleteAnnotation")) { if (observedStates == null || taxa == null) return null; boolean anySelected = taxa.anySelected(); int myColumn = -1; if (getEmployer() instanceof ListModule) { myColumn = ((ListModule) getEmployer()).getMyColumn(this); if (table != null) anySelected = anySelected || table.anyCellSelectedInColumnAnyWay(myColumn); } for (int it = 0; it < taxa.getNumTaxa(); it++) { if (hasData(it) && (!anySelected || selected(taxa, it, myColumn))) { setNote(it, null); } } outputInvalid(); parametersChanged(); return null; } else return super.doCommand(commandName, arguments, checker); }