diff --git a/build.xml b/build.xml index 8a0cb00..1e35754 100644 --- a/build.xml +++ b/build.xml @@ -39,7 +39,8 @@ - + + @@ -147,6 +148,11 @@ + + + + + @@ -167,6 +173,11 @@ + + + + + diff --git a/conf/system/dbmsVersion-html.vm b/conf/system/dbmsVersion-html.vm new file mode 100755 index 0000000..11f51c2 --- /dev/null +++ b/conf/system/dbmsVersion-html.vm @@ -0,0 +1,117 @@ + + + + $bdminfo.config.name + + + + + + +
+

Banks managed by $bdminfo.config.name

+
Configuration
+

+

    +
  • Install path: $bdminfo.config.instpath
  • +
  • Master configuration: $bdminfo.config.instconfpath
  • +
  • Logs path: $bdminfo.config.logpath
  • +
  • Working path: $bdminfo.config.wkpath
  • +
  • Bank configuration: $bdminfo.config.confpath
  • +
  • Bank storage path: $bdminfo.config.dbpath
  • +
  • Bank repository size: $bdminfo.config.reposize
  • +
+

+
+ +
+ + #set( $dbTable = $bdminfo.databases2.mirror_p ) +

Protein banks: ${dbTable.size()}

+ #if( ${dbTable.size()} == 0 ) +

none

+ #else + + + + + + + + + + + #foreach( $db in $dbTable ) + + + + + + + + + + #end +
NameDescriptionAnnotatedSize (sequences)Size on diskInstall date
$db.getName()$db.getDescription()
BLAST+ use: -db $db.getDbPath().substring(0, $db.getDbPath().lastIndexOf("."))
$db.hasAnnotation()$db.getNbSequence()$db.getDiskSize()$db.getTimeStamp()
+ #end + + + #set( $dbTable = $bdminfo.databases2.mirror_n ) +

Nucleotide banks: ${dbTable.size()}

+ #if( ${dbTable.size()} == 0 ) +

none

+ #else + + + + + + + + + + + #foreach( $db in $dbTable ) + + + + + + + + + + #end +
NameDescriptionAnnotatedSize (sequences)Size on diskInstall date
$db.getName()$db.getDescription()
BLAST+ use: -db $db.getDbPath().substring(0, $db.getDbPath().lastIndexOf("."))
$db.hasAnnotation()$db.getNbSequence()$db.getDiskSize()$db.getTimeStamp()
+ #end + + #set( $dbTable = $bdminfo.databases2.mirror_d ) +

Biological classification banks: ${dbTable.size()}

+ #if( ${dbTable.size()} == 0 ) +

none

+ #else + + + + + + + + + + #foreach( $db in $dbTable ) + + + + + + + + + #end +
NameDescriptionSize (sequences)Size on diskInstall date
$db.getName()$db.getDescription()$db.getNbSequence()$db.getDiskSize()$db.getTimeStamp()
+ #end +
+ + + \ No newline at end of file diff --git a/conf/system/dbmsVersion-txt.vm b/conf/system/dbmsVersion-txt.vm new file mode 100644 index 0000000..d2061e4 --- /dev/null +++ b/conf/system/dbmsVersion-txt.vm @@ -0,0 +1,52 @@ +$bdminfo.config.name + +Configuration: + + Install path : $bdminfo.config.instpath + Master configuration : $bdminfo.config.instconfpath + Log path : $bdminfo.config.logpath + Work path : $bdminfo.config.wkpath + Bank configuration file: $bdminfo.config.confpath + Bank repository path : $bdminfo.config.dbpath + Bank repository size : $bdminfo.config.reposize + +Installed banks +#set( $pTable = $bdminfo.databases2.mirror_p ) + - Protein banks: ${pTable.size()} +#if( ${pTable.size()} != 0 ) +#foreach( $db in $pTable ) + * $db.getName() + Description: $db.getDescription() + BLAST+ use: -db $db.getDbPath().substring(0, $db.getDbPath().lastIndexOf(".")) + Annotated bank: $db.hasAnnotation() + Size (sequences): $db.getNbSequence() + Size on disk: $db.getDiskSize() + Install date: $db.getTimeStamp() +#end +#end + +#set( $nTable = $bdminfo.databases2.mirror_n ) + - Nucleotide banks: ${nTable.size()} +#if( ${nTable.size()} != 0 ) +#foreach( $db in $nTable ) + * $db.getName() + Description: $db.getDescription() + BLAST+ use: -db $db.getDbPath().substring(0, $db.getDbPath().lastIndexOf(".")) + Annotated bank: $db.hasAnnotation() + Size (sequences): $db.getNbSequence() + Size on disk: $db.getDiskSize() + Install date: $db.getTimeStamp() +#end +#end + +#set( $dTable = $bdminfo.databases2.mirror_d ) + - Biological classification banks: ${dTable.size()} +#if( ${dTable.size()} != 0 ) +#foreach( $db in $dTable ) + * $db.getName() + Description: $db.getDescription() + Size (terms): $db.getNbSequence() + Size on disk: $db.getDiskSize() + Install date: $db.getTimeStamp() +#end +#end diff --git a/docker/deploy.xml b/docker/deploy.xml index 0cdcad1..30e5e1b 100644 --- a/docker/deploy.xml +++ b/docker/deploy.xml @@ -16,6 +16,14 @@ + + + This is the Ant project file to install DBMS for Docker container. + + Available target is: install + + + Current configuration is: @@ -56,7 +64,8 @@ - + + @@ -98,10 +107,14 @@ - - - - + + + + + + + + diff --git a/docker/run_bdm.sh b/docker/run_bdm.sh index 68985d9..8d93738 100755 --- a/docker/run_bdm.sh +++ b/docker/run_bdm.sh @@ -5,11 +5,11 @@ # # Use: ./run_bdm.sh -c # -# : one of install, query, annotate +# : one of install, query, annotate, info # : remaining arguments passed in after are passed -# to the appropriate BeeDeeM program: install.sh, query.sh -# or annotate.sh. Please refer to these programs to review -# their expected arguments. +# to the appropriate BeeDeeM program: install.sh, query.sh, +# annotate.sh or info.sh. Please refer to these programs to +# review their expected arguments. # # Copyright (c) 2017, Patrick G. Durand # ======================================================================================== @@ -50,6 +50,9 @@ case "$COMMAND" in annotate) . /opt/beedeem/annotate.sh $ALL_ARGS ;; + info) + . /opt/beedeem/info.sh + ;; esac exit 0 diff --git a/scripts/deploy-std.xml b/scripts/deploy-std.xml index b73e55b..662c2c9 100755 --- a/scripts/deploy-std.xml +++ b/scripts/deploy-std.xml @@ -87,7 +87,8 @@ - + + @@ -138,6 +139,10 @@ + + + + @@ -170,6 +175,10 @@ + + + + diff --git a/scripts/info.bat b/scripts/info.bat new file mode 100755 index 0000000..09eb3a3 --- /dev/null +++ b/scripts/info.bat @@ -0,0 +1,45 @@ +@echo off + +rem +rem DBMS program to list installed banks ; for Windows +rem Copyright (c) - Patrick G. Durand, 2007-2017 +rem ------------------------------------------------------------------- +rem User manual: +rem https://pgdurand.gitbooks.io/beedeem/ +rem ------------------------------------------------------------------- +rem The program can be used to list installed banks. +rem +rem In addition, some parameters can be passed to the JVM for special +rem configuration purposes: +rem -DKL_DEBUG=true ; if true, if set, log will be in debug mode +rem -DKL_WORKING_DIR=an_absolute_path ; if not set, log and working +rem directories are set to java.io.tmp +rem -DKL_LOG_FILE=a_file_name ; if set, creates a log file with that +rem name within KL_WORKING_DIR + +set CUR_DIR=%cd% + +rem *** Application home +set KL_APP_HOME=@KL_INSTALL_DIR@ + +rem *** Working directory +set KL_WORKING_DIR=@KL_WORKING_DIR@ + +rem *** Java VM +set JAVA_HOME=@JAVA_ROOT_DIR@ +set KL_JAVA_VM=%JAVA_HOME%\bin\java +set KL_JAVA_ARGS=-Xms128M -Xmx1024M -DKL_HOME="%KL_APP_HOME%" -DKL_WORKING_DIR="%KL_WORKING_DIR%" + +rem *** Create classpath +SETLOCAL ENABLEDELAYEDEXPANSION +set FILES= +set BIN_HOME=%KL_APP_HOME%\\bin +cd %BIN_HOME% +for /F %%f in ('dir /b *.jar') do set FILES=!FILES!;%KL_APP_HOME%\\bin\\%%f + +rem *** Start application +cd %CUR_DIR% +"%KL_JAVA_VM%" %KL_JAVA_ARGS% -classpath "%FILES%" bzh.plealog.dbmirror.main.DumpBankList + +rem *** do not leave immediately (to check potential cmd line messages coming from the application) +pause diff --git a/scripts/info.sh b/scripts/info.sh new file mode 100755 index 0000000..3c629bd --- /dev/null +++ b/scripts/info.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# +# DBMS program to list installed banks ; for Unix +# Copyright (c) - Patrick G. Durand, 2007-2017 +# ------------------------------------------------------------------- +# User manual: +# https://pgdurand.gitbooks.io/beedeem/ +# ------------------------------------------------------------------- +# The program can be used to list installed banks. +# +# In addition, some parameters can be passed to the JVM for special +# configuration purposes:
+# -DKL_DEBUG=true ; if true, if set, log will be in debug mode
+# -DKL_WORKING_DIR=an_absolute_path ; if not set, log and working +# directories are set to java.io.tmp
+# -DKL_LOG_FILE=a_file_name ; if set, creates a log file with that +# name within KL_WORKING_DIR

+ +# *** Application home +KL_APP_HOME=@KL_INSTALL_DIR@ + +# *** Working directory +KL_WORKING_DIR=@KL_WORKING_DIR@ + +# *** Java VM +JAVA_HOME=@JAVA_ROOT_DIR@ +KL_JAVA_VM=$JAVA_HOME/bin/java +KL_JAVA_ARGS="@JAVA_ARGS@ -DKL_HOME=$KL_APP_HOME -DKL_WORKING_DIR=$KL_WORKING_DIR" + +# *** JARs section +KL_JAR_LIST_TMP=`\ls $KL_APP_HOME/bin/*.jar` +KL_JAR_LIST=`echo $KL_JAR_LIST_TMP | sed 's/ /:/g'` + +# *** start application +KL_APP_MAIN_CLASS=bzh.plealog.dbmirror.main.DumpBankList +$KL_JAVA_VM $KL_JAVA_ARGS -classpath $KL_JAR_LIST $KL_APP_MAIN_CLASS diff --git a/src/bzh/plealog/dbmirror/main/DumpBankList.java b/src/bzh/plealog/dbmirror/main/DumpBankList.java new file mode 100644 index 0000000..649c581 --- /dev/null +++ b/src/bzh/plealog/dbmirror/main/DumpBankList.java @@ -0,0 +1,308 @@ +/* Copyright (C) 2007-2017 Patrick G. Durand + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/agpl-3.0.txt + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + */ +package bzh.plealog.dbmirror.main; + +import java.io.BufferedWriter; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tools.ant.util.LinkedHashtable; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.RuntimeConstants; + +import bzh.plealog.dbmirror.util.Utils; +import bzh.plealog.dbmirror.util.conf.Configuration; +import bzh.plealog.dbmirror.util.conf.DBMSAbstractConfig; +import bzh.plealog.dbmirror.util.conf.DBMirrorConfig; +import bzh.plealog.dbmirror.util.descriptor.DBDescriptor; +import bzh.plealog.dbmirror.util.descriptor.DBDescriptorUtils; +import bzh.plealog.dbmirror.util.descriptor.DatabankDescriptor; +import bzh.plealog.dbmirror.util.descriptor.IdxDescriptor; +import bzh.plealog.dbmirror.util.log.LoggerCentral; + +import com.plealog.genericapp.api.log.EZLogger; + +/** + * This is the class to use to report the list of installed banks. Accepted + * arguments are:
+ * -d type of repository. One of: n, p, b, all. Default is: all.
+ * -f format. One of: txt, html. Default is: txt.
+ * In addition, some parameters can be passed to the JVM for special + * configuration purposes:
+ * -DKL_HOME=an_absolute_path ; the absolute path to the KDMS installation home + * dir. If not set, use user.dir java property. -DKL_DEBUG=true ; if true, if + * set, log will be in debug mode
+ * -DKL_WORKING_DIR=an_absolute_path ; if not set, log and working diretories + * are set to java.io.tmp
+ * -DKL_LOG_FILE=a_file_name ; if set, creates a log file with that name within + * KL_WORKING_DIR
+ *
+ * + * @author Patrick G. Durand + */ +public class DumpBankList { + public static final String DB_ARG = "d"; + public static final String FT_ARG = "f"; + + private static final Log LOGGER = LogFactory + .getLog(DBMSAbstractConfig.KDMS_ROOTLOG_CATEGORY + + ".DumpBankList"); + + /** + * Print program usage. + */ + private void printUsage() { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp("DumpBankList", getCmdLineOptions()); + } + + /** + * handle command-line arguments. + */ + public CommandLine handleArguments(String[] args) { + Options options; + GnuParser parser; + CommandLine line = null; + + options = getCmdLineOptions(); + try { + parser = new GnuParser(); + line = parser.parse(options, args); + } catch (Exception exp) { + LOGGER.warn("invalid command-line:" + exp); + printUsage(); + line = null; + } + return line; + } + + /** + * Setup the valid command-line of the application. + */ + private static Options getCmdLineOptions() { + Options opts; + + opts = new Options(); + opts.addOption(DB_ARG, true, + "type of repository. One of: n, p, b, all. Default is: all."); + opts.addOption(FT_ARG, true, "format. One of: txt, html. Default is: txt."); + return opts; + } + + /** + * Get repository for which we have to report bank list. Default is all. + */ + private static String getDatabaseType(CommandLine cmdLine) { + String val = cmdLine.getOptionValue(DB_ARG); + return val == null ? "all" : val; + } + + /** + * Get format to use to report bank list. Default is txt. + */ + private static String getFormatType(CommandLine cmdLine) { + String val = cmdLine.getOptionValue(FT_ARG); + return val == null ? "txt" : val; + } + + /** + * Prepare the bank list for a given type. + */ + private static List getMirrorDBList(DBDescriptor.TYPE type) { + String dbMirrorConfFile = DBMSAbstractConfig.getLocalMirrorConfFile(); + DBMirrorConfig conf = DBDescriptorUtils.getDBMirrorConfig(dbMirrorConfFile); + List dbList = new ArrayList(); + + for (IdxDescriptor descriptor : DBDescriptorUtils.getDBList(conf, type, + true)) { + try { + dbList.add(new DatabankDescriptor(descriptor)); + } catch (Exception ex) { + EZLogger.warn("Unable to read databank " + + (descriptor != null ? descriptor.getName() : "") + " : " + + ex.getMessage()); + } + } + + return dbList; + } + + /** + * Update annotated status of dbList. + */ + private static void setAnnotatedStatus(List dbList, Set annotatedBanks){ + for(DatabankDescriptor dd : dbList){ + dd.setHasAnnotation(annotatedBanks.contains(dd.getName())); + } + } + + /** + * Return set of names of annotated banks. + */ + private Set getAnnotatedBanks(){ + HashSet annotatedBanks = new HashSet<>(); + List dbList; + + dbList = getMirrorDBList(DBDescriptor.TYPE.proteic); + for(DatabankDescriptor dd : dbList){ + annotatedBanks.add(dd.getName()); + } + dbList = getMirrorDBList(DBDescriptor.TYPE.nucleic); + for(DatabankDescriptor dd : dbList){ + annotatedBanks.add(dd.getName()); + } + return annotatedBanks; + } + /** + * Compute cumulative bank size for the entire repository. + */ + private long countSize(long curSize, List dbList){ + for(DatabankDescriptor dd : dbList){ + curSize += dd.getDiskSizeL(); + } + return curSize; + } + + /** + * Run job. + */ + private void doJob(String[] args) { + VelocityEngine ve; + VelocityContext context; + Template t; + StringWriter writer; + String db, ft; + CommandLine cmdLine; + List emptyList = new ArrayList(); + List dbList; + long dbTotalSize = 0l; + + // Configure software + StarterUtils.configureApplication(null, "DumpBankList", true, false, true); + + // Get version info + Properties props = StarterUtils.getVersionProperties(); + + // Handle command-line + cmdLine = handleArguments(args); + db = getDatabaseType(cmdLine); + ft = getFormatType(cmdLine); + + // Setup Maps to be used with Velocity Template engine + LinkedHashtable mdserverinfo = new LinkedHashtable(); + LinkedHashtable config = new LinkedHashtable(); + LinkedHashtable dbs2 = new LinkedHashtable(); + Set annotatedBanks = getAnnotatedBanks(); + + // Report software configuration + config.put( + "name", + props.getProperty("prg.app.name") + " - " + + props.getProperty("prg.version")); + config.put("instpath", DBMSAbstractConfig.getInstallAppPath()); + config.put("instconfpath", StarterUtils.getConfPath() + + DBMSAbstractConfig.MASTER_CONF_FILE); + config.put("wkpath", DBMSAbstractConfig.getWorkingPath()); + config.put("logpath", DBMSAbstractConfig.getLogAppPath()); + config.put("confpath", DBMSAbstractConfig.getLocalMirrorConfFile()); + config.put("dbpath", DBMSAbstractConfig.getLocalMirrorPath()); + + // Report bank list + if ("all".equals(db)) { + // all + dbList = getMirrorDBList(DBDescriptor.TYPE.blastn); + setAnnotatedStatus(dbList, annotatedBanks); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_n", dbList); + dbList = getMirrorDBList(DBDescriptor.TYPE.blastp); + setAnnotatedStatus(dbList, annotatedBanks); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_p", dbList); + dbList = getMirrorDBList(DBDescriptor.TYPE.dico); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_d", dbList); + } else if ("n".equals(db)) { + // only nucleotide + dbList = getMirrorDBList(DBDescriptor.TYPE.blastn); + setAnnotatedStatus(dbList, annotatedBanks); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_n", dbList); + dbs2.put("mirror_p", emptyList); + dbs2.put("mirror_d", emptyList); + } else if ("p".equals(db)) { + // only protein + dbList = getMirrorDBList(DBDescriptor.TYPE.blastp); + setAnnotatedStatus(dbList, annotatedBanks); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_p", dbList); + dbs2.put("mirror_n", emptyList); + dbs2.put("mirror_d", emptyList); + } else if ("b".equals(db)) { + // only biological classification + dbList = getMirrorDBList(DBDescriptor.TYPE.dico); + dbTotalSize = countSize(dbTotalSize, dbList); + dbs2.put("mirror_d", dbList); + dbs2.put("mirror_n", emptyList); + dbs2.put("mirror_p", emptyList); + } + + config.put("reposize", Utils.getBytes(dbTotalSize)); + mdserverinfo.put("config", config); + mdserverinfo.put("databases2", dbs2); + + // Setup Velocity Engine + ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, + "org.apache.velocity.runtime.log.NullLogSystem"); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, + DBMSAbstractConfig.getInstallAppConfPath(Configuration.SYSTEM)); + + // Run Velocity Engine + try (BufferedWriter outWriter = new BufferedWriter(new OutputStreamWriter( + System.out))) { + ve.init(); + // Velocity template is taken from "conf/system" directory. + // One can see that Velocity template name is generated using + // value of cmdline argument "-f" + t = ve.getTemplate(String.format("dbmsVersion-%s.vm", ft)); + context = new VelocityContext(); + context.put("bdminfo", mdserverinfo); + writer = new StringWriter(); + t.merge(context, writer); + outWriter.write(writer.toString()); + } catch (Exception e) { + LoggerCentral.warn(LOGGER, e.toString()); + } + } + + public static void main(String[] args) { + new DumpBankList().doJob(args); + } +} diff --git a/src/bzh/plealog/dbmirror/main/StarterUtils.java b/src/bzh/plealog/dbmirror/main/StarterUtils.java index 9784d8e..b3d7d01 100755 --- a/src/bzh/plealog/dbmirror/main/StarterUtils.java +++ b/src/bzh/plealog/dbmirror/main/StarterUtils.java @@ -18,6 +18,8 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,7 +43,22 @@ public class StarterUtils { private static final String ERR1 = "Unable to load network config: "; private static final String USER_DIR = "user.dir"; - private static String getConfPath() { + /** + * Return the content of the version resource. + */ + protected static Properties getVersionProperties() { + Properties props = new Properties(); + try (InputStream in = StarterUtils.class + .getResourceAsStream("version.properties");) { + props.load(in); + in.close(); + } catch (Exception ex) {// should not happen + System.err.println("Unable to read props: " + ex.toString()); + } + return props; + } + + protected static String getConfPath() { String path; /* @@ -52,7 +69,7 @@ private static String getConfPath() { path = Utils.terminatePath(path); else path = Utils.terminatePath(System.getProperty(USER_DIR)); - path += ("conf" + File.separator); + path += (DBMSAbstractConfig.CONF_PATH_NAME + File.separator); return path; } diff --git a/src/bzh/plealog/dbmirror/main/UiInstaller.java b/src/bzh/plealog/dbmirror/main/UiInstaller.java index d7d75ca..7e0970b 100644 --- a/src/bzh/plealog/dbmirror/main/UiInstaller.java +++ b/src/bzh/plealog/dbmirror/main/UiInstaller.java @@ -20,7 +20,6 @@ import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.io.InputStream; import java.util.Properties; import java.util.ResourceBundle; @@ -38,27 +37,13 @@ import com.plealog.genericapp.api.EZUIStarterListener; public class UiInstaller { - /** - * Return the content of the version resource. - */ - private static Properties getVersionProperties() { - Properties props = new Properties(); - try (InputStream in = UiInstaller.class - .getResourceAsStream("version.properties");) { - props.load(in); - in.close(); - } catch (Exception ex) {// should not happen - System.err.println("Unable to read props: " + ex.toString()); - } - return props; - } public static void main(String[] args) { // This has to be done at the very beginning, i.e. first method call within // main(). EZGenericApplication.initialize("DB-Manager"); // Add application branding - Properties props = UiInstaller.getVersionProperties(); + Properties props = StarterUtils.getVersionProperties(); EZApplicationBranding.setAppName(props.getProperty("prg.app.name")); EZApplicationBranding.setAppVersion(props.getProperty("prg.version")); EZApplicationBranding.setCopyRight(props.getProperty("prg.copyright")); diff --git a/src/bzh/plealog/dbmirror/main/version.properties b/src/bzh/plealog/dbmirror/main/version.properties index 5227eef..1163779 100644 --- a/src/bzh/plealog/dbmirror/main/version.properties +++ b/src/bzh/plealog/dbmirror/main/version.properties @@ -3,7 +3,7 @@ prg.name=beedeem # UI name prg.app.name=BeeDeeM # release prior to 4: KoriBlast/ngKLAST suite of software -prg.version=4.0.0 +prg.version=4.1.0 # Who did what and when prg.copyright=(c) 2007-2017, Patrick G. Durand - Ludovic Antin prg.provider=Plealog diff --git a/src/bzh/plealog/dbmirror/ui/resources/messages.properties b/src/bzh/plealog/dbmirror/ui/resources/messages.properties index 0cf5950..ac1ed29 100755 --- a/src/bzh/plealog/dbmirror/ui/resources/messages.properties +++ b/src/bzh/plealog/dbmirror/ui/resources/messages.properties @@ -229,13 +229,13 @@ KDMSPanel.msg10=This panel reports the Biological Classifications that are used KDMSPanel.msg2=Databank Sources KDMSPanel.msg3=Installed databanks KDMSPanel.msg4=Personal Databanks -KDMSPanel.msg5=Sequence Annotations +KDMSPanel.msg5=Annotated databanks KDMSPanel.msg6=BLAST databanks KDMSPanel.msg7=Biological Classifications KDMSPanel.msg8=This panel reports the databanks that can be used to retrieve sequence annotations (such as features, taxonomy, DB cross-references, etc). During a data retrieval processing, these databanks are queried by order of appearance in this list\: use the up/down arrow buttons to change the databank query ordering. KDMSPanel.msg9=This panel reports the databanks that can be used to run a BLAST search on your local computer. KdmsUI.appname=BeeDeeM -KdmsUI.version=4.0.0 +KdmsUI.version=4.1.0 KdmsUI.msg1=Would like to quit ? LocalIndexInstallPanel.dlg.header=Add a BLAST Databank LocalIndexInstallPanel.format.err1=Your file is not a BLAST databank.\nIt seems to be a {0} file. diff --git a/src/bzh/plealog/dbmirror/util/descriptor/DatabankDescriptor.java b/src/bzh/plealog/dbmirror/util/descriptor/DatabankDescriptor.java new file mode 100755 index 0000000..76a7c69 --- /dev/null +++ b/src/bzh/plealog/dbmirror/util/descriptor/DatabankDescriptor.java @@ -0,0 +1,149 @@ +/* Copyright (C) 2007-2017 Patrick G. Durand + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/agpl-3.0.txt + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + */ +package bzh.plealog.dbmirror.util.descriptor; + +import java.io.File; +import java.io.Serializable; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; +import java.util.Properties; + +import org.apache.commons.io.FileUtils; + +import bzh.plealog.dbmirror.util.Utils; +import bzh.plealog.dbmirror.util.conf.DBMSAbstractConfig; +import bzh.plealog.dbmirror.util.descriptor.DBDescriptor.TYPE; +import bzh.plealog.dbmirror.util.runner.DBStampProperties; + +/** + * This class is used to expose IdxDescriptor to Velocity Templates. + * + * @author Patrick G. Durand + */ +public class DatabankDescriptor implements Serializable { + private static final long serialVersionUID = 5222950557207540653L; + + private String _name; + private String _dbPath; + private String _code; + private String _description; + private String _type; + private String _nbSequence; + private String _diskSize; + private String _timeStamp; + private long _diskSizeL; + private boolean hasAnnotation = false; + + private NumberFormat numFormatter = DecimalFormat + .getInstance(Locale.ENGLISH); + + public DatabankDescriptor(IdxDescriptor descriptor) { + _name = descriptor.getName(); + _dbPath = descriptor.getCode(); + _description = descriptor.getDescription(); + _code = descriptor.getKbCode(); + + if (descriptor.getType().equals(TYPE.blastn) || descriptor.getType().equals(TYPE.nucleic)) + _type = "N"; + else if (descriptor.getType().equals(TYPE.blastp) || descriptor.getType().equals(TYPE.proteic)) + _type = "P"; + else if (descriptor.getType().equals(TYPE.dico)) + _type = "D"; + + String directory = new File(_dbPath).getParent(); + Properties props = DBMSAbstractConfig.readDBStamp(directory); + + _timeStamp = props.getProperty(DBStampProperties.TIME_STAMP); + + if (_type.equals("D")) + _nbSequence = numFormatter.format(Long.valueOf(props + .getProperty(DBStampProperties.NB_ENTRIES))); + else + _nbSequence = numFormatter.format(Long.valueOf(props + .getProperty(DBStampProperties.NB_SEQUENCES))); + _diskSizeL = FileUtils.sizeOfDirectory(new File(directory)); + _diskSize = Utils.getBytes(_diskSizeL); + } + + /** + * @return the _nbSequence + */ + public String getNbSequence() { + return _nbSequence; + } + + /** + * @return the _dbPath + */ + public String getDbPath() { + return _dbPath; + } + + /** + * @return the _code + */ + public String getCode() { + return _code; + } + + /** + * @return the _type + */ + public String getType() { + return _type; + } + + /** + * @return the _name + */ + public String getName() { + return _name; + } + + /** + * @return the _description + */ + public String getDescription() { + return _description; + } + + /** + * @return the _diskSize + */ + public String getDiskSize() { + return _diskSize; + } + + public long getDiskSizeL() { + return _diskSizeL; + } + + public boolean hasAnnotation() { + return hasAnnotation; + } + + public void setHasAnnotation(boolean hasAnnotation) { + this.hasAnnotation = hasAnnotation; + } + + public String getTimeStamp() { + return _timeStamp; + } + + +}