diff --git a/src/main/java/es/uvigo/darwin/jmodeltest/exe/PhymlSingleModel.java b/src/main/java/es/uvigo/darwin/jmodeltest/exe/PhymlSingleModel.java index 94173ba..2849fd5 100644 --- a/src/main/java/es/uvigo/darwin/jmodeltest/exe/PhymlSingleModel.java +++ b/src/main/java/es/uvigo/darwin/jmodeltest/exe/PhymlSingleModel.java @@ -135,7 +135,7 @@ private void writePhyml3CommandLine(Model currentModel, if (currentModel.ispF()) commandLine += " -f m"; // changed from -f e DP200509 else - commandLine += " -f 0.25 0.25 0.25 0.25"; + commandLine += " -f 0.25,0.25,0.25,0.25"; // optimize pinvar if needed if (currentModel.ispI()) @@ -168,6 +168,9 @@ private void writePhyml3CommandLine(Model currentModel, if (numberOfThreads > 0) { commandLine += " --num_threads " + numberOfThreads; } + + // avoid memory warning + commandLine += " --no_memory_check"; // do optimize topology? /* @@ -212,9 +215,17 @@ private void executeCommandLine() { try { File dir = new File(PHYML_PATH); - // to deal with spaces in path we need to fragment commandline (at - // least it works in MacOS X) - String[] executable = { PHYML_PATH + Utilities.getBinaryVersion() }; + String[] executable = new String[1]; + + File phymlBinary = new File (PHYML_PATH + "phyml"); + if (phymlBinary.exists() && phymlBinary.canExecute()) + { + executable[0] = phymlBinary.getAbsolutePath(); + } + else + { + executable[0] = PHYML_PATH + Utilities.getBinaryVersion(); + } String[] tokenizedCommandLine = commandLine.split(" "); String[] cmd = Utilities.specialConcatStringArrays(executable, tokenizedCommandLine); @@ -408,6 +419,7 @@ else if (line.length() > 0 } catch (NullPointerException e) { System.err.println("Error while parsing result data from " + currentModel.getName()); + e.printStackTrace(); } phymlStatFile.close(); diff --git a/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhyml.java b/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhyml.java index d14e74b..05d4d2d 100644 --- a/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhyml.java +++ b/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhyml.java @@ -31,7 +31,7 @@ * RunPhyml.java * * Description: Makes phyml calculate likelihood scores for competing models - * @author Diego Darriba, University of Vigo / University of A Coru–a, Spain + * @author Diego Darriba, University of Vigo / University of A Coruna, Spain * ddarriba@udc.es * @author David Posada, University of Vigo, Spain * dposada@uvigo.es | darwin.uvigo.es diff --git a/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhymlMPJ.java b/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhymlMPJ.java index 3b0b309..3ee5ec3 100644 --- a/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhymlMPJ.java +++ b/src/main/java/es/uvigo/darwin/jmodeltest/exe/RunPhymlMPJ.java @@ -37,7 +37,7 @@ * RunPhymlMPJ.java * * Description: Makes phyml calculate likelihood scores for competing models - * @author Diego Darriba, University of Vigo / University of A Coru–a, Spain + * @author Diego Darriba, University of Vigo / University of A Coruna, Spain * ddarriba@udc.es * @author David Posada, University of Vigo, Spain * dposada@uvigo.es | darwin.uvigo.es diff --git a/src/main/java/es/uvigo/darwin/jmodeltest/www/BrowserLauncher.java b/src/main/java/es/uvigo/darwin/jmodeltest/www/BrowserLauncher.java deleted file mode 100644 index bfc58e2..0000000 --- a/src/main/java/es/uvigo/darwin/jmodeltest/www/BrowserLauncher.java +++ /dev/null @@ -1,603 +0,0 @@ -package es.uvigo.darwin.jmodeltest.www; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * BrowserLauncher is a class that provides one static method, openURL, which opens the default web browser for the - * current user of the system to the given URL. It may support other protocols depending on the system -- mailto, ftp, - * etc. -- but that has not been rigorously tested and is not guaranteed to work.
- * - * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms that are not part of the - * standard JDK. What we're trying to do, though, is to take something that's frequently desirable but inherently - * platform-specific -- opening a default browser -- and allow programmers (you, for example) to do so without worrying - * about dropping into native code or doing anything else similarly evil.
- * - * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without modification or a need - * for additional libraries. All classes that are required on certain platforms to allow this to run are dynamically - * loaded at runtime via reflection and, if not found, will not cause this to do anything other than returning an error - * when opening the browser.
- * - * There are certain system requirements for this class, as it's running through Runtime.exec(), which is Java's way of - * making a native system call. Currently, this requires that a Macintosh have a Finder which supports the GURL event, - * which is true for Mac OS 8.0 and 8.1 systems that have the Internet Scripting AppleScript dictionary installed in - * the Scripting Additions folder in the Extensions folder (which is installed by default as far as I know under Mac OS - * 8.0 and 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems (Windows 95, - * 98, and NT 4.0, as well as later versions of all). On other systems, this drops back from the inherently - * platform-sensitive concept of a default browser and simply attempts to launch Netscape via a shell command.
- * - * This code is Copyright 1999-2001 by Eric Albert (ejalbert@cs.stanford.edu) and may be redistributed or modified in - * any form without restrictions as long as the portion of this comment from this paragraph through the end of the - * comment is not removed. The author requests that he be notified of any application, applet, or other binary that - * makes use of this code, but that's more out of curiosity than anything and is not required. This software includes - * no warranty. The author is not repsonsible for any loss of data or functionality or any adverse or unexpected - * effects of using this software.
- *
- * Credits:
- * Steven Spencer, JavaWorld magazine (Java Tip
- * 66 )
- * Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, Larry Barowski, Trevor
- * Bedzek, Frank Miedrich, and Ron Rabakukk
- *
- * @author Eric Albert (ejalbert@cs.stanford.edu )
- * @version 1.4b1 (Released June 20, 2001)
- */
-public class BrowserLauncher {
-
- /**
- * The Java virtual machine that we are running on. Actually, in most cases we only care about the operating system,
- * but some operating systems require us to switch on the VM.
- */
- private static int jvm;
-
- /** The browser for the system */
- private static Object browser;
-
- /**
- * Caches whether any classes, methods, and fields that are not part of the JDK and need to be dynamically loaded at
- * runtime loaded successfully.
- *
- * Note that if this is false
, openURL()
will always return an IOException.
- */
- private static boolean loadedWithoutErrors;
-
- /** The com.apple.mrj.MRJFileUtils class */
- private static Class mrjFileUtilsClass;
-
- /** The com.apple.mrj.MRJOSType class */
- private static Class mrjOSTypeClass;
-
- /** The com.apple.MacOS.AEDesc class */
- private static Class aeDescClass;
-
- /** The true
if all intialization succeeded false
if any portion of the initialization
- * failed
- */
- private static boolean loadClasses() {
- switch (jvm) {
- case MRJ_2_0:
- try {
- Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
- Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
- Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
- Class aeClass = Class.forName("com.apple.MacOS.ae");
- aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
-
- aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[]{int.class});
- appleEventConstructor = appleEventClass.getDeclaredConstructor(new Class[]{int.class, int.class, aeTargetClass, int.class, int.class});
- aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[]{String.class});
-
- makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[]{String.class});
- putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[]{int.class, aeDescClass});
- sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[]{});
-
- Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject");
- keyDirectObject = (Integer)keyDirectObjectField.get(null);
- Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID");
- kAutoGenerateReturnID = (Integer)autoGenerateReturnIDField.get(null);
- Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID");
- kAnyTransactionID = (Integer)anyTransactionIDField.get(null);
- } catch (ClassNotFoundException cnfe) {
- errorMessage = cnfe.getMessage();
- return false;
- } catch (NoSuchMethodException nsme) {
- errorMessage = nsme.getMessage();
- return false;
- } catch (NoSuchFieldException nsfe) {
- errorMessage = nsfe.getMessage();
- return false;
- } catch (IllegalAccessException iae) {
- errorMessage = iae.getMessage();
- return false;
- }
- break;
- case MRJ_2_1:
- try {
- mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
- mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
- Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
- kSystemFolderType = systemFolderField.get(null);
- findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[]{mrjOSTypeClass});
- getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[]{File.class});
- getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[]{File.class});
- } catch (ClassNotFoundException cnfe) {
- errorMessage = cnfe.getMessage();
- return false;
- } catch (NoSuchFieldException nsfe) {
- errorMessage = nsfe.getMessage();
- return false;
- } catch (NoSuchMethodException nsme) {
- errorMessage = nsme.getMessage();
- return false;
- } catch (SecurityException se) {
- errorMessage = se.getMessage();
- return false;
- } catch (IllegalAccessException iae) {
- errorMessage = iae.getMessage();
- return false;
- }
- break;
- case MRJ_3_0:
- try {
- Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
- Constructor constructor = linker.getConstructor(new Class[]{Class.class});
- linkage = constructor.newInstance(new Object[]{BrowserLauncher.class});
- } catch (ClassNotFoundException cnfe) {
- errorMessage = cnfe.getMessage();
- return false;
- } catch (NoSuchMethodException nsme) {
- errorMessage = nsme.getMessage();
- return false;
- } catch (InvocationTargetException ite) {
- errorMessage = ite.getMessage();
- return false;
- } catch (InstantiationException ie) {
- errorMessage = ie.getMessage();
- return false;
- } catch (IllegalAccessException iae) {
- errorMessage = iae.getMessage();
- return false;
- }
- break;
- case MRJ_3_1:
- try {
- mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
- openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[]{String.class});
- } catch (ClassNotFoundException cnfe) {
- errorMessage = cnfe.getMessage();
- return false;
- } catch (NoSuchMethodException nsme) {
- errorMessage = nsme.getMessage();
- return false;
- }
- break;
- default:
- break;
- }
- return true;
- }
-
-
- /**
- * Attempts to locate the default web browser on the local system. Caches results so it only locates the browser once
- * for each use of this class per JVM instance.
- *
- * @return The browser for the system. Note that this may not be what you would consider to be a standard web
- * browser; instead, it's the application that gets called to open the default web browser. In some cases, this
- * will be a non-String object that provides the means of calling the default browser.
- */
- private static Object locateBrowser() {
- if (browser != null) {
- return browser;
- }
- switch (jvm) {
- case MRJ_2_0:
- try {
- Integer finderCreatorCode = (Integer)makeOSType.invoke(null, new Object[]{FINDER_CREATOR});
- Object aeTarget = aeTargetConstructor.newInstance(new Object[]{finderCreatorCode});
- Integer gurlType = (Integer)makeOSType.invoke(null, new Object[]{GURL_EVENT});
- Object appleEvent = appleEventConstructor.newInstance(new Object[]{gurlType, gurlType, aeTarget, kAutoGenerateReturnID, kAnyTransactionID});
- // Don't set browser = appleEvent because then the next time we call
- // locateBrowser(), we'll get the same AppleEvent, to which we'll already have
- // added the relevant parameter. Instead, regenerate the AppleEvent every time.
- // There's probably a way to do this better; if any has any ideas, please let
- // me know.
- return appleEvent;
- } catch (IllegalAccessException iae) {
- browser = null;
- errorMessage = iae.getMessage();
- return browser;
- } catch (InstantiationException ie) {
- browser = null;
- errorMessage = ie.getMessage();
- return browser;
- } catch (InvocationTargetException ite) {
- browser = null;
- errorMessage = ite.getMessage();
- return browser;
- }
- case MRJ_2_1:
- File systemFolder;
- try {
- systemFolder = (File)findFolder.invoke(null, new Object[]{kSystemFolderType});
- } catch (IllegalArgumentException iare) {
- browser = null;
- errorMessage = iare.getMessage();
- return browser;
- } catch (IllegalAccessException iae) {
- browser = null;
- errorMessage = iae.getMessage();
- return browser;
- } catch (InvocationTargetException ite) {
- browser = null;
- errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage();
- return browser;
- }
- String[] systemFolderFiles = systemFolder.list();
- // Avoid a FilenameFilter because that can't be stopped mid-list
- for (int i = 0; i < systemFolderFiles.length; i++) {
- try {
- File file = new File(systemFolder, systemFolderFiles[i]);
- if (!file.isFile()) {
- continue;
- }
- // We're looking for a file with a creator code of 'MACS' and
- // a type of 'FNDR'. Only requiring the type results in non-Finder
- // applications being picked up on certain Mac OS 9 systems,
- // especially German ones, and sending a GURL event to those
- // applications results in a logout under Multiple Users.
- Object fileType = getFileType.invoke(null, new Object[]{file});
- if (FINDER_TYPE.equals(fileType.toString())) {
- Object fileCreator = getFileCreator.invoke(null, new Object[]{file});
- if (FINDER_CREATOR.equals(fileCreator.toString())) {
- browser = file.toString();
- // Actually the Finder, but that's OK
- return browser;
- }
- }
- } catch (IllegalArgumentException iare) {
- browser = browser;
- errorMessage = iare.getMessage();
- return null;
- } catch (IllegalAccessException iae) {
- browser = null;
- errorMessage = iae.getMessage();
- return browser;
- } catch (InvocationTargetException ite) {
- browser = null;
- errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage();
- return browser;
- }
- }
- browser = null;
- break;
- case MRJ_3_0:
- case MRJ_3_1:
- browser = "";
- // Return something non-null
- break;
- case WINDOWS_NT:
- browser = "cmd.exe";
- break;
- case WINDOWS_9x:
- browser = "command.com";
- break;
- case OTHER:
- default:
- browser = "netscape";
- break;
- }
- return browser;
- }
-
-
- /**
- * Methods required for Mac OS X. The presence of native methods does not cause any problems on other platforms.
- *
- * @param instance Description of Parameter
- * @param signature Description of Parameter
- * @return Description of the Returned Value
- */
- private native static int ICStart(int[] instance, int signature);
-
-
- /**
- * Description of the Method
- *
- * @param instance Description of Parameter
- * @return Description of the Returned Value
- */
- private native static int ICStop(int[] instance);
-
-
- /**
- * Description of the Method
- *
- * @param instance Description of Parameter
- * @param hint Description of Parameter
- * @param data Description of Parameter
- * @param len Description of Parameter
- * @param selectionStart Description of Parameter
- * @param selectionEnd Description of Parameter
- * @return Description of the Returned Value
- */
- private native static int ICLaunchURL(int instance, byte[] hint, byte[] data, int len,
- int[] selectionStart, int[] selectionEnd);
-
- static {
- loadedWithoutErrors = true;
- String osName = System.getProperty("os.name");
- if (osName.startsWith("Mac OS")) {
- String mrjVersion = System.getProperty("mrj.version");
- String majorMRJVersion = mrjVersion.substring(0, 3);
- try {
- double version = Double.valueOf(majorMRJVersion).doubleValue();
- if (version == 2) {
- jvm = MRJ_2_0;
- } else if (version >= 2.1 && version < 3) {
- // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually
- // works via Runtime.exec() and 2.2 supports that but has an openURL() method
- // as well that we currently ignore.
- jvm = MRJ_2_1;
- } else if (version == 3.0) {
- jvm = MRJ_3_0;
- } else if (version >= 3.1) {
- // Assume that all 3.1 and later versions of MRJ work the same.
- jvm = MRJ_3_1;
- } else {
- loadedWithoutErrors = false;
- errorMessage = "Unsupported MRJ version: " + version;
- }
- } catch (NumberFormatException nfe) {
- loadedWithoutErrors = false;
- errorMessage = "Invalid MRJ version: " + mrjVersion;
- }
- } else if (osName.startsWith("Windows")) {
- if (osName.indexOf("9") != -1) {
- jvm = WINDOWS_9x;
- } else {
- jvm = WINDOWS_NT;
- }
- } else {
- jvm = OTHER;
- }
-
- if (loadedWithoutErrors) {
- // if we haven't hit any errors yet
- loadedWithoutErrors = loadClasses();
- }
- }
-}