Commits

YOUNG-SUK LEE committed 638dee0 Merge

merge

  • Participants
  • Parent commits 611be08, c569352

Comments (0)

Files changed (73)

 # Gengetopt is required to update cmdline.c and cmdline.h (in tools) if out of date.
 #! CFLAGS assumes headers in same directory as binaries for installed
 AC_ARG_WITH([gengetopt],
-	[AS_HELP_STRING([--with-gengetopt=PATH], [prefix of gengetopt installation])],
-	[
-	  if test "x$with_gengetopt" = "xyes"; then
-	    with_gengetopt=check
-	  elif test "x$with_gengetopt" = "xno"; then
-	    with_gengetopt = no
+        [AS_HELP_STRING([--with-gengetopt=PATH], [prefix of gengetopt installation])],
+        [
+          if test "x$with_gengetopt" = "xyes"; then
+            with_gengetopt=check
+          elif test "x$with_gengetopt" = "xno"; then
+            with_gengetopt = no
           else
-	    qualify_path with_gengetopt
-	  fi
-	],
-	[with_gengetopt=check])
+            qualify_path with_gengetopt
+          fi
+        ],
+        [with_gengetopt=check])
 LOCAL_PATH_PROG([gengetopt], [gengetopt],
         [GENGETOPT_PREFIX=$prog_gengetopt_prefix
          GENGETOPT_INCLUDES="-I${GENGETOPT_PREFIX}/include"],  dnl found
         [],                                                    dnl found installed
-	[],                                                    dnl found in with path
-	[],                                                    dnl not found
+        [],                                                    dnl found in with path
+        [],                                                    dnl not found
         [])                                                    dnl requested without
 ## set CFLAGS and LIBS
 if test "x$GENGETOPT_PREFIX" != "x"; then
 # If not specified, check for it.
 # If no readline, do not build OntoShell.
 AC_ARG_WITH([readline],
-	[AS_HELP_STRING([--with-readline=PATH], [prefix of readline installation])],
-	[
+        [AS_HELP_STRING([--with-readline=PATH], [prefix of readline installation])],
+        [
          if test "x$with_readline" = "xyes"; then
-	   readline_state=check
+           readline_state=check
          elif test "x$with_readline" != "xno"; then
            readline_state=try
-	   qualify_path with_readline
+           qualify_path with_readline
            LOCAL_CHECK_APPEND_PATHS([$with_readline], [. include], [readline/readline.h], [READLINE_INCLUDE_DIR], [readline_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_readline], [. lib], [libreadline.a], [READLINE_LIB_DIR], [readline_state=warn])
          else
            readline_state=no
          fi
         ],
-	[readline_state=check])
+        [readline_state=check])
 AC_LANG_PUSH([C])
 LOCAL_CHECK_LIB([readline], [readline], [readline("foo")],
-	[readline_state=ok],                                       dnl found
-	[READLINE_LIBS="-lreadline -lncurses"],                    dnl and found installed
-	[
-	  READLINE_CFLAGS="-I $READLINE_INCLUDE_DIR"
-	  READLINE_LIBS="-L $READLINE_LIB_DIR -lreadline -lncurses"
-	],                                                         dnl and found in specified path
-	[],                                                        dnl not found
+        [readline_state=ok],                                       dnl found
+        [READLINE_LIBS="-lreadline -lncurses"],                    dnl and found installed
+        [
+          READLINE_CFLAGS="-I $READLINE_INCLUDE_DIR"
+          READLINE_LIBS="-L $READLINE_LIB_DIR -lreadline -lncurses"
+        ],                                                         dnl and found in specified path
+        [],                                                        dnl not found
         [readline_state=no],                                       dnl and not found installed
         [readline_state=warn],                                     dnl and not found in specified path
-	[],                                                        dnl requested without
-	[#include <stdio.h>
-	 #include "readline/readline.h"],	
-	[-lncurses],
-	[-L $READLINE_LIB_DIR -I $READLINE_INCLUDE_DIR])
+        [],                                                        dnl requested without
+        [#include <stdio.h>
+         #include "readline/readline.h"],
+        [-lncurses],
+        [-L $READLINE_LIB_DIR -I $READLINE_INCLUDE_DIR])
 AC_LANG_POP
 if test "x$readline_state" != "xok"; then
   AC_DEFINE([NO_READLINE], [1])
 #  # hopefully this is an unusual exception
 #  AC_LINK_IFELSE(
 #    [AC_LANG_PROGRAM([#include <stdio.h>
-#		      #include "readline/readline.h"],
-#		      [rl_completion_matches])],
+#                     #include "readline/readline.h"],
+#                     [rl_completion_matches])],
 #    [],
 #    [AC_DEFINE([rl_completion_matches], [completion_matches])])
 #AC_SUBST(READLINE_PREFIX)
 # If not specified, check for it.
 # If no readline, do not build OntoShell.
 AC_ARG_WITH([pthread],
-	[AS_HELP_STRING([--with-pthread=PATH], [prefix of pthread installation])],
-	[
+        [AS_HELP_STRING([--with-pthread=PATH], [prefix of pthread installation])],
+        [
          if test "x$with_pthread" = "xyes"; then
-	   pthread_state=check
+           pthread_state=check
          elif test "x$with_pthread" != "xno"; then
            pthread_state=try
-	   qualify_path with_pthread
+           qualify_path with_pthread
            LOCAL_CHECK_APPEND_PATHS([$with_pthread], [. include], [pthread.h], [PTHREAD_INCLUDE_DIR], [pthread_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_pthread], [. lib], [libpthread.a], [PTHREAD_LIB_DIR], [pthread_state=warn])
          else
            pthread_state=no
          fi
         ],
-	[pthread_state=check])
+        [pthread_state=check])
 AC_LANG_PUSH([C])
 LOCAL_CHECK_LIB([pthread], [pthread], [pthread_create],
-	[pthread_state=ok],                                        dnl found
-	[PTHREAD_LIBS="-lpthread"],                                dnl and found installed
-	[
-	  PTHREAD_CFLAGS="-I $PTHREAD_INCLUDE_DIR"
-	  PTHREAD_LIBS="-L $PTHREAD_LIB_DIR -lpthread"
-	],                                                         dnl and found in specified path
-	[],                                                        dnl not found
+        [pthread_state=ok],                                        dnl found
+        [PTHREAD_LIBS="-lpthread"],                                dnl and found installed
+        [
+          PTHREAD_CFLAGS="-I $PTHREAD_INCLUDE_DIR"
+          PTHREAD_LIBS="-L $PTHREAD_LIB_DIR -lpthread"
+        ],                                                         dnl and found in specified path
+        [],                                                        dnl not found
         [pthread_state=no],                                        dnl and not found installed
         [pthread_state=warn],                                      dnl and not found in specified path
-	[],                                                        dnl requested without
-	[#include <stdio.h>
-	 #include "pthread.h"],	
-	[],
-	[-L $PTHREAD_LIB_DIR -I $PTHREAD_INCLUDE_DIR])
+        [],                                                        dnl requested without
+        [#include <stdio.h>
+         #include "pthread.h"],
+        [],
+        [-L $PTHREAD_LIB_DIR -I $PTHREAD_INCLUDE_DIR])
 AC_LANG_POP
 if test "x$pthread_state" != "xok"; then
   AC_DEFINE([NO_PTHREAD], [1])
   log4cpp_state=no
 else
 AC_ARG_WITH([log4cpp],
-	[AS_HELP_STRING([--with-log4cpp=PATH], [prefix of log4cpp installation or build directory])],
-	[
+        [AS_HELP_STRING([--with-log4cpp=PATH], [prefix of log4cpp installation or build directory])],
+        [
          if test "x$with_log4cpp" = "xyes"; then
            log4cpp_state=check
          elif test "x$with_log4cpp" != "xno"; then
            log4cpp_state=try
-	   qualify_path with_log4cpp
+           qualify_path with_log4cpp
            LOCAL_CHECK_APPEND_PATHS([$with_log4cpp], [. include], [log4cpp/Category.hh], [LOG4CPP_INCLUDE_DIR], [log4cpp_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_log4cpp], [. lib src/.libs], [liblog4cpp.a], [LOG4CPP_LIB_DIR], [log4cpp_state=warn])
          else
            log4cpp_state=no
          fi
         ],
-	[log4cpp_state=check])
+        [log4cpp_state=check])
 LOCAL_CHECK_LIB([log4cpp], [log4cpp], [log4cpp::Category::getInstance("foo")],
         [log4cpp_state=ok],                                       dnl found
         [LOG4CPP_LIBS="-llog4cpp"],                               dnl and found installed
          LOG4CPP_CFLAGS="-I $LOG4CPP_INCLUDE_DIR"
          LOG4CPP_LIBS="-L $LOG4CPP_LIB_DIR -llog4cpp"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [log4cpp_state=no],                                       dnl and not found installed
         [log4cpp_state=warn],                                     dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include "log4cpp/Category.hh"],
+        [#include "log4cpp/Category.hh"],
         [-lpthread],
         [-L $LOG4CPP_LIB_DIR -I $LOG4CPP_INCLUDE_DIR])
 fi
 USE_OPENMP=true
 sleipnir_cv_openmp=yes
 AC_ARG_ENABLE(openmp,
-	[AS_HELP_STRING([--disable-openmp],
-	[disable OpenMP SMP multi-threading])],
-	[if test "$enableval" = no; then sleipnir_cv_openmp=no; USE_OPENMP=false; fi], [])
+        [AS_HELP_STRING([--disable-openmp],
+        [disable OpenMP SMP multi-threading])],
+        [if test "$enableval" = no; then sleipnir_cv_openmp=no; USE_OPENMP=false; fi], [])
 if $USE_OPENMP; then
-	dnl case "$canonical_host_type" in
-	dnl	*-*-mingw* | *-*-cygwin* | *-*-gnu*)
-		AC_MSG_CHECKING([for support of OpenMP])
-		XCFLAGS="$CFLAGS"
-		CFLAGS="$CFLAGS -fopenmp"
-		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-			#include <omp.h>
-			#include <stdio.h>
-		]], [[
-			  _Pragma("omp parallel")  
-			  printf("Hello, world.\n");
-			  return 0;
-			]])],sleipnir_cv_openmp=yes, sleipnir_cv_openmp=no)
-		dnl AC_MSG_FAILURE([Error has occurred])
-		AC_MSG_RESULT([$sleipnir_cv_openmp])
-			if test "$sleipnir_cv_openmp" = yes; then
-			  AC_DEFINE(HAVE_OPENMP,1,[Define if compiler supports OpenMP])
-			  CXXFLAGS="$CXXFLAGS -fopenmp"
-			  USE_OPENMP=true
-			else
-			  CFLAGS="$XCFLAGS"
-			  USE_OPENMP=false
-			fi
-			dnl SLEIPNIR_CHECK_OPENMP(-fopenmp)
-	dnl	;;
-	dnl	*-*-msdosmsvc)
-	dnl	## FIXME is this the right flag for MSVC?
-	dnl	SLEIPNIR_CHECK_OPENMP(-openmp)
-	dnl	;;
-	dnl	## Add other compilers supporting OpenMP here
-	dnl #esac
+        dnl case "$canonical_host_type" in
+        dnl	*-*-mingw* | *-*-cygwin* | *-*-gnu*)
+                AC_MSG_CHECKING([for support of OpenMP])
+                XCFLAGS="$CFLAGS"
+                CFLAGS="$CFLAGS -fopenmp"
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+                        #include <omp.h>
+                        #include <stdio.h>
+                ]], [[
+                          _Pragma("omp parallel")
+                          printf("Hello, world.\n");
+                          return 0;
+                        ]])],sleipnir_cv_openmp=yes, sleipnir_cv_openmp=no)
+                dnl AC_MSG_FAILURE([Error has occurred])
+                AC_MSG_RESULT([$sleipnir_cv_openmp])
+                        if test "$sleipnir_cv_openmp" = yes; then
+                          AC_DEFINE(HAVE_OPENMP,1,[Define if compiler supports OpenMP])
+                          CXXFLAGS="$CXXFLAGS -fopenmp"
+                          USE_OPENMP=true
+                        else
+                          CFLAGS="$XCFLAGS"
+                          USE_OPENMP=false
+                        fi
+                        dnl SLEIPNIR_CHECK_OPENMP(-fopenmp)
+        dnl	;;
+        dnl	*-*-msdosmsvc)
+        dnl	## FIXME is this the right flag for MSVC?
+        dnl	SLEIPNIR_CHECK_OPENMP(-openmp)
+        dnl	;;
+        dnl	## Add other compilers supporting OpenMP here
+        dnl #esac
 fi
 
 #
 # Also check for libsmilexml.a and define SMILEXML_LIB if found (not used?)
 # If none, set NO_SMILE=1.
 AC_ARG_WITH([smile],
-	[AS_HELP_STRING([--with-smile=PATH], [prefix of SMILE installation])],
-	[
+        [AS_HELP_STRING([--with-smile=PATH], [prefix of SMILE installation])],
+        [
         if test "x$with_smile" = "xyes"; then
             smile_state=check
         elif test "x$with_smile" != "xno"; then
             smile_state=try
-	        qualify_path with_smile
+                qualify_path with_smile
             LOCAL_CHECK_APPEND_PATHS([$with_smile], [. include smile include/smile], [smile.h], [SMILE_INCLUDE_DIR], [smile_state=warn])
             LOCAL_CHECK_APPEND_PATHS([$with_smile], [. lib smile], [libsmile.a], [SMILE_LIB_DIR], [smile_state=warn])
         else
             smile_state=no
         fi
     ],
-	[smile_state=check])
-	LOCAL_CHECK_LIB([smile], [smile], [DSL_isFinite(1.0)],
-	
+        [smile_state=check])
+        LOCAL_CHECK_LIB([smile], [smile], [DSL_isFinite(1.0)],
+
     [smile_state=ok],                                         dnl found
     [
-	    SMILE_LIBS="-lsmile"
+            SMILE_LIBS="-lsmile"
         #SMILEXML_LIB
-	],                                                       dnl and found installed
+        ],                                                       dnl and found installed
         [
 #    if test -f "$SMILE_LIB_DIR/libsmilexml.a"; then
 #      AC_DEFINE([SMILEXML_LIB], [1])
 #         SMILE_LIBS="-L $SMILE_LIB_DIR $SMILEXML_LIB -lsmile"
          SMILE_LIBS="-L $SMILE_LIB_DIR -lsmile"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
     [smile_state=no],                                         dnl and not found installed
     [smile_state=warn],                                       dnl and not found in specified path
     [],                                                       dnl requested without
-	[#include "smile.h"],
+        [#include "smile.h"],
     [],
     [-L $SMILE_LIB_DIR -I $SMILE_INCLUDE_DIR])
 if test "x$smile_state" != "xok"; then
          elif test "x$with_libsvm" != "xno"; then
            libsvm_state=try
            qualify_path with_libsvm
-	   LOCAL_CHECK_APPEND_PATHS([$with_libsvm], [. include], [libsvm/svm.h], [LIBSVM_INCLUDE_DIR], [libsvm_state=warn])
+           LOCAL_CHECK_APPEND_PATHS([$with_libsvm], [. include], [libsvm/svm.h], [LIBSVM_INCLUDE_DIR], [libsvm_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_libsvm], [. lib], [liblibsvm.a], [LIBSVM_LIB_DIR], [libsvm_state=warn])
          else
            libsvm_state=no
         [libsvm_state=warn],                                    dnl and not found in specified path
         [],                                                       dnl requested without
         [
-	 #include <sys/types.h>
+         #include <sys/types.h>
          #include "libsvm/svm.h"],
         [],
         [-L $LIBSVM_LIB_DIR -I $LIBSVM_INCLUDE_DIR])
 ## LOCAL_CHECK_LIB(1 lib name, 2 local name, 3 function,
-##   4 action if found, 
-##   5 extra action if found installed, 
+##   4 action if found,
+##   5 extra action if found installed,
 ##   6 extra action if found in 'with' path,
-##   7 action if not found, 
-##   8 action if not found installed, 
+##   7 action if not found,
+##   8 action if not found installed,
 ##   9 action if not found installed in 'with' path,
 ##   10 action if requested without,
 ##   11 headers, 12 extra libs
 # While checking, look for a source distribution in extlib/.
 # If none, set NO_SVM_PERF=1.
 AC_ARG_WITH([svm_perf],
-	[AS_HELP_STRING([--with-svm-perf=PATH], [prefix of SVM Perf installation])],
-	[
+        [AS_HELP_STRING([--with-svm-perf=PATH], [prefix of SVM Perf installation])],
+        [
          if test "x$with_svm_perf" = "xyes"; then
-	   svm_perf_state=check
+           svm_perf_state=check
          elif test "x$with_svm_perf" != "xno"; then
            svm_perf_state=try
-	   qualify_path with_svm_perf
+           qualify_path with_svm_perf
            LOCAL_CHECK_APPEND_PATHS([$with_svm_perf], [. include], [svm_struct_api.h], [SVM_PERF_INCLUDE_DIR], [svm_perf_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_svm_perf], [. lib], [libsvmperf.a], [SVM_PERF_LIB_DIR], [svm_perf_state=warn])
          else
            svm_perf_state=no
          fi
         ],
-	[svm_perf_state=check])
+        [svm_perf_state=check])
 AC_LANG_PUSH([C])
 LOCAL_CHECK_LIB([svmperf], [svm_perf], [optimize_svm],
         [svm_perf_state=ok],                                      dnl found
          SVM_PERF_CFLAGS="-I $SVM_PERF_INCLUDE_DIR"
          SVM_PERF_LIBS="-L $SVM_PERF_LIB_DIR -lsvmperf"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [svm_perf_state=no],                                      dnl and not found installed
         [svm_perf_state=warn],                                    dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include <sys/types.h>
-	 #include "svm_light/svm_common.h",
-	 #include "svm_light/svm_learn.h"],
+        [#include <sys/types.h>
+         #include "svm_light/svm_common.h",
+         #include "svm_light/svm_learn.h"],
         [],
         [-L $SVM_PERF_LIB_DIR -I $SVM_PERF_INCLUDE_DIR])
 AC_LANG_POP
 #AC_SUBST(SVM_PERF_PREFIX)
 AC_SUBST(SVM_PERF_CFLAGS)
 AC_SUBST(SVM_PERF_LIBS)
-#	 #include "svm/svm_struct_api.h"
-#	 #include "svm/svm_struct_api_types.h"],
+#        #include "svm/svm_struct_api.h"
+#        #include "svm/svm_struct_api_types.h"],
+
+## SVM MULTICLASS
+# If the user specifies a path, use it.
+# If the user says not to use it, then don't.
+# If the user doesn't specify anything, check for it.
+# While checking, look for a source distribution in extlib/.
+# If none, set NO_SVM_MULTICLASS=1.
+AC_ARG_WITH([svm_multiclass],
+  [AS_HELP_STRING([--with-svm-multiclass=PATH], [prefix of SVM Multiclass installation])],
+  [
+         if test "x$with_svm_multiclass" = "xyes"; then
+     svm_multiclass_state=check
+         elif test "x$with_svm_multiclass" != "xno"; then
+           svm_multiclass_state=try
+     qualify_path with_svm_multiclass
+           LOCAL_CHECK_APPEND_PATHS([$with_svm_multiclass], [. include], [svm_multiclass/svm_struct_api.h], [SVM_MULTICLASS_INCLUDE_DIR], [svm_multiclass_state=warn])
+           LOCAL_CHECK_APPEND_PATHS([$with_svm_multiclass], [. lib], [svm_multiclass/libsvmmulticlass.a], [SVM_MULTICLASS_LIB_DIR], [svm_multiclass_state=warn])
+         else
+           svm_multiclass_state=no
+         fi
+        ],
+  [svm_multiclass_state=check])
+AC_LANG_PUSH([C])
+LOCAL_CHECK_LIB([svmmulticlass], [svm_multiclass], [optimize_svm],
+        [svm_multiclass_state=ok],                                      dnl found
+        [SVM_MULTICLASS_LIBS="-lsvmmulticlass"],                              dnl and found installed
+        [
+         SVM_MULTICLASS_CFLAGS="-I $SVM_MULTICLASS_INCLUDE_DIR"
+         SVM_MULTICLASS_LIBS="-L $SVM_MULTICLASS_LIB_DIR/svm_multiclass -lsvmmulticlass"
+        ],                                                        dnl and found in specified path
+  [],                                                       dnl not found
+        [svm_multiclass_state=no],                                      dnl and not found installed
+        [svm_multiclass_state=warn],                                    dnl and not found in specified path
+        [],                                                       dnl requested without
+  [#include <sys/types.h>
+   #include "svm_light/svm_common.h",
+   #include "svm_light/svm_learn.h"],
+        [],
+        [-L $SVM_MULTICLASS_LIB_DIR/svm_multiclass -I $SVM_MULTICLASS_INCLUDE_DIR/svm_multiclass])
+AC_LANG_POP
+if test "x$svm_multiclass_state" != "xok"; then
+  AC_DEFINE([NO_SVM_MULTICLASS], [1])
+fi
+#AC_SUBST(SVM_MULTICLASS_PREFIX)
+AC_SUBST(SVM_MULTICLASS_CFLAGS)
+AC_SUBST(SVM_MULTICLASS_LIBS)
+#  #include "svm/svm_struct_api.h"
+#  #include "svm/svm_struct_api_types.h"],
+
+
+## SVM HIERARCHY
+# If the user specifies a path, use it.
+# If the user says not to use it, then don't.
+# If the user doesn't specify anything, check for it.
+# While checking, look for a source distribution in extlib/.
+# If none, set NO_SVM_HIERARCHY=1.
+AC_ARG_WITH([svm_hierarchy],
+  [AS_HELP_STRING([--with-svm-hierarchy=PATH], [prefix of SVM Hierarchy installation])],
+  [
+         if test "x$with_svm_hierarchy" = "xyes"; then
+     svm_hierarchy_state=check
+         elif test "x$with_svm_hierarchy" != "xno"; then
+           svm_hierarchy_state=try
+     qualify_path with_svm_hierarchy
+           LOCAL_CHECK_APPEND_PATHS([$with_svm_hierarchy], [. include], [svm_hierarchy/svm_struct_api.h], [SVM_HIERARCHY_INCLUDE_DIR], [svm_hierarchy_state=warn])
+           LOCAL_CHECK_APPEND_PATHS([$with_svm_hierarchy], [. lib], [svm_hierarchy/libsvmhierarchy.a], [SVM_HIERARCHY_LIB_DIR], [svm_hierarchy_state=warn])
+         else
+           svm_hierarchy_state=no
+         fi
+        ],
+  [svm_hierarchy_state=check])
+AC_LANG_PUSH([C])
+LOCAL_CHECK_LIB([svmhierarchy], [svm_hierarchy], [optimize_svm],
+        [svm_hierarchy_state=ok],                                      dnl found
+        [SVM_HIERARCHY_LIBS="-lsvmhierarchy"],                              dnl and found installed
+        [
+         SVM_HIERARCHY_CFLAGS="-I $SVM_HIERARCHY_INCLUDE_DIR"
+         SVM_HIERARCHY_LIBS="-L $SVM_HIERARCHY_LIB_DIR/svm_hierarchy -lsvmhierarchy"
+        ],                                                        dnl and found in specified path
+  [],                                                       dnl not found
+        [svm_hierarchy_state=no],                                      dnl and not found installed
+        [svm_hierarchy_state=warn],                                    dnl and not found in specified path
+        [],                                                       dnl requested without
+  [#include <sys/types.h>
+   #include "svm_light/svm_common.h",
+   #include "svm_light/svm_learn.h"],
+        [],
+        [-L $SVM_HIERARCHY_LIB_DIR/svm_hierarchy -I $SVM_HIERARCHY_INCLUDE_DIR/svm_hierarchy])
+AC_LANG_POP
+if test "x$svm_hierarchy_state" != "xok"; then
+  AC_DEFINE([NO_SVM_HIERARCHY], [1])
+fi
+#AC_SUBST(SVM_HIERARCHY_PREFIX)
+AC_SUBST(SVM_HIERARCHY_CFLAGS)
+AC_SUBST(SVM_HIERARCHY_LIBS)
+#  #include "svm/svm_struct_api.h"
+#  #include "svm/svm_struct_api_types.h"],
 
 
 ## BOOST
 # If not specified, check for it.
 # BOOST graph lib is required for BNServer.
 AC_ARG_WITH([boost],
-	[AS_HELP_STRING([--with-boost=PATH], [prefix of Boost installation])],
-	[ 
+        [AS_HELP_STRING([--with-boost=PATH], [prefix of Boost installation])],
+        [
          if test "x$with_boost" = "xyes"; then
-	   boost_state=check
+           boost_state=check
          elif test "x$with_boost" != "xno"; then
            boost_state=try
-	   qualify_path with_boost
+           qualify_path with_boost
            LOCAL_CHECK_APPEND_PATHS([$with_boost], [. .. include], [boost/graph/graphviz.hpp], [BOOST_INCLUDE_DIR], [boost_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_boost], [. lib stage/lib], [libboost_graph.a], [BOOST_GRAPH_LIB_DIR], [boost_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_boost], [. lib stage/lib], [libboost_regex.a], [BOOST_REGEX_LIB_DIR], [boost_state=warn])
            if test "x$BOOST_GRAPH_LIB_DIR" != "x$BOOST_REGEX_LIB_DIR"; then
-	     boost_state=warn
- 	   else
-	     BOOST_LIB_DIR=$BOOST_GRAPH_LIB_DIR
-	   fi
+             boost_state=warn
+           else
+             BOOST_LIB_DIR=$BOOST_GRAPH_LIB_DIR
+           fi
          else
            boost_state=no
          fi
         ],
-	[boost_state=check])
+        [boost_state=check])
 LOCAL_CHECK_LIB([boost_graph], [boost], [],
         [boost_state=ok],                                         dnl found
         [],                                                       dnl and found installed
         [],                                                       dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [boost_state=no],                                         dnl and not found installed
         [boost_state=warn],                                       dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include "boost/graph/graphviz.hpp"],
+        [#include "boost/graph/graphviz.hpp"],
         [],
         [-L $BOOST_LIB_DIR -I $BOOST_INCLUDE_DIR])
 if test "x$boost_state" = "xok"; then
          BOOST_CFLAGS="-I $BOOST_INCLUDE_DIR"
          BOOST_LIBS="-L $BOOST_LIB_DIR -lboost_graph -lboost_regex"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [boost_state=no],                                         dnl and not found installed
         [boost_state=warn],                                       dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include "boost/graph/graphviz.hpp"],
+        [#include "boost/graph/graphviz.hpp"],
         [],
         [-L $BOOST_LIB_DIR -I $BOOST_INCLUDE_DIR])
 fi
 ## GSL library
 
 AC_ARG_WITH([gsl],
-	[AS_HELP_STRING([--with-gsl=PATH], [prefix of GSL installation or build dir])],
-	[ 
+        [AS_HELP_STRING([--with-gsl=PATH], [prefix of GSL installation or build dir])],
+        [
          if test "x$with_gsl" = "xyes"; then
-	   		gsl_state=check
+                        gsl_state=check
          elif test "x$with_gsl" != "xno"; then
-           	gsl_state=try
-	   qualify_path with_gsl
+                gsl_state=try
+           qualify_path with_gsl
            LOCAL_CHECK_APPEND_PATHS([$with_gsl], [. include], [gsl/gsl_blas.h], [GSL_INCLUDE_DIR], [gsl_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_gsl], [. lib], [libgsl.a], [GSL_LIB_DIR], [gsl_state=warn])
          else
            gsl_state=no
          fi
         ],
-	[gsl_state=check])
+        [gsl_state=check])
 LOCAL_CHECK_LIB([gsl], [gsl], [gsl_rng_env_setup()],
         [gsl_state=ok],                                 dnl found
         [GSL_LIBS="-lgsl -lgslcblas"],                              dnl and found installed
          GSL_CFLAGS="-I $GSL_INCLUDE_DIR"
          GSL_LIBS="-L $GSL_LIB_DIR -lgsl -lgslcblas"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [gsl_state=no],                                 dnl and not found installed
         [gsl_state=warn],                               dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include <stdio.h>
-	 #include <gsl/gsl_rng.h>],
+        [#include <stdio.h>
+         #include <gsl/gsl_rng.h>],
         [-lgsl -lgslcblas],
         [-L $GSL_LIB_DIR -I $GSL_INCLUDE_DIR])
 if test "x$gsl_state" != "xok"; then
   vowpal_wabbit_state=no
 else
 AC_ARG_WITH([vowpal_wabbit],
-	[AS_HELP_STRING([--with-vowpal-wabbit=PATH], [prefix of Vowpal Wabbit installation or build dir])],
-	[ 
+        [AS_HELP_STRING([--with-vowpal-wabbit=PATH], [prefix of Vowpal Wabbit installation or build dir])],
+        [
          if test "x$with_vowpal_wabbit" = "xyes"; then
-	   vowpal_wabbit_state=check
+           vowpal_wabbit_state=check
          elif test "x$with_vowpal_wabbit" != "xno"; then
            vowpal_wabbit_state=try
-	   qualify_path with_vowpal_wabbit
+           qualify_path with_vowpal_wabbit
            LOCAL_CHECK_APPEND_PATHS([$with_vowpal_wabbit], [. include], [vw.h], [VOWPAL_WABBIT_INCLUDE_DIR], [vowpal_wabbit_state=warn])
            LOCAL_CHECK_APPEND_PATHS([$with_vowpal_wabbit], [. lib], [libvw.a], [VOWPAL_WABBIT_LIB_DIR], [vowpal_wabbit_state=warn])
          else
            vowpal_wabbit_state=no
          fi
         ],
-	[vowpal_wabbit_state=check])
+        [vowpal_wabbit_state=check])
 LOCAL_CHECK_LIB([vw], [vowpal_wabbit], [start_noop()],
         [vowpal_wabbit_state=ok],                                 dnl found
         [VOWPAL_WABBIT_LIBS="-lvw"],                              dnl and found installed
          VOWPAL_WABBIT_CFLAGS="-I $VOWPAL_WABBIT_INCLUDE_DIR"
          VOWPAL_WABBIT_LIBS="-L $VOWPAL_WABBIT_LIB_DIR -lvw"
         ],                                                        dnl and found in specified path
-	[],                                                       dnl not found
+        [],                                                       dnl not found
         [vowpal_wabbit_state=no],                                 dnl and not found installed
         [vowpal_wabbit_state=warn],                               dnl and not found in specified path
         [],                                                       dnl requested without
-	[#include "boost/program_options.hpp"
-	 #include "zlib.h"
-	 #include "noop.h"],
+        [#include "boost/program_options.hpp"
+         #include "zlib.h"
+         #include "noop.h"],
         [-lboost_program_options -lpthread -lz],
         [-L $VOWPAL_WABBIT_LIB_DIR -I $VOWPAL_WABBIT_INCLUDE_DIR])
 fi
 
 
 AC_ARG_WITH([tools],
-	[AS_HELP_STRING([--without-tools], [exclude tools and build lib only])],
-	[if test "x$with_tools" = "xno"; then with_tools=false; else with_tools=true; fi],
-	[with_tools=true])
+        [AS_HELP_STRING([--without-tools], [exclude tools and build lib only])],
+        [if test "x$with_tools" = "xno"; then with_tools=false; else with_tools=true; fi],
+        [with_tools=true])
 
 
 AM_CONDITIONAL([WITH_TOOLS], [$with_tools])
 AM_CONDITIONAL([WITH_SMILE_TOOLS], [test "x$smile_state" = "xok"])
 AM_CONDITIONAL([WITH_SVM_TOOLS], [test "x$svm_perf_state" = "xok"])
+AM_CONDITIONAL([WITH_SVM_MULTICLASS_TOOLS], [test "x$svm_multiclass_state" = "xok"])
+AM_CONDITIONAL([WITH_SVM_HIERARCHY_TOOLS], [test "x$svm_hierarchy_state" = "xok"])
 AM_CONDITIONAL([WITH_SVM_LIBSRC], [test "x$svm_perf_state" = "xok"])
 AM_CONDITIONAL([WITH_VW_TOOLS], [test "x$vowpal_wabbit_state" = "xok"])
 AM_CONDITIONAL([WITH_READLINE_TOOLS], [test "x$readline_state" = "xok"])
 AC_CONFIG_FILES([Makefile \
                  src/Makefile \
                  tools/Makefile \
-		 tools/Answerer/Makefile \
-		 tools/Cliquer/Makefile \
-		 tools/Clinician/Makefile \
-		 tools/Clusterer/Makefile \
-		 tools/Clusters2Dab/Makefile \
-		 tools/COALESCE/Makefile \
-		 tools/Combiner/Makefile \
-		 tools/NetworkCombiner/Makefile \
-		 tools/DChecker/Makefile \
-		 tools/Dat2Dab/Makefile \
-		 tools/Dat2Graph/Makefile \
-		 tools/Data2Bnt/Makefile \
-		 tools/Data2Features/Makefile \
-		 tools/Data2Sql/Makefile \
-		 tools/DataDumper/Makefile \
-		 tools/Distancer/Makefile \
-		 tools/Explainer/Makefile \
-		 tools/Filterer/Makefile \
-		 tools/Funcaeologist/Makefile \
-		 tools/Funcifier/Makefile \
-		 tools/Funcographer/Makefile \
-		 tools/Hubber/Makefile \
-		 tools/KNNImputer/Makefile \
-		 tools/Mat2Txt/Makefile \
-		 tools/MCluster/Makefile \
-		 tools/Matcher/Makefile \
-		 tools/MIer/Makefile \
-		 tools/MIed/Makefile \
-		 tools/NetMiner/Makefile \
-		 tools/Normalizer/Makefile \
-		 tools/Orthologer/Makefile \
-		 tools/Overlapper/Makefile \
-		 tools/PCLPlotter/Makefile \
-		 tools/PCLServer/Makefile \
-		 tools/PCL2Bin/Makefile \
-		 tools/Randomizer/Makefile \
-		 tools/Seqs2Ngrams/Makefile \
-		 tools/SMRF/Makefile \
-		 tools/SVDer/Makefile \
-		 tools/Synthesizer/Makefile \
-		 tools/Txt2Bin/Makefile \
+                 tools/Answerer/Makefile \
+                 tools/Cliquer/Makefile \
+                 tools/Clinician/Makefile \
+                 tools/Clusterer/Makefile \
+                 tools/Clusters2Dab/Makefile \
+                 tools/COALESCE/Makefile \
+                 tools/Combiner/Makefile \
+                 tools/NetworkCombiner/Makefile \
+                 tools/DChecker/Makefile \
+                 tools/Dat2Dab/Makefile \
+                 tools/Dat2Graph/Makefile \
+                 tools/Data2Bnt/Makefile \
+                 tools/Data2Features/Makefile \
+                 tools/Data2Sql/Makefile \
+                 tools/DataDumper/Makefile \
+                 tools/Distancer/Makefile \
+                 tools/Explainer/Makefile \
+                 tools/Filterer/Makefile \
+                 tools/Funcaeologist/Makefile \
+                 tools/Funcifier/Makefile \
+                 tools/Funcographer/Makefile \
+                 tools/Hubber/Makefile \
+                 tools/KNNImputer/Makefile \
+                 tools/Mat2Txt/Makefile \
+                 tools/MCluster/Makefile \
+                 tools/Matcher/Makefile \
+                 tools/MIer/Makefile \
+                 tools/MIed/Makefile \
+                 tools/NetMiner/Makefile \
+                 tools/Normalizer/Makefile \
+                 tools/Orthologer/Makefile \
+                 tools/Overlapper/Makefile \
+                 tools/PCLPlotter/Makefile \
+                 tools/PCLServer/Makefile \
+                 tools/PCL2Bin/Makefile \
+                 tools/Randomizer/Makefile \
+                 tools/Seqs2Ngrams/Makefile \
+                 tools/SMRF/Makefile \
+                 tools/SVDer/Makefile \
+                 tools/Synthesizer/Makefile \
+                 tools/Txt2Bin/Makefile \
                  tools/BNConverter/Makefile \
-		 tools/BNCreator/Makefile \
-		 tools/SparseNetCombiner/Makefile \
-		 tools/SpeciesConnector/Makefile \
-		 tools/BNEvaluator/Makefile \
-		 tools/BNFunc/Makefile \
-		 tools/BNTester/Makefile \
-		 tools/BNTruster/Makefile \
-		 tools/BNs2Txt/Makefile \
-		 tools/BNUnraveler/Makefile \
-		 tools/BNWeaver/Makefile \
-		 tools/Contexter/Makefile \
-		 tools/Counter/Makefile \
-		 tools/Data2DB/Makefile \
-		 tools/SeekReader/Makefile \
-		 tools/SeekTest/Makefile \
-		 tools/SeekMiner/Makefile \
-		 tools/SeekPrep/Makefile \
-		 tools/SeekServer/Makefile \
-		 tools/SeekPValue/Makefile \
-		 tools/SeekEvaluator/Makefile \
-		 tools/SeekGeneRecommender/Makefile \
-		 tools/SeekAggregatedDataset/Makefile \
+                 tools/BNCreator/Makefile \
+                 tools/SparseNetCombiner/Makefile \
+                 tools/SpeciesConnector/Makefile \
+                 tools/BNEvaluator/Makefile \
+                 tools/BNFunc/Makefile \
+                 tools/BNTester/Makefile \
+                 tools/BNTruster/Makefile \
+                 tools/BNs2Txt/Makefile \
+                 tools/BNUnraveler/Makefile \
+                 tools/BNWeaver/Makefile \
+                 tools/Contexter/Makefile \
+                 tools/Counter/Makefile \
+                 tools/Data2DB/Makefile \
+                 tools/SeekReader/Makefile \
+                 tools/SeekTest/Makefile \
+                 tools/SeekMiner/Makefile \
+                 tools/SeekPrep/Makefile \
+                 tools/SeekServer/Makefile \
+                 tools/SeekPValue/Makefile \
+                 tools/SeekEvaluator/Makefile \
+                 tools/SeekGeneRecommender/Makefile \
+                 tools/SeekAggregatedDataset/Makefile \
          tools/DBCombiner/Makefile \
-		 tools/DSLConverter/Makefile \
-		 tools/Dab2Dad/Makefile \
-		 tools/Edges2Posteriors/Makefile \
-		 tools/MEFIT/Makefile \
+                 tools/DSLConverter/Makefile \
+                 tools/Dab2Dad/Makefile \
+                 tools/Edges2Posteriors/Makefile \
+                 tools/MEFIT/Makefile \
                  tools/Data2Svm/Makefile \
-		 tools/SVMer/Makefile \
-		 tools/SVMperfer/Makefile \
-		 tools/SVMperfing/Makefile \
-		 tools/LibSVMer/Makefile \
-		 tools/VWer/Makefile \
+                 tools/SVMer/Makefile \
+                 tools/SVMperfer/Makefile \
+                 tools/SVMmulticlass/Makefile \
+                 tools/SVMhierarchy/Makefile \
+                 tools/SVMperfing/Makefile \
+                 tools/LibSVMer/Makefile \
+                 tools/VWer/Makefile \
                  tools/OntoShell/Makefile \
                  tools/BNServer/Makefile])
 
 echo "  log4cpp                 = $log4cpp_info"
 echo "  SMILE                   = $smile_info"
 echo "  SVM Perf                = $svm_perf_info"
+echo "  SVM Multiclass          = $svm_multiclass_info"
+echo "  SVM Hierarchy          = $svm_hierarchy_info"
 echo "  Vowpal Wabbit           = $vowpal_wabbit_info"
 echo "  pthread                 = $pthread_info"
 echo "  gsl                     = $gsl_info"
 fi
 
 if test "x$sleipnir_cv_openmp" != "xyes"; then
-	cat << EOF
+        cat << EOF
 ** BUILDING WITHOUT OpenMP SUPPORT
 OpenMP is essential for parallization in SEEK toolset.
 SeekServer, SeekGeneRecommender, SeekMiner will run on single thread.
-This is either because you have disabled OpenMP using --disable-openmp, or 
-you have an outdated version of GCC that does not support OpenMP. 
+This is either because you have disabled OpenMP using --disable-openmp, or
+you have an outdated version of GCC that does not support OpenMP.
 In the latter case, please obtain the latest GCC compiler from http://gcc.gnu.org/.
 EOF
 fi
 
 if test "x$gsl_state" != "xok"; then
-	cat << EOF
+        cat << EOF
 ** BUILDING WITHOUT GSL
 GNU GSL is required for building SEEK toolset.
 SeekServer, SeekGeneRecommender, SeekMiner would not be built.
 
 fi
 
+
+
+if test "x$svm_multiclass_state" != "xok"; then
+  cat << EOF
+
+** BUILDING WITHOUT SVM MULTICLASS
+SVM Multiclass is available from http://svmlight.joachims.org/.
+EOF
+
+fi
+
+if test "x$svm_multiclass_state" = "xwarn"; then
+  cat << EOF
+** WARNING: The path to SVM Multiclass may be incorrect.
+I looked for svm_struct_api.h and libsvmmulticlass.a and did not
+find both. NOTE: You may need to make libsvmmulticlass.a. See the README.
+EOF
+
+fi
+
+
+if test "x$svm_hierarchy_state" != "xok"; then
+  cat << EOF
+
+** BUILDING WITHOUT SVM HIERARCHY
+
+EOF
+
+fi
+
+if test "x$svm_hierarchy_state" = "xwarn"; then
+  cat << EOF
+** WARNING: The path to SVM Hierarchy may be incorrect.
+I looked for svm_struct_api.h and libsvmhierarchy.a and did not
+find both. NOTE: You may need to make libsvmhierarchy.a. See the README.
+EOF
+
+fi
+
+
+
 if test "x$smile_state" = "xwarn"; then
   cat << EOF
 ** WARNING: The path to SMILE may be incorrect.
   cat << EOF
 ** WARNING: The path to LibSVM may be incorrect.
 I looked for  libsvm.a and did not
-find. NOTE: You may need to make liblibsvm.a. 
+find. NOTE: You may need to make liblibsvm.a.
 
 ar rcs liblibsvm.a *.o
 
 #cygwin: need to install log4cpp, and gengetopt manually, as not included in cygwin packages
 #cygwin: need to download smile specific for cygwin (linux version does not work)
 #cygwin: need to modify svmperf.h to remove execinfo.h include line
-./configure --prefix=/home/Bernard/sleipnir_build --with-smile=/home/Bernard/sleipnir/smile --with-svm-perf=/home/Bernard/sleipnir/svmperf --with-log4cpp=/usr/local --with-readline=/usr
+./configure --prefix=/home/qzhu/sleipnir_build --with-smile=/home/qzhu/sleipnir/smile --with-svm-perf=/home/qzhu/sleipnir/svmperf --with-log4cpp=/usr/local --with-readline=/usr
 
 my $default_ggo_flags = "-u -N -e";
 my %tools_ggo_flags = (
-		     BNFunc => '-C -N -e',
-		     BNServer => '-C -N -e',
-		     Dat2Graph => '-C -N -e',
-		     Explainer => '-C -N -e',
-		     OntoFitter => '-C -u -N -e',
-		     OntoShell => '-C -N -e',
-		     OntoTrimmer => '-C -N -e',
-		     );
+                     BNFunc => '-C -N -e',
+                     BNServer => '-C -N -e',
+                     Dat2Graph => '-C -N -e',
+                     Explainer => '-C -N -e',
+                     OntoFitter => '-C -u -N -e',
+                     OntoShell => '-C -N -e',
+                     OntoTrimmer => '-C -N -e',
+                     );
 
 my $tools_common_cflags1 = "\$(SLEIPNIR_CFLAGS)";
 my $tools_common_cflags2 = " \$(LOG4CPP_CFLAGS) \$(PTHREAD_CFLAGS)";
 # packages are: SMILE, SVM_PERF, READLINE, PTHREADS, BOOST, VOWPAL_WABBIT, LIBSVM
 # ordering is important for linking
 my %tools_other_packages = (
-			    BNConverter => ['SMILE'],
-			    BNCreator => ['SMILE'],
-			    BNEvaluator => ['SMILE'],
-			    BNServer => ['SMILE', 'BOOST'],
-			    BNTester => ['SMILE'],
-			    BNTruster => ['SMILE'],
-			    BNUnraveler => ['SMILE'],
-			    BNWeaver => ['SMILE'],
-			    BNs2Txt => ['SMILE'],
-			    SpeciesConnector => ['SMILE'],
-#			    BNWrangler => ['SMILE'],
-			    Contexter  => ['SMILE'],
-			    Counter  => ['SMILE'],
-			    DSLConverter  => ['SMILE'],
-			    Data2DB  => ['SMILE'],
-				DBCombiner => ['SMILE'],
-				SeekTest => ['GSL'],
-				SeekReader => ['GSL'],
-				SeekEvaluator => ['GSL'],
-				SeekPrep => ['GSL'],
-				SeekMiner => ['GSL'],
-				SeekServer => ['GSL'],
-				SeekPValue => ['GSL'],
-				SeekGeneRecommender => ['GSL'],
-				SeekAggregatedDataset => ['GSL'],
-				PCLServer => ['GSL'],
-			    Dab2Dad  => ['SMILE'],
-			    Dab2DB  => ['SMILE'],
-			    Data2Svm => ['SVM_PERF'],
-			    Edges2Posteriors => ['SMILE'],
-			    MEFIT  => ['SMILE'],
-			    OntoShell => ['READLINE'],
-			    SVMer => ['SVM_PERF'],
-			    SVMperfer => ['SVM_PERF'],
-			    SVMperfing => ['SVM_PERF'],
-			    LibSVMer => ['LIBSVM'],
-			    VWer => ['VOWPAL_WABBIT'],
-			    );
+                            BNConverter => ['SMILE'],
+                            BNCreator => ['SMILE'],
+                            BNEvaluator => ['SMILE'],
+                            BNServer => ['SMILE', 'BOOST'],
+                            BNTester => ['SMILE'],
+                            BNTruster => ['SMILE'],
+                            BNUnraveler => ['SMILE'],
+                            BNWeaver => ['SMILE'],
+                            BNs2Txt => ['SMILE'],
+                            SpeciesConnector => ['SMILE'],
+#                           BNWrangler => ['SMILE'],
+                            Contexter  => ['SMILE'],
+                            Counter  => ['SMILE'],
+                            DSLConverter  => ['SMILE'],
+                            Data2DB  => ['SMILE'],
+                                DBCombiner => ['SMILE'],
+                                SeekTest => ['GSL'],
+                                SeekReader => ['GSL'],
+                                SeekEvaluator => ['GSL'],
+                                SeekPrep => ['GSL'],
+                                SeekMiner => ['GSL'],
+                                SeekServer => ['GSL'],
+                                SeekPValue => ['GSL'],
+                                SeekGeneRecommender => ['GSL'],
+                                SeekAggregatedDataset => ['GSL'],
+                                PCLServer => ['GSL'],
+                            Dab2Dad  => ['SMILE'],
+                            Dab2DB  => ['SMILE'],
+                            Data2Svm => ['SVM_PERF'],
+                            Edges2Posteriors => ['SMILE'],
+                            MEFIT  => ['SMILE'],
+                            OntoShell => ['READLINE'],
+                            SVMer => ['SVM_PERF'],
+                            SVMperfer => ['SVM_PERF'],
+                            SVMmulticlass => ['SVM_MULTICLASS'],
+                            SVMhierarchy => ['SVM_HIERARCHY'],
+                            SVMperfing => ['SVM_PERF'],
+                            LibSVMer => ['LIBSVM'],
+                            VWer => ['VOWPAL_WABBIT'],
+                            );
 
 if (opendir(TOOLSDIR, "tools")) {
     my $dent;
     while ($dent = readdir(TOOLSDIR)) {
-	next if ($dent =~ /^\.\.?$/);
-	if (-d "tools/$dent") {
-	    if (opendir(TOOLDIR, "tools/$dent")) {
-		my @src_files;
-		my @header_files;
-		my $ggo_file;
-		my $dent2;
-		while ($dent2 = readdir(TOOLDIR)) {
-		    next if ($dent2 =~ /^cmdline\.[ch]$/);
-		    if ($dent2 =~ /\.(c|cpp)$/) {
-			push(@src_files, $dent2);
-		    } elsif ($dent2 =~ /\.h$/) {
-			push(@header_files, $dent2);
-		    } elsif ($dent2 =~ /\.ggo$/) {
-			$ggo_file = $dent2;
-		    }
-		}
-		close(TOOLDIR);
-		if (open(AM_MAKEFILE, "> tools/$dent/Makefile.am")) {
-		    print AM_MAKEFILE "bin_PROGRAMS = $dent\n";
-		    my $extra_cflags = "";
-		    my $extra_libs = "";
-		    my $pkgs = $tools_other_packages{$dent};
-		    for (my $i = 0; $i <= $#$pkgs; $i++) {
-			$extra_cflags .= " \$(".$pkgs->[$i]."_CFLAGS)";
-			$extra_libs .= " \$(".$pkgs->[$i]."_LIBS)";
-		    }
-		    print AM_MAKEFILE "AM_CPPFLAGS = ".$tools_common_cflags1.$extra_cflags.$tools_common_cflags2."\n";
-		    print AM_MAKEFILE "LDADD = ".$tools_common_libs1.$extra_libs.$tools_common_libs2."\n";
-#		    print AM_MAKEFILE "AM_CPPFLAGS = \$(SLEIPNIR_CFLAGS) \$(SMILE_CFLAGS) \$(SVM_PERF_CFLAGS) \$(GENGETOPT_CFLAGS) \$(LOG4CPP_CFLAGS) \$(BOOST_CFLAGS) \$(READLINE_CFLAGS)\n";
-#		    print AM_MAKEFILE "LDADD = \$(SLEIPNIR_LIBS) \$(SMILE_LIBS) \$(SVM_PERF_LIBS) \$(GENGETOPT_LIBS) \$(LOG4CPP_LIBS) \$(BOOST_LIBS) \$(READLINE_LIBS)\n";
-		    if ($ggo_file) {
-			print AM_MAKEFILE "\nif WITH_GENGETOPT\n";
-			print AM_MAKEFILE "gengetopt = \$(prog_gengetopt)\n";
-			print AM_MAKEFILE "BUILT_SOURCES = cmdline.c cmdline.h\n";
-			print AM_MAKEFILE "cmdline.c cmdline.h: $ggo_file\n";
+        next if ($dent =~ /^\.\.?$/);
+        if (-d "tools/$dent") {
+            if (opendir(TOOLDIR, "tools/$dent")) {
+                my @src_files;
+                my @header_files;
+                my $ggo_file;
+                my $dent2;
+                while ($dent2 = readdir(TOOLDIR)) {
+                    next if ($dent2 =~ /^cmdline\.[ch]$/);
+                    if ($dent2 =~ /\.(c|cpp)$/) {
+                        push(@src_files, $dent2);
+                    } elsif ($dent2 =~ /\.h$/) {
+                        push(@header_files, $dent2);
+                    } elsif ($dent2 =~ /\.ggo$/) {
+                        $ggo_file = $dent2;
+                    }
+                }
+                close(TOOLDIR);
+                if (open(AM_MAKEFILE, "> tools/$dent/Makefile.am")) {
+                    print AM_MAKEFILE "bin_PROGRAMS = $dent\n";
+                    my $extra_cflags = "";
+                    my $extra_libs = "";
+                    my $pkgs = $tools_other_packages{$dent};
+                    for (my $i = 0; $i <= $#$pkgs; $i++) {
+                        $extra_cflags .= " \$(".$pkgs->[$i]."_CFLAGS)";
+                        $extra_libs .= " \$(".$pkgs->[$i]."_LIBS)";
+                    }
+                    print AM_MAKEFILE "AM_CPPFLAGS = ".$tools_common_cflags1.$extra_cflags.$tools_common_cflags2."\n";
+                    print AM_MAKEFILE "LDADD = ".$tools_common_libs1.$extra_libs.$tools_common_libs2."\n";
+#                   print AM_MAKEFILE "AM_CPPFLAGS = \$(SLEIPNIR_CFLAGS) \$(SMILE_CFLAGS) \$(SVM_PERF_CFLAGS) \$(GENGETOPT_CFLAGS) \$(LOG4CPP_CFLAGS) \$(BOOST_CFLAGS) \$(READLINE_CFLAGS)\n";
+#                   print AM_MAKEFILE "LDADD = \$(SLEIPNIR_LIBS) \$(SMILE_LIBS) \$(SVM_PERF_LIBS) \$(GENGETOPT_LIBS) \$(LOG4CPP_LIBS) \$(BOOST_LIBS) \$(READLINE_LIBS)\n";
+                    if ($ggo_file) {
+                        print AM_MAKEFILE "\nif WITH_GENGETOPT\n";
+                        print AM_MAKEFILE "gengetopt = \$(prog_gengetopt)\n";
+                        print AM_MAKEFILE "BUILT_SOURCES = cmdline.c cmdline.h\n";
+                        print AM_MAKEFILE "cmdline.c cmdline.h: $ggo_file\n";
 #			print AM_MAKEFILE "cmdline.c: $ggo_file\n";
-			print AM_MAKEFILE "\t\$(gengetopt) -i".$ggo_file." --default-optional ";
-			if ($tools_ggo_flags{$dent}) {
-			    print AM_MAKEFILE $tools_ggo_flags{$dent};
-			} else {
-			    print AM_MAKEFILE $default_ggo_flags;
-			}
-			print AM_MAKEFILE "\nendif\n";
-			push(@src_files, "cmdline.c");
-			push(@header_files, "cmdline.h");
-		    }
-		    print AM_MAKEFILE $dent."_SOURCES = ", join(" ", @src_files), " \\\n\t", join(" ", @header_files), "\n";
-		    close(AM_MAKEFILE);
-		}
-	    } else {
-		die;
-	    }
-	}
+                        print AM_MAKEFILE "\t\$(gengetopt) -i".$ggo_file." --default-optional ";
+                        if ($tools_ggo_flags{$dent}) {
+                            print AM_MAKEFILE $tools_ggo_flags{$dent};
+                        } else {
+                            print AM_MAKEFILE $default_ggo_flags;
+                        }
+                        print AM_MAKEFILE "\nendif\n";
+                        push(@src_files, "cmdline.c");
+                        push(@header_files, "cmdline.h");
+                    }
+                    print AM_MAKEFILE $dent."_SOURCES = ", join(" ", @src_files), " \\\n\t", join(" ", @header_files), "\n";
+                    close(AM_MAKEFILE);
+                }
+            } else {
+                die;
+            }
+        }
     }
     close(TOOLSDIR);
 } else {
 lib_LIBRARIES			= libSleipnir.a
 
-AM_CPPFLAGS = $(GSL_CFLAGS) $(LOG4CPP_CFLAGS) $(SMILE_CFLAGS) $(SVM_PERF_CFLAGS) $(PTHREAD_CFLAGS) $(VOWPAL_WABBIT_CFLAGS) $(LIBSVM_CFLAGS)
+AM_CPPFLAGS = $(GSL_CFLAGS) $(LOG4CPP_CFLAGS) $(SMILE_CFLAGS) $(SVM_PERF_CFLAGS) $(SVM_MULTICLASS_CFLAGS) $(SVM_HIERARCHY_CFLAGS) $(PTHREAD_CFLAGS) $(VOWPAL_WABBIT_CFLAGS) $(LIBSVM_CFLAGS)
 
-#LDADD = $(LOG4CPP_LIBS) $(SMILE_LIBS) $(SVM_PERF_LIBS) $(PTHREAD_LIBS)
+#LDADD = $(LOG4CPP_LIBS) $(SMILE_LIBS) $(SVM_PERF_LIBS) $(SVM_MULTICLASS_LIBS) $(SVM_HIERARCHY_LIBS) $(PTHREAD_LIBS)
 
 if WITH_SVM_TOOLS
 libSleipnir_SVM_SOURCES = svm.cpp svmperf.cpp
 libSleipnir_SVM_INCLUDES = svm.h svmi.h svmperf.h
 endif
 
+if WITH_SVM_MULTICLASS_TOOLS
+libSleipnir_SVM_MULTICLASS_SOURCES = svmstruct.cpp
+libSleipnir_SVM_MULTICLASS_INCLUDES = svmstruct.h
+endif
+
+if WITH_SVM_HIERARCHY_TOOLS
+libSleipnir_SVM_HIERARCHY_SOURCES = svmstructtree.cpp
+libSleipnir_SVM_HIERARCHY_INCLUDES = svmstructtree.h
+endif
+
 if WITH_LIBSVM_TOOLS
 libSleipnir_LIBSVM_SOURCES = libsvm.cpp
 libSleipnir_LIBSVM_INCLUDES = libsvm.h
 	seekwriter.cpp			\
 	seekplatform.cpp		\
 	seekcentral.cpp		\
-	seeknetwork.cpp	
+	seeknetwork.cpp
 libSleipnir_GSL_INCLUDES = \
 	seekplatform.h			\
 	seekcentral.h			\
 	seekwriter.h			\
 	seekdataset.h			\
 	seekmap.h				\
-	seeknetwork.h	
+	seeknetwork.h
 endif
 libSleipnir_a_SOURCES	=	\
 	annotation.cpp			\
 	$(libSleipnir_SVM_SOURCES) \
 	$(libSleipnir_GSL_SOURCES) \
 	$(libSleipnir_LIBSVM_SOURCES) \
+	$(libSleipnir_SVM_MULTICLASS_SOURCES)\
+	$(libSleipnir_SVM_HIERARCHY_SOURCES)\
 	vwb.cpp
 include_HEADERS			=	\
 	annotation.h			\
 	$(libSleipnir_SVM_INCLUDES)  \
 	$(libSleipnir_GSL_SOURCES) \
 	$(libSleipnir_LIBSVM_INCLUDES) \
+	$(libSleipnir_SVM_MULTICLASS_INCLUDES)\
+	$(libSleipnir_SVM_HIERARCHY_INCLUDES)\
 	trie.h					\
 	triei.h					\
 	typesi.h				\

src/SVMhierarchy.cpp

+#include <fstream>
+#include <iostream>
+#include <iterator>
+#include <vector>
+#include <queue>
+
+/*****************************************************************************
+* This file is provided under the Creative Commons Attribution 3.0 license.
+*
+* You are free to share, copy, distribute, transmit, or adapt this work
+* PROVIDED THAT you attribute the work to the authors listed below.
+* For more information, please see the following web page:
+* http://creativecommons.org/licenses/by/3.0/
+*
+* This file is a component of the Sleipnir library for functional genomics,
+* authored by:
+* Curtis Huttenhower (chuttenh@princeton.edu)
+* Mark Schroeder
+* Maria D. Chikina
+* Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
+*
+* If you use this library, the included executable tools, or any related
+* code in your work, please cite the following publication:
+* Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
+* Olga G. Troyanskaya.
+* "The Sleipnir library for computational functional genomics"
+*****************************************************************************/
+#include "stdafx.h"
+#include "cmdline.h"
+#include "statistics.h"
+
+using namespace SVMArc;
+//#include "../../extlib/svm_light/svm_light/kernel.h"
+
+
+
+
+
+
+
+int main(int iArgs, char** aszArgs) {
+	gengetopt_args_info sArgs;
+
+	CPCL PCL;
+	SVMArc::CSVMSTRUCTTREE SVM;
+
+	size_t i, j, k , iGene, jGene;
+	double bestscore;
+;
+	ifstream ifsm;
+	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
+		cmdline_parser_print_help();
+		return 1;
+	}
+
+	//Set Parameters
+	SVM.SetLearningAlgorithm(sArgs.learning_algorithm_arg);
+	SVM.SetVerbosity(sArgs.verbosity_arg);
+	SVM.SetLossFunction(sArgs.loss_function_arg);
+
+		cerr << "SetLossFunction" <<sArgs.loss_function_arg<< endl;
+
+	if (sArgs.cross_validation_arg < 1){
+		cerr << "cross_valid is <1. Must be set at least 1" << endl;
+		return 1;
+	}
+	else if(sArgs.cross_validation_arg < 2){
+		cerr << "cross_valid is set to 1. No cross validation holdouts will be run." << endl;
+	}
+
+	SVM.SetTradeoff(sArgs.tradeoff_arg);
+
+	if (sArgs.slack_flag)
+		SVM.UseSlackRescaling();
+	else
+		SVM.UseMarginRescaling();
+
+	cerr << "SetRescaling" << endl;
+	SVM.ReadOntology(sArgs.ontoparam_arg); // Read Ontology File
+	if (!SVM.parms_check()) {
+		cerr << "Parameter check not passed, see above errors" << endl;
+		return 1;
+	}
+
+			cerr << "Parameter check" << endl;
+
+	//  cout << "there are " << vecLabels.size() << " labels processed" << endl;
+	size_t iFile;
+	vector<string> PCLs;
+	if (sArgs.input_given) {
+		if (!PCL.Open(sArgs.input_arg, sArgs.skip_arg, sArgs.mmap_flag)) {
+			cerr << "Could not open input PCL" << endl;
+			return 1;
+		}
+	}
+
+	//Read labels from file
+	vector<SVMArc::SVMLabel> vecLabels;
+	set<string> setLabeledGenes;
+	if (sArgs.labels_given) {
+		ifsm.clear();
+		ifsm.open(sArgs.labels_arg);
+		if (ifsm.is_open())
+			vecLabels = SVM.ReadLabels(ifsm);
+		else {
+			cerr << "Could not read label file" << endl;
+			return 1;
+		}
+		for (i = 0; i < vecLabels.size(); i++)
+			setLabeledGenes.insert(vecLabels[i].GeneName);
+	}
+				cerr << "Read labels from file" << endl;
+
+
+	//Training
+	SAMPLE* pTrainSample;
+	vector<SVMArc::SVMLabel> pTrainVector[sArgs.cross_validation_arg];
+	vector<SVMArc::SVMLabel> pTestVector[sArgs.cross_validation_arg];
+	vector<SVMArc::Result> AllResults;
+	vector<SVMArc::Result> tmpAllResults;
+
+	if (sArgs.model_given && sArgs.labels_given) { //learn once and write to file
+		pTrainSample = SVM.CreateSample(PCL, vecLabels);
+		SVM.Learn(*pTrainSample);
+		SVM.WriteModel(sArgs.model_arg);
+	} else if (sArgs.model_given && sArgs.output_given) { //read model and classify all
+		vector<SVMLabel> vecAllLabels;
+
+		for (size_t i = 0; i < PCL.GetGenes(); i++)
+			vecAllLabels.push_back(SVMLabel(PCL.GetGene(i), 0));
+
+		SVM.ReadModel(sArgs.model_arg);
+		AllResults = SVM.Classify(PCL, vecAllLabels);
+		ofstream ofsm;
+		ofsm.open(sArgs.output_arg);
+		if (ofsm.is_open())
+			SVM.PrintResults(AllResults, ofsm);
+		else {
+			cerr << "Could not open output file" << endl;
+		}
+	} else if (sArgs.output_given && sArgs.labels_given) {
+		//do learning and classifying with cross validation
+		//set up training data
+		if( sArgs.cross_validation_arg > 1){	    
+			for (i = 0; i < sArgs.cross_validation_arg; i++) {
+				pTestVector[i].reserve((size_t) vecLabels.size()
+					/ sArgs.cross_validation_arg + sArgs.cross_validation_arg);
+				pTrainVector[i].reserve((size_t) vecLabels.size()
+					/ (sArgs.cross_validation_arg)
+					* (sArgs.cross_validation_arg - 1)
+					+ sArgs.cross_validation_arg);
+				for (j = 0; j < vecLabels.size(); j++) {
+					if (j % sArgs.cross_validation_arg == i) {
+						pTestVector[i].push_back(vecLabels[j]);
+					} else {
+						pTrainVector[i].push_back((vecLabels[j]));
+					}
+				}
+			}
+		}
+		else{ // if you have less than 2 fold cross, no cross validation is done, all train genes are used and predicted
+			// no holdout so train is the same as test gene set
+			pTestVector[0].reserve((size_t) vecLabels.size() + sArgs.cross_validation_arg);
+			pTrainVector[0].reserve((size_t) vecLabels.size() + sArgs.cross_validation_arg);
+
+			for (j = 0; j < vecLabels.size(); j++) {
+				pTestVector[0].push_back(vecLabels[j]);		      
+				pTrainVector[0].push_back(vecLabels[j]);		    
+			}
+
+		}
+		//set up training data done
+
+		//set up validation data
+		vector<SVMLabel> vec_allUnlabeledLabels;
+		vector<Result> vec_allUnlabeledResults;
+		vector<Result> vec_tmpUnlabeledResults;
+		if (sArgs.all_flag) {
+			vec_allUnlabeledLabels.reserve(PCL.GetGenes());
+			vec_allUnlabeledResults.reserve(PCL.GetGenes());
+			for (i = 0; i < PCL.GetGenes(); i++) {
+				if (setLabeledGenes.find(PCL.GetGene(i))
+					== setLabeledGenes.end()) {
+						vec_allUnlabeledLabels.push_back(
+							SVMLabel(PCL.GetGene(i), 0));
+						vec_allUnlabeledResults.push_back(Result(PCL.GetGene(i)));
+				}
+			}
+		}
+		//run once
+		for (i = 0; i < sArgs.cross_validation_arg; i++) {
+			pTrainSample = SVM.CreateSample(PCL,
+				pTrainVector[i]);
+
+			cerr << "Cross Validation Trial " << i << endl;
+			SVM.Learn(*pTrainSample);
+			cerr << "Learned" << endl;
+			tmpAllResults = SVM.Classify(PCL,	pTestVector[i]);
+			cerr << "Classified " << tmpAllResults.size() << " examples"<< endl;
+			AllResults.insert(AllResults.end(), tmpAllResults.begin(), tmpAllResults.end());
+			tmpAllResults.resize(0);
+			if (sArgs.all_flag) {
+				vec_tmpUnlabeledResults = SVM.Classify(
+					PCL, vec_allUnlabeledLabels);
+				
+				if(i == 0){
+					for (j = 0; j < vec_tmpUnlabeledResults.size(); j++){
+						vec_allUnlabeledResults[j].num_class = vec_tmpUnlabeledResults[j].num_class;
+						for( k = 1; k <= vec_tmpUnlabeledResults[j].num_class; k++)
+							vec_allUnlabeledResults[j].Scores.push_back(vec_tmpUnlabeledResults[j].Scores[k]);
+					}
+				}
+				else{
+					for (j = 0; j < vec_tmpUnlabeledResults.size(); j++)
+						for( k = 1; k <= vec_tmpUnlabeledResults[j].num_class; k++)
+							vec_allUnlabeledResults[j].Scores[k] += vec_tmpUnlabeledResults[j].Scores[k];
+				}
+
+			}
+			if (i > 0) {
+				SVMArc::CSVMSTRUCTTREE::FreeSample(*pTrainSample);
+			}
+		}
+					cerr << "5" << endl;
+
+		if (sArgs.all_flag) { //add the unlabeled results
+			for (j = 0; j < vec_allUnlabeledResults.size(); j++)
+				for( k = 1; k <= vec_allUnlabeledResults[j].num_class; k++){
+					if(k==1){
+						vec_allUnlabeledResults[j].Scores[k]/= sArgs.cross_validation_arg;
+						bestscore=vec_allUnlabeledResults[j].Scores[k];
+						vec_allUnlabeledResults[j].Value=k;
+					}else{
+						vec_allUnlabeledResults[j].Scores[k]/= sArgs.cross_validation_arg;
+						if(vec_allUnlabeledResults[j].Scores[k] < bestscore){
+							bestscore = vec_allUnlabeledResults[j].Scores[k];
+							vec_allUnlabeledResults[j].Value=k;
+						}
+					}
+				}
+
+			AllResults.insert(AllResults.end(),
+				vec_allUnlabeledResults.begin(),
+				vec_allUnlabeledResults.end());
+						cerr << "6" << endl;
+
+		}
+					cerr << "7" << endl;
+
+		ofstream ofsm;
+		ofsm.clear();
+		ofsm.open(sArgs.output_arg);
+		SVM.PrintResults(AllResults, ofsm);
+		return 0;
+
+	} else {
+		cerr << "More options are needed" << endl;
+	}
+
+}
+

src/compactmatrixi.h

 #ifndef COMPACTMATRIXI_H
 #define COMPACTMATRIXI_H
 
+//may need to enable the following lines for Cygwin compilation
+//#ifndef SIZE_MAX
+//#define SIZE_MAX (4294967295U) //assumes 32bit GCC
+//#endif
+
 #include "halfmatrixi.h"
 
 namespace Sleipnir {
 	size_t sofar = 0;
 	for(bb=0; bb<numTimes; sofar+=sizes[bb], bb++){
 
-		fprintf(stderr, "Started allocated memory %d\n", bb);
+		fprintf(stderr, "Started allocated memory %lu\n", bb);
 		/* load all Databaselets into memory, for efficiency */
 		unsigned char **charImages =
 			(unsigned char**)malloc(vecDatabaselet.size()*sizeof(unsigned char*));
 				/* open a new Databaselet containing only one gene */
 				string thisGene = first->GetGene(sofar + i);
 				size_t iGeneID = mapstrintGenes[thisGene];
-				sprintf(acNumber, "%08u", iGeneID);
+				sprintf(acNumber, "%08lu", iGeneID);
 
 				string path = strOutDirectory + "/" + acNumber + ".db";
 				vector<string> vecstrThisGene;
 				DBS.m_fstm.close();
 				free(abImage);
 
-				fprintf(stderr, "Finished writing abImage gene %d (of %d) in %d (of %d)\n", i, 
+				fprintf(stderr, "Finished writing abImage gene %lu (of %lu) in %lu (of %lu)\n", i, 
 					sizes[bb], bb, sizes.size());
 
 			}
 		for( j = i; j < vecstrGenes.size( ); j += m_vecpDBs.size( ) )
 			vecstrSubset.push_back( vecstrGenes[ j ] );
 #pragma warning(disable : 4996)
-		sprintf( acNumber, "%08u", i );
+		sprintf( acNumber, "%08lu", i );
 #pragma warning(default : 4996)
 		strFile = strOutputDirectory + '/' + acNumber + c_acExtension;
 		if( !( i % 100 ) )
 		vecstrSubset.clear( );
 		for( j = i; j < vecstrGenes.size( ); j += m_vecpDBs.size( ) )
 			vecstrSubset.push_back( vecstrGenes[ j ] ); //contains index for 1000, 2000, 3000th genes
-		sprintf( acNumber, "%08u", i );
+		sprintf( acNumber, "%08lu", i );
 		strFile = strOutputDirectory + '/' + acNumber + c_acExtension;
 
 		if( !( i % 100 ) )
 				if(m_useNibble){
 					vecData[ iInOffset ].Initialize( veciMyGenes.size( ), veciGenes.size( ), 16, true );
 				}else{
-					vecData[ iInOffset ].Initialize( veciMyGenes.size( ), veciGenes.size( ), 256, true );
+					vecData[ iInOffset ].Initialize( veciMyGenes.size( ), veciGenes.size( ), (unsigned char) 256, true );
 				}
 
 				string	strName = CMeta::Filename( CMeta::Deextension( CMeta::Basename( vecstrFiles[ iInBase + iInOffset ].c_str() ) ) );
 		vecstrSubset.clear( );
 		for( j = i; j < vecstrGenes.size( ); j += m_vecpDBs.size( ) )
 			vecstrSubset.push_back( vecstrGenes[ j ] ); //contains index for 1000, 2000, 3000th genes
-		sprintf( acNumber, "%08u", i );
+		sprintf( acNumber, "%08lu", i );
 		string strFile = strDBDirectory + '/' + acNumber + c_acExtension;
 		uint32_t iGenes = vecstrGenes.size();
 		uint32_t iDset = iDatasets;

src/seekcentral.cpp

 	m_mapstrintDataset.clear();
 	m_mapstrintGene.clear();
 	m_searchdsetMap.clear();
-	m_DB = NULL;
+	m_vecDB.clear();
+	m_vecDBDataset.clear();
 	m_rData = NULL;
 	m_maxNumDB = 50;
 
 	m_iGenes = 0;
 	m_numThreads = 0;
 	m_bSubtractGeneAvg = false;
-	m_bSubtractPlatformAvg = false;
-	m_bDividePlatformStdev = false;
+	m_bNormPlatform = false;
 	m_bLogit = false;
-	m_bCorrelation = false;
+	m_eDistMeasure = CSeekDataset::Z_SCORE;
+	m_bOutputWeightComponent = false;
+	m_bSimulateWeight = false;
 	m_bOutputText = false;
 	m_bSquareZ = false;
 	m_bSharedDB = false;
 	m_counts.clear();
 	m_weight.clear();
 	m_final.clear();
+	m_vecDBDataset.clear();
 
 	m_vecstrAllQuery.clear();
 	m_Query.clear();
 	m_mapstriPlatform.clear();
 	m_vecstrPlatform.clear();
 
-	if(m_DB!=NULL){
+	if(m_vecDB.size()!=0){
+		if(!m_bSharedDB){
+			for(i=0; i<m_vecDB.size(); i++)
+				delete m_vecDB[i];
+		}
+		for(i=0; i<m_vecDB.size(); i++)
+			m_vecDB[i] = NULL;
+		m_vecDB.clear();
+	}
+
+	/*if(m_DB!=NULL){
 		if(!m_bSharedDB){
 			delete m_DB;
 		}
 		m_DB = NULL;
-	}
+	}*/
 	m_iDatasets = 0;
 	m_iGenes = 0;
 	m_numThreads = 0;
 //assume DB has been read (with gvar, sinfo information)
 //assume datasets and genes have been read
 //assume m_enableNetwork is on
-bool CSeekCentral::Initialize(string &output_dir, string &query, string &search_dset,
-	CSeekCentral *src, float &query_min_required, bool &bCorrelation,
-	bool &bSubtractGeneAvg, bool &bSubtractPlatformAvg, bool &bDividePlatformStdev,
-	const int& iClient){
+//* CDatabaselet collection is shared between multiple clients (m_bSharedDB)
+bool CSeekCentral::Initialize(
+	const string &output_dir, const string &query,
+	const string &search_dset, CSeekCentral *src, const int iClient,
+	const float query_min_required,
+	const enum CSeekDataset::DistanceMeasure eDistMeasure,
+	const bool bSubtractGeneAvg, const bool bNormPlatform){
 
-	//fprintf(stderr, "B0 %lu\n", CMeta::GetMemoryUsage());
 	m_output_dir = output_dir; //LATER, TO BE DELETED
 	m_maxNumDB = src->m_maxNumDB;
 	m_bSharedDB = true;
 	m_bSquareZ = src->m_bSquareZ;
 	m_bOutputText = src->m_bOutputText;
 	m_bSubtractGeneAvg = bSubtractGeneAvg;
-	m_bSubtractPlatformAvg = bSubtractPlatformAvg;
-	m_bDividePlatformStdev = bDividePlatformStdev;
+	m_bNormPlatform = bNormPlatform;
 	m_bLogit = src->m_bLogit;
-	m_bCorrelation = bCorrelation;
-	m_vecstrGenes.resize(src->m_vecstrGenes.size());
+	m_eDistMeasure = eDistMeasure;
+
+	m_bOutputWeightComponent = src->m_bOutputWeightComponent;
+	m_bSimulateWeight = src->m_bSimulateWeight;
 
 	m_bRandom = false;
 	m_iNumRandom = 1;
 	m_randRandom = NULL;	
 
+	m_vecstrGenes.resize(src->m_vecstrGenes.size());
 	copy(src->m_vecstrGenes.begin(), src->m_vecstrGenes.end(), m_vecstrGenes.begin());
 
 	m_vecstrDatasets.resize(src->m_vecstrDatasets.size());
 	m_iDatasets = m_vecstrDatasets.size();
 	m_iGenes = m_vecstrGenes.size();
 
-	//fprintf(stderr, "%d %d\n", m_iDatasets, m_iGenes);
-	//fprintf(stderr, "B1 %lu\n", CMeta::GetMemoryUsage());
-
 	//read search datasets
 	vector<string> sd;
 	CMeta::Tokenize(search_dset.c_str(), sd, "|", false);
 	m_vecstrSearchDatasets.resize(sd.size());
 	for(i=0; i<sd.size(); i++){
 		CMeta::Tokenize(sd[i].c_str(), m_vecstrSearchDatasets[i], " ", false);
-		//fprintf(stderr, "%s\n", sd[i].c_str());
 	}
 	//read queries
 	vector<string> sq;
 	m_vecstrAllQuery.resize(sq.size());
 	for(i=0; i<sq.size(); i++){
 		CMeta::Tokenize(sq[i].c_str(), m_vecstrAllQuery[i], " ", false);
-		//fprintf(stderr, "%s\n", sq[i].c_str());
 	}
-	//fprintf(stderr, "%s\n", output_dir.c_str());
+
 	m_searchdsetMap.resize(m_vecstrAllQuery.size());
 	for(i=0; i<m_vecstrAllQuery.size(); i++){
 		m_searchdsetMap[i] = new CSeekIntIntMap(m_vecstrDatasets.size());
 				m_mapstrintDataset[m_vecstrSearchDatasets[i][j]]);
 	}
 
-	//fprintf(stderr, "B2 %lu\n", CMeta::GetMemoryUsage());
+	m_vecDB.resize(src->m_vecDB.size());
+	for(i=0; i<m_vecDB.size(); i++)
+		m_vecDB[i] = src->m_vecDB[i];
+	//m_DB = src->m_DB; //shared DB
 
-	m_DB = src->m_DB; //shared DB
+	m_vecDBDataset.resize(src->m_vecDB.size());
+	for(i=0; i<m_vecDB.size(); i++){
+		m_vecDBDataset[i].resize(src->m_vecDBDataset[i].size());
+		copy(src->m_vecDBDataset[i].begin(), src->m_vecDBDataset[i].end(),
+		m_vecDBDataset[i].begin());
+	}
 
-	CSeekTools::LoadDatabase(*m_DB, m_vc, src->m_vc, m_vp, src->m_vp,
-		m_vecstrDatasets, m_mapstrstrDatasetPlatform, m_mapstriPlatform);
-
-	//fprintf(stderr, "B3 %lu\n", CMeta::GetMemoryUsage());
+	CSeekTools::LoadDatabase(m_vecDB, m_iGenes, m_iDatasets,
+		m_vc, src->m_vc, m_vp, src->m_vp, m_vecstrDatasets,
+		m_mapstrstrDatasetPlatform, m_mapstriPlatform);
 
 	if(!CalculateRestart())
 		return false;
 				count[j]++;
 				present++;
 			}
+
 			//datasets that contains all query genes (very stringent)
 			//if(present==m_vecstrAllQuery[l].size()){
 
 }
 
 //load everything except query, search datasets, output directory
-bool CSeekCentral::Initialize(const char *gene, const char *quant,
-	const char *dset, const char *platform, const char *db,
-	const char *prep, const char *gvar, const char *sinfo,
-	const bool &useNibble, const ushort &num_db,
-	const ushort &buffer, const bool &to_output_text,
-	const bool &bCorrelation, const bool &bSubtractAvg,
-	const bool &bSubtractPlatformAvg, const bool &bDividePlatformStdev,
-	const bool &bLogit, const float &fCutOff, const float &fPercentRequired, 
-	const bool &bSquareZ, 
-	//three new ones
-	const bool &bRandom, const int &iNumRandom, gsl_rng *rand){
+bool CSeekCentral::Initialize(const vector<CSeekDBSetting*> &vecDBSetting,
+	const ushort buffer, const bool to_output_text,
+	const bool bOutputWeightComponent, const bool bSimulateWeight,
+	const enum CSeekDataset::DistanceMeasure dist_measure,
+	const bool bSubtractAvg, const bool bNormPlatform,
+	const bool bLogit, const float fCutOff, const float fPercentRequired,
+	const bool bSquareZ, const bool bRandom, const int iNumRandom,
+	gsl_rng *rand, const bool useNibble){
 
 	m_maxNumDB = buffer;
 	m_numThreads = 8; //changed from 8
 	m_fPercentQueryAfterScoreCutOff = fPercentRequired;
 	m_bSquareZ = bSquareZ;
 
+	m_bOutputWeightComponent = bOutputWeightComponent;
+	m_bSimulateWeight = bSimulateWeight;
+
 	//random retrieval==========================
 	m_bRandom = bRandom;
 	m_iNumRandom = iNumRandom;
 	m_randRandom = rand; //random-case only
-	//===
+	//==========================================
 
 	if(!m_bRandom){
 		m_randRandom = NULL;
 
 	m_bOutputText = to_output_text;
 	m_bSubtractGeneAvg = bSubtractAvg;
-	m_bSubtractPlatformAvg = bSubtractPlatformAvg;
-	m_bDividePlatformStdev = bDividePlatformStdev;
+	m_bNormPlatform = bNormPlatform;
 	m_bLogit = bLogit;
-	m_bCorrelation = bCorrelation;
+	m_eDistMeasure = dist_measure;
 
-	string strGvarDirectory = gvar;
-	string strSinfoDirectory = sinfo;
-	if(m_bCorrelation && sinfo=="NA"){
-		fprintf(stderr, "Error: not specifying sinfo!\n");
-		return false;
-	}
+	bool bCorrelation = false;
 
-	if(m_bCorrelation && (m_bSubtractGeneAvg || m_bSubtractPlatformAvg ||
-		m_bDividePlatformStdev || m_bLogit)){
-		fprintf(stderr, 
-			"Warning: setting subtract_avg, subtract_platform to false\n");
-		m_bSubtractGeneAvg = false;
-		m_bSubtractPlatformAvg = false;
-		m_bDividePlatformStdev = false;
-		m_bLogit = false;
+	if(dist_measure==CSeekDataset::CORRELATION){
+		bCorrelation = true;
+		if(m_bSubtractGeneAvg || m_bNormPlatform || m_bLogit){
+			fprintf(stderr,
+				"Warning: setting subtract_avg, norm platform to false\n");
+			m_bSubtractGeneAvg = false;
+			m_bNormPlatform = false;
+			m_bLogit = false;
+		}
 	}
 
 	//read genes
 	vector<string> vecstrGeneID;
-	if(!CSeekTools::ReadListTwoColumns(gene, vecstrGeneID, m_vecstrGenes))
+	if(!CSeekTools::ReadListTwoColumns(vecDBSetting[0]->GetValue("gene"),
+		vecstrGeneID, m_vecstrGenes))
 		return false;
-
 	for(i=0; i<m_vecstrGenes.size(); i++)
 		m_mapstrintGene[m_vecstrGenes[i]] = i;
 
-	CSeekTools::ReadQuantFile(quant, m_quant);
-	m_DB = new CDatabase(useNibble);
+	//read quant file
+	CSeekTools::ReadQuantFile(vecDBSetting[0]->GetValue("quant"), m_quant);
 
-	//read datasets
-	if(!CSeekTools::ReadListTwoColumns(dset, m_vecstrDatasets, m_vecstrDP))
-		return false;
+	m_vecstrDatasets.clear();
+	m_vecstrDP.clear();
+	m_mapstriPlatform.clear();
+	m_mapstrstrDatasetPlatform.clear();
+	m_mapstrintDataset.clear();
+	m_vp.clear();
+
+	m_vecDB.resize(vecDBSetting.size());
+	m_vecDBDataset.resize(vecDBSetting.size());
+	for(i=0; i<vecDBSetting.size(); i++)
+		m_vecDB[i] = NULL;
+
+	for(i=0; i<vecDBSetting.size(); i++){
+		if(dist_measure==CSeekDataset::CORRELATION &&
+		vecDBSetting[i]->GetValue("sinfo")=="NA"){
+			fprintf(stderr, "Error: not specifying sinfo!\n");
+			return false;
+		}
+
+		m_vecDB[i] = new CDatabase(useNibble);
+		//read datasets
+		vector<string> vD, vDP;
+		if(!CSeekTools::ReadListTwoColumns(vecDBSetting[i]->GetValue("dset"), vD, vDP))
+			return false;
+
+		for(j=0; j<vD.size(); j++){
+			m_vecstrDatasets.push_back(vD[j]);
+			m_vecDBDataset[i].push_back(vD[j]);
+			m_vecstrDP.push_back(vDP[j]);
+		}
+
+		vector<string> vecstrPlatforms;
+		map<string,ushort> mapstriPlatform;
+		vector<CSeekPlatform> vp;
+		CSeekTools::ReadPlatforms(vecDBSetting[i]->GetValue("platform"), vp,
+			vecstrPlatforms, mapstriPlatform);
+		for(map<string,ushort>::iterator it=mapstriPlatform.begin();
+			it!=mapstriPlatform.end(); it++){
+			m_mapstriPlatform[it->first] = it->second;
+		}
+
+		int cur = m_vp.size();
+		m_vp.resize(cur+vp.size());
+		for(j=0; j<vp.size(); j++)
+			m_vp[cur+j].Copy(vp[j]);
+	}
 
 	for(i=0; i<m_vecstrDatasets.size(); i++){
 		m_mapstrstrDatasetPlatform[m_vecstrDatasets[i]] = m_vecstrDP[i];
 		m_mapstrintDataset[m_vecstrDatasets[i]] = i;
 	}
 
-	vector<string> vecstrPlatforms;
-	CSeekTools::ReadPlatforms(platform, m_vp, vecstrPlatforms,
-		m_mapstriPlatform);
-
 	m_iDatasets = m_vecstrDatasets.size();
 	m_iGenes = m_vecstrGenes.size();
 
-	m_DB->Open(db, m_vecstrGenes, m_iDatasets, num_db);
-	CSeekTools::LoadDatabase(*m_DB, prep, gvar, sinfo, m_vecstrDatasets,
-		m_mapstrstrDatasetPlatform, m_mapstriPlatform, m_vp, m_vc);
+	for(i=0; i<vecDBSetting.size(); i++){
+		m_vecDB[i]->Open(vecDBSetting[i]->GetValue("db"),
+			m_vecstrGenes, m_vecDBDataset[i].size(), vecDBSetting[i]->GetNumDB());
+	}
+
+	CSeekTools::LoadDatabase(m_vecDB, m_iGenes, m_iDatasets,
+		vecDBSetting, m_vecstrDatasets, m_mapstrstrDatasetPlatform,
+		m_mapstriPlatform, m_vp, m_vc, m_vecDBDataset, m_mapstrintDataset,
+		false, bCorrelation);
 
 	return true;
 }
 
+bool CSeekCentral::Initialize(
+	const vector<CSeekDBSetting*> &vecDBSetting,
+	const char *search_dset, const char *query,
+	const char *output_dir, const ushort buffer, const bool to_output_text,
+	const bool bOutputWeightComponent, const bool bSimulateWeight,
+	const enum CSeekDataset::DistanceMeasure dist_measure,
+	const bool bSubtractAvg, const bool bNormPlatform,
+	const bool bLogit, const float fCutOff, const float fPercentRequired,
+	const bool bSquareZ, const bool bRandom, const int iNumRandom,
+	gsl_rng *rand, const bool useNibble){
 
-bool CSeekCentral::Initialize(const char *gene, const char *quant,
-	const char *dset, const char *search_dset,
-	const char *query, const char *platform, const char *db,
-	const char *prep, const char *gvar, const char *sinfo,
-	const bool &useNibble, const ushort &num_db,
-	const ushort &buffer, const char *output_dir, const bool &to_output_text,
-	const bool &bCorrelation, const bool &bSubtractAvg,
-	const bool &bSubtractPlatformAvg, const bool &bDividePlatformStdev,
-	const bool &bLogit, const float &fCutOff, const float &fPercentRequired, 
-	const bool &bSquareZ,
-	//three new ones
-	const bool &bRandom, const int &iNumRandom, gsl_rng *rand){
-
-	if(!CSeekCentral::Initialize(gene, quant, dset, platform, 
-		db, prep, gvar, sinfo, useNibble, num_db, buffer, to_output_text, 
-		bCorrelation, bSubtractAvg, bSubtractPlatformAvg, bDividePlatformStdev, 
-		bLogit, fCutOff, fPercentRequired, bSquareZ, bRandom, iNumRandom, rand)){
+	if(!CSeekCentral::Initialize(vecDBSetting, buffer, to_output_text,
+		bOutputWeightComponent, bSimulateWeight, dist_measure,
+		bSubtractAvg, bNormPlatform, bLogit, fCutOff, fPercentRequired,
+		bSquareZ, bRandom, iNumRandom, rand, useNibble)){
 		return false;
 	}
 
 	omp_set_num_threads(m_numThreads);
 	m_output_dir = output_dir;
 
-	//read search datasets
-	if(!CSeekTools::ReadMultipleQueries(search_dset, m_vecstrSearchDatasets))
-		return false;
 	//read queries
 	if(!CSeekTools::ReadMultipleQueries(query, m_vecstrAllQuery))
 		return false;
 
+	//read search datasets
+	string strSearchDset = search_dset;
+	if(strSearchDset=="NA"){
+		m_vecstrSearchDatasets.resize(m_vecstrAllQuery.size());
+		for(i=0; i<m_vecstrAllQuery.size(); i++){
+			m_vecstrSearchDatasets[i].resize(m_vecstrDatasets.size());
+			for(j=0; j<m_vecstrDatasets.size(); j++){
+				m_vecstrSearchDatasets[i][j] = m_vecstrDatasets[j];
+			}
+		}
+	}else{
+		if(!CSeekTools::ReadMultipleQueries(search_dset, m_vecstrSearchDatasets)){
+			fprintf(stderr, "Error reading search datasets\n");
+			return false;
+		}
+		if(m_vecstrSearchDatasets.size()!=m_vecstrAllQuery.size()){
+			fprintf(stderr, "Search_dset file doesn't have enough lines. Remember 1 line / query!\n");
+			return false;
+		}
+	}
+
 	m_searchdsetMap.resize(m_vecstrAllQuery.size());
 	for(i=0; i<m_vecstrAllQuery.size(); i++){
 		m_searchdsetMap[i] = new CSeekIntIntMap(m_vecstrDatasets.size());
-		for(j=0; j<m_vecstrSearchDatasets[i].size(); j++)
+		for(j=0; j<m_vecstrSearchDatasets[i].size(); j++){
 			m_searchdsetMap[i]->Add(
 				m_mapstrintDataset[m_vecstrSearchDatasets[i][j]]);
+		}
 	}
 
 	if(!CalculateRestart()) return false;
 
-
 	return true;
 }
 
 	vector<ushort> queryGenes;
 	ushort j;
 	for(j=0; j<vecstrQuery.size(); j++){
-		size_t m = m_DB->GetGene(vecstrQuery[j]);
-		if(m==-1) continue;
-		queryGenes.push_back(m);
+		if(m_mapstrintGene.find(vecstrQuery[j])==
+			m_mapstrintGene.end()) continue;
+		//size_t m = m_DB->GetGene(vecstrQuery[j]);
+		//if(m==-1) continue;
+		//queryGenes.push_back(m);
+		queryGenes.push_back(m_mapstrintGene[vecstrQuery[j]]);
 	}
 	queryGenes.resize(queryGenes.size());
 	query.InitializeQuery(queryGenes, m_iGenes);
 		else{
 			m_master_rank[j] =
 				(m_master_rank[j] / m_sum_weight[j] - 320) / 100.0;
-			if(m_bCorrelation){
+			if(m_eDistMeasure==CSeekDataset::CORRELATION){
 				m_master_rank[j] = m_master_rank[j] / 3.0;
 			}
 			//m_master_rank[j] = m_master_rank[j];
 	const vector<char> &cQuery = query.GetQueryPresence();
 	for(ii=0, jj=0; jj<500; ii++){
 		if(cQuery[final[ii].i]==1) continue;
+		//fprintf(stderr, "%s %.5f\n",
+		//	m_DB->GetGene((size_t)final[ii].i).c_str(), final[ii].f);
 		fprintf(stderr, "%s %.5f\n",
-			m_DB->GetGene((size_t)final[ii].i).c_str(), final[ii].f);
+			m_vecstrGenes[(size_t)final[ii].i].c_str(), final[ii].f);
 		jj++;
 	}
 	return true;
 	}
 
 	//NEED TO MAKE THIS A PARAMETER
-	bool simulateWeight = true;
+	bool simulateWeight = m_bSimulateWeight;
 
 	//output weight component (Mar 19)
-	bool weightComponent = true;
+	bool weightComponent = m_bOutputWeightComponent;
 
 	l = 0;
 	//oct 20, 2012: whether to redo current query with equal weighting
 
 	for(i=0; i<m_vecstrAllQuery.size(); i++){
 
-
 		//simulated weight case ======================
 		/*if(simulateWeight && redoWithEqual>=1) //1 or 2 
 			current_sm = EQUAL;
 
 		if(m_mapLoadTime.find(i)!=m_mapLoadTime.end()){
 			if(!m_bRandom || l==0){ //l==0: first random repetition
-				CSeekTools::ReadDatabaselets(*m_DB, m_mapLoadTime[i], m_vc, 
-				m_iClient, m_bEnableNetwork);
+				CSeekTools::ReadDatabaselets(m_vecDB, m_iGenes, m_iDatasets,
+					m_mapLoadTime[i], m_vc, m_mapstrintGene, m_vecDBDataset,
+					m_mapstrintDataset, m_iClient, m_bEnableNetwork);
 			}
 		}
 
 			CSeekIntIntMap *mapG = m_vc[d]->GetGeneMap();
 			CSeekIntIntMap *mapQ = m_vc[d]->GetQueryMap();
 
-			//if(mapG->GetNumSet()<10000){
-			//	continue;
-			//}
+			if(mapG->GetNumSet()<10000){
+				continue;
+			}
 
 			if(mapQ==NULL ||mapQ->GetNumSet()==0){
 				if(DEBUG) fprintf(stderr, "This dataset is skipped\n");
 			if(DEBUG) fprintf(stderr, "Initializing %d\n",
 				(int) this_q.size());
 			m_vc[d]->InitializeDataMatrix(m_rData[tid], m_quant, m_iGenes,
-				iQuery, m_bSubtractGeneAvg, m_bSubtractPlatformAvg, m_bLogit,
-				m_bCorrelation, m_fScoreCutOff, m_bRandom, m_randRandom);
-			//m_bSubtractPlatformStdev is not used, it's assumed
+				iQuery, m_bSubtractGeneAvg, m_bNormPlatform, m_bLogit,
+				m_eDistMeasure, m_fScoreCutOff, m_bRandom, m_randRandom);
 
 			float w = -1;
 			float report_w = -1; //for showing weight of dataset