/** * 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; }
/*.................................................................................................................*/ 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; }
public void calculateNumber(Taxon taxon, MesquiteNumber result, MesquiteString resultString) { if (result == null) return; clearResultAndLastResult(result); Taxa taxa = taxon.getTaxa(); int it = taxa.whichTaxonNumber(taxon); if (taxa != currentTaxa || observedStates == null) { observedStates = matrixSourceTask.getCurrentMatrix(taxa); currentTaxa = taxa; } if (observedStates == null || !(observedStates.getParentData() instanceof DNAData)) return; DNAData data = (DNAData) observedStates.getParentData(); int count = data.getAminoAcidNumbers(it, ProteinData.TER, countEvenIfOthers.getValue()); if (result != null) result.setValue(count); if (resultString != null) resultString.setValue( "Number of stop codons in taxon " + observedStates.getName() + ": " + count); saveLastResult(result); saveLastResultString(resultString); }
/*.................................................................................................................*/ public Tree retrieveTreeBlock(TreeVector treeList, MesquiteDouble finalScore) { logln("Preparing to receive TNT trees."); boolean success = false; taxa = treeList.getTaxa(); // TODO finalScore.setValue(finalValue); suppressProjectPanelReset(); CommandRecord oldCR = MesquiteThread.getCurrentCommandRecord(); CommandRecord scr = new CommandRecord(true); MesquiteThread.setCurrentCommandRecord(scr); // define file paths and set tree files as needed. setFileNames(); String[] outputFilePaths = externalProcRunner.getOutputFilePaths(); String treeFilePath = outputFilePaths[OUT_TREEFILE]; taxonNumberTranslation = getTaxonNumberTranslation(taxa); namer.setNumberTranslationTable(taxonNumberTranslation); runFilesAvailable(); // read in the tree files success = false; Tree t = null; MesquiteBoolean readSuccess = new MesquiteBoolean(false); // TreeVector tv = new TreeVector(taxa); if (bootstrapOrJackknife()) { if (resamplingAllConsensusTrees) t = ZephyrUtil.readTNTTreeFile( this, treeList, taxa, treeFilePath, "TNT " + getResamplingKindName() + " Rep", 0, readSuccess, false, false, null, namer); // set first tree number as 0 as will remove the first one later. else t = ZephyrUtil.readTNTTreeFile( this, treeList, taxa, treeFilePath, "TNT " + getResamplingKindName() + " Majority Rule Tree", 1, readSuccess, false, false, freqRef, namer); } else t = ZephyrUtil.readTNTTreeFile( this, treeList, taxa, treeFilePath, "TNTTree", 1, readSuccess, false, harvestOnlyStrictConsensus, null, namer); success = t != null; if (success && bootstrapOrJackknife() && resamplingAllConsensusTrees) { t = t.cloneTree(); treeList.removeElementAt(0, false); // get rid of first one as this is the bootstrap tree } MesquiteThread.setCurrentCommandRecord(oldCR); success = readSuccess.getValue(); if (!success) { logln("Execution of TNT unsuccessful [2]"); if (!beanWritten) postBean("unsuccessful [2]", false); beanWritten = true; } else { if (!beanWritten) postBean("successful", false); beanWritten = true; } desuppressProjectPanelReset(); if (data != null) data.decrementEditInhibition(); // manager.deleteElement(tv); // get rid of temporary tree block externalProcRunner.finalCleanup(); if (success) return t; return null; }