Commits

Qian Zhu committed c8eb988 Merge

Merge

Comments (0)

Files changed (12)

 # 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"],
+
 
 
 ## 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_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/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 "  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 strongly recommended.
+It 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$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
 
 
 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'],
+                            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) $(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) $(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_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)\
 	vwb.cpp
 include_HEADERS			=	\
 	annotation.h			\
 	$(libSleipnir_SVM_INCLUDES)  \
 	$(libSleipnir_GSL_SOURCES) \
 	$(libSleipnir_LIBSVM_INCLUDES) \
+	$(libSleipnir_SVM_MULTICLASS_INCLUDES)\
 	trie.h					\
 	triei.h					\
 	typesi.h				\
+/*****************************************************************************
+* 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 "svmstruct.h"
+#include "pclset.h"
+#include "dataset.h"
+#include "meta.h"
+#include "genome.h"
+#include "compactmatrix.h"
+#include <vector>
+#include <set>
+
+#define  SLACK_RESCALING    1
+#define  MARGIN_RESCALING   2
+
+namespace SVMArc {
+	extern "C" {
+		//    void free_struct_model(STRUCTMODEL sm);
+		void free_struct_sample(SAMPLE s);
+		//    void svm_learn_struct_joint_custom(SAMPLE sample,
+		//            STRUCT_LEARN_PARM *sparm,
+		//            LEARN_PARM *lparm, KERNEL_PARM *kparm,
+		//            STRUCTMODEL *sm);
+		//    SAMPLE read_struct_examples_sleipnir(DOC **all_docs, double*all_labels, int example_size, int total_features, STRUCT_LEARN_PARM *sparm);
+		//    void free_struct_model(STRUCTMODEL sm);
+		//    void free_struct_sample(SAMPLE s);
+		//    void set_struct_verbosity(long verb);
+		//    double estimate_r_delta_average(DOC **, long, KERNEL_PARM *);
+		//    MODEL *read_model(char *);
+		LABEL classify_struct_example(PATTERN x, STRUCTMODEL *sm,
+			STRUCT_LEARN_PARM *sparm);
+		DOC* create_example(long, long, long, double, SVECTOR *);
+		SVECTOR * create_svector(WORD *, char *, double);
+		void set_struct_verbosity(long verb);
+
+	}
+
+	void CSVMSTRUCTMC::SetVerbosity(size_t V) {
+		struct_verbosity = (long) V;
+	}
+
+	bool CSVMSTRUCTMC::initialize() {
+
+		//set directionality
+
+
+		/* set default */
+		Alg = DEFAULT_ALG_TYPE;
+		//Learn_parms
+		struct_parm.C=0.01;
+		struct_parm.slack_norm=1;
+		struct_parm.epsilon=DEFAULT_EPS;
+		struct_parm.custom_argc=0;
+		struct_parm.loss_function=DEFAULT_LOSS_FCT;
+		struct_parm.loss_type=DEFAULT_RESCALING;
+		struct_parm.newconstretrain=100;
+		struct_parm.ccache_size=5;
+		struct_parm.batch_size=100;
+		//Learn_parms
+		//strcpy (learn_parm.predfile, "trans_predictions");
+		strcpy(learn_parm.alphafile, "");
+		//verbosity=0;/*verbosity for svm_light*/
+		//struct_verbosity = 1; /*verbosity for struct learning portion*/
+		learn_parm.biased_hyperplane=1;
+		learn_parm.remove_inconsistent=0;
+		learn_parm.skip_final_opt_check=0;
+		learn_parm.svm_maxqpsize=10;
+		learn_parm.svm_newvarsinqp=0;
+		learn_parm.svm_iter_to_shrink=-9999;
+		learn_parm.maxiter=100000;
+		learn_parm.kernel_cache_size=40;
+		learn_parm.svm_c=99999999;  /* overridden by struct_parm.C */
+		learn_parm.eps=0.001;       /* overridden by struct_parm.epsilon */
+		learn_parm.transduction_posratio=-1.0;
+		learn_parm.svm_costratio=1.0;
+		learn_parm.svm_costratio_unlab=1.0;
+		learn_parm.svm_unlabbound=1E-5;
+		learn_parm.epsilon_crit=0.001;
+		learn_parm.epsilon_a=1E-10;  /* changed from 1e-15 */
+		learn_parm.compute_loo=0;
+		learn_parm.rho=1.0;
+		learn_parm.xa_depth=0;
+		kernel_parm.kernel_type=0;
+		kernel_parm.poly_degree=3;
+		kernel_parm.rbf_gamma=1.0;
+		kernel_parm.coef_lin=1;
+		kernel_parm.coef_const=1;
+		strcpy(kernel_parm.custom, "empty");
+
+		if (learn_parm.svm_iter_to_shrink == -9999) {
+			learn_parm.svm_iter_to_shrink = 100;
+		}
+
+		if ((learn_parm.skip_final_opt_check)
+			&& (kernel_parm.kernel_type == LINEAR)) {
+				printf(
+					"\nIt does not make sense to skip the final optimality check for linear kernels.\n\n");
+				learn_parm.skip_final_opt_check = 0;
+		}
+
+		//struct parms
+
+		/* set number of features to -1, indicating that it will be computed
+		in init_struct_model() */
+		struct_parm.num_features = -1;
+
+		return true;
+	}
+
+	bool CSVMSTRUCTMC::parms_check() {
+		if ((learn_parm.skip_final_opt_check) && (learn_parm.remove_inconsistent)) {
+			fprintf(
+				stderr,
+				"\nIt is necessary to do the final optimality check when removing inconsistent \nexamples.\n");
+			return false;
+		}
+		if ((learn_parm.svm_maxqpsize < 2)) {
+			fprintf(
+				stderr,
+				"\nMaximum size of QP-subproblems not in valid range: %ld [2..]\n",
+				learn_parm.svm_maxqpsize);
+			return false;
+		}
+		if ((learn_parm.svm_maxqpsize < learn_parm.svm_newvarsinqp)) {
+			fprintf(
+				stderr,
+				"\nMaximum size of QP-subproblems [%ld] must be larger than the number of\n",
+				learn_parm.svm_maxqpsize);
+			fprintf(
+				stderr,
+				"new variables [%ld] entering the working set in each iteration.\n",
+				learn_parm.svm_newvarsinqp);
+			return false;
+		}
+		if (learn_parm.svm_iter_to_shrink < 1) {
+			fprintf(
+				stderr,
+				"\nMaximum number of iterations for shrinking not in valid range: %ld [1,..]\n",
+				learn_parm.svm_iter_to_shrink);
+			return false;
+		}
+		if (struct_parm.C < 0) {
+			fprintf(
+				stderr,
+				"\nTrade-off between training error and margin is not set (C<0)!\nC value will be set to default value. Clight = Cpef * 100 / n \n");
+		}
+		if (learn_parm.transduction_posratio > 1) {
+			fprintf(stderr,
+				"\nThe fraction of unlabeled examples to classify as positives must\n");
+			fprintf(stderr, "be less than 1.0 !!!\n\n");
+			return false;
+		}
+		if (learn_parm.svm_costratio <= 0) {
+			fprintf(stderr,
+				"\nThe COSTRATIO parameter must be greater than zero!\n\n");
+			return false;
+		}
+		if (struct_parm.epsilon <= 0) {
+			fprintf(stderr,
+				"\nThe epsilon parameter must be greater than zero!\n\n");
+			return false;
+		}
+		if ((struct_parm.slack_norm < 1) || (struct_parm.slack_norm > 2)) {
+			fprintf(stderr,
+				"\nThe norm of the slacks must be either 1 (L1-norm) or 2 (L2-norm)!\n\n");
+			return false;
+		}
+
+		if ((struct_parm.loss_type != SLACK_RESCALING) && (struct_parm.loss_type
+			!= MARGIN_RESCALING)) {
+				fprintf(
+					stderr,
+					"\nThe loss type must be either 1 (slack rescaling) or 2 (margin rescaling)!\n\n");
+				return false;
+		}
+
+		if (learn_parm.rho < 0) {
+			fprintf(stderr,
+				"\nThe parameter rho for xi/alpha-estimates and leave-one-out pruning must\n");
+			fprintf(stderr,
+				"be greater than zero (typically 1.0 or 2.0, see T. Joachims, Estimating the\n");
+			fprintf(stderr,
+				"Generalization Performance of an SVM Efficiently, ICML, 2000.)!\n\n");
+			return false;
+		}
+		if ((learn_parm.xa_depth < 0) || (learn_parm.xa_depth > 100)) {
+			fprintf(stderr,
+				"\nThe parameter depth for ext. xi/alpha-estimates must be in [0..100] (zero\n");
+			fprintf(stderr,
+				"for switching to the conventional xa/estimates described in T. Joachims,\n");
+			fprintf(
+				stderr,
+				"Estimating the Generalization Performance of an SVM Efficiently, ICML, 2000.)\n");
+			return false;
+		}
+
+
+
+		return true;
+	}
+
+
+
+	DOC* CSVMSTRUCTMC::CreateDoc(Sleipnir::CPCL &PCL, size_t iGene, size_t iDoc) {
+		WORD* aWords;
+		size_t i, j, iWord, iWords, iPCL, iExp;
+		float d;
+		DOC* pRet;
+		pRet->fvec->words[0].weight;
+		//get number of features
+		iWords = PCL.GetExperiments();
+		//cerr<<"Newing WORDS "<<(iWords+1)*sizeof(WORD)<<endl;
+		aWords = new WORD[iWords + 1];
+		//set the words
+		for (i = 0; i < iWords; ++i) {
+			aWords[i].wnum = i + 1;
+			if (!Sleipnir::CMeta::IsNaN(d = PCL.Get(iGene, i)))
+				aWords[i].weight = d;
+			else
+				aWords[i].weight = 0;
+		}
+		aWords[i].wnum = 0;
+		// cerr<<"START Create Example"<<endl;
+		pRet = create_example(iDoc, 0, 0, 1, create_svector(aWords, "", 1));
+		//cerr<<"END create example"<<endl;
+		delete[] aWords;
+		return pRet;
+	}
+
+
+
+
+
+	SAMPLE* CSVMSTRUCTMC::CreateSample(Sleipnir::CPCL &PCL, vector<SVMLabel> SVMLabels) {
+		size_t i, j, iGene, iDoc;
+		int     n;       /* number of examples */
+		int *target;
+		long num_classes=0;
+		SAMPLE* pSample = new SAMPLE;
+		EXAMPLE* examples;
+		DOC** docs;
+		vector<DOC*> vec_pDoc;
+		vec_pDoc.reserve(SVMLabels.size());
+		vector<int> vecClass;
+		vecClass.reserve(SVMLabels.size());
+
+		iDoc = 0;
+		float numPositives, numNegatives;
+		numPositives = numNegatives = 0;
+		for (i = 0; i < SVMLabels.size(); i++) {
+			//     cout<< "processing gene " << SVMLabels[i].GeneName << endl;
+			if (!SVMLabels[i].hasIndex) {
+				SVMLabels[i].SetIndex(PCL.GetGene(SVMLabels[i].GeneName));
+			}
+			iGene = SVMLabels[i].index;
+			//   cout << SVMLabels[i].GeneName<<" gene at location "<<iGene << endl;
+			if (iGene != -1) {
+				//       cout << "creating doc" << endl;
+				iDoc++;
+				vec_pDoc.push_back(CreateDoc(PCL, iGene, iDoc - 1));
+				vecClass.push_back(SVMLabels[i].Target);
+			}
+		}
+
+		//copy patterns and labels to new vector
+		docs = new DOC*[vec_pDoc.size()];
+		n = vec_pDoc.size();
+		//cout << "Read in " << n << "Standards"<<endl;
+		copy(vec_pDoc.begin(), vec_pDoc.end(), docs);
+		vec_pDoc.clear();
+
+		//cerr << "NEW Class array" << endl;
+		target = new int[vecClass.size()];
+		copy(vecClass.begin(), vecClass.end(), target);
+		vecClass.clear();
+
+
+
+		examples=(EXAMPLE *)my_malloc(sizeof(EXAMPLE)*n);
+		for(i=0;i<n;i++)     /* find highest class label */
+			if(num_classes < target[i]) 
+				num_classes=target[i];
+
+		for(i=0;i<n;i++)     /* make sure all class labels are positive */
+			if(target[i]<1) {
+				printf("\nERROR: The class label '%d' of example number %ld is not greater than '1'!\n",target[i],i+1);
+				exit(1);
+			} 
+			for(i=0;i<n;i++) {          /* copy docs over into new datastructure */
+				examples[i].x.doc=docs[i];
+				examples[i].y.Class=target[i];
+				examples[i].y.scores=NULL;
+				examples[i].y.num_classes=num_classes;
+			}
+			free(target);
+			free(docs);
+			pSample->n=n;
+			pSample->examples=examples;
+
+			if(struct_verbosity>=0)
+				printf(" (%d examples) ",pSample->n);
+
+
+
+
+			return pSample;
+			//cerr<<"DONE CreateSample"<<endl;
+	}
+
+	//Single gene classification
+
+	vector<Result> CSVMSTRUCTMC::Classify(Sleipnir::CPCL &PCL,
+		vector<SVMLabel> SVMLabels) {
+			size_t i, j,k, iGene, iDoc;
+			vector<int> vecClass;
+			vector<Result> vecResult;
+			iDoc = 0;
+			PATTERN pattern;
+			pattern.totdoc = 1;
+			cerr << "CLASSIFY classifying " << endl;
+			LABEL label;
+			for (i = 0; i < SVMLabels.size(); i++) {
+				if (!SVMLabels[i].hasIndex) {
+					SVMLabels[i].SetIndex(PCL.GetGene(SVMLabels[i].GeneName));
+				}
+				iGene = SVMLabels[i].index;
+				   //cout << "CLASS gene=" << iGene << endl;
+				if (iGene != -1) {
+					iDoc++;
+
+					//cout << "CLASS iDOC=" << iDoc << endl;
+					pattern.doc = CreateDoc(PCL, iGene, iDoc);
+					//cerr<<"Doc Created"<<endl;
+					label	= classify_struct_example(pattern, &structmodel,
+						&struct_parm);
+					//cerr<<"CLASSIED"<<endl;
+					vecClass.push_back(SVMLabels[i].Target);
+					vecResult.resize(iDoc);
+					vecResult[iDoc - 1].GeneName = SVMLabels[i].GeneName;
+					vecResult[iDoc - 1].Target = SVMLabels[i].Target;
+					vecResult[iDoc - 1].Value = label.Class;
+					vecResult[iDoc - 1].num_class=struct_parm.num_classes;
+					//vecResult[iDoc - 1].Scores.reserve(label.num_classes);
+					for (k = 1; k <= struct_parm.num_classes; k++)
+								vecResult[iDoc - 1].Scores.push_back(label.scores[k]);
+					//cerr<<"CLASSIFY Called FreeDoc"<<endl;
+					FreeDoc(pattern.doc);
+					//cerr<<"CLASSIFY End FreeDoc"<<endl;
+				}
+			}
+
+			return vecResult;
+	}
+
+
+	void CSVMSTRUCTMC::FreeSample_leave_Doc(SAMPLE s){
+		/* Frees the memory of sample s. */
+		int i;
+		for(i=0;i<s.n;i++) {
+			free(s.examples[i].x.doc);
+			free_label(s.examples[i].y);
+		}
+		free(s.examples);
+	}
+
+
+
+}
+
+/*****************************************************************************
+* 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"
+*****************************************************************************/
+
+#ifndef NO_SVM_STRUCT
+#ifndef SVMSTRUCTI_H
+#define SVMSTRUCTI_H
+#include "pclset.h"
+#include "meta.h"
+#include "dat.h"
+
+#include <stdio.h>
+
+/* removed to support cygwin */
+//#include <execinfo.h>
+
+namespace SVMArc {
+	extern "C" {
+
+#define class Class
+
+#include <svm_multiclass/svm_light/svm_common.h>
+#include <svm_multiclass/svm_light/svm_learn.h>
+#include <svm_multiclass/svm_struct_api_types.h>
+#include <svm_multiclass/svm_struct/svm_struct_common.h>
+#include <svm_multiclass/svm_struct_api.h>
+#include <svm_multiclass/svm_struct/svm_struct_learn.h>
+#undef class
+		//#include "svm_struct_api.h"
+
+	}
+
+	class SVMLabel {
+	public:
+		string GeneName;
+		size_t Target;
+		size_t index;
+		bool hasIndex;
+		SVMLabel(std::string name, size_t target) {
+			GeneName = name;
+			Target = target;
+			hasIndex = false;
+			index = -1;
+		}
+
+		SVMLabel() {
+			GeneName = "";
+			Target = 0;
+		}
+		void SetIndex(size_t i) {
+			index = i;
+			hasIndex = true;
+		}
+	};
+
+	class Result {
+	public:
+		std::string GeneName;
+		int Target;
+		int Value;
+		vector<double> Scores;
+		int num_class;
+		int CVround;
+		int Rank;
+		Result() {
+			GeneName = "";
+			Target = 0;
+			Value = Sleipnir::CMeta::GetNaN();
+		}
+
+		Result(std::string name, int cv = -1) {
+			GeneName = name;
+			Target = 0;
+			Value = 0;
+			CVround = cv;
+			Rank = -1;
+			num_class = 0;
+
+		}
+		string toString() {
+			stringstream ss;
+			ss << GeneName << '\t' << Target << '\t' << Value << '\t' << "CV"
+				<< CVround;
+			if (Rank != -1) {
+				ss << '\t' << Rank;
+			}
+			return ss.str();
+		}
+
+	};
+
+	enum EFilter {
+		EFilterInclude = 0, EFilterExclude = EFilterInclude + 1,
+	};
+
+	//this class encapsulates the model and parameters and has no associated data
+
+
+	//class for SVMStruct
+	class CSVMSTRUCTMC {
+
+	public:
+		LEARN_PARM learn_parm;
+		KERNEL_PARM kernel_parm;
+		STRUCT_LEARN_PARM struct_parm;
+		STRUCTMODEL structmodel;
+		int Alg;
+		CSVMSTRUCTMC() {
+			initialize();
+			//set_struct_verbosity(5);
+		}
+
+		void SetLossFunction(size_t loss_f) {
+			struct_parm.loss_function = loss_f;
+		}
+
+		void SetTradeoff(double tradeoff) {
+			struct_parm.C = tradeoff;
+		}
+		void SetLearningAlgorithm(int alg) {
+			Alg = alg;
+		}
+		void SetKernel(int K) {
+			kernel_parm.kernel_type = K;
+		}
+		void SetPolyD(int D) {
+			kernel_parm.poly_degree = D;
+		}
+
+		//void UseCPSP() {
+		//	Alg = 9;
+		//	struct_parm.preimage_method = 2;
+		//	struct_parm.sparse_kernel_size = 500;
+		//	struct_parm.bias = 0;
+		//}
+
+		//void SetRBFGamma(double g) {
+		//	kernel_parm.rbf_gamma = g;
+		//	UseCPSP();
+		//}
+
+		void UseSlackRescaling() {
+			struct_parm.loss_type = SLACK_RESCALING;
+		}
+
+		void UseMarginRescaling() {
+			struct_parm.loss_type = MARGIN_RESCALING;
+		}
+
+
+
+		void ReadModel(char* model_file) {
+			FreeModel();
+			structmodel = read_struct_model(model_file, &struct_parm);
+		}
+
+		void WriteModel(char* model_file) {
+			if (kernel_parm.kernel_type == LINEAR) {
+				ofstream ofsm;
+				ofsm.open(model_file);
+				for (size_t i = 0; i < structmodel.sizePsi; i++) {
+					ofsm << structmodel.w[i+1] << endl;
+				}
+			} else {
+				write_struct_model(model_file, &structmodel, &struct_parm);
+			}
+		}
+
+		void WriteWeights(ostream& osm) {
+			osm << structmodel.w[0];
+			for (size_t i = 1; i < structmodel.sizePsi + 1; i++)
+				osm << '\t' << structmodel.w[i];
+			osm << endl;
+		}
+
+		static void FreePattern(pattern x) {
+			free_pattern(x);
+		}
+
+		static void FreeLabel(label y) {
+			free_label(y);
+		}
+
+		void FreeModel() {
+			free_struct_model(structmodel);
+		}
+
+		static void FreeSample(sample s) {
+			free_struct_sample(s);
+		}
+
+		static void FreeDoc(DOC* pDoc) {
+			free_example(pDoc, true);
+		}
+		void SetVerbosity(size_t V);
+
+		//static members process data
+		//single gene predictions
+
+
+		//creates a Doc for a given gene index in a single microarray
+		static DOC* CreateDoc(Sleipnir::CPCL &PCL, size_t iGene, size_t iDoc);
+
+
+		//Creates a sample using a single PCL and SVMlabels Looks up genes by name.
+		static SAMPLE
+			* CreateSample(Sleipnir::CPCL &PCL, vector<SVMLabel> SVMLabels);
+
+		//Classify single genes
+		vector<Result> Classify(Sleipnir::CPCL& PCL, vector<SVMLabel> SVMLabels);
+
+		//MEMBER functions wraps learning
+		void Learn(SAMPLE &sample) {
+			cerr << "SLACK NORM =" << struct_parm.slack_norm << endl;
+			/*  if (kernel_parm.kernel_type==CUSTOM)
+			svm_learn_struct_joint_custom(sample, &struct_parm, &learn_parm, &kernel_parm, &structmodel);
+			else*/
+
+
+			cerr << "ALG=" << Alg << endl;
+
+			if(Alg == 0)
+				svm_learn_struct(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel,NSLACK_ALG);
+			else if(Alg == 1)
+				svm_learn_struct(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel,NSLACK_SHRINK_ALG);
+			else if(Alg == 2)
+				svm_learn_struct_joint(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel,ONESLACK_PRIMAL_ALG);
+			else if(Alg == 3)
+				svm_learn_struct_joint(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel,ONESLACK_DUAL_ALG);
+			else if(Alg == 4)
+				svm_learn_struct_joint(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel,ONESLACK_DUAL_CACHE_ALG);
+			else if(Alg == 9)
+				svm_learn_struct_joint_custom(sample,&struct_parm,&learn_parm,&kernel_parm,&structmodel);
+			else
+				exit(1);
+			//
+		}
+
+
+		bool parms_check();
+		bool initialize();
+
+
+
+		// free the sample but don't free the Docs
+		static void FreeSample_leave_Doc(SAMPLE s);
+
+
+
+		STRUCTMODEL read_struct_model_w_linear(char *file, STRUCT_LEARN_PARM *sparm);
+	};
+
+
+};
+
+
+#endif // NO_SVM_SVMSTRUCT
+#endif // SVMSTRUCT_H
 if WITH_TOOLS
   TOOLS_SUBDIRS = \
-          Answerer \
+	  Answerer \
 	  Cliquer \
 	  Clinician \
 	  Clusterer \
 	  Txt2Bin
 if WITH_SMILE_TOOLS
     SMILE_TOOLS_SUBDIRS = \
-          BNConverter \
+	  BNConverter \
 	  BNCreator \
 	  SpeciesConnector \
 	  BNEvaluator \
 endif
 if WITH_SVM_TOOLS
     SVM_TOOLS_SUBDIRS = \
-          Data2Svm \
+	  Data2Svm \
 	  SVMer \
 	  SVMperfing \
 	  SVMperfer
 endif
+if WITH_SVM_MULTICLASS_TOOLS
+    SVM_MULTICLASS_SUBDIRS = \
+		SVMmulticlass
+endif
+
 if WITH_LIBSVM_TOOLS
     LIBSVM_TOOLS_SUBDIRS = \
 	  LibSVMer
 endif
 endif
 
-SUBDIRS = $(TOOLS_SUBDIRS) $(SMILE_TOOLS_SUBDIRS) $(BOOST_TOOLS_SUBDIRS) $(SVM_TOOLS_SUBDIRS) $(READLINE_TOOLS_SUBDIRS) $(VW_TOOLS_SUBDIRS) $(GSL_TOOLS_SUBDIRS) $(LIBSVM_TOOLS_SUBDIRS)
+SUBDIRS = $(TOOLS_SUBDIRS) $(SMILE_TOOLS_SUBDIRS) $(BOOST_TOOLS_SUBDIRS) $(SVM_TOOLS_SUBDIRS) $(READLINE_TOOLS_SUBDIRS) $(VW_TOOLS_SUBDIRS) $(GSL_TOOLS_SUBDIRS) $(LIBSVM_TOOLS_SUBDIRS) $(SVM_MULTICLASS_TOOLS_SUBDIRS)

tools/SVMmulticlass/SVMmulti.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"
+
+vector<SVMArc::SVMLabel> ReadLabels(ifstream & ifsm) {
+
+	static const size_t c_iBuffer = 1024;
+	char acBuffer[c_iBuffer];
+	vector<string> vecstrTokens;
+	vector<SVMArc::SVMLabel> vecLabels;
+	size_t numPositives, numNegatives;
+	numPositives = numNegatives = 0;
+	while (!ifsm.eof()) {
+		ifsm.getline(acBuffer, c_iBuffer - 1);
+		acBuffer[c_iBuffer - 1] = 0;
+		vecstrTokens.clear();
+		CMeta::Tokenize(acBuffer, vecstrTokens);
+		if (vecstrTokens.empty())
+			continue;
+		if (vecstrTokens.size() != 2) {
+			cerr << "Illegal label line (" << vecstrTokens.size() << "): "
+				<< acBuffer << endl;
+			continue;
+		}
+		vecLabels.push_back(SVMArc::SVMLabel(vecstrTokens[0], atoi(
+			vecstrTokens[1].c_str())));
+		if (vecLabels.back().Target > 0)
+			numPositives++;
+		else
+			numNegatives++;
+	}
+	return vecLabels;
+}
+
+struct SortResults {
+
+	bool operator()(const SVMArc::Result& rOne, const SVMArc::Result & rTwo) const {
+		return (rOne.Value < rTwo.Value);
+	}
+};
+
+size_t PrintResults(vector<SVMArc::Result> vecResults, ofstream & ofsm) {
+	sort(vecResults.begin(), vecResults.end(), SortResults());
+	int LabelVal;
+	for (size_t i = 0; i < vecResults.size(); i++) {
+		ofsm << vecResults[i].GeneName << '\t' << vecResults[i].Target << '\t'
+			<< vecResults[i].Value<<'\t';
+		for(size_t j=1;j<=vecResults[i].num_class;j++)
+			ofsm << vecResults[i].Scores[j]<<'\t';
+		ofsm<< endl;
+
+	}
+};
+
+
+int main(int iArgs, char** aszArgs) {
+	gengetopt_args_info sArgs;
+
+	CPCL PCL;
+	SVMArc::CSVMSTRUCTMC 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);
+
+
+	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();
+
+
+	if (!SVM.parms_check()) {
+		cerr << "Parameter check not passed, see above errors" << endl;
+		return 1;
+	}
+
+	//  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 = ReadLabels(ifsm);
+		else {
+			cerr << "Could not read label file" << endl;
+			return 1;
+		}
+		for (i = 0; i < vecLabels.size(); i++)
+			setLabeledGenes.insert(vecLabels[i].GeneName);
+	}
+
+
+	//Training
+	SVMArc::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 = CSVMSTRUCTMC::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())
+			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 = SVMArc::CSVMSTRUCTMC::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::CSVMSTRUCTMC::FreeSample(*pTrainSample);
+			}
+		}
+
+		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());
+		}
+
+		ofstream ofsm;
+		ofsm.clear();
+		ofsm.open(sArgs.output_arg);
+		PrintResults(AllResults, ofsm);
+		return 0;
+
+	} else {
+		cerr << "More options are needed" << endl;
+	}
+
+}
+

tools/SVMmulticlass/SVMmulti.ggo

+package	"SVMmulti"
+version	"1.0"
+purpose	"Wrapper for SVM-multiclass"
+
+section "Main"
+option	"labels"				l	"Labels file"
+										string	typestr="filename"	no
+option	"output"				o	"Output file "
+										string	typestr="filename"  no
+option	"input"					i	"Input PCL file "
+										string	typestr="filename"  yes
+option	"model"					m	"Model file"
+										string	typestr="filename"  no
+option  "all"       			a   "Always classify all genes in PCLs"  
+										flag off
+
+option  "slack"       			S   "Use slack rescaling (instead of margin rescaling)"