Skip to content

Commit

Permalink
Merge pull request #74 from MesquiteProject/development
Browse files Browse the repository at this point in the history
Version 3.31
  • Loading branch information
wmaddisn authored Sep 20, 2017
2 parents 42eabe0 + 71af628 commit 68f815d
Show file tree
Hide file tree
Showing 27 changed files with 235 additions and 96 deletions.
8 changes: 4 additions & 4 deletions Source/mesquite/Mesquite.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public class Mesquite extends MesquiteTrunk
{
/*.................................................................................................................*/
public String getCitation() {
return "Maddison, W.P. & D.R. Maddison. 2017. Mesquite: A modular system for evolutionary analysis. Version 3.3. http://mesquiteproject.org";
return "Maddison, W.P. & D.R. Maddison. 2017. Mesquite: A modular system for evolutionary analysis. Version 3.31. http://mesquiteproject.org";
}
/*.................................................................................................................*/
public String getVersion() {
return "3.3";
return "3.31";
}

/*.................................................................................................................*/
public int getVersionInt() {
return 330;
return 331;
}
/*.................................................................................................................*/
public double getMesquiteVersionNumber(){
return 3.3;
return 3.31;
}
/*.................................................................................................................*/
public String getDateReleased() {
Expand Down
13 changes: 8 additions & 5 deletions Source/mesquite/align/ClustalAlign/ClustalAlign.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ public String getDefaultProgramOptions(){
}

public void appendDefaultOptions(StringBuffer shellScript, String inFilePath, String outFilePath, MolecularData data) {
shellScript.append(" -infile=" + StringUtil.protectFilePathForUnix(inFilePath) + " -align -output=pir ");
if (data instanceof ProteinData)
shellScript.append("-type=protein ");
else
shellScript.append("-type=dna ");
shellScript.append(" -infile=" + StringUtil.protectFilePathForUnix(inFilePath) + " -align -output=pir ");
if (data instanceof ProteinData)
shellScript.append("-type=protein ");
else
shellScript.append("-type=dna ");
if (scriptBased)
shellScript.append("-outfile="+StringUtil.protectFilePathForUnix(outFilePath));

}


Expand Down
5 changes: 4 additions & 1 deletion Source/mesquite/align/MAFFTAlign/MAFFTAlign.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ public String getDefaultProgramOptions(){
}

public void appendDefaultOptions(StringBuffer shellScript, String inFilePath, String outFilePath, MolecularData data) {
shellScript.append(" " + StringUtil.protectFilePathForUnix(inFilePath));
if (scriptBased)
shellScript.append(" " + StringUtil.protectFilePathForUnix(inFilePath) + " > " + outFilePath);
else
shellScript.append(" " + StringUtil.protectFilePathForUnix(inFilePath));
}

public String getDNAExportInterpreter () {
Expand Down
5 changes: 4 additions & 1 deletion Source/mesquite/align/MuscleAlign/MuscleAlign.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ public String getDefaultProgramOptions(){
}

public void appendDefaultOptions(StringBuffer shellScript, String inFilePath, String outFilePath, MolecularData data) {
shellScript.append(" -in " + StringUtil.protectFilePathForUnix(inFilePath));
if (scriptBased)
shellScript.append(" -in " + StringUtil.protectFilePathForUnix(inFilePath)+" -out " + StringUtil.protectFilePathForUnix(outFilePath));
else
shellScript.append(" -in " + StringUtil.protectFilePathForUnix(inFilePath));
}

public String getDNAExportInterpreter () {
Expand Down
64 changes: 40 additions & 24 deletions Source/mesquite/align/lib/ExternalSequenceAligner.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ public abstract class ExternalSequenceAligner extends MultipleSequenceAligner im
boolean includeGaps = false;
String programOptions = "" ;
Random rng;
protected boolean scriptBased = false;
public static int runs = 0;
//ShellScriptRunner scriptRunner;
ShellScriptRunner scriptRunner;
ExternalProcessManager externalRunner;
/*.................................................................................................................*/
public boolean startJob(String arguments, Object condition, boolean hiredByName) {
rng = new Random(System.currentTimeMillis());
programOptions = getDefaultProgramOptions();
loadPreferences();
scriptBased = MesquiteTrunk.isJavaVersionLessThan(1.7);
return true;
}
public abstract String getProgramCommand();
Expand All @@ -59,16 +61,25 @@ public boolean startJob(String arguments, Object condition, boolean hiredByName)

/*.................................................................................................................*/
public String getStdErr() {
if (externalRunner!=null)
if (scriptBased){
if (scriptRunner!=null)
return scriptRunner.getStdErr();
}
else if (externalRunner!=null)
return externalRunner.getStdErr();
return "";
}
/*.................................................................................................................*/
public String getStdOut() {
if (externalRunner!=null)
if (scriptBased){
if (scriptRunner!=null)
return scriptRunner.getStdOut();
}
else if (externalRunner!=null)
return externalRunner.getStdOut();
return "";
}

public boolean userAborted(){
return false;
}
Expand All @@ -77,9 +88,13 @@ public String checkStatus(){
return null;
}
public boolean stopExecution(){
if (externalRunner!=null)
if (scriptBased){
if (scriptRunner!=null)
scriptRunner.stopExecution();
}
else if (externalRunner!=null) {
externalRunner.stopExecution();
//scriptRunner = null;
}
return false;
}

Expand Down Expand Up @@ -343,10 +358,11 @@ else if (!(firstTaxon==0 && lastTaxon==matrix.getNumTaxa())) { // we are doing
argumentsForLogging.append(" " + programOptions + " "+ getQueryProgramOptions());
}
shellScript.append(StringUtil.lineEnding());
// shellScript.append(ShellScriptUtil.getRemoveCommand(runningFilePath));
shellScript.append(ShellScriptUtil.getRemoveCommand(runningFilePath));

String scriptPath = rootDir + "alignerScript" + MesquiteFile.massageStringToFilePathSafe(unique) + ".bat";
MesquiteFile.putFileContents(scriptPath, shellScript.toString(), false);
if (scriptBased)
MesquiteFile.putFileContents(scriptPath, shellScript.toString(), false);

logln("Requesting the operating system to run " + getProgramName());
logln("Location of " + getProgramName()+ ": " + getProgramPath());
Expand All @@ -357,22 +373,22 @@ else if (!(firstTaxon==0 && lastTaxon==matrix.getNumTaxa())) { // we are doing
ProgressIndicator progressIndicator = new ProgressIndicator(getProject(), getProgramName()+" alignment in progress");
progressIndicator.start();


/* scriptRunner = new ShellScriptRunner(scriptPath, runningFilePath, null, true, getName(), outputFilePaths, this, this, false); //scriptPath, runningFilePath, null, true, name, outputFilePaths, outputFileProcessor, watcher, true
success = scriptRunner.executeInShell();
success = scriptRunner.monitorAndCleanUpShell(progressIndicator);
*/

String arguments = argumentsForLogging.toString();
arguments=StringUtil.stripBoundingWhitespace(arguments);
externalRunner = new ExternalProcessManager(this, rootDir, getProgramPath(), arguments,getName(), outputFilePaths, this, this, true);
//ShellScriptUtil.changeDirectory(rootDir, rootDir);
externalRunner.setStdOutFileName(outFileName);
success = externalRunner.executeInShell();
if (success)
success = externalRunner.monitorAndCleanUpShell(progressIndicator);

if (scriptBased) {
scriptRunner = new ShellScriptRunner(scriptPath, runningFilePath, null, true, getName(), outputFilePaths, this, this, true); //scriptPath, runningFilePath, null, true, name, outputFilePaths, outputFileProcessor, watcher, true
success = scriptRunner.executeInShell();
if (success)
success = scriptRunner.monitorAndCleanUpShell(progressIndicator);
} else {
String arguments = argumentsForLogging.toString();

arguments=StringUtil.stripBoundingWhitespace(arguments);
externalRunner = new ExternalProcessManager(this, rootDir, getProgramPath(), arguments,getName(), outputFilePaths, this, this, true);
//ShellScriptUtil.changeDirectory(rootDir, rootDir);
externalRunner.setStdOutFileName(outFileName);
success = externalRunner.executeInShell();
if (success)
success = externalRunner.monitorAndCleanUpShell(progressIndicator);
}

if (progressIndicator.isAborted()){
logln("Alignment aborted by user\n");
Expand All @@ -387,7 +403,7 @@ else if (!(firstTaxon==0 && lastTaxon==matrix.getNumTaxa())) { // we are doing
CommandRecord oldCR = MesquiteThread.getCurrentCommandRecord();
CommandRecord scr = new CommandRecord(true);
MesquiteThread.setCurrentCommandRecord(scr);
String failureText = StringUtil.tokenize("Output file containing aligned sequences $$$$$$$$$");
String failureText = StringUtil.tokenize("Output file containing aligned sequences ");
if (data instanceof DNAData)
tempDataFile = (MesquiteFile)coord.doCommand("linkFileExp", failureText +" " + StringUtil.tokenize(outFilePath) + " " + StringUtil.tokenize(getDNAImportInterpreter()) + " suppressImportFileSave ", CommandChecker.defaultChecker); //TODO: never scripting???
else
Expand Down
3 changes: 2 additions & 1 deletion Source/mesquite/lib/AlertWithLinkToDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public AlertWithLinkToDirectory (MesquiteWindow parent, String title, String me
addTextArea(message, 5);

//nullifyAddPanel();
addDirectoryButton();
if (MesquiteFile.canShowDirectory())
addDirectoryButton();

completeAndShowDialog ("OK", null,true, this);

Expand Down
16 changes: 15 additions & 1 deletion Source/mesquite/lib/ExternalProcessManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public void setStdErrFileName(String stdErrFileName) {
stdErrFilePath = MesquiteFile.getDirectoryPathFromFilePath(directoryPath) + MesquiteFile.fileSeparator + stdErrFileName;
}


public static boolean isAlive(Process proc) {
if (MesquiteTrunk.isJavaGreaterThanOrEqualTo(1.8))
return proc.isAlive();
try {
proc.exitValue();
return false;
} catch (Exception e) {
return true;
}

}
/*.................................................................................................................*/
public Snapshot getSnapshot(MesquiteFile file) {
Snapshot temp = new Snapshot();
Expand Down Expand Up @@ -233,6 +245,8 @@ public static String[] getStringArrayWithSplitting(String string1, String string
/** 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(){
if (MesquiteTrunk.isJavaVersionLessThan(1.7))
return false;
proc = null;
externalProcess = new MesquiteExternalProcess();
externalProcess.start(directoryPath, stdOutFilePath, stdErrFilePath, getStringArrayWithSplitting(programCommand, programOptions));
Expand Down Expand Up @@ -295,7 +309,7 @@ public boolean monitorAndCleanUpShell(ProgressIndicator progressIndicator){
return false;
}
stillGoing = watcher == null || watcher.continueShellProcess(proc);
if (proc!=null && !proc.isAlive()) {
if (proc!=null && !isAlive(proc)) {
stillGoing=false;
boolean goodValue = goodExitValue(proc.exitValue(), true);
if (!goodValue && !ownerModule.isDoomed() && !watcher.userAborted()) {
Expand Down
3 changes: 3 additions & 0 deletions Source/mesquite/lib/MesquiteDialogParent.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ public void setVisible(boolean b){
MesquiteDialog.currentWizard = null;
if (b && isWizard)
MesquiteDialog.currentWizard = this;
if (b) {
pleaseBringToFront(); //This is a workaround to the problem of a more recent dialog box dropping behind an older one. PUts on different thread.
super.setVisible(b);
}
}

public void hideForCalculation(){
Expand Down
2 changes: 1 addition & 1 deletion Source/mesquite/lib/MesquiteExternalProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void kill () {
proc.destroy();
try {
Thread.sleep(100);
if (proc.isAlive())
if (ExternalProcessManager.isAlive(proc))
proc.destroyForcibly();
} catch (Exception e) {
}
Expand Down
7 changes: 6 additions & 1 deletion Source/mesquite/lib/MesquiteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,12 @@ public synchronized static void appendFileContents(String relativePath, String c
}

/*.................................................................................................................*/
/** Shows the File in the finder or Windows Explorer" */
/** Returns whether a directory can be shown in the OS's file browser." */
public static boolean canShowDirectory() {
return (MesquiteTrunk.isMacOSX() || MesquiteTrunk.isWindows());
}
/*.................................................................................................................*/
/** Shows the directory specified in path in the Finder or Windows Explorer" */
public static void showDirectory(String path) {
if (path == null)
return;
Expand Down
22 changes: 19 additions & 3 deletions Source/mesquite/lib/MesquiteModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public abstract class MesquiteModule extends EmployerEmployee implements Command
/*.................................................................................................................*/
/** returns build date of the Mesquite system (e.g., "22 September 2003") */
public final static String getBuildDate() {
return "12 September 2017";
return "21 September 2017";
}
/*.................................................................................................................*/
/** returns version of the Mesquite system */
public final static String getMesquiteVersion() {
return "3.3";
return "3.31";
}
/*.................................................................................................................*/
/** returns letter in the build number of the Mesquite system (e.g., "e" of "e58") */
Expand All @@ -86,7 +86,7 @@ public final static String getBuildLetter() {
public final static int getBuildNumber() {
//as of 26 Dec 08, build naming changed from letter + number to just number. Accordingly j105 became 473, based on
// highest build numbers of d51+e81+g97+h66+i69+j105 + 3 for a, b, c
return 854;
return 858;
}
//0.95.80 14 Mar 01 - first beta release
//0.96 2 April 01 beta - second beta release
Expand Down Expand Up @@ -133,6 +133,7 @@ public final static int getBuildNumber() {
//3.11 = 766 released 3 December 2016, fix of miswriting of codon positions
//3.20 = 801 released 1 January 2017
//3.30 = 854 released 12 Sept 2017
//3.31 = 858 released 20 Sept 2017
/*.................................................................................................................*/
/** returns a string if this is a special version of Mesquite */
public final static String getSpecialVersion() {
Expand Down Expand Up @@ -1116,6 +1117,17 @@ else if (AlertDialog.query(containerOfModule(), "Problem", s + "\n\nPlease send
/*.................................................................................................................*/
/** Displays an alert in connection to an exception*/
public void exceptionAlert(Throwable e, String s) {
String incompatibilityMessage = null;
if (e instanceof NoSuchMethodError){
incompatibilityMessage = "An error indicates that you may have a package installed that is incompatible "
+ "with this version of Mesquite. Please check your add-on packages like Zephyr, Chromaseq, etc. to ensure they are up to date,"
+ " and that you are using an up to date version of Mesquite.";
}
else if (e instanceof NoClassDefFoundError){
incompatibilityMessage = "An error indicates that you may have an incomplete version of Mesquite, or a package installed that is incompatible "
+ "with this version of Mesquite. Please check your add-on packages like Zephyr, Chromaseq, etc. to ensure they are up to date,"
+ " and that you are using an up to date version of Mesquite. You may need to reinstall Mesquite.";
}
MesquiteTrunk.errorReportedDuringRun = true;
StackTraceElement[] stt = e.getStackTrace();
String rep = MesquiteException.lastLocMessage() + "\n";
Expand All @@ -1131,6 +1143,8 @@ public void exceptionAlert(Throwable e, String s) {
((MesquiteThread)t).doCleanUp();
logln(s);
if (!PhoneHomeUtil.phoneHomeSuccessful || !MesquiteTrunk.reportErrors || MesquiteTrunk.suppressErrorReporting){
if (incompatibilityMessage != null)
discreetAlert(incompatibilityMessage);
if (!MesquiteThread.isScripting() && !AlertDialog.query(containerOfModule(), "Crash", s, "OK", "Force Quit"))
MesquiteTrunk.mesquiteTrunk.exit(true, 0);
return;
Expand All @@ -1154,6 +1168,8 @@ else if (MainThread.emergencyCancelled || MesquiteTrunk.errorReportedToHome){//

}
else {
if (incompatibilityMessage != null)
discreetAlert(incompatibilityMessage);
int resp = AlertDialog.query(containerOfModule(), "Crash", s + "\n\nPlease send a report of this crash to the Mesquite server, to help us debug it and improve Mesquite. None of your data will be sent, but your log file up to this point will be sent." + addendum, "OK, Send Report and Continue", "OK, Send and Force Quit", "Close without sending");
if (resp < 2)
reportCrashToHome(e, s);
Expand Down
3 changes: 3 additions & 0 deletions Source/mesquite/lib/MesquiteModuleInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public MesquiteModuleInfo (Class c, MesquiteModule mb, CommandChecker checker, S
this.packageURL = (( PackageIntroInterface)mb).getPackageURL();
isPackageIntro = true;
hideable = (( PackageIntroInterface)mb).getHideable();
if ((( PackageIntroInterface)mb).getMinimumMesquiteVersionRequiredInt()> MesquiteTrunk.mesquiteTrunk.getVersionInt())
MesquiteTrunk.mesquiteTrunk.discreetAlert("The package " + packageName
+ " requires a newer version of Mesquite (at least version " + (( PackageIntroInterface)mb).getMinimumMesquiteVersionRequired() + "). The package might not function properly and may cause crashes.");
}
mb.mesquiteStartup();
this.nexusBlockTest = mb.getNexusBlockTest();//�
Expand Down
9 changes: 9 additions & 0 deletions Source/mesquite/lib/MesquiteThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,15 @@ public String getCurrentCommandExplanation(){
return null;
}

/*.................................................................................................................*/
public static void pauseForMilliseconds(double milliseconds){
try {
Thread.sleep((int)(milliseconds));
}
catch (InterruptedException e) {
return;
}
}
/*.................................................................................................................*/
public static void pauseForSeconds(double seconds){
try {
Expand Down
9 changes: 5 additions & 4 deletions Source/mesquite/lib/PhoneHomeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ public static void processSingleNotice(MesquiteModuleInfo mmi, StringBuffer noti
appliesToBuild = appliesToBuild && (forBuildNumberEqualOrLess >= MesquiteModule.getBuildNumber());

if (MesquiteInteger.isCombinable(forPackageVersionExactly))
appliesToBuild = appliesToBuild && (forPackageVersionExactly == mmi.getVersionInt());
appliesToBuild = appliesToBuild && (forPackageVersionExactly == mmi.getPackageVersionInt());
if (MesquiteInteger.isCombinable(forPackageVersionEqualOrGreater))
appliesToBuild = appliesToBuild && (forPackageVersionEqualOrGreater <= mmi.getVersionInt());
appliesToBuild = appliesToBuild && (forPackageVersionEqualOrGreater <= mmi.getPackageVersionInt());
if (MesquiteInteger.isCombinable(forPackageVersionEqualOrLess))
appliesToBuild = appliesToBuild && (forPackageVersionEqualOrLess >= mmi.getVersionInt());
appliesToBuild = appliesToBuild && (forPackageVersionEqualOrLess >= mmi.getPackageVersionInt());

}

Expand Down Expand Up @@ -499,7 +499,8 @@ private static String handleMessages(boolean adHoc, String noticesFromHome, Mesq
int lastNotice = phoneHomeRecord.getLastNotice();
int lastVersionNoticed = phoneHomeRecord.getLastVersionNoticed();


String name = mmi.getName();

Element root = XMLUtil.getRootXMLElementFromString("mesquite",noticesFromHome);
if (root==null)
return null;
Expand Down
Loading

0 comments on commit 68f815d

Please sign in to comment.