Skip to content
Snippets Groups Projects
Commit d7b60cf9 authored by fedoreno's avatar fedoreno
Browse files

SSDM-1822: educatedly guessing location of BLAST supplied with ELN

SVN: 35115
parent 8fa47c0d
No related branches found
No related tags found
No related merge requests found
......@@ -132,8 +132,7 @@ public class BlastDatabaseCreationMaintenanceTask implements IMaintenanceTask
makeblastdb = blastToolDirectory + "makeblastdb";
if (process(makeblastdb, "-version") == false)
{
operationLog.error("BLAST isn't installed or property '" + BlastUtils.BLAST_TOOLS_DIRECTORY_PROPERTY
+ "' hasn't been correctly specified.");
BlastUtils.logMissingTools(operationLog);
makeblastdb = null;
}
makembindex = blastToolDirectory + "makembindex";
......
......@@ -17,10 +17,16 @@
package ch.systemsx.cisd.openbis.dss.generic.shared.utils;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import org.apache.commons.lang.SystemUtils;
import org.apache.log4j.Logger;
import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginScanner.ScannerType;
import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginsUtils;
/**
* Constants and static method about BLAST support.
*
......@@ -28,10 +34,18 @@ import org.apache.log4j.Logger;
*/
public class BlastUtils
{
private static final String BLAST_ROOT = "eln-lims/bin/blast";
private static final String LINUX = "linux/bin/";
private static final String MAC = "mac/bin/";
public static final String BLAST_TOOLS_DIRECTORY_PROPERTY = "blast-tools-directory";
public static final String BLAST_DATABASES_FOLDER_PROPERTY = "blast-databases-folder";
public static final String DEFAULT_BLAST_DATABASES_FOLDER = "blast-databases";
public static File getBlastDatabaseFolder(Properties properties, File storeRoot)
{
return getFile(properties, BLAST_DATABASES_FOLDER_PROPERTY, DEFAULT_BLAST_DATABASES_FOLDER, storeRoot);
......@@ -40,11 +54,36 @@ public class BlastUtils
public static String getBLASTToolDirectory(Properties properties)
{
String blastToolsDirectory = properties.getProperty(BLAST_TOOLS_DIRECTORY_PROPERTY, "");
if (blastToolsDirectory.endsWith("/") || blastToolsDirectory.isEmpty())
if (false == blastToolsDirectory.isEmpty())
{
if (blastToolsDirectory.endsWith(File.separator))
{
return blastToolsDirectory;
}
return blastToolsDirectory + File.separator;
}
return getBestGuessBLASTToolDirectory(properties);
}
private static String getBestGuessBLASTToolDirectory(Properties properties)
{
String corePluginsFolder = CorePluginsUtils.getCorePluginsFolder(properties, ScannerType.DSS);
Path path = Paths.get(corePluginsFolder, BLAST_ROOT).toAbsolutePath();
if (false == path.toFile().exists())
{
return blastToolsDirectory;
return "";
}
return blastToolsDirectory + "/";
if (SystemUtils.IS_OS_LINUX)
{
return path.resolve(LINUX).toString() + File.separator;
}
return path.resolve(MAC).toString() + File.separator;
}
public static File getFile(Properties properties, String pathProperty, String defaultPath, File storeRoot)
......@@ -55,7 +94,7 @@ public class BlastUtils
public static void logMissingTools(Logger operationLog)
{
operationLog.error("BLAST isn't installed or property '" + BLAST_TOOLS_DIRECTORY_PROPERTY
operationLog.error("BLAST isn't installed or property '" + BLAST_TOOLS_DIRECTORY_PROPERTY
+ "' hasn't been correctly specified.");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment