MatrixREDUCE

From Informatics

Jump to: navigation, search

see also - CDT, JNI, Aracne, Cluster

Contents

MatrixREDUCE component in geWorkbench

This component includes pieces whose history and whereabouts are hard-to-find and probably lost:

  1. geWorkbench component code - actively maintained, but depending on a Java wrapper in the form of a jar file
  2. the Java wrapper in the form of a jar file. The source code is at login.c2b2.columbia.edu:/cvs/magnet/matrixreduce_distribution.
  3. the actual source of the algorithm itself, presumably in C. Source code is available at http://bussemaker.bio.columbia.edu/software/MatrixREDUCE/index.html The binary executive on a few platform are included in geWorkbench release. The rest of the page is the very old document about how to build the binary, but without the source code it is useless.
  4. The latest version of this is newer than what we use in geWorkbench http://bussemaker.bio.columbia.edu/software/REDUCE/

Building MatrixREDUCE in Eclipse CDT

Create the Project

  • Place the MatrixREDUCE source in your eclipse workpace.
    • where is the source code, presumably in C?
  • untar and unzip - tar -zxvf MatrixREDUCE.tar.gz
  • create a new C project in eclipse with the name MatrixREDUCE (the name of the folder should be the same as the name of the resulting folder you just unzipped). Make sure the project type is Shared Library.

* Under GCC Compiler and Linker, add the -mno-cygwin option ... see here for information on how to do this.

  • Get the GNU Scientific Library (GSL) - http://www.gnu.org/software/gsl/
    • In cygwin, untar & unzip - tar -zxvf gsl-1.8.tar.gz
    • cd into gsl-1.8
    • run ./configure
    • make
    • make install

Creating the dll

THIS DOESN'T WORK ... ESPECIALLY WHEN TRYING TO COMPILE AND LINK WITH CYGWIN AS A RESULT OF THE DEPENDENCY ON CYGWIN1.DLL ... SEE RUNTIME.EXEC BELOW

I have concluded that cygwin's gcc causes problems ... I am using Borland again since it worked before. For some reason, there was a problem linking with the gsl dll file created with cygwin (when running make in /gsl-1.6). Instead of fighting with this further, I first installed the Gsl for Windows (via the installer). I then added:

  • C:\GnuWin32\include to my -I option in bcc32.cfg
  • C:\GnuWin32\lib to the -L option
  • C:\GnuWin32\lib to the -L option in ilink.cfg

I then ran (from dos prompt)

  • bcc32 -tWM -tWD -l libgsl.lib libgslcblas.lib helloworld.c

only to get

Error: 'C:\GNUWIN32\LIB\LIBGSL.LIB' contains invalid OMF record, type 0x21 (possibly COFF)

This lead me to the following link: http://sourceforge.net/mailarchive/forum.php?forum_id=2177&max_rows=25&style=nested&viewmonth=200204

To try and resolve this, I created my own .lib files by doing the following:

Downloaded the then binaries from here: http://gnuwin32.sourceforge.net/packages/gsl.htm. To create the extension module, I then did the following (using the following site as my reference: http://vitkuplab.cu-genome.org/html/mdehoon/software/python/index.html):

  • downloaded pexports
  • put pexports on my Path
  • cd into gsl-1.6/bin directory
  • ran pexports libgsl.dll > libgsl.def
  • ran the dll tool with the following: dlltool --dllname libgsl.dll --def libgsl.def --output-lib liblibgsl.a
  • ran the dll tool with the following: dlltool --dllname libgsl.dll --def libgsl.def --output-lib liblibgsl.lib

Do the same for libgslcblas.dll

I still get the same error: Error: 'C:\GNUWIN32\LIB\LIBGSL.LIB' contains invalid OMF record, type 0x21 (possibly COFF)

Creating the exe

  • Created successfully with cygwin and CDT (don't set the -mno-cygwin flag). First, make sure you run the instructions under Create the Project, then let eclipse build the .exe for you using the CDT plugin.
  • In Java:
    • To see where you should place the .exe (so you don't have to add any paths to java.library.path), run the following:
public static void main( String[] args ) {
try {
BufferedWriter out = new BufferedWriter( new FileWriter( "outputtestfile.txt" ) );
out.write( "aString" );
out.close();
} catch ( IOException e ) {
}
  • Now search for outputtestfile.txt. This is where you should place your .exe (the default).
  • Add the following to your main:
public static void main(String[] args) {
try {
log.debug("Using runtime.exec()");
Process process = Runtime.getRuntime().exec("MatrixREDUCE.exe");
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
System.out.printf("Output of running %s is: ", Arrays
.toString(args));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}

The reason for:

InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
System.out.printf("Output of running %s is: ", Arrays.toString(args));

is because the executable is running in a separate process. Thus, you will not directly see the results of the child process writing out to the System.out (if native code writes to System.err, use process.getErrorStream() above).

Running the exe from the command line(under Windows)

These instructions must be followed to execute MatrixREDUCE.exe from the command line. Your environment can be configured in one of two ways:

Procedure A

  • If not already installed, install Cygwin. Get the required packages as well as:
    • Math - lapack
    • Devel - gcc, gcc-core, gcc-g++, gcc-mingw, gcc-mingw-core, gcc-mingw-g++
    • Create the environmental variable %CYGWIN_HOME% and add the following to your path environmental variable:
      •  %CYGWIN_HOME\bin%;%CYGWIN_HOME%\lib\lapack

Procedure B

  • On your desktop, go to Start->Run->califano11\pub and copy matrixReduce_deps.zip to your machine. Unzip and add matrixReduce_deps to your path.

In both cases, you must restart your dos prompts for the settings to take place.

Running MatrixREDUCE under Linux, Unix, and Mac

You'll need to make following files executable:

  • bin/matrixreduce/FitModelMac
  • bin/matrixreduce/FitModel

ex: chmod 700 bin/matrixreduce/FitModelMac

Personal tools