From b2c22e061bfbacd558f196d9c53bdd7fa3a09d2c Mon Sep 17 00:00:00 2001 From: Don Pellegrino Date: Mon, 08 Jun 2009 16:48:29 +0000 Subject: Refactored the visualization code from exp004 to its own project here. --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..dac0f89 --- a/dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Don Pellegrino, Drexel University, don@drexel.edu diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..a6d8603 --- a/dev/null +++ b/Makefile.am @@ -0,0 +1,2 @@ +ACLOCAL_AMFLAGS = -I ax +SUBDIRS = src diff --git a/README b/README new file mode 100644 index 0000000..0c29887 --- a/dev/null +++ b/README @@ -0,0 +1,24 @@ +Visualization system to explore the data from exp004. + +====================== +CLUSTER.CIS.DREXEL.EDU +====================== + +Building on cluster.cis.drexel.edu requires explicitly adding a number +of NCBI libraries and using the local install of the NCBI toolkit. +Before running ./configure set the following: + + export LDFLAGS=-L/usr/local/ncbi/lib + export CPPFLAGS=-I/usr/local/ncbi/include + +Before running a program that makes use of BLAST create a ~/.ncbirc +file with the following contents. This instruction is based on a +message at +http://osdir.com/ml/science.biology.informatics.bulletin/2006-02/msg00061.html + + [NCBI] + data=/usr/local/ncbi/data + + [BLAST] + BLASTMAT=/usr/local/ncbi/data + diff --git a/ax/acx_pthread.m4 b/ax/acx_pthread.m4 new file mode 100644 index 0000000..e4e91d3 --- a/dev/null +++ b/ax/acx_pthread.m4 @@ -0,0 +1,242 @@ +dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl @summary figure out how to build C programs using POSIX threads +dnl +dnl This macro figures out how to build C programs using POSIX threads. +dnl It sets the PTHREAD_LIBS output variable to the threads library and +dnl linker flags, and the PTHREAD_CFLAGS output variable to any special +dnl C compiler flags that are needed. (The user can also force certain +dnl compiler flags/libs to be tested by setting these environment +dnl variables.) +dnl +dnl Also sets PTHREAD_CC to any special C compiler that is needed for +dnl multi-threaded programs (defaults to the value of CC otherwise). +dnl (This is necessary on AIX to use the special cc_r compiler alias.) +dnl +dnl NOTE: You are assumed to not only compile your program with these +dnl flags, but also link it with them as well. e.g. you should link +dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS +dnl $LIBS +dnl +dnl If you are only building threads programs, you may wish to use +dnl these variables in your default LIBS, CFLAGS, and CC: +dnl +dnl LIBS="$PTHREAD_LIBS $LIBS" +dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +dnl CC="$PTHREAD_CC" +dnl +dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute +dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to +dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +dnl +dnl ACTION-IF-FOUND is a list of shell commands to run if a threads +dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to +dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the +dnl default action will define HAVE_PTHREAD. +dnl +dnl Please let the authors know if this macro fails on any platform, or +dnl if you have any other suggestions or comments. This macro was based +dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with +dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros +dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. +dnl We are also grateful for the helpful feedback of numerous users. +dnl +dnl @category InstalledPackages +dnl @author Steven G. Johnson +dnl @version 2006-05-29 +dnl @license GPLWithACException + +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) + if test x"$acx_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC + fi +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD diff --git a/ax/ax_check_gl.m4 b/ax/ax_check_gl.m4 new file mode 100644 index 0000000..08305c1 --- a/dev/null +++ b/ax/ax_check_gl.m4 @@ -0,0 +1,95 @@ +dnl @synopsis AX_CHECK_GL +dnl +dnl Check for an OpenGL implementation. If GL is found, the required +dnl compiler and linker flags are included in the output variables +dnl "GL_CFLAGS" and "GL_LIBS", respectively. This macro adds the +dnl configure option "--with-apple-opengl-framework", which users can +dnl use to indicate that Apple's OpenGL framework should be used on Mac +dnl OS X. If Apple's OpenGL framework is used, the symbol +dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GL implementation +dnl is found, "no_gl" is set to "yes". +dnl +dnl @category InstalledPackages +dnl @author Braden McDaniel +dnl @version 2004-11-15 +dnl @license AllPermissive + +AC_DEFUN([AX_CHECK_GL], +[AC_REQUIRE([AC_PATH_X])dnl +AC_REQUIRE([ACX_PTHREAD])dnl + +# +# There isn't a reliable way to know we should use the Apple OpenGL framework +# without a configure option. A Mac OS X user may have installed an +# alternative GL implementation (e.g., Mesa), which may or may not depend on X. +# +AC_ARG_WITH([apple-opengl-framework], + [AC_HELP_STRING([--with-apple-opengl-framework], + [use Apple OpenGL framework (Mac OS X only)])]) +if test "X$with_apple_opengl_framework" = "Xyes"; then + AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], + [Use the Apple OpenGL framework.]) + GL_LIBS="-framework OpenGL" +else + AC_LANG_PUSH(C) + + AX_LANG_COMPILER_MS + if test X$ax_compiler_ms = Xno; then + GL_CFLAGS="${PTHREAD_CFLAGS}" + GL_LIBS="${PTHREAD_LIBS} -lm" + fi + + # + # Use x_includes and x_libraries if they have been set (presumably by + # AC_PATH_X). + # + if test "X$no_x" != "Xyes"; then + if test -n "$x_includes"; then + GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}" + fi + if test -n "$x_libraries"; then + GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}" + fi + fi + + AC_CHECK_HEADERS([windows.h]) + + AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], + [ax_cv_check_gl_libgl="no" + ax_save_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" + ax_save_LIBS="${LIBS}" + LIBS="" + ax_check_libs="-lopengl32 -lGL" + for ax_lib in ${ax_check_libs}; do + if test X$ax_compiler_ms = Xyes; then + ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` + else + ax_try_lib="${ax_lib}" + fi + LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +# if HAVE_WINDOWS_H && defined(_WIN32) +# include +# endif +# include ]], + [[glBegin(0)]])], + [ax_cv_check_gl_libgl="${ax_try_lib}"; break]) + done + LIBS=${ax_save_LIBS} + CPPFLAGS=${ax_save_CPPFLAGS}]) + + if test "X${ax_cv_check_gl_libgl}" = "Xno"; then + no_gl="yes" + GL_CFLAGS="" + GL_LIBS="" + else + GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}" + fi + AC_LANG_POP(C) +fi + +AC_SUBST([GL_CFLAGS]) +AC_SUBST([GL_LIBS]) +])dnl diff --git a/ax/ax_check_glu.m4 b/ax/ax_check_glu.m4 new file mode 100644 index 0000000..29d30bd --- a/dev/null +++ b/ax/ax_check_glu.m4 @@ -0,0 +1,71 @@ +dnl @synopsis AX_CHECK_GLU +dnl +dnl Check for GLU. If GLU is found, the required preprocessor and +dnl linker flags are included in the output variables "GLU_CFLAGS" and +dnl "GLU_LIBS", respectively. This macro adds the configure option +dnl "--with-apple-opengl-framework", which users can use to indicate +dnl that Apple's OpenGL framework should be used on Mac OS X. If +dnl Apple's OpenGL framework is used, the symbol +dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GLU implementation +dnl is found, "no_glu" is set to "yes". +dnl +dnl @category InstalledPackages +dnl @author Braden McDaniel +dnl @version 2004-11-15 +dnl @license AllPermissive + +AC_DEFUN([AX_CHECK_GLU], +[AC_REQUIRE([AX_CHECK_GL])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +GLU_CFLAGS="${GL_CFLAGS}" +if test "X${with_apple_opengl_framework}" != "Xyes"; then + AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu], + [ax_cv_check_glu_libglu="no" + ax_save_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" + ax_save_LIBS="${LIBS}" + LIBS="" + ax_check_libs="-lglu32 -lGLU" + for ax_lib in ${ax_check_libs}; do + if test X$ax_compiler_ms = Xyes; then + ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` + else + ax_try_lib="${ax_lib}" + fi + LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" + # + # libGLU typically links with libstdc++ on POSIX platforms. However, + # setting the language to C++ means that test program source is named + # "conftest.cc"; and Microsoft cl doesn't know what to do with such a + # file. + # + AC_LANG_PUSH([C++]) + if test X$ax_compiler_ms = Xyes; then + AC_LANG_PUSH([C]) + fi + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +# if HAVE_WINDOWS_H && defined(_WIN32) +# include +# endif +# include ]], + [[gluBeginCurve(0)]])], + [ax_cv_check_glu_libglu="${ax_try_lib}"; break]) + if test X$ax_compiler_ms = Xyes; then + AC_LANG_POP([C]) + fi + AC_LANG_POP([C++]) + done + LIBS=${ax_save_LIBS} + CPPFLAGS=${ax_save_CPPFLAGS}]) + if test "X${ax_cv_check_glu_libglu}" = "Xno"; then + no_glu="yes" + GLU_CFLAGS="" + GLU_LIBS="" + else + GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}" + fi +fi +AC_SUBST([GLU_CFLAGS]) +AC_SUBST([GLU_LIBS]) +]) diff --git a/ax/ax_check_glut.m4 b/ax/ax_check_glut.m4 new file mode 100644 index 0000000..239769f --- a/dev/null +++ b/ax/ax_check_glut.m4 @@ -0,0 +1,78 @@ +dnl @synopsis AX_CHECK_GLUT +dnl +dnl Check for GLUT. If GLUT is found, the required compiler and linker +dnl flags are included in the output variables "GLUT_CFLAGS" and +dnl "GLUT_LIBS", respectively. This macro adds the configure option +dnl "--with-apple-opengl-framework", which users can use to indicate +dnl that Apple's OpenGL framework should be used on Mac OS X. If +dnl Apple's OpenGL framework is used, the symbol +dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If GLUT is not found, +dnl "no_glut" is set to "yes". +dnl +dnl @category InstalledPackages +dnl @author Braden McDaniel +dnl @version 2004-11-15 +dnl @license AllPermissive + +AC_DEFUN([AX_CHECK_GLUT], +[AC_REQUIRE([AX_CHECK_GLU])dnl +AC_REQUIRE([AC_PATH_XTRA])dnl + +if test "X$with_apple_opengl_framework" = "Xyes"; then + GLUT_CFLAGS="${GLU_CFLAGS}" + GLUT_LIBS="-framework GLUT -lobjc ${GL_LIBS}" +else + GLUT_CFLAGS=${GLU_CFLAGS} + GLUT_LIBS=${GLU_LIBS} + + # + # If X is present, assume GLUT depends on it. + # + # if test "X${no_x}" != "Xyes"; then + # GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}" + # fi + + AC_LANG_PUSH(C) + + ax_save_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}" + + AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut], + [ax_cv_check_glut_libglut="no" + ax_save_LIBS="${LIBS}" + LIBS="" + ax_check_libs="-lglut32 -lglut" + for ax_lib in ${ax_check_libs}; do + if test X$ax_compiler_ms = Xyes; then + ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` + else + ax_try_lib="${ax_lib}" + fi + LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +# if HAVE_WINDOWS_H && defined(_WIN32) +# include +# endif +# include ]], + [[glutMainLoop()]])], + [ax_cv_check_glut_libglut="${ax_try_lib}"; break]) + + done + LIBS=${ax_save_LIBS} + ]) + CPPFLAGS="${ax_save_CPPFLAGS}" + AC_LANG_POP(C) + + if test "X${ax_cv_check_glut_libglut}" = "Xno"; then + no_glut="yes" + GLUT_CFLAGS="" + GLUT_LIBS="" + else + GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}" + fi +fi + +AC_SUBST([GLUT_CFLAGS]) +AC_SUBST([GLUT_LIBS]) +])dnl diff --git a/ax/ax_lang_compiler_ms.m4 b/ax/ax_lang_compiler_ms.m4 new file mode 100644 index 0000000..2b3d5a8 --- a/dev/null +++ b/ax/ax_lang_compiler_ms.m4 @@ -0,0 +1,23 @@ +dnl @synopsis AX_LANG_COMPILER_MS +dnl +dnl Check whether the compiler for the current language is Microsoft. +dnl +dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU +dnl Autoconf implementation. +dnl +dnl @category InstalledPackages +dnl @author Braden McDaniel +dnl @version 2004-11-15 +dnl @license AllPermissive + +AC_DEFUN([AX_LANG_COMPILER_MS], +[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler], + [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER + choke me +#endif +]])], + [ax_compiler_ms=yes], + [ax_compiler_ms=no]) +ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms +])]) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..a7924d3 --- a/dev/null +++ b/configure.ac @@ -0,0 +1,24 @@ +AC_INIT([exp005], [0.1], [don@drexel.edu]) +AM_INIT_AUTOMAKE([-Wall, -Werror, -Wno-portability]) +AC_PROG_CC +AM_CONFIG_HEADER([config.h]) +AC_CONFIG_FILES([ + Makefile + src/Makefile +]) + +# Check for OpenGL libraries GLUT, GLU and GL. OpenGL is used for the +# visualization rendering and interaction. +AX_CHECK_GLUT + +# Check for the NCBI Toolkit libraries. +AC_SEARCH_LIBS([log10],[m]) +AC_SEARCH_LIBS([NlmThreadsAvailable],[ncbi]) +AC_SEARCH_LIBS([SeqAlignNew],[ncbiobj]) +AC_SEARCH_LIBS([Blast_RedoOneMatch],[blastcompadj]) +AC_SEARCH_LIBS([BioseqBlastEngine],[ncbitool]) + +# Check for the new curses library for terminal output. +AC_SEARCH_LIBS([clrtoeol],[ncurses]) + +AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..bd0d702 --- a/dev/null +++ b/src/Makefile.am @@ -0,0 +1,28 @@ +bin_PROGRAMS = exp004viz + +exp004viz_SOURCES = \ + controller/exp004display.c \ + controller/exp004mouse.c \ + controller/exp004processhits.c \ + controller/exp004reshape.c \ + exp004viz.c \ + model/exp004base.c \ + util/check_error.c \ + view/exp004geometry.c \ + view/exp004view.c + +exp004viz_LDADD = ${GLUT_LIBS} + +noinst_HEADERS = \ + controller/exp004display.h \ + controller/exp004mouse.h \ + controller/exp004processhits.h \ + controller/exp004reshape.h \ + model/exp004base.h \ + model/exp004state.h \ + util/check_error.h \ + view/exp004geometry.h \ + view/exp004state0.h \ + view/exp004view.h + +AM_CFLAGS = -Wall -std=gnu99 -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include/ncbi diff --git a/src/controller/exp004display.c b/src/controller/exp004display.c new file mode 100644 index 0000000..e893ad6 --- a/dev/null +++ b/src/controller/exp004display.c @@ -0,0 +1,16 @@ +#include "exp004display.h" +#include "../view/exp004geometry.h" +#include +#include + +#define WINHEIGHT 500 + +void +exp004display (void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + exp004geometry (GL_RENDER); + glutSwapBuffers (); + + return; +} diff --git a/src/controller/exp004display.h b/src/controller/exp004display.h new file mode 100644 index 0000000..6a5f9f7 --- a/dev/null +++ b/src/controller/exp004display.h @@ -0,0 +1,6 @@ +#ifndef EXP004DISPLAY_H +#define EXP004DISPLAY_H + +void exp004display (void); + +#endif // EXP004DISPLAY_H diff --git a/src/controller/exp004mouse.c b/src/controller/exp004mouse.c new file mode 100644 index 0000000..11117bf --- a/dev/null +++ b/src/controller/exp004mouse.c @@ -0,0 +1,90 @@ +#include "exp004mouse.h" +#include "exp004processhits.h" +#include "../view/exp004geometry.h" +#include "../view/exp004state0.h" +#include "../util/check_error.h" +#include +#include + +#define SIZE 500 +#define N 3 + +void +exp004mouse (int button, int state, int x, int y) +{ + + if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) + { + + /* + * "Specify the array to be used for the returned hit records + * with glSelectBuffer () [Redbook]." + */ + GLuint select_buf[SIZE]; + glSelectBuffer (SIZE, select_buf); + + /* + * "Enter selection mode by specifying GL_SELECT with + * glRenderMode () [Redbook]." + */ + glRenderMode (GL_SELECT); + + /* + * "Initialize the name stack using glInitNames () and glPush + * Names () [Redbook]." + */ + glInitNames (); + glPushName (0); + + /* + * "Define the viewing volume you want to use for selection. + * Usually this is different from the viewing volume you + * originally used to draw the scene, so you probably want to + * save and then restore the current transformation state with + * glPushMatrix () and glPopMatrix () [Redbook]." + */ + glMatrixMode (GL_PROJECTION); + glPushMatrix (); + glLoadIdentity (); + + GLint viewport[4]; + glGetIntegerv (GL_VIEWPORT, viewport); + + gluPickMatrix ((GLdouble) x, + (GLdouble) (viewport[3] - y), + N, + N, + viewport); + + gluOrtho2D(exp004state0.ortho.min_x, + exp004state0.ortho.max_x, + exp004state0.ortho.min_y, + exp004state0.ortho.max_y); + + /* + * "Alternately issue primitive drawing commands and commands to + * manipulate the name stack so that each primitive of interest + * has appropriate names assigned [Redbook]." + */ + exp004geometry (GL_SELECT); + + glMatrixMode (GL_PROJECTION); + glPopMatrix (); + glutSwapBuffers (); + + /* + * "Exit selection mode and process the returned selection data + * (the hit records) [Redbook]." + */ + GLint hits = glRenderMode (GL_RENDER); + check_error (__FILE__, __LINE__); + + /* "process hits from selection mode rendering [Angel,2008]." */ + exp004processhits (hits, select_buf); + + /* "normal render [Angel,2008]." */ + glutPostRedisplay (); + } + + return; +} diff --git a/src/controller/exp004mouse.h b/src/controller/exp004mouse.h new file mode 100644 index 0000000..a6809be --- a/dev/null +++ b/src/controller/exp004mouse.h @@ -0,0 +1,6 @@ +#ifndef EXP004MOUSE_H +#define EXP004MOUSE_H + +void exp004mouse (int button, int state, int x, int y); + +#endif // EXP004MOUSE_H diff --git a/src/controller/exp004processhits.c b/src/controller/exp004processhits.c new file mode 100644 index 0000000..29fbbbc --- a/dev/null +++ b/src/controller/exp004processhits.c @@ -0,0 +1,54 @@ +/* I seem to need this for glGenBuffers as per + http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */ +#define GL_GLEXT_PROTOTYPES + +#include "exp004processhits.h" +#include "../view/exp004state0.h" +#include + +/* + * The implementation of this function is based on + * [Angel,2008,pp80-81]. + */ +void +exp004processhits (GLint hits, GLuint buffer[]) +{ + /* + * A simple alias to make the code more readable. + */ + EXP004STATE* S = &exp004state0; + + printf ("Hits: %d\n", hits); + + GLuint *hitlist = buffer; + + for (int i = 0; i < hits; i++) + { + hitlist += 3; + + /* + * Report the hit to the terminal. + */ + printf ("Hit %i: %s\n", i + 1, exp004state0.gi_data[*hitlist]); + + /* + * Add the hits to the selection. + */ + exp004state0.selection[*hitlist] = true; + exp004state0.base_colors_data[*hitlist][0] = SELECT_COLOR_R; + exp004state0.base_colors_data[*hitlist][1] = SELECT_COLOR_G; + exp004state0.base_colors_data[*hitlist][2] = SELECT_COLOR_B; + + hitlist++; + } + + glBindBuffer (GL_ARRAY_BUFFER, S->buffers[BASE_COLORS]); + glColorPointer (3, GL_FLOAT, 0, 0); + glBufferData (GL_ARRAY_BUFFER, + sizeof (S->base_colors_data), S->base_colors_data, + GL_STATIC_DRAW); + + printf ("\n"); + + return; +} diff --git a/src/controller/exp004processhits.h b/src/controller/exp004processhits.h new file mode 100644 index 0000000..d61e9a7 --- a/dev/null +++ b/src/controller/exp004processhits.h @@ -0,0 +1,8 @@ +#ifndef EXP004PROCESSHITS_H +#define EXP004PROCESSHITS_H + +#include + +void exp004processhits (GLint hits, GLuint buffer[]); + +#endif // EXP004PROCESSHITS_H diff --git a/src/controller/exp004reshape.c b/src/controller/exp004reshape.c new file mode 100644 index 0000000..7aaff08 --- a/dev/null +++ b/src/controller/exp004reshape.c @@ -0,0 +1,55 @@ +#include "exp004reshape.h" +#include "../view/exp004state0.h" +#include + +void +exp004reshape (int w, int h) +{ + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + + /* + * This scaling produces an odd effect when the coordinates are not + * centered at 0,0. When 0,0 is the lower left rather than the + * center this reshape is a bit unnatural since the image is not + * centered in the middle of the window. + */ + + if (w <= h) + { + exp004state0.ortho.min_x = + exp004state0.ortho_min; + exp004state0.ortho.max_x = + exp004state0.ortho_max; + exp004state0.ortho.min_y = + exp004state0.ortho_min * (GLfloat) h / (GLfloat) w; + exp004state0.ortho.max_y = + exp004state0.ortho_max * (GLfloat) h / (GLfloat) w; + } + else + { + exp004state0.ortho.min_x = + exp004state0.ortho_min * (GLfloat) w / (GLfloat) h; + exp004state0.ortho.max_x = + exp004state0.ortho_max * (GLfloat) w / (GLfloat) h; + exp004state0.ortho.min_y = + exp004state0.ortho_min; + exp004state0.ortho.max_y = + exp004state0.ortho_max; + } + + gluOrtho2D(exp004state0.ortho.min_x, + exp004state0.ortho.max_x, + exp004state0.ortho.min_y, + exp004state0.ortho.max_y); + + glMatrixMode (GL_MODELVIEW); + + // Set the viewport equal to the size of the window. + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + + exp004state0.viewport.w = w; + exp004state0.viewport.h = h; + + return; +} diff --git a/src/controller/exp004reshape.h b/src/controller/exp004reshape.h new file mode 100644 index 0000000..3bb20a5 --- a/dev/null +++ b/src/controller/exp004reshape.h @@ -0,0 +1,6 @@ +#ifndef EXP004RESHAPE_H +#define EXP004RESHAPE_H + +void exp004reshape (int w, int h); + +#endif // EXP004RESHAPE_H diff --git a/src/exp004viz.c b/src/exp004viz.c new file mode 100644 index 0000000..08d5953 --- a/dev/null +++ b/src/exp004viz.c @@ -0,0 +1,15 @@ +#include +#include "view/exp004view.h" + +int +main (int argc, char **argv) +{ + glutInit (&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); + + exp004view (); + + glutMainLoop (); + + return 0; +} diff --git a/src/model/exp004base.c b/src/model/exp004base.c new file mode 100644 index 0000000..56a20e5 --- a/dev/null +++ b/src/model/exp004base.c @@ -0,0 +1,107 @@ +/* I seem to need this for glGenBuffers as per + http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */ +#define GL_GLEXT_PROTOTYPES + +#include "exp004base.h" +#include "../view/exp004state0.h" +#include +#include +#include + +void +exp004base (void) +{ + /* + * A simple alias to make the code more readable. + */ + EXP004STATE* S = &exp004state0; + + /* + * This implementation can be improved by mapping the video memory + * directly rather than loading into system memory and then copying + * into video memory. + */ + + FILE* coords = + fopen ("/home/don/exp004/test/run20090514/run20090514.coords", "r"); + int i = 0; + + /* + * Initialize the bounding box of the points. + */ + S->bb.min_x = 0.0; + S->bb.max_x = 0.0; + S->bb.min_y = 0.0; + S->bb.max_y = 0.0; + + for (i = 0; i < ROWS; i++) + { + fscanf (coords, "%s %f %f\n", + S->gi_data[i], + &S->base_vertices_data[i][0], + &S->base_vertices_data[i][1]); + + if (S->base_vertices_data[i][0] < S->bb.min_x) + S->bb.min_x = S->base_vertices_data[i][0]; + if (S->base_vertices_data[i][0] > S->bb.max_x) + S->bb.max_x = S->base_vertices_data[i][0]; + if (S->base_vertices_data[i][1] < S->bb.min_y) + S->bb.min_y = S->base_vertices_data[i][1]; + if (S->base_vertices_data[i][1] > S->bb.max_y) + S->bb.max_y = S->base_vertices_data[i][1]; + + /* + * Deselected by default. + */ + S->selection[i] = false; + + S->base_colors_data[i][0] = DEFAULT_COLOR_R; + S->base_colors_data[i][1] = DEFAULT_COLOR_G; + S->base_colors_data[i][2] = DEFAULT_COLOR_B; + } + fclose (coords); + + /* + * Find the largest axis and use it to setup the projection. This + * is done to preserve the aspect ratio. The aspect ratio should be + * preserved since relative distance is a meaningful indicator in + * the map. + */ + + // Min of min x or min y. + if (S->bb.min_x <= S->bb.min_y) + S->ortho_min = S->bb.min_x; + else + S->ortho_min = S->bb.min_y; + S->ortho_min--; + + // Max of max x or max y. + if (S->bb.max_x >= S->bb.max_y) + S->ortho_max = S->bb.max_x; + else + S->ortho_max = S->bb.max_y; + S->ortho_max++; + + // Invert the y coordinate to match up with the LGL Java viewer. + for (i = 0; i < ROWS; i++) + S->base_vertices_data[i][1] = + S->ortho_max - S->base_vertices_data[i][1]; + + S->points = i; + + glGenBuffers (2, S->buffers); + + glBindBuffer (GL_ARRAY_BUFFER, S->buffers[BASE_VERTICES]); + glVertexPointer (2, GL_FLOAT, 0, 0); + glBufferData (GL_ARRAY_BUFFER, + sizeof (S->base_vertices_data), S->base_vertices_data, + GL_STATIC_DRAW); + + glBindBuffer (GL_ARRAY_BUFFER, S->buffers[BASE_COLORS]); + glColorPointer (3, GL_FLOAT, 0, 0); + glBufferData (GL_ARRAY_BUFFER, + sizeof (S->base_colors_data), S->base_colors_data, + GL_STATIC_DRAW); + + return; +} diff --git a/src/model/exp004base.h b/src/model/exp004base.h new file mode 100644 index 0000000..4f8492d --- a/dev/null +++ b/src/model/exp004base.h @@ -0,0 +1,9 @@ +#ifndef EXP004BASE_H +#define EXP004BASE_H + +/* + * Build the base layer of the map. + */ +void exp004base (void); + +#endif // EXP004BASE_H diff --git a/src/model/exp004state.h b/src/model/exp004state.h new file mode 100644 index 0000000..e45f679 --- a/dev/null +++ b/src/model/exp004state.h @@ -0,0 +1,101 @@ +#ifndef EXP004STATE_H +#define EXP004STATE_H + +#include + +/* + * Buffer object identifiers. + */ +#define BASE_VERTICES 0 +#define BASE_COLORS 1 + +/* + * Vertices in the graph. + */ +#define ROWS 83905 + +#define DEFAULT_COLOR_R 0.2 +#define DEFAULT_COLOR_G 0.2 +#define DEFAULT_COLOR_B 0.2 + +#define SELECT_COLOR_R 1.0 +#define SELECT_COLOR_G 1.0 +#define SELECT_COLOR_B 1.0 + +/* + * Maintain state of the model. + */ +typedef struct +{ + + /* + * Track the bounding box of the points. + */ + struct { + float min_x; + float max_x; + float min_y; + float max_y; + } bb; + + /* + * Minimum coordinate for the orthographic projection. + */ + float ortho_min; + + /* + * Maximum coordinate for the orthographic projection. + */ + float ortho_max; + + /* + * Orthographic coordinates after aspect preserving scaling. + */ + struct { + float min_x; + float max_x; + float min_y; + float max_y; + } ortho; + + /* + * Viewport size. + */ + struct { + int w; + int h; + } viewport; + + /* + * Points loaded. + */ + int points; + + /* + * Buffer objects. + */ + unsigned int buffers[1]; + + /* + * GI Identifiers indexed by row. + */ + char gi_data[ROWS][20]; + + /* + * 2D coordinates for each protein. + */ + float base_vertices_data[ROWS][2]; + + /* + * RGB color for each protein. + */ + float base_colors_data[ROWS][3]; + + /* + * Selection list. + */ + bool selection[ROWS]; + +} EXP004STATE; + +#endif // EXP004STATE_H diff --git a/src/util/check_error.c b/src/util/check_error.c new file mode 100644 index 0000000..dbe5b8f --- a/dev/null +++ b/src/util/check_error.c @@ -0,0 +1,17 @@ +#include +#include +#include + +void +check_error (const char *filename, unsigned int linenum) +{ + GLenum errCode = glGetError (); + if (errCode != GL_NO_ERROR) + { + const GLubyte *errString = gluErrorString (errCode); + error_at_line (-1, errno, filename, linenum, + "OpenGL Error %s", errString); + } + + return; +} diff --git a/src/util/check_error.h b/src/util/check_error.h new file mode 100644 index 0000000..7aa6495 --- a/dev/null +++ b/src/util/check_error.h @@ -0,0 +1,9 @@ +#ifndef CHECK_ERROR_H +#define CHECK_ERROR_H + +/* + * Based on example 14-1 in Shreiner p603. + */ +void check_error (const char *filename, unsigned int linenum); + +#endif // CHECK_ERROR_H diff --git a/src/view/exp004geometry.c b/src/view/exp004geometry.c new file mode 100644 index 0000000..9ff6475 --- a/dev/null +++ b/src/view/exp004geometry.c @@ -0,0 +1,32 @@ +/* I seem to need this for glGenBuffers as per + http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */ +#define GL_GLEXT_PROTOTYPES + +#include "exp004geometry.h" +#include "exp004state0.h" +#include + +void +exp004geometry (GLenum mode) +{ + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + + glPointSize (0.1); + glColor3f (0.2, 0.2, 0.2); + + if (mode == GL_SELECT) + { + for (int i = 0; i < ROWS; i++) + { + glLoadName (i); + glDrawArrays (GL_POINTS, i, 1); + } + } + else + { + glDrawArrays (GL_POINTS, 0, ROWS); + } + + return; +} diff --git a/src/view/exp004geometry.h b/src/view/exp004geometry.h new file mode 100644 index 0000000..582be48 --- a/dev/null +++ b/src/view/exp004geometry.h @@ -0,0 +1,8 @@ +#ifndef EXP004GEOMETRY_H +#define EXP004GEOMETRY_H + +#include + +void exp004geometry (GLenum mode); + +#endif // EXP004GEOMETRY_H diff --git a/src/view/exp004state0.h b/src/view/exp004state0.h new file mode 100644 index 0000000..2b60ce9 --- a/dev/null +++ b/src/view/exp004state0.h @@ -0,0 +1,8 @@ +#ifndef EXP004STATE0_H +#define EXP004STATE0_H + +#include "../model/exp004state.h" + +EXP004STATE exp004state0; + +#endif // EXP004STATE0_H diff --git a/src/view/exp004view.c b/src/view/exp004view.c new file mode 100644 index 0000000..5e3b8ab --- a/dev/null +++ b/src/view/exp004view.c @@ -0,0 +1,44 @@ +#include "../controller/exp004display.h" +#include "../controller/exp004mouse.h" +#include "../controller/exp004reshape.h" +#include "../model/exp004base.h" +#include "exp004view.h" +#include + +void +exp004view (void) +{ + // GLUT Initialization + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow ("Exp004"); + + // GL Initialization + glClearColor (0.0, 0.0, 0.0, 1.0); + glColor3f (1.0, 1.0, 1.0); + glEnable (GL_AUTO_NORMAL); + glEnable (GL_DEPTH_TEST); + glEnable (GL_MAP1_VERTEX_3); + glShadeModel (GL_SMOOTH); + + /* Buffer objects to use. */ + glEnableClientState (GL_COLOR_ARRAY); + glEnableClientState (GL_VERTEX_ARRAY); + + /* Enable Antialiasing as described in "Antialiasing" + [Shreiner,247]. */ + glEnable (GL_LINE_SMOOTH); + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); + + // Initialize the model. + exp004base (); + + // Callbacks (Controllers) + glutDisplayFunc (exp004display); + glutMouseFunc (exp004mouse); + glutReshapeFunc (exp004reshape); + + return; +} diff --git a/src/view/exp004view.h b/src/view/exp004view.h new file mode 100644 index 0000000..0086f53 --- a/dev/null +++ b/src/view/exp004view.h @@ -0,0 +1,6 @@ +#ifndef EXP004VIEW_H +#define EXP004VIEW_H + +void exp004view (void); + +#endif // EXP004VIEW_H -- cgit v0.8.3.1-22-g547a