--- /dev/null
+# Doxyfile 1.4.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = mussa
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = $Revision$
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish,
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese,
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish,
+# Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# This tag can be used to specify the encoding used in the generated output.
+# The encoding is not always determined by the language that is chosen,
+# but also whether or not the output is meant for Windows or non-Windows users.
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
+# forces the Windows encoding (this is the default for the Windows binary),
+# whereas setting the tag to NO uses a Unix-style encoding (the default for
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
+# only. Doxygen will then generate output that is more tailored for Java.
+# For instance, namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is YES.
+
+SHOW_DIRECTORIES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from the
+# version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the progam writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT =
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that a graph may be further truncated if the graph's
+# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH
+# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default),
+# the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, which results in a white background.
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
-# may the coders of gcc be infested with the fleas of ten thousand camels...
+BASEDIR := ./
-CFLAGS=-ftemplate-depth-25
-#CFLAGS= -ftemplate-depth-25 -ggdb
-#-Winline
+CXXFLAGS :=
+LDFLAGS := -lfltk
-OFLAG= -O
+# each module will add to this, .os are derived from it
+SRC :=
-# this is sufficient on debian machines
-#LDFLAGS= -lfltk
+include module.mk
+include gui/module.mk
-# this is what's needed on redhat machines
-#LDFLAGS= -lfltk -L/usr/X11R6/lib -lX11
-# this is what's needed on fedora machines
-#LDFLAGS= -lfltk -L/usr/X11R6/lib -lX11 -lXft
+# process what the module.mks defined
+OBJ := $(patsubst %.cxx,%.o, $(filter %.cxx,$(SRC)))
+DEPS := $(OBJ:.o=.d)
-# this is what's needed on gentoo machines
-LDFLAGS= -L/usr/lib/fltk-1.1/ -lfltk -L/usr/X11R6/lib -lX11 -lXft
-
-# needed for apple/OS X
-#LDFLAGS= -framework Carbon -framework ApplicationServices -lfltk
-
-# needed for cygwin/mingw32
-#CFLAGS=-ftemplate-depth-25 -mno-cygwin
-#LDFLAGS= -lfltk -L/usr/lib/w32lib -lgdi32 -lws2_32 -luuid -lole32
+mussa: $(OBJ)
+ g++ -o $@ $(CXXFLAGS) $(LDFLAGS) $^
-# to check for memory leaks
-MEMFLAG= -lefence
+%.d: %.cxx
+ makedepend -o.d $(dirname $^) $(CFLAGS) $(CXXFILAGS) $^ -f- > $@
-all: mussa
+%.o: %.cxx
+ g++ -c -o $@ $(CXXFLAGS) $^
-sequence.o : sequence.cc sequence.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c sequence.cc
+include $(DEPS)
-flp.o : flp.cc flp.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c flp.cc
+clean:
+ -rm $(OBJ) $(DEPS)
-flp_seqcomp.o : flp_seqcomp.cc flp.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c flp_seqcomp.cc
-seqcomp : seqcomp.cc flp.o flp_seqcomp.o sequence.o
- $(CXX) $(CFLAGS) $(OFLAG) -o seqcomp seqcomp.cc flp.o flp_seqcomp.o sequence.o
-
-mussa_nway.o : mussa_nway.cc mussa_nway.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c mussa_nway.cc
-
-mussa_nway_other.o : mussa_nway_other.cc mussa_nway.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c mussa_nway_other.cc
-
-mussa_nway_entropy.o : mussa_nway_entropy.cc mussa_nway.hh
- $(CXX) $(CFLAGS) $(OFLAG) -c mussa_nway_entropy.cc
-
-mussa_class.o : mussa_class.cc mussa_class.hh
- $(CXX) $(CFLAGS) -c mussa_class.cc
-
-mussan : sequence.o flp.o flp_seqcomp.o mussa_nway.o mussa_class.o \
- mussa_overlord.o mussa.cc
- $(CXX) $(CFLAGS) -o mussa mussa.cc mussa_overlord.o \
- mussa_class.o mussa_nway.o flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
-
-mussa_gui_seq_view.o : mussa_gui_seq_view.cc mussa_gui_seq_view.hh
- $(CXX) $(CFLAGS) -c mussa_gui_seq_view.cc
-
-mussa_gui_seq.o : mussa_gui_seq.cc mussa_gui_seq.hh
- $(CXX) $(CFLAGS) -c mussa_gui_seq.cc
-
-mussa_gui_seq_text.o : mussa_gui_seq_text.cc mussa_gui_seq_text.hh
- $(CXX) $(CFLAGS) -c mussa_gui_seq_text.cc
-
-mussa_gui_motif_window.o : mussa_gui_motif_window.cc mussa_gui_motif_window.hh
- $(CXX) $(CFLAGS) -c mussa_gui_motif_window.cc
-
-mussa_gui_annot_window.o : mussa_gui_annot_window.cc mussa_gui_annot_window.hh
- $(CXX) $(CFLAGS) -c mussa_gui_annot_window.cc
-
-mussa_gui_load_window.o : mussa_gui_load_window.cc mussa_gui_load_window.hh
- $(CXX) $(CFLAGS) -c mussa_gui_load_window.cc
-
-mussa_gui_subana.o : mussa_gui_subana.cc mussa_gui_subana.hh
- $(CXX) $(CFLAGS) -c mussa_gui_subana.cc
-
-mussa_gui_conn_view.o : mussa_gui_conn_view.cc mussa_gui_conn_view.hh
- $(CXX) $(CFLAGS) -O -c mussa_gui_conn_view.cc
-
-mussa_gui_conn_window.o : mussa_gui_conn_window.cc mussa_gui_conn_window.hh
- $(CXX) $(CFLAGS) -c mussa_gui_conn_window.cc
-
-mussa : sequence.o flp.o flp_seqcomp.o \
- mussa_nway.o mussa_nway_other.o \
- mussa_nway_entropy.o mussa_class.o \
- mussa_gui_seq.o mussa_gui_seq_view.o \
- mussa_gui_motif_window.o mussa_gui_annot_window.o \
- mussa_gui_load_window.o mussa_gui_subana.o \
- mussa_gui_seq_text.o \
- mussa_gui_conn_view.o mussa_gui_conn_window.o \
- mussa.cc
- $(CXX) $(CFLAGS) -o mussa mussa.cc \
- mussa_gui_conn_view.o mussa_gui_conn_window.o \
- mussa_gui_seq_text.o \
- mussa_gui_subana.o mussa_gui_load_window.o \
- mussa_gui_motif_window.o mussa_gui_annot_window.o \
- mussa_gui_seq.o mussa_gui_seq_view.o \
- mussa_class.o mussa_nway.o \
- mussa_nway_entropy.o mussa_nway_other.o \
- flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
-
-
-clean :
- rm *.o
-
-cleaner :
- rm *~
-
-#mussa_overlord.o : mussa_overlord.cc mussa_overlord.hh
-# $(CXX) $(CFLAGS) -c mussa_overlord.cc
-
-
-
-annot_test : sequence.o annot_test.cc
- $(CXX) $(CFLAGS) -o annot_test annot_test.cc sequence.o
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// ----------------------------------------
-// ---------- flp.cc -----------
-// ----------------------------------------
-
-#include "flp.hh"
-
-#include <fstream>
-#include <iostream>
-
-using namespace std;
-
-FLPs::FLPs()
-{
-}
-
-void
-FLPs::setup(string type, int win_size, int hard_thres, int len1, int len2)
-{
- list<match> empty_match_list;
- int i;
-
- window_size = win_size;
- hard_threshold = hard_thres;
- seq1_length = len1;
- seq2_length = len2;
- ana_type = type;
- seq1_win_num = seq1_length - win_size + 1;
- seq2_win_num = seq2_length - win_size + 1;
- all_matches.reserve(seq1_win_num);
-
- empty_match_list.clear();
- for(i = 0; i < seq1_win_num; i++)
- all_matches.push_back(empty_match_list);
-}
-
-int
-FLPs::win_num()
-{
- return seq1_win_num;
-}
-
-/*
-bool
-FLPs::match_less(match *match1, match *match2)
-{
- if (match1->score < match2->score)
- return true;
- else if ( (match1->score == match2->score) &&
- (match1->index < match2->index) )
- return true;
- else
- return false;
-}
-
-void
-FLPs::sort()
-{
- int i;
-
- for(i = 0; i < seq1_win_num; i++)
- if (!all_matches[i].empty())
- all_matches[i].sort(&FLPs::match_less);
-}
-*/
-
-list<int>
-FLPs::matches(int index)
-{
- list<int> these_matches;
- list<match>::iterator list_i, list_end;
-
- index = abs(index);
- list_i = all_matches[index].begin();
- list_end = all_matches[index].end();
- //if (list_i == list_end)
- //cout << "its fuckin empty!!!!";
- while (list_i != list_end)
- {
- these_matches.push_back(list_i->index);
- //cout << list_i->index << " ";
- ++list_i;
- }
- //cout << endl;
-
- return these_matches;
-}
-
-list<int>
-FLPs::thres_matches(int index, int thres)
-{
- list<int> thres_matches;
- list<match>::iterator list_i, list_end;
-
- index = abs(index);
- list_i = all_matches[index].begin();
- list_end = all_matches[index].end();
- thres_matches.clear();
-
- //if (list_i == list_end)
- //cout << "its fuckin empty!!!!";
- while (list_i != list_end)
- {
- if (list_i->score >= thres)
- thres_matches.push_back(list_i->index);
- //cout << list_i->index << " ";
-
- ++list_i;
- }
- //cout << endl;
-
- return thres_matches;
-}
-
-
-void
-FLPs::file_save(string save_file_path)
-{
- fstream save_file;
- list<match>::iterator match_i, match_list_end;
- int i;
-
- save_file.open(save_file_path.c_str(), ios::out);
-
- save_file << "<Seqcomp type=" << ana_type << " win=" << window_size;
- save_file << " thres=" << hard_threshold << ">\n";
-
- for(i = 0; i < seq1_win_num; i++)
- {
- if (!all_matches[i].empty())
- {
- match_i = all_matches[i].begin();
- match_list_end = all_matches[i].end();
- while (match_i != match_list_end)
- {
- save_file << match_i->index << "," << match_i->score << " ";
- ++match_i;
- }
- }
- save_file << endl;
- }
-
- save_file << "</Seqcomp>\n";
-
- save_file.close();
-}
-
-void
-FLPs::file_load(string file_path)
-{
- fstream data_file;
- string file_data, file_data_line, pair_data, index_data, score_data;
- int type, window, hard_thres;
- match a_match;
- string::size_type split_index, comma_index;
- bool tag_open = false;
- list<match> a_match_list;
- int i;
-
-
-
-
-
-
- data_file.open(file_path.c_str(), ios::in);
-
- getline(data_file,file_data_line);
- // parse seqcomp open tag and parameters
- // eg <Seqcomp type=mussa win=30 thres=21>
- // if parse successful...
- tag_open = true;
-
- while ((!data_file.eof()) && tag_open)
- {
- // intialize list to empty
- a_match_list.clear();
-
- getline(data_file,file_data_line);
-
- if (file_data_line == "</Seqcomp>")
- tag_open = false;
- // parse line of matches
- else if (file_data_line == "")
- {
- //cout << "empty line\n";
- all_matches.push_back(a_match_list);
- }
- else
- {
- split_index = file_data_line.find(" ");
-
- while (split_index != string::npos)
- {
- pair_data = file_data_line.substr(0,split_index);
- file_data_line = file_data_line.substr(split_index+1);
- //cout << "pair_data = " << pair_data << "...";
- // parse out the 2 pieces of data, index and score of pair match
- comma_index = pair_data.find(",");
- index_data = pair_data.substr(0, comma_index);
- a_match.index = atoi(index_data.c_str() );
- score_data = pair_data.substr(comma_index+1);
- a_match.score = atoi(score_data.c_str() );
-
- //cout << a_match.index << "," << a_match.score << " ";
-
- a_match_list.push_back(a_match);
-
- split_index = file_data_line.find(" ");
- }
- //cout << "\n";
- all_matches.push_back(a_match_list);
- }
- }
- seq1_win_num = all_matches.size();
- cout << "windows in flp = " << all_matches.size() << endl;
- data_file.close();
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe ";
- cout << "fum\n";
-*/
-
-
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// ----------------------------------------
+// ---------- flp.cc -----------
+// ----------------------------------------
+
+#include "flp.hh"
+
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+
+FLPs::FLPs()
+{
+}
+
+void
+FLPs::setup(string type, int win_size, int hard_thres, int len1, int len2)
+{
+ list<match> empty_match_list;
+ int i;
+
+ window_size = win_size;
+ hard_threshold = hard_thres;
+ seq1_length = len1;
+ seq2_length = len2;
+ ana_type = type;
+ seq1_win_num = seq1_length - win_size + 1;
+ seq2_win_num = seq2_length - win_size + 1;
+ all_matches.reserve(seq1_win_num);
+
+ empty_match_list.clear();
+ for(i = 0; i < seq1_win_num; i++)
+ all_matches.push_back(empty_match_list);
+}
+
+int
+FLPs::win_num()
+{
+ return seq1_win_num;
+}
+
+/*
+bool
+FLPs::match_less(match *match1, match *match2)
+{
+ if (match1->score < match2->score)
+ return true;
+ else if ( (match1->score == match2->score) &&
+ (match1->index < match2->index) )
+ return true;
+ else
+ return false;
+}
+
+void
+FLPs::sort()
+{
+ int i;
+
+ for(i = 0; i < seq1_win_num; i++)
+ if (!all_matches[i].empty())
+ all_matches[i].sort(&FLPs::match_less);
+}
+*/
+
+list<int>
+FLPs::matches(int index)
+{
+ list<int> these_matches;
+ list<match>::iterator list_i, list_end;
+
+ index = abs(index);
+ list_i = all_matches[index].begin();
+ list_end = all_matches[index].end();
+ //if (list_i == list_end)
+ //cout << "its fuckin empty!!!!";
+ while (list_i != list_end)
+ {
+ these_matches.push_back(list_i->index);
+ //cout << list_i->index << " ";
+ ++list_i;
+ }
+ //cout << endl;
+
+ return these_matches;
+}
+
+list<int>
+FLPs::thres_matches(int index, int thres)
+{
+ list<int> thres_matches;
+ list<match>::iterator list_i, list_end;
+
+ index = abs(index);
+ list_i = all_matches[index].begin();
+ list_end = all_matches[index].end();
+ thres_matches.clear();
+
+ //if (list_i == list_end)
+ //cout << "its fuckin empty!!!!";
+ while (list_i != list_end)
+ {
+ if (list_i->score >= thres)
+ thres_matches.push_back(list_i->index);
+ //cout << list_i->index << " ";
+
+ ++list_i;
+ }
+ //cout << endl;
+
+ return thres_matches;
+}
+
+
+void
+FLPs::file_save(string save_file_path)
+{
+ fstream save_file;
+ list<match>::iterator match_i, match_list_end;
+ int i;
+
+ save_file.open(save_file_path.c_str(), ios::out);
+
+ save_file << "<Seqcomp type=" << ana_type << " win=" << window_size;
+ save_file << " thres=" << hard_threshold << ">\n";
+
+ for(i = 0; i < seq1_win_num; i++)
+ {
+ if (!all_matches[i].empty())
+ {
+ match_i = all_matches[i].begin();
+ match_list_end = all_matches[i].end();
+ while (match_i != match_list_end)
+ {
+ save_file << match_i->index << "," << match_i->score << " ";
+ ++match_i;
+ }
+ }
+ save_file << endl;
+ }
+
+ save_file << "</Seqcomp>\n";
+
+ save_file.close();
+}
+
+void
+FLPs::file_load(string file_path)
+{
+ fstream data_file;
+ string file_data, file_data_line, pair_data, index_data, score_data;
+ int type, window, hard_thres;
+ match a_match;
+ string::size_type split_index, comma_index;
+ bool tag_open = false;
+ list<match> a_match_list;
+ int i;
+
+
+
+
+
+
+ data_file.open(file_path.c_str(), ios::in);
+
+ getline(data_file,file_data_line);
+ // parse seqcomp open tag and parameters
+ // eg <Seqcomp type=mussa win=30 thres=21>
+ // if parse successful...
+ tag_open = true;
+
+ while ((!data_file.eof()) && tag_open)
+ {
+ // intialize list to empty
+ a_match_list.clear();
+
+ getline(data_file,file_data_line);
+
+ if (file_data_line == "</Seqcomp>")
+ tag_open = false;
+ // parse line of matches
+ else if (file_data_line == "")
+ {
+ //cout << "empty line\n";
+ all_matches.push_back(a_match_list);
+ }
+ else
+ {
+ split_index = file_data_line.find(" ");
+
+ while (split_index != string::npos)
+ {
+ pair_data = file_data_line.substr(0,split_index);
+ file_data_line = file_data_line.substr(split_index+1);
+ //cout << "pair_data = " << pair_data << "...";
+ // parse out the 2 pieces of data, index and score of pair match
+ comma_index = pair_data.find(",");
+ index_data = pair_data.substr(0, comma_index);
+ a_match.index = atoi(index_data.c_str() );
+ score_data = pair_data.substr(comma_index+1);
+ a_match.score = atoi(score_data.c_str() );
+
+ //cout << a_match.index << "," << a_match.score << " ";
+
+ a_match_list.push_back(a_match);
+
+ split_index = file_data_line.find(" ");
+ }
+ //cout << "\n";
+ all_matches.push_back(a_match_list);
+ }
+ }
+ seq1_win_num = all_matches.size();
+ cout << "windows in flp = " << all_matches.size() << endl;
+ data_file.close();
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe ";
+ cout << "fum\n";
+*/
+
+
#include <string>
#include <vector>
-
-// FLP = Fixed Length Pairs (Data)
-// vector of linked lists of the match type struct
+//! FLP = Fixed Length Pairs (Data)
+/*!
+ * vector of linked lists of the match type struct
+ */
class FLPs
{
private:
+ //! the number of base pairs used to compute this sliding window
int window_size;
+ //! the minimum tnumber of base pairs need for this window to be saved.
int hard_threshold;
int seq1_length, seq2_length, seq1_win_num, seq2_win_num;
std::string ana_type;
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// ----------------------------------------
-// ---------- flp_seqcomp.cc -----------
-// ----------------------------------------
-
-#include "flp.hh"
-using namespace std;
-
-// Note one recording RC matches. This version of 'seqcomp' records RC matches
-// as index of the window start in its nonRC form. However, past versions of
-// the analysis recorded it as the index of the rear of the window, as the
-// following legacy comment indicates. FR still uses this method
-
-// Titus thinks the start of an RC window should be its "rear" in the
-// normal version of the sequence. He's wrong, of course, and in the
-// future my followers will annihilate his in the Final Battle, but for
-// now I'll let him have his way.
-
-// note seq2_i is actually the index of the leaving bp, so need to +1
-
-inline void
-FLPs::add(int seq1_i, int seq2_i, int a_score, int i2_offset)
-{
- match a_match;
-
-
- if (a_score >= hard_threshold)
- {
- a_match.index = seq2_i + i2_offset;
- a_match.score = a_score;
-
- all_matches[seq1_i].push_back(a_match);
- }
-}
-
-
-void
-FLPs::seqcomp(string sseq1, string sseq2, bool is_RC)
-{
- int start_i, seq1_i, seq2_i, win_i; // loop variables
- int matches; // number of matches in to a window
- int i2_offset;
- char * seq1, * seq2;
-
-
- seq1 = (char *) sseq1.c_str();
- seq2 = (char *) sseq2.c_str();
-
-
- if (is_RC)
- i2_offset = window_size - seq2_length;
- else
- i2_offset = 0;
-
-
- // this does the "upper diagonals" of the search
-
- // loop thru the start positions for sequence 1
- for(start_i = 0; start_i < seq1_win_num; start_i++)
- {
- matches = 0;
- // compare initial window
- for(win_i = 0; win_i < window_size; win_i++)
- if ((seq1[start_i+win_i] == seq2[win_i]) &&
- (seq1[start_i+win_i] != 'N')) // N's match nothing **
- matches++;
-
- //seq2_i is always 0 for initial win
- seq2_i = 0;
-
- // call inlined function that adds match if it is above threshold
- add(start_i, seq2_i, matches, i2_offset);
-
- // run through rest of seq1 and seq2 with current seq1 offset (ie start_i)
- // compare the bps leaving and entering the window and modify matches count
- seq1_i = start_i;
- while( (seq1_i < seq1_win_num-1) && (seq2_i < seq2_win_num-1) )
- {
- // copmpare the bp leaving the window
- if ((seq1[seq1_i] == seq2[seq2_i]) &&
- (seq1[seq1_i] != 'N')) // N's match nothing
- matches = matches -1;
-
- // compare the bp entering the window
- if ((seq1[seq1_i+window_size] == seq2[seq2_i+window_size]) &&
- (seq1[seq1_i+window_size] != 'N')) // N's match nothing
- matches = matches + 1;
-
- add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
-
- seq1_i = seq1_i + 1; // increment seq1_i to next window
- seq2_i = seq2_i + 1; // increment seq2_i to next window
- } // end of loop thru the current offset sequence
- } // end of loop thru the start positions of seq1 sequence
-
-
- // this does the "lower diagonals" of the search
-
- // loop thru the start positions for sequence 1
- for(start_i = 1; start_i < seq2_win_num; start_i++)
- {
- matches = 0;
-
- // compare initial window
- for(win_i = 0; win_i < window_size; win_i++)
- if ((seq2[start_i+win_i] == seq1[win_i]) &&
- (seq2[start_i+win_i] != 'N')) // N's match nothing
- matches++;
-
- //seq2_i is always start_i for initial window
- seq2_i = start_i;
-
- add(0, seq2_i, matches, i2_offset);
-
- // run through rest of seq1 and seq2 with current seq1 offset (ie start_i)
- // compare the bps leaving and entering the window and modify matches count
- seq1_i = 0;
- while( (seq1_i < seq1_win_num-1) && (seq2_i < seq2_win_num-1) )
- {
- // copmpare the bp leaving the window
- if ((seq1[seq1_i] == seq2[seq2_i]) &&
- (seq1[seq1_i] != 'N')) // N's match nothing
- matches = matches - 1;
-
- // compare the bp entering the window
- if ((seq1[seq1_i+window_size] == seq2[seq2_i+window_size]) &&
- (seq1[seq1_i+window_size] != 'N')) // N's match nothing
- matches = matches + 1;
-
- add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
-
- seq1_i = seq1_i + 1; // increment seq1_i to next window
- seq2_i = seq2_i + 1; // increment seq2_i to next window
- } // end of loop thru the current offset sequence
- } // end of loop thru the start positions of seq2 sequence
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// ----------------------------------------
+// ---------- flp_seqcomp.cc -----------
+// ----------------------------------------
+
+#include "flp.hh"
+using namespace std;
+
+// Note one recording RC matches. This version of 'seqcomp' records RC matches
+// as index of the window start in its nonRC form. However, past versions of
+// the analysis recorded it as the index of the rear of the window, as the
+// following legacy comment indicates. FR still uses this method
+
+// Titus thinks the start of an RC window should be its "rear" in the
+// normal version of the sequence. He's wrong, of course, and in the
+// future my followers will annihilate his in the Final Battle, but for
+// now I'll let him have his way.
+
+// note seq2_i is actually the index of the leaving bp, so need to +1
+
+inline void
+FLPs::add(int seq1_i, int seq2_i, int a_score, int i2_offset)
+{
+ match a_match;
+
+
+ if (a_score >= hard_threshold)
+ {
+ a_match.index = seq2_i + i2_offset;
+ a_match.score = a_score;
+
+ all_matches[seq1_i].push_back(a_match);
+ }
+}
+
+
+void
+FLPs::seqcomp(string sseq1, string sseq2, bool is_RC)
+{
+ int start_i, seq1_i, seq2_i, win_i; // loop variables
+ int matches; // number of matches in to a window
+ int i2_offset;
+ char * seq1, * seq2;
+
+
+ seq1 = (char *) sseq1.c_str();
+ seq2 = (char *) sseq2.c_str();
+
+
+ if (is_RC)
+ i2_offset = window_size - seq2_length;
+ else
+ i2_offset = 0;
+
+
+ // this does the "upper diagonals" of the search
+
+ // loop thru the start positions for sequence 1
+ for(start_i = 0; start_i < seq1_win_num; start_i++)
+ {
+ matches = 0;
+ // compare initial window
+ for(win_i = 0; win_i < window_size; win_i++)
+ if ((seq1[start_i+win_i] == seq2[win_i]) &&
+ (seq1[start_i+win_i] != 'N')) // N's match nothing **
+ matches++;
+
+ //seq2_i is always 0 for initial win
+ seq2_i = 0;
+
+ // call inlined function that adds match if it is above threshold
+ add(start_i, seq2_i, matches, i2_offset);
+
+ // run through rest of seq1 and seq2 with current seq1 offset (ie start_i)
+ // compare the bps leaving and entering the window and modify matches count
+ seq1_i = start_i;
+ while( (seq1_i < seq1_win_num-1) && (seq2_i < seq2_win_num-1) )
+ {
+ // copmpare the bp leaving the window
+ if ((seq1[seq1_i] == seq2[seq2_i]) &&
+ (seq1[seq1_i] != 'N')) // N's match nothing
+ matches = matches -1;
+
+ // compare the bp entering the window
+ if ((seq1[seq1_i+window_size] == seq2[seq2_i+window_size]) &&
+ (seq1[seq1_i+window_size] != 'N')) // N's match nothing
+ matches = matches + 1;
+
+ add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
+
+ seq1_i = seq1_i + 1; // increment seq1_i to next window
+ seq2_i = seq2_i + 1; // increment seq2_i to next window
+ } // end of loop thru the current offset sequence
+ } // end of loop thru the start positions of seq1 sequence
+
+
+ // this does the "lower diagonals" of the search
+
+ // loop thru the start positions for sequence 1
+ for(start_i = 1; start_i < seq2_win_num; start_i++)
+ {
+ matches = 0;
+
+ // compare initial window
+ for(win_i = 0; win_i < window_size; win_i++)
+ if ((seq2[start_i+win_i] == seq1[win_i]) &&
+ (seq2[start_i+win_i] != 'N')) // N's match nothing
+ matches++;
+
+ //seq2_i is always start_i for initial window
+ seq2_i = start_i;
+
+ add(0, seq2_i, matches, i2_offset);
+
+ // run through rest of seq1 and seq2 with current seq1 offset (ie start_i)
+ // compare the bps leaving and entering the window and modify matches count
+ seq1_i = 0;
+ while( (seq1_i < seq1_win_num-1) && (seq2_i < seq2_win_num-1) )
+ {
+ // copmpare the bp leaving the window
+ if ((seq1[seq1_i] == seq2[seq2_i]) &&
+ (seq1[seq1_i] != 'N')) // N's match nothing
+ matches = matches - 1;
+
+ // compare the bp entering the window
+ if ((seq1[seq1_i+window_size] == seq2[seq2_i+window_size]) &&
+ (seq1[seq1_i+window_size] != 'N')) // N's match nothing
+ matches = matches + 1;
+
+ add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
+
+ seq1_i = seq1_i + 1; // increment seq1_i to next window
+ seq2_i = seq2_i + 1; // increment seq2_i to next window
+ } // end of loop thru the current offset sequence
+ } // end of loop thru the start positions of seq2 sequence
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "AnnotWindow.hh"
+#include <iostream>
+#include <FL/fl_show_colormap.H>
+
+using namespace std;
+
+annot_color
+new_blank_annot()
+{
+ annot_color *a_annot;
+
+ a_annot = new annot_color;
+ a_annot->type = "";
+ a_annot->color = (Fl_Color) 5;
+ //cout << "type: " << a_annot->type << endl;
+
+ return *a_annot;
+}
+
+
+void
+cb_annot_color(Fl_Button* o, void* v)
+{
+ annot_instance * blah = (annot_instance *) v;
+ AnnotWindow* T= blah->mw_ptr;
+ T->cb_annot_color_i(o,blah->index);
+}
+
+AnnotWindow::AnnotWindow(int w, int h, const char* title,
+ vector<annot_color> * some_annots):Fl_Window(w,h,title)
+{
+ int i, annot_num;
+
+ the_annots = some_annots;
+ annot_count = 0;
+
+ annot_color_buttons.clear();
+
+ begin();
+ annot_input_pack = new Fl_Pack(0, 0, w, h);
+ annot_input_pack->spacing(4);
+
+ // button to add new annot inputs
+ add_annot = new Fl_Button(0,0,100,24,"Add Annot Slot");
+ add_annot->callback((Fl_Callback*)add_annot_cb, this);
+ annot_input_pack->add(add_annot);
+ // test button to make sure annot data is being stored
+ test = new Fl_Button(0,0,100,24,"show annots");
+ test->callback((Fl_Callback*)print_cb, this);
+ annot_input_pack->add(test);
+
+ // creat an initial set of annot input widgets and attach to annot vector
+ annot_num = some_annots->size();
+ for (i = 0; i < annot_num; i++)
+ {
+ add_annot_input(i);
+ annot_count++;
+ }
+
+ add(annot_input_pack);
+
+ end();
+ resizable(this);
+ show();
+}
+
+ //tmp_input->user_data((void*) i);
+
+AnnotWindow::~AnnotWindow(){}
+
+void
+AnnotWindow::add_annot_input(int index)
+{
+ Fl_Output * new_input;
+ Fl_Button *new_color_button;
+ annot_instance * something;
+ Fl_Pack * annot_hor_pack;
+
+
+ something = new annot_instance;
+ something->mw_ptr = this;
+ something->index = index;
+
+ annot_hor_pack = new Fl_Pack(0, 0, w(), 24);
+ annot_hor_pack->type(Fl_Pack::HORIZONTAL);
+ annot_hor_pack->spacing(4);
+
+ // setup the color display/selection button
+ new_color_button = new Fl_Button(0, 0, 24, 24, "");
+ new_color_button->color((*the_annots)[index].color);
+ new_color_button->box(FL_FLAT_BOX);
+ new_color_button->callback((Fl_Callback*)cb_annot_color, (void*) something);
+ annot_color_buttons.push_back(new_color_button);
+ annot_hor_pack->add(new_color_button);
+
+
+ // setup the annot inputs
+ new_input = new Fl_Output(0, 0, 200, 24, "");
+ new_input->value( ((*the_annots)[index].type).c_str() );
+ //new_input->callback((Fl_Callback*)cb_annot_in, (void*) something);
+ annot_ins.push_back(new_input);
+ annot_hor_pack->add(new_input);
+
+ annot_input_pack->add(annot_hor_pack);
+}
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void
+AnnotWindow::cb_annot_in_i(Fl_Input* o, int i)
+{
+ (*the_annots)[i].type = o->value();
+}
+
+void
+AnnotWindow::cb_annot_color_i(Fl_Button* o, int i)
+{
+ //Fl_Color new_color;
+
+ (*the_annots)[i].color = fl_show_colormap((*the_annots)[i].color);
+ //annot_color_buttons[i]->
+ o->color((*the_annots)[i].color);
+ redraw();
+}
+
+void AnnotWindow::add_annot_cb(Fl_Button* o, void* v)
+{
+ AnnotWindow* T=(AnnotWindow*)v;
+ T->add_annot_cb_real(o,v);
+}
+
+
+void AnnotWindow::add_annot_cb_real(Fl_Button* , void*)
+{
+ annot_color blank_annot;
+
+ //blank_annot.name = "";
+ //blank_annot.seq = "";
+ blank_annot = new_blank_annot();
+ (*the_annots).push_back(blank_annot);
+ add_annot_input(annot_count++);
+ redraw();
+}
+
+
+void AnnotWindow::print_cb(Fl_Button* o, void* v)
+{
+ AnnotWindow* T=(AnnotWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void AnnotWindow::print_cb_real(Fl_Button* , void*)
+{
+ int i;
+
+ for (i = 0; i < annot_count; i++)
+ cout << (*the_annots)[i].type << endl;
+}
+
+/*
+void
+cb_annot_in(Fl_Input* o, void* v)
+{
+ annot_instance * blah = (annot_instance *) v;
+ AnnotWindow* T= blah->mw_ptr;
+ T->cb_annot_in_i(o,blah->index);
+}
+
+
+*/
--- /dev/null
+#ifndef _MUSSA_GUI_ANNOT_WINDOW_H_
+#define _MUSSA_GUI_ANNOT_WINDOW_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Button.H>
+
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Output.H>
+#include <FL/Fl_Pack.H>
+
+#include "MotifWindow.hh"
+
+struct annot_color
+{
+ std::string type;
+ Fl_Color color;
+};
+
+//typedef annot_ptr *annot;
+
+
+class AnnotWindow : public Fl_Window
+{
+ public:
+ AnnotWindow(int w, int h, const char* title,
+ std::vector<annot_color> * some_annots);
+ ~AnnotWindow();
+ Fl_Pack * annot_input_pack;
+ std::list<Fl_Output*> annot_ins;
+ std::vector<Fl_Button*> annot_color_buttons;
+ std::list<Fl_Input*> name_ins;
+ Fl_Button* test;
+ Fl_Button* add_annot;
+
+ void cb_annot_in_i(Fl_Input*, int i);
+ void cb_annot_color_i(Fl_Button* o, int i);
+
+ private:
+ std::vector<annot_color> * the_annots;
+ int annot_count;
+
+ void add_annot_input(int index);
+
+ static void add_annot_cb(Fl_Button*, void*);
+ inline void add_annot_cb_real(Fl_Button*, void*);
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+struct annot_instance
+{
+ AnnotWindow * mw_ptr;
+ int index;
+};
+
+annot_color new_blank_annot();
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "ConnView.hh"
+
+#include <iomanip>
+#include <math.h>
+
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
+
+using namespace std;
+
+void
+ConnView::setup(string name, int sq_num, int win_len,
+ vector<Sequence> *some_seqs,
+ Nway_Paths *some_paths)
+{
+ int i, i2, seq_length;
+ Sequence a_seq;
+ motif blank_motif;
+ annot_color new_annot;
+
+
+ ana_name = name;
+ seq_num = sq_num;
+ window = win_len;
+ S = some_seqs;
+ P = some_paths;
+
+ cout << "num of paths = " << some_paths->refined_pathz.size() << endl;
+
+ cout << "x()=" << x() << " y()=" << y() << " w()=" << w() << " h()=" << h();
+ cout << endl;
+
+ max_seq_len = 0;
+ for(i = 0; i < seq_num; ++i)
+ {
+ a_seq = (*S)[i];
+ cout << a_seq.len() << endl;
+ seq_length = a_seq.len();
+ seq_lens.push_back(seq_length);
+ if (seq_length > max_seq_len)
+ max_seq_len = seq_length;
+ if (seq_length < 1000)
+ seq_scales.push_back(1);
+ else if (seq_length < 1000000)
+ seq_scales.push_back(2);
+ else
+ seq_scales.push_back(3);
+ }
+
+ name_pad = 80;
+ y_pad = 20;
+
+ x_scale_factor = (float) max_seq_len / (w() - name_pad);
+ cout << "scale factor is " << x_scale_factor << endl;
+ y_seq_incre = (h()-(y_pad*2)) / (seq_num - 1);
+
+
+ drag_start = -1000;
+ drag_end = -1000;
+ ref_seq_num = 0;
+
+ dragging = false;
+ selected = false;
+
+ highlight.clear();
+ show_bars = false;
+ show_lines = false;
+ bar_interval = max_seq_len / 20;
+ line_interval = max_seq_len / 20;
+ ref_seq_num = 0;
+
+
+ some_motifs.clear();
+ for(i = 0; i < 5; ++i)
+ {
+ blank_motif = new_blank_motif();
+ some_motifs.push_back(blank_motif);
+ }
+
+ // find all unique annotation type ids
+ some_annots.clear();
+ vector<annot_color>::iterator annot_type_i;
+ list<annot>::iterator annot_i;
+
+ // loop thru all sequences
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ cout << "ConnView: annotation loop\n";
+ // loop thru all annotation entries in this sequence
+ for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
+ {
+ cout << annot_i->start << ", " << annot_i->end << " : ";
+ cout << annot_i->name << " " << annot_i->type << endl;
+ // loop thru annotation types
+ annot_type_i = some_annots.begin();
+ bool type_unfound = true;
+ while ((annot_type_i != some_annots.end()) && type_unfound)
+ {
+ if (annot_i->type == annot_type_i->type)
+ type_unfound = false; // stop search if found
+ ++annot_type_i;
+ }
+ //if unfound, then add to list
+ if (type_unfound)
+ {
+ new_annot = new_blank_annot();
+ new_annot.type = annot_i->type;
+ some_annots.push_back(new_annot);
+ }
+ }
+ }
+}
+
+
+void
+ConnView::scale_paths()
+{
+ vector<int> a_path;
+ list<vector<int> >::iterator pathz_i;
+ int i2;
+
+
+ scaled_pathz.clear();
+
+ for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
+ {
+ a_path = *pathz_i;
+ for(i2 = 0; i2 <= seq_num; i2++)
+ a_path[i2] = (int) (a_path[i2] / x_scale_factor);
+ scaled_pathz.push_back(a_path);
+ }
+}
+
+void
+ConnView::toggle_bars()
+{
+ show_bars = !show_bars;
+ redraw();
+}
+
+void
+ConnView::set_bar_interval(int new_bar_len)
+{
+ bar_interval = new_bar_len;
+ cout << "bar interval = " << bar_interval << endl;
+ redraw();
+}
+
+void
+ConnView::toggle_lines()
+{
+ show_lines = !show_lines;
+ redraw();
+}
+
+void
+ConnView::set_line_interval(int new_line_len)
+{
+ line_interval = new_line_len;
+ cout << "line interval = " << line_interval << endl;
+ redraw();
+}
+
+
+void
+ConnView::draw()
+{
+ // this is temporary - check if new motifs have been added
+ check_new_motifs();
+
+ // clear drawing area and set background to white
+ fl_color(FL_WHITE);
+ fl_rectf(x(), y(), w(), h());
+
+
+ // draw the scale indicators if they are on
+ // put into own method soon...
+ int i, div_num, x_loc;
+ float div_len_scaled;
+
+ if (show_bars)
+ {
+ div_num = max_seq_len / bar_interval;
+ div_len_scaled = ((float) bar_interval) / x_scale_factor;
+ fl_color(230,230,230);
+ for(i = 0; i <= div_num; i+=2)
+ {
+ x_loc = (int)(i * div_len_scaled+x());
+ fl_rectf(x_loc, y(), (int) div_len_scaled, h());
+ }
+ }
+
+ if (show_lines)
+ {
+ div_num = max_seq_len / line_interval;
+ div_len_scaled = ((float) line_interval) / x_scale_factor;
+ fl_color(0,0,0);
+ fl_line_style(FL_SOLID, 1, NULL);
+ for(i = 0; i <= div_num; i++)
+ {
+ x_loc = (int)(i * div_len_scaled+x());
+ fl_line(x_loc, y(), x_loc, h()+y());
+ }
+ }
+
+
+ // divide up the space with some light blue lines
+ fl_color(150,200,255);
+ fl_line_style(FL_SOLID, 2, NULL);
+ fl_rect(x(), y(), w(), h());
+ fl_line(w()+x()-name_pad, y(), w()+x()-name_pad, h()+y());
+
+ draw_paths();
+
+ // white out any overdraw from path area into name/info area
+ fl_color(FL_WHITE);
+ fl_rectf(w()+x()-name_pad, y(), w()+x(), h());
+
+ draw_sequence_stuff();
+
+ // draw selection box
+ /*
+ if (selected)
+ {
+ fl_color(FL_BLACK);
+ fl_line_style(FL_SOLID, 1, NULL);
+ fl_rect(drag_start,(ref_seq_num*y_seq_incre)+y(),drag_end-drag_start,
+ 16);
+ }
+ */
+}
+
+
+void
+ConnView::draw_paths()
+{
+ list<vector<int> >::iterator i;
+ int i2, i3, y_loc, x_loc, x_start, x_end;
+ vector<int> a_path;
+ list<bool>::iterator highlight_i;
+ int window_size;
+ bool rc_color;
+ int path_start, path_end;
+ //Sequence a_seq;
+
+
+ // determine which paths to highlight
+ highlight.clear();
+ for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
+ {
+ a_path = *i;
+ // determine if path falls within the selected region and mark it for
+ // highlighted color
+ path_start = abs(a_path[ref_seq_num+1]);
+ path_end = path_start + a_path[0];
+ if ( ( (path_start >= drag_start-x()) && (path_end <= drag_end-x()) ) ||
+ ( (path_start < drag_start-x()) && (path_end > drag_end-x()) ) ||
+ ( (path_start < drag_start-x()) && (path_end > drag_start-x()) ) ||
+ ( (path_start < drag_end-x()) && (path_end > drag_end-x()) ) )
+ highlight.push_back(true);
+ else
+ highlight.push_back(false);
+ }
+
+ fl_line_style(FL_SOLID, 1, NULL);
+ // draw non-highlight paths (ie not in the selection box)
+ highlight_i = highlight.begin();
+ for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
+ {
+ a_path = *i;
+ y_loc = y()+y_pad;
+
+ // get window size to determine line width
+ window_size = a_path[0];
+ // make sure width is at least 1 - might be zero to my slack rounding
+ if (window_size == 0)
+ window_size = 1;
+
+ if (!(*highlight_i))
+ for(i2 = 1; i2 < seq_num; i2++)
+ {
+ // RC case handling
+ // ugh, an xor...only want blue if one of the nodes is rc
+ if ( ((a_path[i2] < 0) || (a_path[i2+1] < 0)) &&
+ !((a_path[i2] < 0) && (a_path[i2+1] < 0)) )
+ fl_color(200,200,255);
+ else
+ fl_color(255,200,200);
+
+ fl_line_style(FL_SOLID, 1, NULL);
+ fl_polygon((int)abs(a_path[i2])+x(), y_loc + 3,
+ (int)abs(a_path[i2])+window_size+x(), y_loc + 3,
+ (int)abs(a_path[i2+1])+window_size+x(), y_loc + y_seq_incre - 3,
+ (int)abs(a_path[i2+1])+x(), y_loc + y_seq_incre - 3);
+
+ y_loc += y_seq_incre;
+ }
+ ++highlight_i;
+ }
+
+ // draw highlighted paths (ie in or partially in selection)
+ // drawing these separately and after other paths so they are on top
+ highlight_i = highlight.begin();
+ for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
+ {
+ a_path = *i;
+ y_loc = y()+y_pad;
+
+ // get window size to determine line width
+ window_size = a_path[0];
+ // make sure width is at least 1 - might be zero to my slack rounding
+ if (window_size == 0)
+ window_size = 1;
+
+ if (*highlight_i)
+ for(i2 = 1; i2 < seq_num; i2++)
+ {
+ // RC case handling
+ // ugh, an xor...only want blue if one of the nodes is rc
+ if ( ((a_path[i2] < 0) || (a_path[i2+1] < 0)) &&
+ !((a_path[i2] < 0) && (a_path[i2+1] < 0)) )
+ fl_color(FL_BLUE);
+ else
+ fl_color(FL_RED);
+
+ fl_polygon((int)abs(a_path[i2])+x(), y_loc + 3,
+ (int)abs(a_path[i2])+window_size+x(), y_loc + 3,
+ (int)abs(a_path[i2+1])+window_size+x(), y_loc + y_seq_incre - 3,
+ (int)abs(a_path[i2+1])+x(), y_loc + y_seq_incre - 3);
+
+ y_loc += y_seq_incre;
+ }
+ ++highlight_i;
+ }
+}
+
+/*
+ list<vector<int> >::iterator i;
+ int window_size;
+ bool rc_color;
+ int path_start, path_end;
+ Sequence a_seq;
+ vector<int> a_path;
+*/
+
+void
+ConnView::draw_sequence_stuff()
+{
+ int i2, i3, y_loc, y_offset, x_loc, x_start, x_end, mv_offset;
+ list<annot>::iterator annot_i;
+ string species_name, seq_length;
+ stringstream raw_length;
+
+
+ // draw sequence representation lines
+ fl_font(FL_COURIER, 14);
+ //fl_color(FL_BLACK);
+ fl_color(100,100,100);
+ // normally size 7, adjust for various screenshotage
+ fl_line_style(FL_SOLID, 11, NULL);
+ y_loc = y()+y_pad;
+ y_offset = 5;
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ if (i2 == seq_num - 1)
+ y_offset = -10;
+ x_loc = (int)(seq_lens[i2] / x_scale_factor) + x();
+ //report_float("seq scaled len", x_loc);
+ fl_line(x(),y_loc,x_loc,y_loc);
+
+ species_name = (*S)[i2].species;
+ fl_draw(species_name.c_str(), x()+w()-name_pad+5, y_loc+y_offset);
+
+ // funkiness to figure out which genomic scale to report size in
+ if (seq_scales[i2] == 1)
+ raw_length << setprecision(3) << seq_lens[i2] << " bp";
+ else if (seq_scales[i2] == 2)
+ raw_length << setprecision(3) << seq_lens[i2] / 1000.0 << " Kb";
+ else if (seq_scales[i2] == 3)
+ raw_length << setprecision(3) << seq_lens[i2] /1000000.0<< " Mb";
+ seq_length = raw_length.str();
+ fl_draw(seq_length.c_str(), x()+w()-name_pad+5, y_loc+y_offset+15);
+ raw_length.str("");
+
+ y_loc += y_seq_incre;
+ }
+
+ //fl_line(x(),y()+y_pad/2,w()-name_pad,y()+y_pad/2);
+ //fl_line(x(),y()+h()-y_pad/2,w()-name_pad,y()+h()-y_pad/2);
+
+ // draw annotations
+ vector<annot_color>::iterator annot_type_i;
+
+ fl_color(FL_GREEN);
+ fl_line_style(FL_SOLID, 3, NULL);
+ y_loc = y()+y_pad;
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ // loop thru all annotation entries
+ for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = 0;
+
+ // loop thru annotation types to determine color
+ annot_type_i = some_annots.begin();
+ bool type_unfound = true;
+ while ((annot_type_i != some_annots.end()) && type_unfound)
+ {
+ if (annot_i->type == annot_type_i->type)
+ {
+ fl_color(annot_type_i->color);
+ type_unfound = false;
+ }
+ else
+ fl_color(FL_GREEN);
+ ++annot_type_i;
+ }
+
+ // calculate scaled start and end, and draw
+ x_start = (int)(annot_i->start / x_scale_factor) + x();
+ x_end = (int)(annot_i->end / x_scale_factor) + x();
+ fl_line(x_start,y_loc+mv_offset,x_end,y_loc+mv_offset);
+ }
+ y_loc += y_seq_incre;
+ }
+
+
+ // draw motifs found
+ vector<motif>::iterator motif_i;
+ vector<int> some_motif_locs;
+ vector<int>::iterator i_locs;
+ int scale_len, motif_len;
+
+ fl_color(255,0,255);
+ fl_line_style(FL_SOLID, 9, NULL);
+ motif_i = some_motifs.begin();
+ while (motif_i != some_motifs.end())
+ {
+ fl_color(motif_i->color);
+ motif_len = motif_i->seq.length();
+ scale_len = (int) (motif_len / x_scale_factor);
+ if (scale_len == 0)
+ scale_len = 1;
+ y_loc = y()+y_pad;
+ if (!motif_i->locations.empty())
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ some_motif_locs = (*motif_i).locations[i2];
+
+ i_locs = some_motif_locs.begin();
+ while (i_locs != some_motif_locs.end())
+ {
+ x_start = (int)(*i_locs / x_scale_factor) + x();
+ fl_line(x_start,y_loc,x_start+scale_len,y_loc);
+ ++i_locs;
+ }
+ y_loc += y_seq_incre;
+ }
+ ++motif_i;
+ }
+}
+
+
+void
+ConnView::resize(int new_x, int new_y, int new_w, int new_h)
+{
+
+ x(new_x);
+ y(new_y);
+ w(new_w);
+ h(new_h);
+
+ x_scale_factor = (float) max_seq_len / (w() - name_pad);
+ cout << "scale factor is " << x_scale_factor << endl;
+ y_seq_incre = (h()-(2*y_pad)) / (seq_num - 1);
+
+ scale_paths();
+}
+
+
+void
+ConnView::reporter(string var, int value)
+{
+ cout << var << " : " << value << endl;
+}
+
+
+void
+ConnView::report_float(string var, float value)
+{
+ cout << var << " : " << value << endl;
+}
+
+int
+ConnView::handle(int e)
+{
+ int return_value;
+ float y_calc_tmp;
+
+ // this empty string needs to be put on cout, otherwise the -O optimize
+ // compile option seems to throw this function away with the following:
+ // gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
+ cout << "";
+
+ // why do I need a -O for this module? Well, originally I just used the
+ // same compile flags for all modules. I changed that. However, on debian
+ // systems I need the -O otherwise the behavior I observe on redhat machines
+ // with above compiler happens if I don't have that empty cout. WTF
+
+ switch(e)
+ {
+ case FL_PUSH:
+ if (Fl::event_button3())
+ {
+ spawnSeq();
+ return_value = 1;
+ }
+ else if (Fl::event_button2())
+ {
+ find_motifs();
+ return_value = 1;
+ }
+ break;
+ case FL_DRAG:
+ if (!dragging)
+ {
+ drag_start = Fl::event_x();
+ y_drag_start = (float) Fl::event_y();
+ ref_seq_num = (int) (round ( (y_drag_start/y_seq_incre) ) );
+ dragging = true;
+ selected = false;
+ return_value = 1;
+ }
+ fl_line_style(FL_SOLID, 1, NULL);
+ fl_overlay_rect(drag_start, (ref_seq_num*y_seq_incre)+y(),
+ Fl::event_x()-drag_start, 16);
+
+ break;
+ case FL_RELEASE:
+ if (dragging)
+ {
+ drag_end = Fl::event_x();
+ dragging = false;
+ selected = true;
+ redraw();
+ return_value = 1;
+ }
+ break;
+ default:
+ return_value = Fl_Widget::handle(e);
+ }
+
+ return return_value;
+}
+
+
+
+void
+ConnView::check_new_motifs()
+{
+ vector<motif>::iterator i;
+ int i2;
+ vector<int> some_motif_locs;
+ vector<int>::iterator i_locs;
+
+ i = some_motifs.begin();
+ while (i != some_motifs.end())
+ {
+ if (i->dirty)
+ {
+ cout << i->seq << " is new\n";
+ i->locations.clear();
+ //i_locs = i->locations;
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ some_motif_locs = (*S)[i2].find_motif(i->seq);
+ (*i).locations.push_back(some_motif_locs);
+
+
+ i_locs = some_motif_locs.begin();
+ while (i_locs != some_motif_locs.end())
+ {
+ cout << *i_locs << " ";
+ ++i_locs;
+ }
+ cout << endl;
+
+ }
+
+ i->dirty = false;
+ }
+ ++i;
+ }
+}
+
+
+void
+ConnView::spawnSeq()
+{
+ list<vector<int> > selected_paths;
+ list<vector<int> >::iterator pathz_i;
+ int i2, i3, y_loc, x_loc, x_start, x_end;
+ vector<int> a_path;
+ list<bool>::iterator highlight_i;
+ int y_max;
+ string window_name;
+
+
+ if (selected)
+ {
+ // make new list of connections that are highlighted
+ selected_paths.clear();
+ highlight_i = highlight.begin();
+ for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
+ {
+ if (*highlight_i)
+ {
+ a_path = *pathz_i;
+ selected_paths.push_back(a_path);
+ }
+ ++highlight_i;
+ }
+
+ // give 50 pixels of height per sequence
+ y_max = seq_num * 50;
+ window_name = "Mussa Sequence: " + ana_name;
+
+ a_seq_win = new SeqWindow(800, y_max, (const char*) window_name.c_str(),
+ seq_num,
+ S, selected_paths, seq_lens, &some_motifs);
+ }
+}
+
+
+void
+ConnView::find_motifs()
+{
+ motif_find_window = new MotifWindow(300, 300, "Motifs", &some_motifs);
+}
+
+void
+ConnView::annot_win()
+{
+ annot_color_window = new AnnotWindow(300, 300, "Annotations", &some_annots);
+}
+
+// @!@! special hacked in color coding for the myf5/6 region annots
+
+/*
+ if (annot_i->type == "mvista")
+ {
+ fl_color(255,230,0);
+ fl_line_style(FL_SOLID, 8, NULL);
+ mv_offset = -4;
+ }
+ else if (annot_i->type == "reg")
+ {
+ fl_line_style(FL_SOLID, 10, NULL);
+ mv_offset = -8;
+
+ if (annot_i->name == "CNS")
+ fl_color(255,150,0);
+ else if (annot_i->name == "ELA")
+ fl_color(0,200,120);
+ else if (annot_i->name == "ES")
+ fl_color(0,200,200);
+ else if (annot_i->name == "NA")
+ fl_color(120,120,120);
+ else if (annot_i->name == "EA")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -13;
+ fl_color(0,200,120);
+ }
+ else if (annot_i->name == "VS")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -6;
+ fl_color(255,255,0);
+ }
+ else if (annot_i->name == "SP")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -13;
+ fl_color(255,230,150);
+ }
+ else if (annot_i->name == "L")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -6;
+ fl_color(0,0,100);
+ }
+ else if (annot_i->name == "TCM")
+ fl_color(0,130,230);
+ }
+*/
--- /dev/null
+#ifndef _MUSSA_GUI_CONN_VIEW_H_
+#define _MUSSA_GUI_CONN_VIEW_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <list>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "sequence.hh"
+#include "SeqView.hh"
+#include "SeqWindow.hh"
+#include "MotifWindow.hh"
+#include "AnnotWindow.hh" // aparently for annot_color
+#include "mussa_nway.hh"
+
+#include <FL/Fl_Box.H>
+
+class Nway_Paths;
+class ConnView : public Fl_Box
+{
+ public:
+ ConnView(int x_top,int y_top,int x_bot,int y_bot) :
+ Fl_Box(x_top,y_top,x_bot,y_bot)
+ {}
+
+ void setup(std::string name, int sq_num, int win_len,
+ std::vector<Sequence> *, Nway_Paths *);
+ void scale_paths();
+
+ void spawnSeq();
+ void find_motifs();
+ void annot_win();
+
+ void toggle_bars();
+ void set_bar_interval(int new_bar_len);
+ void toggle_lines();
+ void set_line_interval(int new_line_len);
+
+
+ private:
+ std::string ana_name;
+ int seq_num, window, threshold;
+ bool win_append, thres_append;
+
+ //this data is passed as pointers to the instantiated classes
+ std::vector<Sequence> *S;
+ Nway_Paths *P;
+
+ int name_pad, y_pad;
+ float x_scale_factor;
+ int y_seq_incre;
+ int drag_start, drag_end;
+ float y_drag_start;
+ int ref_seq_num, max_seq_len;
+ bool dragging, selected;
+ std::list<bool> highlight;
+
+ //path data scaled for current view size
+ std::list<std::vector<int> > scaled_pathz;
+ std::vector<int> seq_lens;
+ std::vector<int> seq_scales;
+ int bar_interval, line_interval;
+ bool show_bars, show_lines;
+
+ //keeps track of all the motifs the user has inputed
+ std::vector<motif> some_motifs;
+ MotifWindow *motif_find_window;
+
+ //keeps track of the colors assigned to each motif type
+ std::vector<annot_color> some_annots;
+ AnnotWindow *annot_color_window;
+
+ SeqWindow *a_seq_win;
+
+ void draw();
+ void draw_paths();
+ void draw_sequence_stuff();
+
+ void resize(int x, int y, int w, int h);
+ int handle(int e);
+ void check_new_motifs();
+
+ //for drawing function debugging
+ void reporter(std::string var, int value);
+ void report_float(std::string var, float value);
+};
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "ConnWindow.hh"
+
+#include <iostream>
+using namespace std;
+
+void
+load_ana_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_load_ana_cb();
+}
+
+
+void
+ConnWindow::real_load_ana_cb()
+{
+ char *picked_file;
+ string a_file_path;
+ string err_msg;
+
+ cout << "Load! Load! Load, ye yellow-bellied seadogs!\n";
+ //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ picked_file = fl_dir_chooser("Find an Analysis", "", 1);
+ if (picked_file != NULL)
+ {
+ a_file_path = picked_file;
+ cout << "doo wah diddy diddy dum diddy doo\n";
+ cout << a_file_path << endl;
+
+ // load the analysis
+ an_analysis = new Mussa();
+ err_msg = an_analysis->load(a_file_path);
+ //.substr(0,a_file_path.find(".mu")));
+
+ if (err_msg == "")
+ {
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+ // show the user the analysis
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+ conn_box->scale_paths();
+ }
+ else
+ {
+ fl_alert(err_msg.c_str());
+ cout << err_msg << endl;
+ }
+ }
+}
+
+
+void
+do_ana_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_do_ana_cb();
+}
+
+
+void
+ConnWindow::real_do_ana_cb()
+{
+ char *picked_file;
+ string a_file_path;
+ string err_msg;
+
+ picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
+ if (picked_file != NULL)
+ {
+ a_file_path = picked_file;
+
+ an_analysis = new Mussa();
+ err_msg = an_analysis->load_mupa_file(a_file_path);
+
+ if (err_msg == "")
+ {
+ err_msg = an_analysis->analyze(0, 0, 't', 0.0);
+ }
+
+ if (err_msg == "")
+ {
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+ // show the user the analysis
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+ conn_box->scale_paths();
+ }
+ else
+ {
+ fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+ }
+}
+
+
+void
+setup_ana_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_setup_ana_cb();
+}
+
+void
+ConnWindow::real_setup_ana_cb()
+{
+ an_analysis = new Mussa();
+ setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
+
+ while(setup_win->visible())
+ Fl::wait(.1);
+ cout << "Like a warm summer day\n";
+
+ if (setup_win->done())
+ {
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+ // is it this easy? what if setup window encounters an error...??
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+
+ conn_box->scale_paths();
+ }
+}
+
+
+void
+subana_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_subana_cb();
+}
+
+void
+ConnWindow::real_subana_cb()
+{
+ string subana_name;
+
+ sub_analysis = new Mussa();
+ subana_win = new SubAnalysisWindow(500,400,"Sub Analysis Setup", sub_analysis,
+ an_analysis->the_Seqs);
+
+ while(subana_win->visible())
+ Fl::wait(.1);
+ cout << "Like a warm summer day\n";
+
+ if (subana_win->done())
+ {
+ subana_name = "SubMussa: " + sub_analysis->ana_name;
+ sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
+ cout << "Like a warm day in may\n";
+ sub_conn_win->add_ana(sub_analysis);
+ //Fl::visual(FL_DOUBLE|FL_INDEX);
+ //sub_conn_box->show();
+ }
+}
+
+
+void
+seq_show_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_seq_show_cb();
+}
+
+void
+ConnWindow::real_seq_show_cb()
+{
+ show_seq_win = new SeqTextWindow(500,400,"Seq Show", an_analysis->the_Seqs);
+}
+
+void
+seq_win_spawn_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_seq_win_spawn_cb();
+}
+
+void
+ConnWindow::real_seq_win_spawn_cb()
+{
+ conn_box->spawnSeq();
+}
+
+void
+motif_find_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_motif_find_cb();
+}
+
+void
+ConnWindow::real_motif_find_cb()
+{
+ conn_box->find_motifs();
+}
+
+void
+annot_win_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_annot_win_cb();
+}
+
+void
+ConnWindow::real_annot_win_cb()
+{
+ conn_box->annot_win();
+}
+
+
+// all the crap needed for dealing with the scale bars
+void
+toggle_scale_bars_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_toggle_bars_cb();
+}
+
+void
+ConnWindow::real_toggle_bars_cb()
+{
+ conn_box->toggle_bars();
+}
+
+void
+set_bar_len_cb(Fl_Input* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ cout << "WAAAAAAAAA\n";
+ T->real_set_bar_len_cb(o);
+}
+
+void
+ConnWindow::real_set_bar_len_cb(Fl_Input* o)
+{
+ int new_bar_len;
+
+ new_bar_len = atoi(o->value());
+ cout << "new bar len = " << new_bar_len << endl;
+ conn_box->set_bar_interval(new_bar_len);
+}
+
+
+// all the crap needed for dealing with the scale lines
+void
+toggle_scale_lines_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_toggle_lines_cb();
+}
+
+void
+ConnWindow::real_toggle_lines_cb()
+{
+ conn_box->toggle_lines();
+}
+
+void
+set_line_len_cb(Fl_Input* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ cout << "WAAAAAAAAA\n";
+ T->real_set_line_len_cb(o);
+}
+
+void
+ConnWindow::real_set_line_len_cb(Fl_Input* o)
+{
+ int new_line_len;
+
+ new_line_len = atoi(o->value());
+ cout << "new line len = " << new_line_len << endl;
+ conn_box->set_line_interval(new_line_len);
+}
+
+
+// setting new soft threshold
+
+void
+set_soft_thres_cb(Fl_Input* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ cout << "WAAAAAAAAA\n";
+ T->real_set_soft_thres_cb(o);
+}
+
+void
+ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
+{
+ int new_soft_thres;
+
+ new_soft_thres = atoi(o->value());
+ cout << "new soft thres = " << new_soft_thres << endl;
+
+ an_analysis->set_soft_thres(new_soft_thres);
+ an_analysis->set_ana_mode('t');
+ an_analysis->nway();
+ conn_box->scale_paths();
+ conn_box->redraw();
+
+ // hacked in stuff to save muway files at different thresholds
+ string save_path;
+ ostringstream append_info;
+
+ save_path = an_analysis->ana_name + "/"
+ + an_analysis->ana_name.substr(0,an_analysis->ana_name.find("_t"));
+ append_info.str("");
+ append_info << "_t" << new_soft_thres << ".muway";
+ //<< "_w" << an_analysis->window
+ save_path += append_info.str();
+ cout << "saving as: " << save_path << endl;
+ an_analysis->save_muway(save_path);
+}
+
+
+
+
+ConnWindow::ConnWindow(int w, int h, const char* title):
+ Fl_Double_Window(w,h,title)
+{
+ int button_len = 120;
+ Fl_Color a_color = fl_rgb_color(150, 200, 255);
+
+ padding = 5;
+
+ begin();
+ //fl_color(150,200,255);
+ color(FL_WHITE);
+ resizable(this);
+
+
+ // create file menu button
+ file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "Analysis");
+ file_menu->color(FL_WHITE,a_color);
+ file_menu->box(FL_BORDER_BOX);
+ file_menu->clear();
+
+ // add menu items
+ file_menu->add("Do Analysis", 0, (Fl_Callback *) do_ana_cb, this);
+ file_menu->add("Load Analysis", 0, (Fl_Callback *) load_ana_cb, this);
+ file_menu->add("Setup Analysis", 0, (Fl_Callback *) setup_ana_cb, this);
+ file_menu->add("Sub Analysis", 0, (Fl_Callback *) subana_cb, this);
+
+
+ view_menu = new Fl_Menu_Button(padding+button_len,2, button_len, 30, "View");
+ view_menu->color(FL_WHITE,a_color);
+ view_menu->box(FL_BORDER_BOX);
+ view_menu->clear();
+ view_menu->add("Sequence Zoom", 0, (Fl_Callback*) seq_win_spawn_cb, this);
+ view_menu->add("Motif Finder", 0, (Fl_Callback*) motif_find_cb, this);
+ view_menu->add("Annotations", 0, (Fl_Callback*) annot_win_cb, this);
+ view_menu->add("Copy Seq", 0, (Fl_Callback*) seq_show_cb, this);
+ view_menu->add("Toggle Bars", 0, (Fl_Callback*) toggle_scale_bars_cb, this,
+ FL_MENU_TOGGLE|FL_MENU_VALUE);
+ view_menu->add("Toggle Lines", 0, (Fl_Callback*) toggle_scale_lines_cb, this,
+ FL_MENU_TOGGLE|FL_MENU_VALUE);
+
+ bar_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
+ bar_input->value("");
+ bar_input->when(FL_WHEN_ENTER_KEY);
+ bar_input->callback((Fl_Callback*)set_bar_len_cb, this);
+
+ line_input = new Fl_Input(padding+5*button_len, 2, button_len, 30, "Line Interval (bp)");
+ line_input->value("");
+ line_input->when(FL_WHEN_ENTER_KEY);
+ line_input->callback((Fl_Callback*)set_line_len_cb, this);
+
+
+ thres_input = new Fl_Input(padding+7*button_len, 2, button_len, 30, "Threshold");
+ thres_input->value("");
+ thres_input->when(FL_WHEN_ENTER_KEY);
+ thres_input->callback((Fl_Callback*)set_soft_thres_cb, this);
+
+
+ // create the connections box
+ conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
+ //conn_box = new ConnView(padding, padding, w-2*padding, h-2*padding);
+
+ end();
+ show();
+}
+
+
+ConnWindow::~ConnWindow()
+{}
+
+
+void
+ConnWindow::add_ana(Mussa *the_ana)
+{
+ an_analysis = the_ana;
+
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+ conn_box->scale_paths();
+}
--- /dev/null
+#ifndef _MUSSA_GUI_CONN_WINDOW_H_
+#define _MUSSA_GUI_CONN_WINDOW_H_
+
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <string>
+
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Menu_Bar.H>
+#include <FL/Fl_Menu_Item.H>
+
+#include "ConnView.hh"
+#include "SetupWindow.hh"
+#include "SubAnalysisWindow.hh"
+#include "SeqTextWindow.hh"
+
+//! Window for showing the lines connecting the various sequences together
+class ConnWindow : public Fl_Double_Window
+{
+ private:
+ Mussa *an_analysis, *sub_analysis;
+ ConnWindow *sub_conn_win;
+
+ Fl_Menu_Button *file_menu;
+ Fl_Menu_Button *view_menu;
+ Fl_Menu_Bar *menu_bar;
+ Fl_Input *bar_input;
+ Fl_Input *line_input;
+ Fl_Input *thres_input;
+ ConnView *conn_box;
+ SetupWindow *setup_win;
+ SubAnalysisWindow *subana_win;
+ SeqTextWindow *show_seq_win;
+ int padding, name_pad;
+ std::string window_name;
+
+ public:
+ ConnWindow(int w, int h, const char* title);
+ ~ConnWindow();
+ void add_ana(Mussa *the_ana);
+
+ void real_load_ana_cb();
+ void real_do_ana_cb();
+ void real_setup_ana_cb();
+ void real_subana_cb();
+ void real_resthres();
+ void real_seq_show_cb();
+
+ void real_seq_win_spawn_cb();
+ void real_motif_find_cb();
+ void real_annot_win_cb();
+
+ void real_toggle_bars_cb();
+ void real_set_bar_len_cb(Fl_Input* o);
+ void real_toggle_lines_cb();
+ void real_set_line_len_cb(Fl_Input* o);
+ void real_set_soft_thres_cb(Fl_Input* o);
+};
+
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "MotifWindow.hh"
+
+#include <iostream>
+
+#include <FL/fl_show_colormap.H>
+
+using namespace std;
+
+motif
+new_blank_motif()
+{
+ motif *a_motif;
+
+ a_motif = new motif;
+ a_motif->name = "";
+ a_motif->seq = "";
+ a_motif->color = (Fl_Color) 5;
+ a_motif->locations.clear();
+ a_motif->dirty = false;
+
+ cout << "name: " << a_motif->name << " seq: " << a_motif->seq << endl;
+
+ return *a_motif;
+}
+
+
+void
+cb_motif_in(Fl_Input* o, void* v)
+{
+ motif_instance * blah = (motif_instance *) v;
+ MotifWindow* T= blah->mw_ptr;
+ T->cb_motif_in_i(o,blah->index);
+}
+
+
+void
+cb_motif_color(Fl_Button* o, void* v)
+{
+ motif_instance * blah = (motif_instance *) v;
+ MotifWindow* T= blah->mw_ptr;
+ T->cb_motif_color_i(o,blah->index);
+}
+
+
+MotifWindow::MotifWindow(int w, int h, const char* title,
+ vector<motif> * some_motifs):Fl_Window(w,h,title)
+{
+ int i;
+
+ the_motifs = some_motifs;
+ motif_count = 0;
+
+ motif_color_buttons.clear();
+
+ begin();
+ motif_input_pack = new Fl_Pack(0, 0, w, h);
+ motif_input_pack->spacing(4);
+
+ // button to add new motif inputs
+ add_motif = new Fl_Button(0,0,100,24,"Add Motif Slot");
+ add_motif->callback((Fl_Callback*)add_motif_cb, this);
+ motif_input_pack->add(add_motif);
+ // test button to make sure motif data is being stored
+ test = new Fl_Button(0,0,100,24,"show motifs");
+ test->callback((Fl_Callback*)print_cb, this);
+ motif_input_pack->add(test);
+ // creat an initial set of motif input widgets and attach to motif vector
+ for (i = 0; i < 5; i++)
+ {
+ add_motif_input(i);
+ motif_count++;
+ }
+
+
+
+
+ add(motif_input_pack);
+
+ end();
+ resizable(this);
+ show();
+}
+
+ //tmp_input->user_data((void*) i);
+
+MotifWindow::~MotifWindow(){}
+
+void
+MotifWindow::add_motif_input(int index)
+{
+ Fl_Input * new_input;
+ Fl_Button *new_color_button;
+ motif_instance * something;
+ Fl_Pack * motif_hor_pack;
+
+
+ something = new motif_instance;
+ something->mw_ptr = this;
+ something->index = index;
+
+ motif_hor_pack = new Fl_Pack(0, 0, w(), 24);
+ motif_hor_pack->type(Fl_Pack::HORIZONTAL);
+ motif_hor_pack->spacing(4);
+
+ // setup the color display/selection button
+ new_color_button = new Fl_Button(0, 0, 24, 24, "");
+ new_color_button->color((*the_motifs)[index].color);
+ new_color_button->box(FL_FLAT_BOX);
+ new_color_button->callback((Fl_Callback*)cb_motif_color, (void*) something);
+ motif_color_buttons.push_back(new_color_button);
+ motif_hor_pack->add(new_color_button);
+
+
+ // setup the motif inputs
+ new_input = new Fl_Input(0, 0, 200, 24, "");
+ new_input->value( ((*the_motifs)[index].seq).c_str() );
+ new_input->callback((Fl_Callback*)cb_motif_in, (void*) something);
+ motif_ins.push_back(new_input);
+ motif_hor_pack->add(new_input);
+
+ motif_input_pack->add(motif_hor_pack);
+}
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void
+MotifWindow::cb_motif_in_i(Fl_Input* o, int i)
+{
+ (*the_motifs)[i].seq = o->value();
+ (*the_motifs)[i].dirty = true;
+}
+
+void
+MotifWindow::cb_motif_color_i(Fl_Button* o, int i)
+{
+ //Fl_Color new_color;
+
+ (*the_motifs)[i].color = fl_show_colormap((*the_motifs)[i].color);
+ //motif_color_buttons[i]->
+ o->color((*the_motifs)[i].color);
+ redraw();
+}
+
+void MotifWindow::add_motif_cb(Fl_Button* o, void* v)
+{
+ MotifWindow* T=(MotifWindow*)v;
+ T->add_motif_cb_real(o,v);
+}
+
+
+void MotifWindow::add_motif_cb_real(Fl_Button* , void*)
+{
+ motif blank_motif;
+
+ //blank_motif.name = "";
+ //blank_motif.seq = "";
+ blank_motif = new_blank_motif();
+ (*the_motifs).push_back(blank_motif);
+ add_motif_input(motif_count++);
+ redraw();
+}
+
+
+void MotifWindow::print_cb(Fl_Button* o, void* v)
+{
+ MotifWindow* T=(MotifWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void MotifWindow::print_cb_real(Fl_Button* , void*)
+{
+ int i;
+
+ for (i = 0; i < motif_count; i++)
+ cout << (*the_motifs)[i].seq << endl;
+}
--- /dev/null
+#ifndef _MUSSA_GUI_MOTIF_WINDOW_H_
+#define _MUSSA_GUI_MOTIF_WINDOW_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Button.H>
+
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Pack.H>
+
+#include "mussa_class.hh"
+
+struct motif
+{
+ std::string name, seq;
+ Fl_Color color;
+ std::vector<std::vector<int> > locations;
+ bool dirty;
+};
+
+//typedef motif_ptr *motif;
+
+
+class MotifWindow : public Fl_Window
+{
+ public:
+ MotifWindow(int w, int h, const char* title, std::vector<motif> * some_motifs);
+ ~MotifWindow();
+ Fl_Pack * motif_input_pack;
+ std::list<Fl_Input*> motif_ins;
+ std::vector<Fl_Button*> motif_color_buttons;
+ std::list<Fl_Input*> name_ins;
+ Fl_Button* test;
+ Fl_Button* add_motif;
+
+ void cb_motif_in_i(Fl_Input*, int i);
+ void cb_motif_color_i(Fl_Button* o, int i);
+
+ private:
+ std::vector<motif> * the_motifs;
+ int motif_count;
+
+ void add_motif_input(int index);
+
+ static void add_motif_cb(Fl_Button*, void*);
+ inline void add_motif_cb_real(Fl_Button*, void*);
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+struct motif_instance
+{
+ MotifWindow * mw_ptr;
+ int index;
+};
+
+motif new_blank_motif();
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "SeqTextWindow.hh"
+
+#include <iostream>
+using namespace std;
+void
+get_seq_cb(Fl_Button* o, void* v)
+{
+ SeqTextWindow* T=(SeqTextWindow*)v;
+ T->real_get_seq_cb();
+}
+
+void
+SeqTextWindow::real_get_seq_cb()
+{
+ string sub_seq_formatted;
+ int seq_len, i, line_len;
+
+
+ cout << "length = " << seq_end-seq_start << endl;
+
+ // make sure inputed values within valid ranges
+ if ((seq_end > seq_start) && (seq_id > -1) && (seq_id < the_Seqs.size()) )
+ {
+ sub_sequence = the_Seqs[seq_id].subseq(seq_start, seq_end-seq_start);
+
+ sub_seq_formatted = "";
+ seq_len = sub_sequence.size();
+ line_len = 40;
+ for (i = 0; i < seq_len; i += line_len)
+ {
+ sub_seq_formatted.append(sub_sequence.substr(i,line_len));
+ sub_seq_formatted.append("\n");
+ }
+
+ seq_display->value((const char *)sub_seq_formatted.c_str());
+ }
+}
+
+
+// *** input seq index id
+
+void
+set_seq_id_cb(Fl_Input* o, void* v)
+{
+ SeqTextWindow* T=(SeqTextWindow*)v;
+ T->real_set_seq_id_cb(o);
+}
+
+void
+SeqTextWindow::real_set_seq_id_cb(Fl_Input* o)
+{
+ seq_id = atoi(o->value()) - 1; // -1 since arrays start at 0
+}
+
+
+// *** input seq start index
+
+void
+set_seq_start_cb(Fl_Input* o, void* v)
+{
+ SeqTextWindow* T=(SeqTextWindow*)v;
+ T->real_set_seq_start_cb(o);
+}
+
+void
+SeqTextWindow::real_set_seq_start_cb(Fl_Input* o)
+{
+ seq_start = atoi(o->value());
+}
+
+// *** input seq end index
+
+void
+set_seq_end_cb(Fl_Input* o, void* v)
+{
+ SeqTextWindow* T=(SeqTextWindow*)v;
+ T->real_set_seq_end_cb(o);
+}
+
+void
+SeqTextWindow::real_set_seq_end_cb(Fl_Input* o)
+{
+ seq_end = atoi(o->value());
+}
+
+
+SeqTextWindow::SeqTextWindow(int w, int h, const char* title,
+ vector<Sequence> some_Seqs):Fl_Window(w,h,title)
+{
+ string a_name;
+ color(FL_WHITE);
+ the_Seqs = some_Seqs;
+
+
+ seq_id = -1;
+ seq_start = 1000000;
+ seq_end = -1000000;
+
+ begin();
+
+ seq_id_input = new Fl_Input(80,10,30,30, "Seq num: ");
+ seq_id_input->value("");
+ seq_id_input->callback((Fl_Callback*)set_seq_id_cb, this);
+
+ seq_start_input = new Fl_Input(160,10,100,30, " start: ");
+ seq_start_input->value("");
+ seq_start_input->callback((Fl_Callback*)set_seq_start_cb, this);
+
+ seq_end_input = new Fl_Input(310,10,100,30, "end: ");
+ seq_end_input->value("");
+ seq_end_input->callback((Fl_Callback*)set_seq_end_cb, this);
+
+ seq_display = new Fl_Multiline_Output(10, 50, w-20, h-60, "");
+ seq_display->value("");
+
+ //seq_display2 = new Fl_Text_Display(10,100, w-20, h-110,"");
+
+ // button to get the sequence
+ get_seq_but = new Fl_Button(w-80,10,80,30,"Get Seq");
+ get_seq_but->callback((Fl_Callback*)get_seq_cb, this);
+
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SeqTextWindow::~SeqTextWindow(){}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
--- /dev/null
+#ifndef _MUSSA_GUI_SEQ_TEXT_H_
+#define _MUSSA_GUI_SEQ_TEXT_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Text_Buffer.H>
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Window.H>
+
+#include "sequence.hh"
+
+class SeqTextWindow : public Fl_Window
+{
+ public:
+ SeqTextWindow(int w, int h, const char* title, std::vector<Sequence> some_Seqs);
+ ~SeqTextWindow();
+
+ Fl_Button* get_seq_but;
+ Fl_Multiline_Output* seq_display;
+ Fl_Text_Buffer* seq_buffer;
+ Fl_Text_Display* seq_display2;
+ Fl_Input *seq_id_input;
+ Fl_Input *seq_start_input;
+ Fl_Input *seq_end_input;
+
+ // callback receiver functions
+
+ void real_get_seq_cb();
+ void real_set_seq_id_cb(Fl_Input* o);
+ void real_set_seq_start_cb(Fl_Input* o);
+ void real_set_seq_end_cb(Fl_Input* o);
+
+ private:
+ // sequence data
+ std::vector<Sequence> the_Seqs;
+ std::string sub_sequence;
+ int seq_id, seq_start, seq_end;
+};
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "SeqView.hh"
+#include <iostream>
+#include <sstream>
+
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
+
+using namespace std;
+
+void
+SeqView::setup(string name, int sq_num,
+ vector<Sequence> *some_seqs,
+ list<vector<int> > some_paths, vector<int> some_lens,
+ vector<motif> *some_motifs)
+{
+ int seq_i;
+ list<vector<int> >::iterator pathz_i;
+
+
+ ana_name = name;
+ seq_num = sq_num;
+ S = some_seqs;
+ P = some_paths;
+ seq_lens = some_lens;
+ the_motifs = some_motifs;
+
+ y_seq_incre = (y_max-10-10) / (seq_num - 1);
+
+ fl_font(FL_COURIER, 14);
+ cout << "font width: " << fl_width('A') << endl;
+
+ index_pad = 6 * (int) fl_width('A') + 5;
+
+ align_offsets(0);
+
+ raw_sequence.clear();
+ for(seq_i = 0; seq_i < seq_num; ++seq_i)
+ raw_sequence.push_back( (*S)[seq_i].seq() );
+
+ for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
+ {
+ show_aligns.push_back(true);
+ }
+
+ dragging = false;
+ scroll_offset = 0;
+ //scroll_pos = 0;
+ drag_change = 0;
+
+ cout << "waaaaa!\n";
+ cout << x() << " " << y() << " " << w() << " " << h() << endl;
+}
+
+void
+SeqView::resize(int new_x, int new_y, int new_w, int new_h)
+{
+ x(new_x);
+ y(new_y);
+ w(new_w);
+ h(new_h);
+
+ // hmmm, why do I use these values on the the widgets inherent ones?
+ // I think there was a reason...once?
+ x_max = new_w;
+ y_max = new_h;
+ x_min = new_x;
+ y_min = new_y;
+
+ // things that need to be recalculated
+ y_seq_incre = (y_max-10-10) / (seq_num - 1);
+}
+
+
+
+
+void
+SeqView::draw()
+{
+ double ch_width;
+
+
+ // clear drawing area and set background to white
+ fl_color(FL_WHITE);
+ fl_rectf(x(), y(), w(), h());
+
+
+ fl_font(FL_COURIER, 14);
+ //blatantly stolen from FR2
+ ch_width = fl_width('A'); // monospaced: all characters are same width
+
+
+ if (show_bars)
+ {
+ int grey_box_num, grey_box_len;
+ int i;
+ // draw in some light grey boxes every 10bp to delineate for user
+ //fl_color(200,235,235);
+ fl_color(180,180,180);
+ grey_box_num = (((x_max - index_pad) / (int) ch_width) / 10) + 1;
+ grey_box_len = 10 * (int) ch_width;
+ for(i = 0; i < grey_box_num; i++)
+ if ((i % 2) != 0)
+ fl_rectf(x()+index_pad-1 + (i * grey_box_len), y(), grey_box_len, h());
+ }
+
+ if (show_motifs)
+ draw_motifs(ch_width);
+
+ draw_sequence(ch_width);
+
+ draw_match_lines(ch_width);
+
+ draw_indices(ch_width);
+
+
+ // draw some bounding boxes to visually separate things
+ fl_color(150,200,255);
+ fl_line_style(FL_SOLID, 2, NULL);
+ fl_rect(x(), y(), w(), h());
+ fl_rect(x()+index_pad-1, y(), w()-2*(index_pad-1), h());
+}
+
+void
+SeqView::draw_motifs(double ch_width)
+{
+ vector<motif>::iterator motif_i;
+ vector<int> some_motif_locs;
+ vector<int>::iterator i_locs;
+ int scale_len, motif_len, i2;
+ int y_loc, x_start;
+
+ //fl_color(255,0,255);
+ fl_line_style(FL_SOLID, 10, NULL);
+ motif_i = the_motifs->begin();
+ while (motif_i != the_motifs->end())
+ {
+ fl_color(motif_i->color);
+ motif_len = motif_i->seq.length();
+ scale_len = (int) (motif_len * ch_width);
+ y_loc = y_min + 10;
+ if (!motif_i->locations.empty())
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ some_motif_locs = (*motif_i).locations[i2];
+
+ i_locs = some_motif_locs.begin();
+ while (i_locs != some_motif_locs.end())
+ {
+ x_start = (int) ((*i_locs +scroll_offset - seq_align_offsets[i2])
+ * ch_width) + index_pad + x();
+
+ //cout << *i_locs << ":" << x_start << " ";
+ // don't draw highlights outside of box range, they can wraparound past some boundry
+ if ((x_start > 0) && (x_start < w()))
+ fl_line(x_start,y_loc,x_start+scale_len,y_loc);
+ ++i_locs;
+ }
+ //cout << endl;
+ y_loc += y_seq_incre;
+ }
+ ++motif_i;
+ }
+}
+
+void
+SeqView::draw_sequence(double ch_width)
+{
+ int i, seq_i, y_loc;
+ Sequence a_seq;
+ string sub_seq;
+ int seq_len, sub_seq_start, sub_seq_len;
+
+
+
+ fl_color(FL_BLACK);
+ y_loc = y_min + 10 + 5;
+
+ for(seq_i = 0; seq_i < seq_num; seq_i++)
+ {
+ seq_len = raw_sequence[seq_i].length();
+ sub_seq_start = seq_align_offsets[seq_i] - scroll_offset;
+ sub_seq_len = (x_max - index_pad) / (int) ch_width;
+ //cout << x_max << " index_pad: " << index_pad << " y - ip: " << (x_max - index_pad) << endl;
+
+ // gotta check thru boundary conditions to make sure we're producing the
+ // right string for the current position (otherwise gonna crash due to
+ // illegal indexing into substr
+ if (sub_seq_start < 0)
+ {
+ sub_seq_len = sub_seq_len - sub_seq_start;
+ if (sub_seq_len < 0)
+ sub_seq_len = 0;
+ sub_seq_start = 0;
+ }
+ else if (sub_seq_start >= seq_len)
+ {
+ sub_seq_start = seq_len;
+ sub_seq_len = 0;
+ }
+ else if ((sub_seq_start + sub_seq_len) >= seq_len)
+ sub_seq_len = seq_len - sub_seq_start;
+
+ sub_seq = raw_sequence[seq_i].substr(sub_seq_start, sub_seq_len);
+ fl_draw(sub_seq.c_str(), index_pad, y_loc);
+ y_loc += y_seq_incre;
+ }
+}
+
+
+void
+SeqView::draw_match_lines(double ch_width)
+{
+ int i, y_loc;
+ vector<int> a_path;
+ list<vector<int> >::iterator pathz_i;
+ int i2, i3;
+ int x_start, y_start, x_end, y_end;
+ int window_length, win_i;
+ int rc_1 = 0;
+ int rc_2 = 0;
+ int offset1, offset2;
+ float center1, center2;
+ bool rc_color;
+ vector<bool> rc_list;
+ bool full_match;
+ vector<bool> matched;
+ int align_counter;
+
+
+ align_counter = 0;
+ for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
+ {
+ if (show_aligns[align_counter])
+ {
+ a_path = *pathz_i;
+ window_length = a_path[0];
+
+ // determine which parts of the path are RC relative to first species
+ rc_list.clear();
+ for(i2 = 1; i2 <= seq_num; i2++)
+ {
+ if (a_path[i2] < 0)
+ rc_list.push_back(true);
+ else
+ rc_list.push_back(false);
+ }
+
+ // loop over each bp in the conserved region for all sequences
+ for(win_i = 0; win_i < window_length; win_i++)
+ {
+ // determine which exact base pairs match between the sequences
+ full_match = true;
+ for(i2 = 1; i2 < seq_num; i2++)
+ {
+ // assume not rc as most likely, adjust below
+ rc_1 = 0;
+ rc_2 = 0;
+ // no matter the case, any RC node needs adjustments
+ if (a_path[i2] < 0)
+ rc_1 = window_length-1;
+ if (a_path[i2+1] < 0)
+ rc_2 = window_length-1;
+
+ x_start = (abs(a_path[i2]-rc_1+win_i));
+ x_end = (abs(a_path[i2+1]-rc_2+win_i));
+
+ // RC case handling
+ // ugh, and xor...only want rc coloring if just one of the nodes is rc
+ // if both nodes are rc, then they are 'normal' relative to each other
+ if ( ( rc_list[i2] || rc_list[i2-1] ) &&
+ !(rc_list[i2] && rc_list[i2-1] ) )
+ { //the hideous rc matching logic - not complex, but annoying
+ if ( !( ( (raw_sequence[i2-1][x_start] == 'A') &&
+ (raw_sequence[i2][x_end] == 'T') ) ||
+ ( (raw_sequence[i2-1][x_start] == 'T') &&
+ (raw_sequence[i2][x_end] == 'A') ) ||
+ ( (raw_sequence[i2-1][x_start] == 'G') &&
+ (raw_sequence[i2][x_end] == 'C') ) ||
+ ( (raw_sequence[i2-1][x_start] == 'C') &&
+ (raw_sequence[i2][x_end] == 'G') ) ) )
+ full_match = false;
+ }
+ else
+ {
+ if (!( (raw_sequence[i2-1][x_start] == raw_sequence[i2][x_end]) &&
+ (raw_sequence[i2-1][x_start] != 'N') &&
+ (raw_sequence[i2][x_end] != 'N') ) )
+ full_match = false;
+ }
+ }
+
+ // draw for matches stretching across all sequences
+ if (full_match)
+ {
+ fl_line_style(FL_SOLID, 1, NULL);
+
+ // now can draw the line for each bp in this window that matches
+ // grrr, need to ask if anyone cares if I switch the seq top-bot order...
+ i3 = 0;
+ y_loc = y_min + 5;
+ for(i2 = 1; i2 < seq_num; i2++)
+ {
+ // assume not rc as most likely, adjust below
+ rc_1 = 0;
+ rc_2 = 0;
+ // this makes the lines start in the middle of the drawn char/bp
+ center1 = 0.5;
+ center2 = 0.5;
+ // no matter the case, any RC node needs adjustments
+ if (a_path[i2] < 0)
+ {
+ rc_1 = window_length;
+ center1 = -center1;
+ }
+ if (a_path[i2+1] < 0)
+ {
+ rc_2 = window_length;
+ center2 = -center2;
+ }
+
+ // set offset based on current alignment for which bp to show
+ offset1 = seq_align_offsets[i2-1];
+ offset2 = seq_align_offsets[i2];
+
+ if ( ( rc_list[i2] || rc_list[i2-1] ) &&
+ !(rc_list[i2] && rc_list[i2-1] ) )
+ fl_color(FL_BLUE);
+ else
+ fl_color(FL_RED);
+
+ // maybe shouldn't recalc these, but store values from first loop
+ x_start = (abs((int) (a_path[i2]-rc_1+win_i)));
+ x_end = (abs((int) (a_path[i2+1]-rc_2+win_i)));
+
+ fl_line( (int)((x_start+center1-offset1+scroll_offset)*ch_width)
+ + index_pad, y_loc + 10,
+ (int)((x_end+center2-offset2+scroll_offset)*ch_width)
+ + index_pad, y_loc+y_seq_incre );
+ y_loc += y_seq_incre;
+ }
+ }
+ }
+ }
+ align_counter++;
+ }
+}
+
+void
+SeqView::draw_indices(double ch_width)
+{
+ int seq_i;
+ Sequence a_seq;
+ int y_loc;
+ ostringstream an_index;
+ int shown_seq_len;
+
+
+ // clear out space on sides to draw in index values
+ // I block out the sides rather than adding offsets to the drawing of seq
+ // and conservation lines since the lines need to draw off the 'edge'
+ fl_color(FL_WHITE);
+ fl_rectf(0, y_min, index_pad, h()+y_min);
+ fl_rectf(w()-index_pad, y_min, index_pad, h()+y_min);
+
+ // now can draw in the indices of the start and end of the shown sequence
+ fl_color(FL_BLACK);
+ y_loc = y_min + 10 + 5;
+ for(seq_i = 0; seq_i < seq_num; seq_i++)
+ {
+ an_index.str("");
+ an_index << (seq_align_offsets[seq_i]-scroll_offset);
+ fl_draw((an_index.str()).c_str(), 2, y_loc);
+
+ shown_seq_len = (w() - 2 * index_pad) / (int) ch_width;
+ an_index.str("");
+ an_index << (seq_align_offsets[seq_i]-scroll_offset+shown_seq_len);
+ fl_draw((an_index.str()).c_str(), w()-index_pad+2, y_loc);
+ y_loc += y_seq_incre;
+ }
+}
+
+
+void
+SeqView::toggle_align(int align_num)
+{
+ //cout << align_num << endl;
+ //cout << show_aligns[align_num] << endl;
+ show_aligns[align_num] = !show_aligns[align_num];
+ //cout << show_aligns[align_num] << endl;
+}
+
+
+void
+SeqView::align_offsets(int align_num)
+{
+ list<vector<int> >::iterator pathz_i;
+ int i;
+ vector<int> a_path;
+ int window_length;
+
+ cout << "alignment: " << align_num << endl;
+
+ if (P.begin() == P.end())
+ cout << "crud....\n";
+ else
+ {
+ pathz_i = P.begin();
+
+ while(pathz_i != P.end())
+ ++pathz_i;
+
+ // find the path specified
+ i = 0;
+ pathz_i = P.begin();
+ while( (i < align_num) && (pathz_i != P.end()) )
+ {
+ ++i;
+ ++pathz_i;
+ }
+
+ // now set the alignment offsets - basically where the path starts
+ seq_align_offsets.clear();
+ for(i = 0; i < seq_num ; i++)
+ {
+ //cout << (*pathz_i)[i+1] << endl;
+ seq_align_offsets.push_back( abs((*pathz_i)[i+1]) );
+ // for testing purposes: to see everything in the short test sequences
+ //seq_align_offsets.push_back(0);
+ }
+ // reset any dragging done, otherwise might be hard to find selected align
+ scroll_offset = 0;
+ }
+}
+
+
+
+int
+SeqView::handle(int e)
+{
+ int return_value;
+
+ // this empty string needs to be put on cout, otherwise the -O optimize
+ // compile option seems to throw this function away with the following:
+ // gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
+ cout << "";
+
+ switch(e)
+ {
+ case FL_PUSH:
+ if (Fl::event_button3())
+ {
+ cout << "menu menu menu!\n";
+ return_value = 1;
+ }
+ break;
+ case FL_DRAG:
+ if (!dragging)
+ {
+ drag_change = Fl::event_x();
+ dragging = true;
+ return_value = 1;
+ }
+ drag_change = Fl::event_x() - drag_change;
+ scroll_offset += drag_change;
+ drag_change = Fl::event_x();
+ redraw();
+ break;
+ case FL_RELEASE:
+ if (dragging)
+ {
+ //scroll_offset += Fl::event_x() - drag_start;
+ //scroll_dist = Fl::event_x() - drag_start;
+ //scroll_offset += scroll_dist;
+ //scroll_offset += scroll_pos;
+ dragging = false;
+ redraw();
+ return_value = 1;
+ }
+ break;
+ default:
+ return_value = Fl_Widget::handle(e);
+ }
+
+ return return_value;
+}
+
+void
+SeqView::toggle_bars()
+{
+ show_bars = !show_bars;
+ redraw();
+}
+
+
+void
+SeqView::toggle_motifs()
+{
+ show_motifs = !show_motifs;
+ redraw();
+}
+
+
+void
+SeqView::reporter(string id, int value)
+{
+ cout << id << " : " << value << endl;
+}
+
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
--- /dev/null
+#ifndef _MUSSA_GUI_SEQ_VIEW_H_
+#define _MUSSA_GUI_SEQ_VIEW_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Box.H>
+
+#include "MotifWindow.hh"
+#include "SetupWindow.hh"
+
+class SeqView : public Fl_Box
+{
+ public:
+ SeqView(int x_top,int y_top,int x_bot,int y_bot) :
+ Fl_Box(x_top,y_top,x_bot,y_bot)
+ {
+ x_max = x_bot;
+ y_max = y_bot;
+ x_min = x_top;
+ y_min = y_top;
+ show_bars = true;
+ show_motifs = true;
+ }
+
+ void setup(std::string name, int sq_num, std::vector<Sequence> *some_seqs,
+ std::list<std::vector<int> > some_paths,
+ std::vector<int> some_lens, std::vector<motif> *some_motifs);
+ void align_offsets(int align_num);
+ void toggle_align(int align_num);
+ void toggle_bars();
+ void toggle_motifs();
+
+ private:
+ std::string ana_name;
+ int seq_num;
+ int base_window_len;
+
+ //this data is passed as pointers to the instantiated classes
+ std::vector<Sequence> *S;
+ //list of paths in selection box
+ std::list<std::vector<int> > P;
+ std::vector<int> seq_lens;
+ //pointer to passed motif data
+ std::vector<motif> *the_motifs;
+
+ int x_max, y_max, x_min, y_min;
+ int y_seq_incre;
+ int index_pad;
+ std::vector<int> seq_align_offsets;
+ std::vector<std::string> raw_sequence;
+ bool dragging;
+ int drag_change, scroll_offset;
+ bool show_bars, show_motifs;
+ std::vector<bool> show_aligns;
+
+ void resize(int new_x, int new_y, int new_w, int new_h);
+ void draw();
+ void draw_motifs(double ch_width);
+ void draw_sequence(double ch_width);
+ void draw_match_lines(double ch_width);
+ void draw_indices(double ch_width);
+ int handle(int e);
+ void reporter(std::string id, int value);
+};
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "SeqWindow.hh"
+
+#include <sstream>
+
+#include <FL/Fl.H>
+
+using namespace std;
+
+void
+set_align_cb(Fl_Widget* widg, void* the_data)
+{
+ menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
+ SeqWindow* T= blah->swm_ptr;
+ T->real_set_align_cb(blah->which_align);
+}
+
+
+void
+SeqWindow::real_set_align_cb(int which_align)
+{
+ vector<int> a_path;
+ int window_length;
+
+
+ a_path = *P.begin();
+ window_length = a_path[0];
+ cout << window_length << endl;
+
+ cout << "fum1\n";
+ seq_box->align_offsets(which_align);
+ seq_box->redraw();
+}
+
+
+void
+show_align_cb(Fl_Widget* widg, void* the_data)
+{
+ menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
+ SeqWindow* T= blah->swm_ptr;
+ T->real_show_align_cb(blah->which_align);
+}
+
+
+void
+SeqWindow::real_show_align_cb(int which_align)
+{
+ vector<int> a_path;
+ int window_length;
+
+
+ cout << "fumish\n";
+ seq_box->toggle_align(which_align);
+ seq_box->redraw();
+}
+
+
+void
+toggle_bars_cb(Fl_Button* o, void* v)
+{
+ SeqWindow* T=(SeqWindow*)v;
+ T->real_toggle_bars_cb();
+}
+
+
+void
+SeqWindow::real_toggle_bars_cb()
+{
+ seq_box->toggle_bars();
+}
+
+
+void
+toggle_motifs_cb(Fl_Button* o, void* v)
+{
+ SeqWindow* T=(SeqWindow*)v;
+ T->real_toggle_motifs_cb();
+}
+
+
+void
+SeqWindow::real_toggle_motifs_cb()
+{
+ seq_box->toggle_motifs();
+}
+
+
+// main code, window creation
+
+SeqWindow::SeqWindow(int w, int h, const char* title, int sq_num,
+ vector<Sequence> *some_seqs,
+ list<vector<int> > some_paths,
+ vector<int> some_lens,
+ vector<motif> *some_motifs):
+ Fl_Double_Window(w,h,title)
+{
+ menu_align_data_bundle * some_menu_data;
+ vector<int> a_path;
+ int window_length, align_number;
+ int i;
+ ostringstream align_id_ostr;
+ string align_id_string;
+ list<vector<int> >::iterator align_iter;
+
+
+
+ // most of this stuff is here just to pass to SeqView object
+ // some is needed to setup the window menus
+ seq_num = sq_num;
+ S = some_seqs;
+ P = some_paths;
+ seq_lens = some_lens;
+ the_motifs = some_motifs;
+
+
+ begin();
+ color(FL_WHITE);
+ resizable(this);
+
+ // make the menu that allows alignment selection
+ choose_align_menu = new Fl_Menu_Button(5, 2, 180, 30, "Choose Alignment");
+ choose_align_menu->color(FL_WHITE,FL_BLUE);
+ choose_align_menu->box(FL_BORDER_BOX);
+ choose_align_menu->clear();
+
+ // make the menu that allows alignment selection
+ show_align_menu = new Fl_Menu_Button(190, 2, 180, 30, "Show Alignment");
+ show_align_menu->color(FL_WHITE,FL_BLUE);
+ show_align_menu->box(FL_BORDER_BOX);
+ show_align_menu->clear();
+
+
+ // adds menu items for each path
+ align_iter = P.begin();
+ align_number = 0;
+ while(align_iter != P.end())
+ {
+ some_menu_data = new menu_align_data_bundle;
+ some_menu_data->swm_ptr = this;
+ some_menu_data->which_align = align_number;
+ align_id_ostr << (*align_iter)[0] << ": ";
+ for(i = 1; i <= seq_num; i++)
+ align_id_ostr << (*align_iter)[i] << ", ";
+ align_id_string = align_id_ostr.str();
+ choose_align_menu->add((const char*)align_id_string.c_str(), 0,
+ (Fl_Callback *) set_align_cb,
+ (void*) some_menu_data);
+ show_align_menu->add((const char*)align_id_string.c_str(), 0,
+ (Fl_Callback *) show_align_cb,
+ (void*) some_menu_data, FL_MENU_TOGGLE|FL_MENU_VALUE);
+
+ align_id_ostr.str("");
+ ++align_number;
+ ++align_iter;
+ }
+
+ /*
+ show_align_menu->add("f&ee");
+ show_align_menu->add("f&ie");
+ show_align_menu->add("f&oe");
+ show_align_menu->add("f&um");
+ */
+
+ Fl_Button *test_but = new Fl_Button(375, 2, 150, 30, "Toggle Motifs");
+ test_but->color(FL_WHITE,FL_BLUE);
+ test_but->box(FL_BORDER_BOX);
+ test_but->callback((Fl_Callback*) toggle_motifs_cb, this);
+
+ toggle_bars = new Fl_Button(530, 2, 150, 30, "Toggle 10bp bars");
+ toggle_bars->color(FL_WHITE,FL_BLUE);
+ toggle_bars->box(FL_BORDER_BOX);
+ toggle_bars->callback((Fl_Callback*) toggle_bars_cb, this);
+
+
+ // make the view of the sequence
+ seq_box = new SeqView(0, 34, w, h-34);
+ seq_box->setup(ana_name, seq_num, S, P, seq_lens, the_motifs);
+ //real_set_align_cb(2);
+
+ end();
+ Fl::visual(FL_DOUBLE|FL_INDEX);
+ show();
+}
+
+
+
+/*
+ some_menu_data = new menu_align_data_bundle;
+ some_menu_data->swm_ptr = this;
+ some_menu_data->which_align = 2;
+ choose_align_menu->add("f&ie", FL_ALT+'i', (Fl_Callback *) set_align_cb,
+ (void*) some_menu_data);
+
+ some_menu_data = new menu_align_data_bundle;
+ some_menu_data->swm_ptr = this;
+ some_menu_data->which_align = 3;
+ choose_align_menu->add("f&oe", FL_ALT+'o', (Fl_Callback *) set_align_cb,
+ (void*) some_menu_data);
+
+ some_menu_data = new menu_align_data_bundle;
+ some_menu_data->swm_ptr = this;
+ some_menu_data->which_align = 4;
+ choose_align_menu->add("f&um", FL_ALT+'u', (Fl_Callback *) set_align_cb,
+ (void*) some_menu_data);
+*/
+
+
+
+
--- /dev/null
+#ifndef _MUSSA_GUI_SEQ_H_
+#define _MUSSA_GUI_SEQ_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <iostream>
+#include <list>
+#include <string>
+#include <vector>
+
+#include "SeqView.hh"
+
+#include <FL/Fl_Menu_Bar.H>
+#include <FL/Fl_Menu_Item.H>
+#include <FL/Fl_Menu_Button.H>
+#include <FL/Fl_Double_Window.H>
+
+class SeqWindow : public Fl_Double_Window
+{
+ private:
+ std::string ana_name;
+ int base_window_len;
+
+ //this data is passed as pointers to the instantiated classes
+ std::vector<Sequence> *S;
+ // list of paths in selection box
+ std::list<std::vector<int> > P;
+ std::vector<int> seq_lens;
+ //pointer to passed motif data
+ std::vector<motif> *the_motifs;
+
+ int x_max, y_max;
+ Fl_Menu_Button *choose_align_menu;
+ Fl_Menu_Button *show_align_menu;
+ Fl_Button *toggle_bars;
+ SeqView *seq_box;
+
+ public:
+ int seq_num;
+
+ SeqWindow(int w, int h, const char* title, int sq_num,
+ std::vector<Sequence> *some_seqs,
+ std::list<std::vector<int> > some_paths,
+ std::vector<int> some_lens,
+ std::vector<motif> *some_motifs);
+ virtual ~SeqWindow(){ std::cout << "dying\n"; }
+
+ void make_choose_menu();
+ void make_show_menu();
+ void real_set_align_cb(int which_align);
+ void real_show_align_cb(int which_align);
+ void real_toggle_bars_cb();
+ void real_toggle_motifs_cb();
+};
+
+
+struct menu_align_data_bundle
+{
+ SeqWindow * swm_ptr;
+ int which_align;
+};
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "SetupWindow.hh"
+#include "mussa_class.hh"
+#include <iostream>
+#include <FL/Fl_File_Chooser.H>
+
+using namespace std;
+
+bool
+SetupWindow::done()
+{
+ return all_done;
+}
+
+
+void
+do_analysis_cb(Fl_Button* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_do_analysis();
+}
+
+
+// passes the parameters to the mussa class object and orders it to run
+void
+SetupWindow::real_do_analysis()
+{
+ int i;
+ string err_msg;
+
+ // <-- need a check here to make sure all vars have a valid value
+
+ an_analysis->clear();
+ an_analysis->set_name(ana_name);
+ an_analysis->set_seq_num(seq_num);
+ an_analysis->set_window(window);
+ an_analysis->set_threshold(threshold);
+
+ for(i=0; i < seq_num; i++)
+ an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
+ sub_seq_starts[i], sub_seq_ends[i]);
+
+ err_msg = an_analysis->analyze(0,0, 't', 0.0);
+ //cout << "Feel the tribal beat\n";
+ if (!(err_msg == ""))
+ {
+ //fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+
+ all_done = true;
+
+ hide();
+}
+
+
+void
+choose_seq_file_cb(Fl_Button* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_choose_seq_file_cb(blah->index);
+}
+
+
+void
+SetupWindow::real_choose_seq_file_cb(int i)
+{
+ char *picked_file;
+ string a_file_path;
+
+ picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ a_file_path = picked_file;
+ seq_files[i] = a_file_path;
+ seq_inputs[i]->value((const char *)picked_file);
+}
+
+
+void
+seq_file_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_seq_file_in_cb(o,blah->index);
+}
+
+
+void
+SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
+{
+ seq_files[i] = o->value();
+ // leaving this as a reminder that bools will need to be set to determine
+ // if all needed fields have been filled with some value before an analysis
+ // is attempted
+ //(*the_motifs)[i].dirty = true;
+}
+
+//char *picked_file;
+//picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+
+// *** Annot file selection
+
+void
+choose_annot_file_cb(Fl_Button* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_choose_annot_file_cb(blah->index);
+}
+
+
+void
+SetupWindow::real_choose_annot_file_cb(int i)
+{
+ char *picked_file;
+ string a_file_path;
+
+ picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ a_file_path = picked_file;
+ annot_files[i] = a_file_path;
+ annot_inputs[i]->value((const char *)picked_file);
+}
+
+void
+annot_file_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_annot_file_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
+{
+ annot_files[i] = o->value();
+}
+
+
+// *** fasta index selection
+
+void
+fa_index_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_fa_index_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
+{
+ fasta_indices[i] = atoi(o->value());
+}
+
+// *** subsequence start select
+
+void
+sub_start_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_sub_start_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_starts[i] = atoi(o->value());
+}
+
+// *** subsequence end select
+
+void
+sub_end_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_sub_end_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_ends[i] = atoi(o->value());
+
+}
+
+// *** input analysis name
+
+void
+set_ana_name_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_ana_name_cb(o);
+}
+
+void
+SetupWindow::real_set_ana_name_cb(Fl_Input* o)
+{
+ ana_name = o->value();
+}
+
+// *** input window size
+
+void
+set_win_size_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_win_size_cb(o);
+}
+
+void
+SetupWindow::real_set_win_size_cb(Fl_Input* o)
+{
+ window = atoi(o->value());
+}
+
+// *** input threshold
+
+void
+set_threshold_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_threshold_cb(o);
+}
+
+void
+SetupWindow::real_set_threshold_cb(Fl_Input* o)
+{
+ threshold = atoi(o->value());
+}
+
+void
+set_seq_num_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_seq_num_cb(o);
+}
+
+// *** input number of sequences, add appropriate inputs for each sequence
+
+void
+SetupWindow::real_set_seq_num_cb(Fl_Input* o)
+{
+ int i;
+
+ seq_num = atoi(o->value());
+ seq_inputs.clear();
+ annot_inputs.clear();
+
+ seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
+ seq_scroll->color(FL_WHITE);
+
+ for (i = 0; i < seq_num; i++)
+ {
+ seq_files.push_back("");
+ annot_files.push_back("");
+ fasta_indices.push_back(1);
+ sub_seq_starts.push_back(0);
+ sub_seq_ends.push_back(0);
+ add_seq_input(i);
+ }
+ seq_scroll->box(FL_DOWN_FRAME);
+ add(seq_scroll);
+ redraw();
+}
+
+
+SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
+{
+ color(FL_WHITE);
+
+ an_analysis = the_analysis;
+ all_done = false;
+
+ begin();
+
+ name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
+ name_input->value("");
+ //name_input->when(FL_WHEN_ENTER_KEY);
+ name_input->box(FL_BORDER_BOX);
+ name_input->callback((Fl_Callback*)set_ana_name_cb, this);
+
+ // add in radio buttons for win_append and thres_append eventually
+ win_append = true;
+ thres_append = true;
+
+ win_input = new Fl_Input(65,45,100,30, "Window ");
+ win_input->value("");
+ win_input->callback((Fl_Callback*)set_win_size_cb, this);
+
+ thres_input = new Fl_Input(250,45,100,30, "Threshold ");
+ thres_input->value("");
+ thres_input->callback((Fl_Callback*)set_threshold_cb, this);
+
+ seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
+ seq_num_input->value("");
+ seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
+
+ // button to launch the analysis
+ test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
+ test->callback((Fl_Callback*)do_analysis_cb, this);
+
+ // test button to make sure setup data is being stored
+ test = new Fl_Button(w-200,h-30,100,30,"show setup");
+ test->callback((Fl_Callback*)print_cb, this);
+
+ // generic input, keeping around as template for future additions
+ //_input = new Fl_Input(0, , 30, "");
+ //_input->value("");
+ //_input->when(FL_WHEN_ENTER_KEY);
+ //_input->callback((Fl_Callback*)set__cb, this);
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SetupWindow::~SetupWindow(){}
+
+
+void
+SetupWindow::add_seq_input(int i)
+{
+ Fl_Input *fasta_input, *start_input, *end_input;
+ Fl_Button *seq_browse, *annot_browse;
+
+
+ // this remembers what seq index each input is associated with
+ seq_data_instance * something;
+ something = new seq_data_instance;
+ something->sw_ptr = this;
+ something->index = i;
+
+
+ // setup sequence file input for text input or file browsing
+ seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
+ seq_inputs[i]->value("");
+ seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
+
+ seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
+ seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
+
+ // setup annotation file input for text input or file browsing
+ annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
+ annot_inputs[i]->value("");
+ annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
+
+ annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
+ annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
+
+ // index of fasta seq wanted if more than 1 seq in file
+ fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
+ fasta_input->value("");
+ fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
+
+ // subsequence select, index of first bp wanted
+ start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
+ start_input->value("");
+ start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
+
+ // subsequence select, index of last bp wanted
+ end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
+ end_input->value("");
+ end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
+
+ seq_scroll->add(seq_inputs[i]);
+ seq_scroll->add(seq_browse);
+ seq_scroll->add(annot_inputs[i]);
+ seq_scroll->add(annot_browse);
+ seq_scroll->add(fasta_input);
+ seq_scroll->add(start_input);
+ seq_scroll->add(end_input);
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void SetupWindow::print_cb(Fl_Button* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void SetupWindow::print_cb_real(Fl_Button* , void*)
+{
+ cout << "ana_name: " << ana_name << endl;
+ cout << "win: " << window << endl;
+ cout << "thres: " << threshold << endl;
+ cout << "seq_num: " << seq_num << endl;
+ //cout << "win_add: " << win_append << end;
+ //cout << "thres_add: " << thres_append << endl;
+
+ int i;
+
+
+
+ for (i = 0; i < seq_num; i++)
+ {
+ cout << seq_files[i] << endl;
+ cout << annot_files[i] << endl;
+ cout << "fasta: " << fasta_indices[i];
+ cout << " start: " << sub_seq_starts[i];
+ cout << " end: " << sub_seq_ends[i] << endl;
+ cout << "blargle!\n";
+ }
+ cout << "end of inputs\n" << endl;
+}
--- /dev/null
+#ifndef _MUSSA_GUI_LOAD_WINDOW_H_
+#define _MUSSA_GUI_LOAD_WINDOW_H_
+
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Scroll.H>
+#include <FL/Fl_Window.H>
+
+class Mussa;
+#include "SetupWindow.hh"
+
+class SetupWindow : public Fl_Window
+{
+ public:
+ SetupWindow(int w, int h, const char* title, Mussa *an_analysis);
+ ~SetupWindow();
+
+ bool done();
+
+ //did I put these in public for a reason?
+ Fl_Button* test;
+ Fl_Input *name_input;
+ Fl_Input *win_input;
+ Fl_Input *thres_input;
+ Fl_Input *seq_num_input;
+ Fl_Scroll *seq_scroll;
+ // need to keep track of these so a browsed file search can set the input
+ // fields to teh selected file
+ std::vector<Fl_Input*> seq_inputs, annot_inputs;
+
+
+ // callback receiver functions
+
+ void real_do_analysis();
+
+ void real_set_ana_name_cb(Fl_Input* o);
+ void real_set_win_size_cb(Fl_Input* o);
+ void real_set_threshold_cb(Fl_Input* o);
+ void real_set_seq_num_cb(Fl_Input* o);
+
+ void real_seq_file_in_cb(Fl_Input* o, int i);
+ void real_choose_seq_file_cb(int i);
+ void real_annot_file_in_cb(Fl_Input* o, int i);
+ void real_choose_annot_file_cb(int i);
+
+ void real_fa_index_in_cb(Fl_Input* o, int i);
+ void real_sub_start_in_cb(Fl_Input* o, int i);
+ void real_sub_end_in_cb(Fl_Input* o, int i);
+
+ private:
+ Mussa *an_analysis;
+ std::string ana_name;
+ int window, threshold, seq_num;
+ std::vector<std::string> seq_files, annot_files;
+ std::vector<int> fasta_indices, sub_seq_starts, sub_seq_ends;
+ bool win_append, thres_append;
+
+ bool all_done;
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+
+ void add_seq_input(int index);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+
+struct seq_data_instance
+{
+ SetupWindow * sw_ptr;
+ int index;
+};
+
+#endif
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "SubAnalysisWindow.hh"
+
+#include <iostream>
+using namespace std;
+
+void
+do_subana_cb(Fl_Button* o, void* v)
+{
+ SubAnalysisWindow* T=(SubAnalysisWindow*)v;
+ T->real_do_subana();
+}
+
+
+// passes the parameters to the mussa class object and orders it to run
+void
+SubAnalysisWindow::real_do_subana()
+{
+ int i;
+ string a_sequence, err_msg;
+
+ // <-- need a check here to make sure all vars have a valid value
+
+ an_analysis->clear();
+ an_analysis->set_name(ana_name);
+ an_analysis->set_seq_num(seq_num);
+ an_analysis->set_window(window);
+ an_analysis->set_threshold(threshold);
+
+ for(i=0; i < seq_num; i++)
+ {
+ a_sequence = the_Seqs[i].seq();
+ cout << a_sequence.length() << endl;
+ a_sequence = a_sequence.substr(sub_seq_starts[i],
+ sub_seq_ends[i] - sub_seq_starts[i] );
+ cout << a_sequence.length() << endl;
+ an_analysis->add_a_seq(a_sequence);
+ }
+
+ err_msg = an_analysis->analyze(0,0, 't', 0.0);
+
+ cout << "Feel the tribal beat\n";
+ if (!(err_msg == ""))
+ {
+ //fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+
+ all_done = true;
+
+ hide();
+}
+
+
+
+// *** subsequence start select
+
+void
+sub_start_in_cb1(Fl_Input* o, void* v)
+{
+ sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
+ SubAnalysisWindow* T= blah->sw_ptr;
+ T->real_sub_start_in_cb(o,blah->index);
+}
+
+void
+SubAnalysisWindow::real_sub_start_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_starts[i] = atoi(o->value());
+}
+
+// *** subsequence end select
+
+void
+sub_end_in_cb1(Fl_Input* o, void* v)
+{
+ sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
+ SubAnalysisWindow* T= blah->sw_ptr;
+ T->real_sub_end_in_cb(o,blah->index);
+}
+
+void
+SubAnalysisWindow::real_sub_end_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_ends[i] = atoi(o->value());
+
+}
+
+// *** input analysis name
+
+void
+set_ana_name_cb1(Fl_Input* o, void* v)
+{
+ SubAnalysisWindow* T=(SubAnalysisWindow*)v;
+ T->real_set_ana_name_cb(o);
+}
+
+void
+SubAnalysisWindow::real_set_ana_name_cb(Fl_Input* o)
+{
+ ana_name = o->value();
+}
+
+// *** input window size
+
+void
+set_win_size_cb1(Fl_Input* o, void* v)
+{
+ SubAnalysisWindow* T=(SubAnalysisWindow*)v;
+ T->real_set_win_size_cb(o);
+}
+
+void
+SubAnalysisWindow::real_set_win_size_cb(Fl_Input* o)
+{
+ window = atoi(o->value());
+}
+
+// *** input threshold
+
+void
+set_threshold_cb1(Fl_Input* o, void* v)
+{
+ SubAnalysisWindow* T=(SubAnalysisWindow*)v;
+ T->real_set_threshold_cb(o);
+}
+
+void
+SubAnalysisWindow::real_set_threshold_cb(Fl_Input* o)
+{
+ threshold = atoi(o->value());
+}
+
+
+bool
+SubAnalysisWindow::done()
+{
+ return all_done;
+}
+
+
+SubAnalysisWindow::SubAnalysisWindow(int w, int h, const char* title,Mussa *the_analysis,
+ vector<Sequence> some_Seqs):Fl_Window(w,h,title)
+{
+ string a_name;
+
+ color(FL_WHITE);
+
+ an_analysis = the_analysis;
+ the_Seqs = some_Seqs;
+ all_done = false;
+
+ // initialize parameters
+ ana_name = "";
+ window = -1;
+ threshold = -1;
+
+ begin();
+
+ name_input = new Fl_Input(135, 10, w-140, 30, "SubAnalysis Name ");
+ name_input->value("");
+ //name_input->when(FL_WHEN_ENTER_KEY);
+ name_input->box(FL_BORDER_BOX);
+ name_input->callback((Fl_Callback*)set_ana_name_cb1, this);
+
+ // add in radio buttons for win_append and thres_append eventually
+ win_append = true;
+ thres_append = true;
+
+ win_input = new Fl_Input(135,45,100,30, "Window: ");
+ win_input->value("");
+ win_input->callback((Fl_Callback*)set_win_size_cb1, this);
+
+ thres_input = new Fl_Input(320,45,100,30, "Threshold: ");
+ thres_input->value("");
+ thres_input->callback((Fl_Callback*)set_threshold_cb1, this);
+
+ // button to launch the analysis
+ test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
+ test->callback((Fl_Callback*)do_subana_cb, this);
+
+ // test button to make sure setup data is being stored
+ test = new Fl_Button(w-200,h-30,100,30,"show setup");
+ test->callback((Fl_Callback*)print_cb, this);
+
+ // add all the inputs for the sub sequence starts & ends
+ int i;
+
+ seq_num = the_Seqs.size();
+
+ seq_scroll = new Fl_Scroll(5,80,w-10,h-115);
+ seq_scroll->color(FL_WHITE);
+
+ for (i = 0; i < seq_num; i++)
+ {
+ sub_seq_starts.push_back(0);
+ sub_seq_ends.push_back(0);
+ a_name = the_Seqs[i].sp_name();
+ cout << a_name << endl;
+ add_seq_input(i, a_name);
+ }
+ seq_scroll->box(FL_DOWN_FRAME);
+ //add(seq_scroll);
+ //redraw();
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SubAnalysisWindow::~SubAnalysisWindow(){}
+
+
+void
+SubAnalysisWindow::add_seq_input(int i, string a_name)
+{
+ Fl_Input *start_input, *end_input;
+
+
+ // this remembers what seq index each input is associated with
+ sub_seq_data_instance * something;
+ something = new sub_seq_data_instance;
+ something->sw_ptr = this;
+ something->index = i;
+
+
+ // subsequence select, index of first bp wanted
+ start_input = new Fl_Input(150, 85+(i*35), 70, 30, "start index: ");
+ start_input->value("");
+ start_input->callback((Fl_Callback*)sub_start_in_cb1, (void*) something);
+
+ // subsequence select, index of last bp wanted
+ end_input = new Fl_Input(300, 85+(i*35), 70, 30, "end index: ");
+ end_input->value("");
+ end_input->callback((Fl_Callback*)sub_end_in_cb1, (void*) something);
+
+ seq_scroll->add(start_input);
+ seq_scroll->add(end_input);
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void SubAnalysisWindow::print_cb(Fl_Button* o, void* v)
+{
+ SubAnalysisWindow* T=(SubAnalysisWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void SubAnalysisWindow::print_cb_real(Fl_Button* , void*)
+{
+ cout << "ana_name: " << ana_name << endl;
+ cout << "win: " << window << endl;
+ cout << "thres: " << threshold << endl;
+ cout << "seq_num: " << seq_num << endl;
+ //cout << "win_add: " << win_append << end;
+ //cout << "thres_add: " << thres_append << endl;
+
+ int i;
+
+
+
+ for (i = 0; i < seq_num; i++)
+ {
+ //cout << seq_files[i] << endl;
+ //cout << annot_files[i] << endl;
+ //cout << "fasta: " << fasta_indices[i];
+ cout << " start: " << sub_seq_starts[i];
+ cout << " end: " << sub_seq_ends[i] << endl;
+ cout << "blargle!\n";
+ }
+ cout << "end of inputs\n" << endl;
+}
--- /dev/null
+#ifndef _MUSSA_GUI_SUBANA_H_
+#define _MUSSA_GUI_SUBANA_H_
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+#include <string>
+#include <vector>
+
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_Scroll.H>
+
+#include "mussa_class.hh"
+#include "SeqTextWindow.hh"
+
+class SubAnalysisWindow : public Fl_Window
+{
+ public:
+ SubAnalysisWindow(int w, int h, const char* title, Mussa *an_analysis,
+ std::vector<Sequence> some_Seqs);
+ ~SubAnalysisWindow();
+ bool done();
+
+
+ Fl_Button* test;
+
+ Fl_Input *name_input;
+ Fl_Input *win_input;
+ Fl_Input *thres_input;
+ Fl_Input *seq_num_input;
+ Fl_Scroll *seq_scroll;
+ // need to keep track of these so a browsed file search can set the input
+ // fields to the selected file
+ std::vector<Fl_Input*> seq_inputs, annot_inputs;
+
+
+ // callback receiver functions
+
+ void real_do_subana();
+
+ void real_set_ana_name_cb(Fl_Input* o);
+ void real_set_win_size_cb(Fl_Input* o);
+ void real_set_threshold_cb(Fl_Input* o);
+
+ void real_sub_start_in_cb(Fl_Input* o, int i);
+ void real_sub_end_in_cb(Fl_Input* o, int i);
+
+ private:
+ // sequence data
+ std::vector<Sequence> the_Seqs;
+ Mussa *an_analysis;
+ std::string ana_name;
+ int window, threshold, seq_num;
+ std::vector<int> sub_seq_starts, sub_seq_ends;
+ bool win_append, thres_append;
+ bool all_done;
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+
+ void add_seq_input(int index, std::string a_name);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+
+
+struct sub_seq_data_instance
+{
+ SubAnalysisWindow * sw_ptr;
+ int index;
+};
+#endif
--- /dev/null
+CURDIR := $(BASEDIR)gui/
+
+SOURCES.cxx := AnnotWindow.cxx \
+ ConnView.cxx \
+ ConnWindow.cxx \
+ MotifWindow.cxx \
+ SeqTextWindow.cxx \
+ SeqView.cxx \
+ SeqWindow.cxx \
+ SetupWindow.cxx \
+ SubAnalysisWindow.cxx
+
+SRC += $(addprefix $(CURDIR), $(SOURCES.cxx))
+CXXFLAGS += -I$(CURDIR)
+
--- /dev/null
+CURDIR := $(BASEDIR)
+
+SOURCES.cxx := flp.cxx \
+ flp_seqcomp.cxx \
+ mussa.cxx \
+ mussa_class.cxx \
+ mussa_nway.cxx \
+ mussa_nway_entropy.cxx \
+ mussa_nway_other.cxx \
+ sequence.cxx
+ #seqcomp.cxx \ #(old seqcomp)
+ #mussa_nway_refine.cxx \ (broken code)
+
+SRC += $(addprefix $(CURDIR), $(SOURCES.cxx))
+CXXFLAGS += -I$(CURDIR)
+
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_conn_window.hh"
-#include <iostream>
-using namespace std;
-
-char
-parse_args(int argc, char **argv, string *a_file_path, int *window,
- int *threshold, char *ana_mode, float *ent_thres);
-
-
-int main(int argc, char **argv)
-{
- Mussa an_analysis;
- string a_file_path;
- char * picked_file;
- int window, threshold;
- float ent_thres;
- char run_mode, ana_mode;
- int x_max=1000;
- int y_max=500;
- string err_msg;
-
-
- err_msg = "";
-
- // yeah, its horrible to be passing these by reference, but I just don't see
- // any other way without making parse_args part of MussaClass, which just
- // seems wrong (args are after all, an io type thing, and the gui only mode
- // will have it own way as well...
- run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
- &ana_mode, &ent_thres);
-
- cout << "mussa: run mode = " << run_mode;
- cout << "\tfile_path = "<< a_file_path << endl;
- cout << "mussa: ent_thres = " << ent_thres << endl;
-
- // if no error from parse args (run_mode = 'e', ie error), run in proper mode
- if (run_mode != 'e')
- {
- if ((run_mode == 'f') || (run_mode == 'n'))
- {
- err_msg = an_analysis.load_mupa_file(a_file_path);
- err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
- //an_overlord.do_analysis();
- }
-
- if (run_mode == 'v')
- err_msg = an_analysis.load(a_file_path);
- //an_overlord.get_analysis();
-
- // no longer needed, but still semi-useful reality check...
- if (run_mode == 'g')
- {
- cout << "GTV - All Gui, All the Time\n";
- }
-
- if (err_msg == "")
- {
- if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
- {
- //an_overlord.spawnConnView(1000,500);
- ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
-
- // we have an analysis already if in these 2 modes
- if ((run_mode == 'f') || (run_mode == 'v'))
- a_conn_win->add_ana(&an_analysis);
-
- Fl::run();
- }
- }
- else
- cout << err_msg << endl;
- }
-}
-
-
-// minimal arg reading function, not very robust to errors
-char
-parse_args(int argc, char **argv, string *a_file_path, int *window,
- int *threshold, char *ana_mode, float *ent_thres)
-{
- int i, else_i;
- string an_arg;
- char run_mode;
-
- // initialize these to 0 as flag if they are not changed
- *window = 0;
- *threshold = 0;
- *ent_thres = 0.0;
- run_mode = 'e'; //error default if no run mode set implicitly or explicitly
- *ana_mode = 't'; // default to transitivie analyses mode
-
-
-
- // no args means gui only mode
- if (argc == 1)
- run_mode = 'g';
- // 1 arg means its a mupa file and run in full mode
- /*
- else if (argc == 2)
- {
- }
- */
- else
- {
- else_i = 0;
- i = 1;
- while (i < argc)
- {
- an_arg = * ++argv;
- i++;
-
- // see what alternate mode the user wants to run in
- if (an_arg == "-m")
- {
- an_arg = * ++argv;
- i++;
- if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
- run_mode = an_arg[0];
- else
- {
- cout << "Error: \'" << an_arg;
- cout << "\' is not a valid analysis mode for -a argument" << endl;
- run_mode = 'e';
- }
- *a_file_path = * ++argv;
- i++;
- }
- // alternate analyses modes
- else if (an_arg == "-a")
- {
- an_arg = * ++argv;
- i++;
- // t = transitive, r = radial, e = entropy
- if ( (an_arg == "t") || (an_arg == "r") || (an_arg == "e") )
- *ana_mode = an_arg[0];
- else
- {
- cout << "Error: \'" << an_arg;
- cout << "\' is not a valid run mode for -m argument" << endl;
- run_mode = 'e';
- }
-
- }
- else if (an_arg == "-w") // alternate window size arg
- {
- *window = atoi(* ++argv);
- i++;
- }
- else if (an_arg == "-t") // alternate threshold arg
- {
- *threshold = atoi(* ++argv);
- i++;
- }
- else if (an_arg == "-et") // alternate entropy threshold arg
- {
- *ent_thres = atof(* ++argv);
- i++;
- }
- else
- {
- if (else_i == 0)
- {
- *a_file_path = an_arg;
- run_mode = 'f';
- else_i++;
- }
- else
- {
- //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
- cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;
- run_mode == 'e';
- }
- }
- }
- }
-
- return run_mode;
-}
-
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "ConnWindow.hh"
+#include <iostream>
+using namespace std;
+
+char
+parse_args(int argc, char **argv, string *a_file_path, int *window,
+ int *threshold, char *ana_mode, float *ent_thres);
+
+
+int main(int argc, char **argv)
+{
+ Mussa an_analysis;
+ string a_file_path;
+ char * picked_file;
+ int window, threshold;
+ float ent_thres;
+ char run_mode, ana_mode;
+ int x_max=1000;
+ int y_max=500;
+ string err_msg;
+
+
+ err_msg = "";
+
+ // yeah, its horrible to be passing these by reference, but I just don't see
+ // any other way without making parse_args part of MussaClass, which just
+ // seems wrong (args are after all, an io type thing, and the gui only mode
+ // will have it own way as well...
+ run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
+ &ana_mode, &ent_thres);
+
+ cout << "mussa: run mode = " << run_mode;
+ cout << "\tfile_path = "<< a_file_path << endl;
+ cout << "mussa: ent_thres = " << ent_thres << endl;
+
+ // if no error from parse args (run_mode = 'e', ie error), run in proper mode
+ if (run_mode != 'e')
+ {
+ if ((run_mode == 'f') || (run_mode == 'n'))
+ {
+ err_msg = an_analysis.load_mupa_file(a_file_path);
+ err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
+ //an_overlord.do_analysis();
+ }
+
+ if (run_mode == 'v')
+ err_msg = an_analysis.load(a_file_path);
+ //an_overlord.get_analysis();
+
+ // no longer needed, but still semi-useful reality check...
+ if (run_mode == 'g')
+ {
+ cout << "GTV - All Gui, All the Time\n";
+ }
+
+ if (err_msg == "")
+ {
+ if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
+ {
+ //an_overlord.spawnConnView(1000,500);
+ ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
+
+ // we have an analysis already if in these 2 modes
+ if ((run_mode == 'f') || (run_mode == 'v'))
+ a_conn_win->add_ana(&an_analysis);
+
+ Fl::run();
+ }
+ }
+ else
+ cout << err_msg << endl;
+ }
+}
+
+
+// minimal arg reading function, not very robust to errors
+char
+parse_args(int argc, char **argv, string *a_file_path, int *window,
+ int *threshold, char *ana_mode, float *ent_thres)
+{
+ int i, else_i;
+ string an_arg;
+ char run_mode;
+
+ // initialize these to 0 as flag if they are not changed
+ *window = 0;
+ *threshold = 0;
+ *ent_thres = 0.0;
+ run_mode = 'e'; //error default if no run mode set implicitly or explicitly
+ *ana_mode = 't'; // default to transitivie analyses mode
+
+
+
+ // no args means gui only mode
+ if (argc == 1)
+ run_mode = 'g';
+ // 1 arg means its a mupa file and run in full mode
+ /*
+ else if (argc == 2)
+ {
+ }
+ */
+ else
+ {
+ else_i = 0;
+ i = 1;
+ while (i < argc)
+ {
+ an_arg = * ++argv;
+ i++;
+
+ // see what alternate mode the user wants to run in
+ if (an_arg == "-m")
+ {
+ an_arg = * ++argv;
+ i++;
+ if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
+ run_mode = an_arg[0];
+ else
+ {
+ cout << "Error: \'" << an_arg;
+ cout << "\' is not a valid analysis mode for -a argument" << endl;
+ run_mode = 'e';
+ }
+ *a_file_path = * ++argv;
+ i++;
+ }
+ // alternate analyses modes
+ else if (an_arg == "-a")
+ {
+ an_arg = * ++argv;
+ i++;
+ // t = transitive, r = radial, e = entropy
+ if ( (an_arg == "t") || (an_arg == "r") || (an_arg == "e") )
+ *ana_mode = an_arg[0];
+ else
+ {
+ cout << "Error: \'" << an_arg;
+ cout << "\' is not a valid run mode for -m argument" << endl;
+ run_mode = 'e';
+ }
+
+ }
+ else if (an_arg == "-w") // alternate window size arg
+ {
+ *window = atoi(* ++argv);
+ i++;
+ }
+ else if (an_arg == "-t") // alternate threshold arg
+ {
+ *threshold = atoi(* ++argv);
+ i++;
+ }
+ else if (an_arg == "-et") // alternate entropy threshold arg
+ {
+ *ent_thres = atof(* ++argv);
+ i++;
+ }
+ else
+ {
+ if (else_i == 0)
+ {
+ *a_file_path = an_arg;
+ run_mode = 'f';
+ else_i++;
+ }
+ else
+ {
+ //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
+ cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;
+ run_mode == 'e';
+ }
+ }
+ }
+ }
+
+ return run_mode;
+}
+
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// ----------------------------------------
-// ---------- mussa_class.cc -----------
-// ----------------------------------------
-
-#include "mussa_class.hh"
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-
-Mussa::Mussa()
-{
-}
-
-// set all parameters to null state
-void
-Mussa::clear()
-{
- ana_name = "";
- seq_num = 0;
- window = 0;
- threshold = 0;
- soft_thres = 0;
- win_append = false;
- thres_append = false;
- seq_files.clear();
- fasta_indices.clear();
- annot_files.clear();
- sub_seq_starts.clear();
- sub_seq_ends.clear();
-}
-
-// these 5 simple methods manually set the parameters for doing an analysis
-// used so that the gui can take input from user and setup the analysis
-// note - still need a set_append(bool, bool) method...
-void
-Mussa::set_name(string a_name)
-{
- ana_name = a_name;
-}
-
-void
-Mussa::set_seq_num(int a_num)
-{
- seq_num = a_num;
-}
-
-void
-Mussa::set_window(int a_window)
-{
- window = a_window;
-}
-
-void
-Mussa::set_threshold(int a_threshold)
-{
- threshold = a_threshold;
- //soft_thres = a_threshold;
-}
-
-void
-Mussa::set_soft_thres(int sft_thres)
-{
- soft_thres = sft_thres;
-}
-
-void
-Mussa::set_ana_mode(char new_ana_mode)
-{
- ana_mode = new_ana_mode;
-}
-
-// takes a string and sets it as the next seq - no AGCTN checking atm
-void
-Mussa::add_a_seq(string a_seq)
-{
- Sequence aSeq;
-
- aSeq.set_seq(a_seq);
- the_Seqs.push_back(aSeq);
-}
-
-
-// sets info for just 1 seq at a time
-void
-Mussa::set_seq_info(string seq_file, string annot_file, int fa_i, int a_start, int the_end)
-{
- seq_files.push_back(seq_file);
- fasta_indices.push_back(fa_i);
- annot_files.push_back(annot_file);
- sub_seq_starts.push_back(a_start);
- sub_seq_ends.push_back(the_end);
-}
-
-string
-Mussa::load_mupa_file(string para_file_path)
-{
- ifstream para_file;
- string file_data_line;
- string param, value, annot_file;
- int split_index, fasta_index;
- int sub_seq_start, sub_seq_end;
- bool seq_params, did_seq;
- string err_msg;
- int bogo;
- bool parsing_path;
- int new_index, dir_index;
-
-
- // initialize values
- clear();
-
- para_file.open(para_file_path.c_str(), ios::in);
-
- // if file was opened, read the parameter values
- if (para_file)
- {
- // need to find the path to the .mupa file
- parsing_path = true;
- dir_index = 0;
- while (parsing_path)
- {
- new_index = (para_file_path.substr(dir_index)).find("/");
- //cout << "mu class: "<< new_index << endl;
- if (new_index > 0)
- dir_index += new_index + 1;
- else
- parsing_path = false;
- }
-
- file_path_base = para_file_path.substr(0,dir_index);
- cout << "mu class: mupa base path = " << file_path_base << endl;
-
- // setup loop by getting file's first line
- getline(para_file,file_data_line);
- split_index = file_data_line.find(" ");
- param = file_data_line.substr(0,split_index);
- value = file_data_line.substr(split_index+1);
-
- while (!para_file.eof())
- {
- did_seq = false;
- if (param == "ANA_NAME")
- ana_name = value;
- else if (param == "APPEND_WIN")
- win_append = true;
- else if (param == "APPEND_THRES")
- thres_append = true;
- else if (param == "SEQUENCE_NUM")
- seq_num = atoi(value.c_str());
- else if (param == "WINDOW")
- window = atoi(value.c_str());
- else if (param == "THRESHOLD")
- threshold = atoi(value.c_str());
- else if (param == "SEQUENCE")
- {
- seq_files.push_back(file_path_base + value);
- fasta_index = 1;
- annot_file = "";
- sub_seq_start = 0;
- sub_seq_end = 0;
- seq_params = true;
-
- while ((!para_file.eof()) && seq_params)
- {
- getline(para_file,file_data_line);
- split_index = file_data_line.find(" ");
- param = file_data_line.substr(0,split_index);
- value = file_data_line.substr(split_index+1);
-
- if (param == "FASTA_INDEX")
- fasta_index = atoi(value.c_str());
- else if (param == "ANNOTATION")
- annot_file = file_path_base + value;
- else if (param == "SEQ_START")
- sub_seq_start = atoi(value.c_str());
- else if (param == "SEQ_END")
- {
- cout << "hey! " << atoi(value.c_str()) << endl;
- sub_seq_end = atoi(value.c_str());
- }
- //ignore empty lines or that start with '#'
- else if ((param == "") || (param == "#")) {}
- else seq_params = false;
- }
-
- fasta_indices.push_back(fasta_index);
- annot_files.push_back(annot_file);
- sub_seq_starts.push_back(sub_seq_start);
- sub_seq_ends.push_back(sub_seq_end);
- did_seq = true;
- }
- //ignore empty lines or that start with '#'
- else if ((param == "") || (param == "#")) {}
- else
- {
- cout << "Illegal/misplaced mussa parameter in file\n";
- cout << param << "\n";
- }
-
- if (!did_seq)
- {
- getline(para_file,file_data_line);
- split_index = file_data_line.find(" ");
- param = file_data_line.substr(0,split_index);
- value = file_data_line.substr(split_index+1);
- did_seq = false;
- }
- }
-
- para_file.close();
-
- soft_thres = threshold;
- cout << "nway mupa: ana_name = " << ana_name << " seq_num = " << seq_num;
- cout << " window = " << window << " threshold = " << threshold << endl;
-
- return "";
- }
-
- // no file was loaded, signal error
- else
- {
- err_msg = "Config File: " + para_file_path + " not found";
- return err_msg;
- }
-}
-
-// if (!((param == "") || (param == "#")))
-// cout << value << " = " << param << endl;
-
-
-string
-Mussa::analyze(int w, int t, char the_ana_mode, double new_ent_thres)
-{
- string err_msg;
- time_t t1, t2, begin, end;
- double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
-
-
- cout << "nway ana: seq_num = " << seq_num << endl;
-
- begin = time(NULL);
-
- // now loading parameters from file must be done separately
- //t1 = time(NULL);
- //err_msg = load_mupa_file(para_file_path);
- //t2 = time(NULL);
- //setuptime = difftime(t2, t1);
-
- ana_mode = the_ana_mode;
- ent_thres = new_ent_thres;
- if (w > 0)
- window = w;
- if (t > 0)
- {
- threshold = t;
- soft_thres = t;
- }
-
- //if (err_msg == "")
- //{
- cout << "fee\n";
- t1 = time(NULL);
- err_msg = get_Seqs();
- t2 = time(NULL);
- seqloadtime = difftime(t2, t1);
-
-
- if (err_msg == "")
- {
- cout << "fie\n";
- t1 = time(NULL);
- seqcomp();
- t2 = time(NULL);
- seqcomptime = difftime(t2, t1);
-
-
- cout << "foe\n";
- t1 = time(NULL);
- cout << "nway ana: seq_num = " << seq_num << endl;
- the_paths.setup(seq_num, window, threshold);
- nway();
- t2 = time(NULL);
- nwaytime = difftime(t2, t1);
-
-
- cout << "fum\n";
- t1 = time(NULL);
- save();
- t2 = time(NULL);
- savetime = difftime(t2, t1);
-
- end = time(NULL);
- totaltime = difftime(end, begin);
-
-
- cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
- //setup\t
- //cout << setuptime << "\t";
- cout << seqloadtime << "\t";
- cout << seqcomptime << "\t";
- cout << nwaytime << "\t";
- cout << savetime << "\t";
- cout << totaltime << "\n";
- }
- else
- return err_msg;
- //}
- //else
- //return err_msg;
-}
-
-
-string
-Mussa::get_Seqs()
-{
- list<string>::iterator seq_files_i, annot_files_i;
- list<int>::iterator fasta_indices_i, seq_starts_i, seq_ends_i;
- Sequence aSeq;
- string err_msg;
-
-
- seq_files_i = seq_files.begin();
- fasta_indices_i = fasta_indices.begin();
- annot_files_i = annot_files.begin();
- seq_starts_i = sub_seq_starts.begin();
- seq_ends_i = sub_seq_ends.begin();
-
- err_msg = "";
-
- while ( (seq_files_i != seq_files.end()) && (err_msg == "") )
- /* it should be guarenteed that each of the following exist
- should I bother checking, and how to deal with if not true...
- &&
- (fasta_indices_i != fasta_indices.end()) &&
- (annot_files_i != annot_files.end()) &&
- (seq_starts_i != sub_seq_starts.end()) &&
- (seq_ends_i != sub_seq_ends.end()) )
- */
- {
- err_msg = aSeq.load_fasta(*seq_files_i, *fasta_indices_i,*seq_starts_i,
- *seq_ends_i);
- if (err_msg == "")
- {
- if (*annot_files_i != "")
- err_msg = aSeq.load_annot(*annot_files_i, *seq_starts_i, *seq_ends_i);
-
- if (err_msg == "")
- {
- the_Seqs.push_back(aSeq);
- cout << aSeq.hdr() << endl;
- //cout << aSeq.seq() << endl;
- aSeq.clear();
- ++seq_files_i; // advance all the iterators
- ++fasta_indices_i;
- ++annot_files_i;
- ++seq_starts_i;
- ++seq_ends_i;
- }
- else
- break;
- }
- else
- break;
- }
-
- return err_msg;
-}
-
-
-void
-Mussa::seqcomp()
-{
- int i, i2; // loop vars over sequences to analyze
- vector<int> seq_lens;
- vector<FLPs> empty_FLP_vector;
- FLPs dummy_comp;
- string save_file_string;
-
- empty_FLP_vector.clear();
- for(i = 0; i < seq_num; i++)
- {
- all_comps.push_back(empty_FLP_vector);
- for(i2 = 0; i2 < seq_num; i2++)
- all_comps[i].push_back(dummy_comp);
- }
- for(i = 0; i < seq_num; i++)
- seq_lens.push_back(the_Seqs[i].len());
-
- for(i = 0; i < seq_num; i++)
- for(i2 = i+1; i2 < seq_num; i2++)
- {
- cout << "seqcomping: " << i << " v. " << i2 << endl;
- all_comps[i][i2].setup("m", window, threshold, seq_lens[i],seq_lens[i2]);
- all_comps[i][i2].seqcomp(the_Seqs[i].seq(), the_Seqs[i2].seq(), false);
- all_comps[i][i2].seqcomp(the_Seqs[i].seq(),the_Seqs[i2].rev_comp(),true);
- }
-}
-
-
-
-void
-Mussa::nway()
-{
- vector<string> some_Seqs;
- int i;
-
-
- cout << "nway: ana mode = " << ana_mode << endl;
- cout << "nway: seq_num = " << seq_num << endl;
-
- the_paths.set_soft_thres(soft_thres);
-
- if (ana_mode == 't')
- the_paths.trans_path_search(all_comps);
-
- else if (ana_mode == 'r')
- the_paths.radiate_path_search(all_comps);
-
- else if (ana_mode == 'e')
- {
- //unlike other methods, entropy needs to look at the sequence at this stage
- some_Seqs.clear();
- for(i = 0; i < seq_num; i++)
- some_Seqs.push_back(the_Seqs[i].seq());
-
- the_paths.setup_ent(ent_thres, some_Seqs); // ent analysis extra setup
- the_paths.entropy_path_search(all_comps);
- }
-
- // old recursive transitive analysis function
- else if (ana_mode == 'o')
- the_paths.find_paths_r(all_comps);
-
- the_paths.simple_refine();
-}
-
-void
-Mussa::save()
-{
- string save_name, save_path, create_dir_cmd, flp_filepath;
- fstream save_file;
- ostringstream append_info;
- int i, i2, dir_create_status;
-
-
- // not sure why, but gotta close file each time since can't pass file streams
-
- save_name = ana_name;
-
- // gotta do bit with adding win & thres if to be appended
- if (win_append)
- {
- append_info.str("");
- append_info << "_w" << window;
- save_name += append_info.str();
- }
-
- if (thres_append)
- {
- append_info.str("");
- append_info << "_t" << threshold;
- save_name += append_info.str();
- }
-
-//#include <stdlib.h>
- // ******* use appropriate for os ------- 1 of 4
- // the additions for osX make it more sane where it saves the analysis
- // will come up with a cleaner sol'n later...
- create_dir_cmd = "mkdir " + save_name; //linux
- //create_dir_cmd = "mkdir " + file_path_base + save_name; //osX
-
- dir_create_status = system( (const char*) create_dir_cmd.c_str());
- cout << "action: " << dir_create_status << endl;
-
- // save sequence and annots to a special mussa file
-
- // ******** use appropriate for OS ---------- 2 of 4
- save_path = save_name + "/" + save_name + ".museq"; //linux
- //save_path = file_path_base + save_name + "/" + save_name + ".museq"; //osX
-
- save_file.open(save_path.c_str(), ios::out);
- save_file << "<Mussa_Sequence>" << endl;
- //save_file.close();
-
- for(i = 0; i < seq_num; i++)
- the_Seqs[i].save(save_file);
-
- //save_file.open(save_path.c_str(), ios::app);
- save_file << "</Mussa_Sequence>" << endl;
- save_file.close();
-
- // save nway paths to its mussa save file
-
- // ******** use appropriate for OS -------- 3 of 4
- save_path = save_name + "/" + save_name + ".muway"; //linux
- //save_path = file_path_base + save_name + "/" + save_name + ".muway"; //os X
- the_paths.save(save_path);
-
- for(i = 0; i < seq_num; i++)
- for(i2 = i+1; i2 < seq_num; i2++)
- {
- append_info.str("");
- append_info << "_sp_" << i << "v" << i2;
- // ******** use appropriate for OS --------- 4 of 4
- //linux
- save_path = save_name + "/" + save_name + append_info.str() + ".flp";
- //osX
- //save_path = file_path_base + save_name + "/" + save_name + append_info.str() + ".flp";
- all_comps[i][i2].file_save(save_path);
- }
-}
-
-void
-Mussa::save_muway(string save_path)
-{
- the_paths.save(save_path);
-}
-
-string
-Mussa::load(string ana_file)
-{
- int i, i2, new_index, dir_index;
- string file_path_base, a_file_path, ana_path;
- bool parsing_path;
- Sequence tmp_seq;
- string err_msg;
- ostringstream append_info;
- vector<FLPs> empty_FLP_vector;
- FLPs dummy_comp;
-
-
- ana_path = ana_file;
- parsing_path = true;
- dir_index = 0;
- while (parsing_path)
- {
- new_index = (ana_path.substr(dir_index)).find("/");
- //cout << "mu class: "<< new_index << endl;
- if (new_index > 0)
- dir_index += new_index + 1;
- else
- parsing_path = false;
- }
-
- ana_name = ana_path.substr(dir_index);
- cout << "mu class: ana_name = " << ana_name << endl;
- file_path_base = ana_path + "/" + ana_path.substr(dir_index);
- a_file_path = file_path_base + ".muway";
- err_msg = the_paths.load(a_file_path);
- cout << "there is no safe distance\n";
-
- if (err_msg == "")
- {
- seq_num = the_paths.seq_num();
-
- cout << "No BAM\n";
-
- a_file_path = file_path_base + ".museq";
-
- // this is a bit of a hack due to C++ not acting like it should with files
- for (i = 1; i <= seq_num; i++)
- {
- tmp_seq.clear();
- cout << "mussa_class: loading the fucking museq frag...\n";
- tmp_seq.load_museq(a_file_path, i);
- the_Seqs.push_back(tmp_seq);
- }
-
- empty_FLP_vector.clear();
- for(i = 0; i < seq_num; i++)
- {
- all_comps.push_back(empty_FLP_vector);
- for(i2 = 0; i2 < seq_num; i2++)
- all_comps[i].push_back(dummy_comp);
- }
-
- for(i = 0; i < seq_num; i++)
- for(i2 = i+1; i2 < seq_num; i2++)
- {
- append_info.str("");
- append_info << "_sp_" << i << "v" << i2;
- cout << append_info.str() << endl;
- a_file_path = file_path_base + append_info.str() + ".flp";
- all_comps[i][i2].file_load(a_file_path);
- cout << "real size = " << all_comps[i][i2].all_matches.size() << endl;
- }
-
-
- return "";
- }
- else
- return err_msg;
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
-
-
-
-void
-Mussa::save_old()
-{
- fstream save_file;
- int i;
-
- save_file.open(ana_name.c_str(), ios::out);
-
- for(i = 0; i < seq_num; i++)
- save_file << the_Seqs[i].seq() << endl;
-
- save_file << window << endl;
- save_file.close();
- //note more complex eventually since ana_name may need to have
- //window size, threshold and other stuff to modify it...
- the_paths.save_old(ana_name);
-}
-
-
-void
-Mussa::load_old(char * load_file_path, int s_num)
-{
- fstream save_file;
- string file_data_line;
- int i, space_split_i, comma_split_i;
- vector<int> loaded_path;
- string node_pair, node;
- Sequence a_seq;
-
- seq_num = s_num;
- the_paths.setup(seq_num, 0, 0);
- save_file.open(load_file_path, ios::in);
-
- // currently loads old mussa format
-
- // get sequences
- for(i = 0; i < seq_num; i++)
- {
- getline(save_file, file_data_line);
- a_seq.set_seq(file_data_line);
- the_Seqs.push_back(a_seq);
- }
-
- // get window size
- getline(save_file, file_data_line);
- window = atoi(file_data_line.c_str());
- // get paths
-
- while (!save_file.eof())
- {
- loaded_path.clear();
- getline(save_file, file_data_line);
- if (file_data_line != "")
- for(i = 0; i < seq_num; i++)
- {
- space_split_i = file_data_line.find(" ");
- node_pair = file_data_line.substr(0,space_split_i);
- //cout << "np= " << node_pair;
- comma_split_i = node_pair.find(",");
- node = node_pair.substr(comma_split_i+1);
- //cout << "n= " << node << " ";
- loaded_path.push_back(atoi (node.c_str()));
- file_data_line = file_data_line.substr(space_split_i+1);
- }
- //cout << endl;
- the_paths.add_path(loaded_path);
- }
- save_file.close();
-
- //the_paths.save("tmp.save");
-}
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// ----------------------------------------
+// ---------- mussa_class.cc -----------
+// ----------------------------------------
+
+#include "mussa_class.hh"
+#include "flp.hh"
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+Mussa::Mussa()
+{
+}
+
+// set all parameters to null state
+void
+Mussa::clear()
+{
+ ana_name = "";
+ seq_num = 0;
+ window = 0;
+ threshold = 0;
+ soft_thres = 0;
+ win_append = false;
+ thres_append = false;
+ seq_files.clear();
+ fasta_indices.clear();
+ annot_files.clear();
+ sub_seq_starts.clear();
+ sub_seq_ends.clear();
+}
+
+// these 5 simple methods manually set the parameters for doing an analysis
+// used so that the gui can take input from user and setup the analysis
+// note - still need a set_append(bool, bool) method...
+void
+Mussa::set_name(string a_name)
+{
+ ana_name = a_name;
+}
+
+void
+Mussa::set_seq_num(int a_num)
+{
+ seq_num = a_num;
+}
+
+void
+Mussa::set_window(int a_window)
+{
+ window = a_window;
+}
+
+void
+Mussa::set_threshold(int a_threshold)
+{
+ threshold = a_threshold;
+ //soft_thres = a_threshold;
+}
+
+void
+Mussa::set_soft_thres(int sft_thres)
+{
+ soft_thres = sft_thres;
+}
+
+void
+Mussa::set_ana_mode(char new_ana_mode)
+{
+ ana_mode = new_ana_mode;
+}
+
+// takes a string and sets it as the next seq - no AGCTN checking atm
+void
+Mussa::add_a_seq(string a_seq)
+{
+ Sequence aSeq;
+
+ aSeq.set_seq(a_seq);
+ the_Seqs.push_back(aSeq);
+}
+
+
+// sets info for just 1 seq at a time
+void
+Mussa::set_seq_info(string seq_file, string annot_file, int fa_i, int a_start, int the_end)
+{
+ seq_files.push_back(seq_file);
+ fasta_indices.push_back(fa_i);
+ annot_files.push_back(annot_file);
+ sub_seq_starts.push_back(a_start);
+ sub_seq_ends.push_back(the_end);
+}
+
+string
+Mussa::load_mupa_file(string para_file_path)
+{
+ ifstream para_file;
+ string file_data_line;
+ string param, value, annot_file;
+ int split_index, fasta_index;
+ int sub_seq_start, sub_seq_end;
+ bool seq_params, did_seq;
+ string err_msg;
+ int bogo;
+ bool parsing_path;
+ int new_index, dir_index;
+
+
+ // initialize values
+ clear();
+
+ para_file.open(para_file_path.c_str(), ios::in);
+
+ // if file was opened, read the parameter values
+ if (para_file)
+ {
+ // need to find the path to the .mupa file
+ parsing_path = true;
+ dir_index = 0;
+ while (parsing_path)
+ {
+ new_index = (para_file_path.substr(dir_index)).find("/");
+ //cout << "mu class: "<< new_index << endl;
+ if (new_index > 0)
+ dir_index += new_index + 1;
+ else
+ parsing_path = false;
+ }
+
+ file_path_base = para_file_path.substr(0,dir_index);
+ cout << "mu class: mupa base path = " << file_path_base << endl;
+
+ // setup loop by getting file's first line
+ getline(para_file,file_data_line);
+ split_index = file_data_line.find(" ");
+ param = file_data_line.substr(0,split_index);
+ value = file_data_line.substr(split_index+1);
+
+ while (!para_file.eof())
+ {
+ did_seq = false;
+ if (param == "ANA_NAME")
+ ana_name = value;
+ else if (param == "APPEND_WIN")
+ win_append = true;
+ else if (param == "APPEND_THRES")
+ thres_append = true;
+ else if (param == "SEQUENCE_NUM")
+ seq_num = atoi(value.c_str());
+ else if (param == "WINDOW")
+ window = atoi(value.c_str());
+ else if (param == "THRESHOLD")
+ threshold = atoi(value.c_str());
+ else if (param == "SEQUENCE")
+ {
+ seq_files.push_back(file_path_base + value);
+ fasta_index = 1;
+ annot_file = "";
+ sub_seq_start = 0;
+ sub_seq_end = 0;
+ seq_params = true;
+
+ while ((!para_file.eof()) && seq_params)
+ {
+ getline(para_file,file_data_line);
+ split_index = file_data_line.find(" ");
+ param = file_data_line.substr(0,split_index);
+ value = file_data_line.substr(split_index+1);
+
+ if (param == "FASTA_INDEX")
+ fasta_index = atoi(value.c_str());
+ else if (param == "ANNOTATION")
+ annot_file = file_path_base + value;
+ else if (param == "SEQ_START")
+ sub_seq_start = atoi(value.c_str());
+ else if (param == "SEQ_END")
+ {
+ cout << "hey! " << atoi(value.c_str()) << endl;
+ sub_seq_end = atoi(value.c_str());
+ }
+ //ignore empty lines or that start with '#'
+ else if ((param == "") || (param == "#")) {}
+ else seq_params = false;
+ }
+
+ fasta_indices.push_back(fasta_index);
+ annot_files.push_back(annot_file);
+ sub_seq_starts.push_back(sub_seq_start);
+ sub_seq_ends.push_back(sub_seq_end);
+ did_seq = true;
+ }
+ //ignore empty lines or that start with '#'
+ else if ((param == "") || (param == "#")) {}
+ else
+ {
+ cout << "Illegal/misplaced mussa parameter in file\n";
+ cout << param << "\n";
+ }
+
+ if (!did_seq)
+ {
+ getline(para_file,file_data_line);
+ split_index = file_data_line.find(" ");
+ param = file_data_line.substr(0,split_index);
+ value = file_data_line.substr(split_index+1);
+ did_seq = false;
+ }
+ }
+
+ para_file.close();
+
+ soft_thres = threshold;
+ cout << "nway mupa: ana_name = " << ana_name << " seq_num = " << seq_num;
+ cout << " window = " << window << " threshold = " << threshold << endl;
+
+ return "";
+ }
+
+ // no file was loaded, signal error
+ else
+ {
+ err_msg = "Config File: " + para_file_path + " not found";
+ return err_msg;
+ }
+}
+
+// if (!((param == "") || (param == "#")))
+// cout << value << " = " << param << endl;
+
+
+string
+Mussa::analyze(int w, int t, char the_ana_mode, double new_ent_thres)
+{
+ string err_msg;
+ time_t t1, t2, begin, end;
+ double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
+
+
+ cout << "nway ana: seq_num = " << seq_num << endl;
+
+ begin = time(NULL);
+
+ // now loading parameters from file must be done separately
+ //t1 = time(NULL);
+ //err_msg = load_mupa_file(para_file_path);
+ //t2 = time(NULL);
+ //setuptime = difftime(t2, t1);
+
+ ana_mode = the_ana_mode;
+ ent_thres = new_ent_thres;
+ if (w > 0)
+ window = w;
+ if (t > 0)
+ {
+ threshold = t;
+ soft_thres = t;
+ }
+
+ //if (err_msg == "")
+ //{
+ cout << "fee\n";
+ t1 = time(NULL);
+ err_msg = get_Seqs();
+ t2 = time(NULL);
+ seqloadtime = difftime(t2, t1);
+
+
+ if (err_msg == "")
+ {
+ cout << "fie\n";
+ t1 = time(NULL);
+ seqcomp();
+ t2 = time(NULL);
+ seqcomptime = difftime(t2, t1);
+
+
+ cout << "foe\n";
+ t1 = time(NULL);
+ cout << "nway ana: seq_num = " << seq_num << endl;
+ the_paths.setup(seq_num, window, threshold);
+ nway();
+ t2 = time(NULL);
+ nwaytime = difftime(t2, t1);
+
+
+ cout << "fum\n";
+ t1 = time(NULL);
+ save();
+ t2 = time(NULL);
+ savetime = difftime(t2, t1);
+
+ end = time(NULL);
+ totaltime = difftime(end, begin);
+
+
+ cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
+ //setup\t
+ //cout << setuptime << "\t";
+ cout << seqloadtime << "\t";
+ cout << seqcomptime << "\t";
+ cout << nwaytime << "\t";
+ cout << savetime << "\t";
+ cout << totaltime << "\n";
+ }
+ else
+ return err_msg;
+ //}
+ //else
+ //return err_msg;
+}
+
+
+string
+Mussa::get_Seqs()
+{
+ list<string>::iterator seq_files_i, annot_files_i;
+ list<int>::iterator fasta_indices_i, seq_starts_i, seq_ends_i;
+ Sequence aSeq;
+ string err_msg;
+
+
+ seq_files_i = seq_files.begin();
+ fasta_indices_i = fasta_indices.begin();
+ annot_files_i = annot_files.begin();
+ seq_starts_i = sub_seq_starts.begin();
+ seq_ends_i = sub_seq_ends.begin();
+
+ err_msg = "";
+
+ while ( (seq_files_i != seq_files.end()) && (err_msg == "") )
+ /* it should be guarenteed that each of the following exist
+ should I bother checking, and how to deal with if not true...
+ &&
+ (fasta_indices_i != fasta_indices.end()) &&
+ (annot_files_i != annot_files.end()) &&
+ (seq_starts_i != sub_seq_starts.end()) &&
+ (seq_ends_i != sub_seq_ends.end()) )
+ */
+ {
+ err_msg = aSeq.load_fasta(*seq_files_i, *fasta_indices_i,*seq_starts_i,
+ *seq_ends_i);
+ if (err_msg == "")
+ {
+ if (*annot_files_i != "")
+ err_msg = aSeq.load_annot(*annot_files_i, *seq_starts_i, *seq_ends_i);
+
+ if (err_msg == "")
+ {
+ the_Seqs.push_back(aSeq);
+ cout << aSeq.hdr() << endl;
+ //cout << aSeq.seq() << endl;
+ aSeq.clear();
+ ++seq_files_i; // advance all the iterators
+ ++fasta_indices_i;
+ ++annot_files_i;
+ ++seq_starts_i;
+ ++seq_ends_i;
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ return err_msg;
+}
+
+
+void
+Mussa::seqcomp()
+{
+ int i, i2; // loop vars over sequences to analyze
+ vector<int> seq_lens;
+ vector<FLPs> empty_FLP_vector;
+ FLPs dummy_comp;
+ string save_file_string;
+
+ empty_FLP_vector.clear();
+ for(i = 0; i < seq_num; i++)
+ {
+ all_comps.push_back(empty_FLP_vector);
+ for(i2 = 0; i2 < seq_num; i2++)
+ all_comps[i].push_back(dummy_comp);
+ }
+ for(i = 0; i < seq_num; i++)
+ seq_lens.push_back(the_Seqs[i].len());
+
+ for(i = 0; i < seq_num; i++)
+ for(i2 = i+1; i2 < seq_num; i2++)
+ {
+ cout << "seqcomping: " << i << " v. " << i2 << endl;
+ all_comps[i][i2].setup("m", window, threshold, seq_lens[i],seq_lens[i2]);
+ all_comps[i][i2].seqcomp(the_Seqs[i].seq(), the_Seqs[i2].seq(), false);
+ all_comps[i][i2].seqcomp(the_Seqs[i].seq(),the_Seqs[i2].rev_comp(),true);
+ }
+}
+
+
+
+void
+Mussa::nway()
+{
+ vector<string> some_Seqs;
+ int i;
+
+
+ cout << "nway: ana mode = " << ana_mode << endl;
+ cout << "nway: seq_num = " << seq_num << endl;
+
+ the_paths.set_soft_thres(soft_thres);
+
+ if (ana_mode == 't')
+ the_paths.trans_path_search(all_comps);
+
+ else if (ana_mode == 'r')
+ the_paths.radiate_path_search(all_comps);
+
+ else if (ana_mode == 'e')
+ {
+ //unlike other methods, entropy needs to look at the sequence at this stage
+ some_Seqs.clear();
+ for(i = 0; i < seq_num; i++)
+ some_Seqs.push_back(the_Seqs[i].seq());
+
+ the_paths.setup_ent(ent_thres, some_Seqs); // ent analysis extra setup
+ the_paths.entropy_path_search(all_comps);
+ }
+
+ // old recursive transitive analysis function
+ else if (ana_mode == 'o')
+ the_paths.find_paths_r(all_comps);
+
+ the_paths.simple_refine();
+}
+
+void
+Mussa::save()
+{
+ string save_name, save_path, create_dir_cmd, flp_filepath;
+ fstream save_file;
+ ostringstream append_info;
+ int i, i2, dir_create_status;
+
+
+ // not sure why, but gotta close file each time since can't pass file streams
+
+ save_name = ana_name;
+
+ // gotta do bit with adding win & thres if to be appended
+ if (win_append)
+ {
+ append_info.str("");
+ append_info << "_w" << window;
+ save_name += append_info.str();
+ }
+
+ if (thres_append)
+ {
+ append_info.str("");
+ append_info << "_t" << threshold;
+ save_name += append_info.str();
+ }
+
+//#include <stdlib.h>
+ // ******* use appropriate for os ------- 1 of 4
+ // the additions for osX make it more sane where it saves the analysis
+ // will come up with a cleaner sol'n later...
+ create_dir_cmd = "mkdir " + save_name; //linux
+ //create_dir_cmd = "mkdir " + file_path_base + save_name; //osX
+
+ dir_create_status = system( (const char*) create_dir_cmd.c_str());
+ cout << "action: " << dir_create_status << endl;
+
+ // save sequence and annots to a special mussa file
+
+ // ******** use appropriate for OS ---------- 2 of 4
+ save_path = save_name + "/" + save_name + ".museq"; //linux
+ //save_path = file_path_base + save_name + "/" + save_name + ".museq"; //osX
+
+ save_file.open(save_path.c_str(), ios::out);
+ save_file << "<Mussa_Sequence>" << endl;
+ //save_file.close();
+
+ for(i = 0; i < seq_num; i++)
+ the_Seqs[i].save(save_file);
+
+ //save_file.open(save_path.c_str(), ios::app);
+ save_file << "</Mussa_Sequence>" << endl;
+ save_file.close();
+
+ // save nway paths to its mussa save file
+
+ // ******** use appropriate for OS -------- 3 of 4
+ save_path = save_name + "/" + save_name + ".muway"; //linux
+ //save_path = file_path_base + save_name + "/" + save_name + ".muway"; //os X
+ the_paths.save(save_path);
+
+ for(i = 0; i < seq_num; i++)
+ for(i2 = i+1; i2 < seq_num; i2++)
+ {
+ append_info.str("");
+ append_info << "_sp_" << i << "v" << i2;
+ // ******** use appropriate for OS --------- 4 of 4
+ //linux
+ save_path = save_name + "/" + save_name + append_info.str() + ".flp";
+ //osX
+ //save_path = file_path_base + save_name + "/" + save_name + append_info.str() + ".flp";
+ all_comps[i][i2].file_save(save_path);
+ }
+}
+
+void
+Mussa::save_muway(string save_path)
+{
+ the_paths.save(save_path);
+}
+
+string
+Mussa::load(string ana_file)
+{
+ int i, i2, new_index, dir_index;
+ string file_path_base, a_file_path, ana_path;
+ bool parsing_path;
+ Sequence tmp_seq;
+ string err_msg;
+ ostringstream append_info;
+ vector<FLPs> empty_FLP_vector;
+ FLPs dummy_comp;
+
+
+ ana_path = ana_file;
+ parsing_path = true;
+ dir_index = 0;
+ while (parsing_path)
+ {
+ new_index = (ana_path.substr(dir_index)).find("/");
+ //cout << "mu class: "<< new_index << endl;
+ if (new_index > 0)
+ dir_index += new_index + 1;
+ else
+ parsing_path = false;
+ }
+
+ ana_name = ana_path.substr(dir_index);
+ cout << "mu class: ana_name = " << ana_name << endl;
+ file_path_base = ana_path + "/" + ana_path.substr(dir_index);
+ a_file_path = file_path_base + ".muway";
+ err_msg = the_paths.load(a_file_path);
+ cout << "there is no safe distance\n";
+
+ if (err_msg == "")
+ {
+ seq_num = the_paths.seq_num();
+
+ cout << "No BAM\n";
+
+ a_file_path = file_path_base + ".museq";
+
+ // this is a bit of a hack due to C++ not acting like it should with files
+ for (i = 1; i <= seq_num; i++)
+ {
+ tmp_seq.clear();
+ cout << "mussa_class: loading the fucking museq frag...\n";
+ tmp_seq.load_museq(a_file_path, i);
+ the_Seqs.push_back(tmp_seq);
+ }
+
+ empty_FLP_vector.clear();
+ for(i = 0; i < seq_num; i++)
+ {
+ all_comps.push_back(empty_FLP_vector);
+ for(i2 = 0; i2 < seq_num; i2++)
+ all_comps[i].push_back(dummy_comp);
+ }
+
+ for(i = 0; i < seq_num; i++)
+ for(i2 = i+1; i2 < seq_num; i2++)
+ {
+ append_info.str("");
+ append_info << "_sp_" << i << "v" << i2;
+ cout << append_info.str() << endl;
+ a_file_path = file_path_base + append_info.str() + ".flp";
+ all_comps[i][i2].file_load(a_file_path);
+ cout << "real size = " << all_comps[i][i2].all_matches.size() << endl;
+ }
+
+
+ return "";
+ }
+ else
+ return err_msg;
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+
+
+void
+Mussa::save_old()
+{
+ fstream save_file;
+ int i;
+
+ save_file.open(ana_name.c_str(), ios::out);
+
+ for(i = 0; i < seq_num; i++)
+ save_file << the_Seqs[i].seq() << endl;
+
+ save_file << window << endl;
+ save_file.close();
+ //note more complex eventually since ana_name may need to have
+ //window size, threshold and other stuff to modify it...
+ the_paths.save_old(ana_name);
+}
+
+
+void
+Mussa::load_old(char * load_file_path, int s_num)
+{
+ fstream save_file;
+ string file_data_line;
+ int i, space_split_i, comma_split_i;
+ vector<int> loaded_path;
+ string node_pair, node;
+ Sequence a_seq;
+
+ seq_num = s_num;
+ the_paths.setup(seq_num, 0, 0);
+ save_file.open(load_file_path, ios::in);
+
+ // currently loads old mussa format
+
+ // get sequences
+ for(i = 0; i < seq_num; i++)
+ {
+ getline(save_file, file_data_line);
+ a_seq.set_seq(file_data_line);
+ the_Seqs.push_back(a_seq);
+ }
+
+ // get window size
+ getline(save_file, file_data_line);
+ window = atoi(file_data_line.c_str());
+ // get paths
+
+ while (!save_file.eof())
+ {
+ loaded_path.clear();
+ getline(save_file, file_data_line);
+ if (file_data_line != "")
+ for(i = 0; i < seq_num; i++)
+ {
+ space_split_i = file_data_line.find(" ");
+ node_pair = file_data_line.substr(0,space_split_i);
+ //cout << "np= " << node_pair;
+ comma_split_i = node_pair.find(",");
+ node = node_pair.substr(comma_split_i+1);
+ //cout << "n= " << node << " ";
+ loaded_path.push_back(atoi (node.c_str()));
+ file_data_line = file_data_line.substr(space_split_i+1);
+ }
+ //cout << endl;
+ the_paths.add_path(loaded_path);
+ }
+ save_file.close();
+
+ //the_paths.save("tmp.save");
+}
std::string int_to_str(int an_int);
-
class Mussa
{
friend class MussaOverlord;
bool win_override, thres_override;
bool win_append, thres_append;
- // sequence data
+ //! sequence data
std::vector<Sequence> the_Seqs;
- // the seqcomp data
+ //! the seqcomp data
std::vector<std::vector<FLPs> > all_comps;
- // N-way data, ie the mussa results
+ //! N-way data, ie the mussa results
Nway_Paths the_paths;
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_annot_window.hh"
-#include <iostream>
-#include <FL/fl_show_colormap.H>
-
-using namespace std;
-
-annot_color
-new_blank_annot()
-{
- annot_color *a_annot;
-
- a_annot = new annot_color;
- a_annot->type = "";
- a_annot->color = (Fl_Color) 5;
- //cout << "type: " << a_annot->type << endl;
-
- return *a_annot;
-}
-
-
-void
-cb_annot_color(Fl_Button* o, void* v)
-{
- annot_instance * blah = (annot_instance *) v;
- AnnotWindow* T= blah->mw_ptr;
- T->cb_annot_color_i(o,blah->index);
-}
-
-AnnotWindow::AnnotWindow(int w, int h, const char* title,
- vector<annot_color> * some_annots):Fl_Window(w,h,title)
-{
- int i, annot_num;
-
- the_annots = some_annots;
- annot_count = 0;
-
- annot_color_buttons.clear();
-
- begin();
- annot_input_pack = new Fl_Pack(0, 0, w, h);
- annot_input_pack->spacing(4);
-
- // button to add new annot inputs
- add_annot = new Fl_Button(0,0,100,24,"Add Annot Slot");
- add_annot->callback((Fl_Callback*)add_annot_cb, this);
- annot_input_pack->add(add_annot);
- // test button to make sure annot data is being stored
- test = new Fl_Button(0,0,100,24,"show annots");
- test->callback((Fl_Callback*)print_cb, this);
- annot_input_pack->add(test);
-
- // creat an initial set of annot input widgets and attach to annot vector
- annot_num = some_annots->size();
- for (i = 0; i < annot_num; i++)
- {
- add_annot_input(i);
- annot_count++;
- }
-
- add(annot_input_pack);
-
- end();
- resizable(this);
- show();
-}
-
- //tmp_input->user_data((void*) i);
-
-AnnotWindow::~AnnotWindow(){}
-
-void
-AnnotWindow::add_annot_input(int index)
-{
- Fl_Output * new_input;
- Fl_Button *new_color_button;
- annot_instance * something;
- Fl_Pack * annot_hor_pack;
-
-
- something = new annot_instance;
- something->mw_ptr = this;
- something->index = index;
-
- annot_hor_pack = new Fl_Pack(0, 0, w(), 24);
- annot_hor_pack->type(Fl_Pack::HORIZONTAL);
- annot_hor_pack->spacing(4);
-
- // setup the color display/selection button
- new_color_button = new Fl_Button(0, 0, 24, 24, "");
- new_color_button->color((*the_annots)[index].color);
- new_color_button->box(FL_FLAT_BOX);
- new_color_button->callback((Fl_Callback*)cb_annot_color, (void*) something);
- annot_color_buttons.push_back(new_color_button);
- annot_hor_pack->add(new_color_button);
-
-
- // setup the annot inputs
- new_input = new Fl_Output(0, 0, 200, 24, "");
- new_input->value( ((*the_annots)[index].type).c_str() );
- //new_input->callback((Fl_Callback*)cb_annot_in, (void*) something);
- annot_ins.push_back(new_input);
- annot_hor_pack->add(new_input);
-
- annot_input_pack->add(annot_hor_pack);
-}
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
-
-void
-AnnotWindow::cb_annot_in_i(Fl_Input* o, int i)
-{
- (*the_annots)[i].type = o->value();
-}
-
-void
-AnnotWindow::cb_annot_color_i(Fl_Button* o, int i)
-{
- //Fl_Color new_color;
-
- (*the_annots)[i].color = fl_show_colormap((*the_annots)[i].color);
- //annot_color_buttons[i]->
- o->color((*the_annots)[i].color);
- redraw();
-}
-
-void AnnotWindow::add_annot_cb(Fl_Button* o, void* v)
-{
- AnnotWindow* T=(AnnotWindow*)v;
- T->add_annot_cb_real(o,v);
-}
-
-
-void AnnotWindow::add_annot_cb_real(Fl_Button* , void*)
-{
- annot_color blank_annot;
-
- //blank_annot.name = "";
- //blank_annot.seq = "";
- blank_annot = new_blank_annot();
- (*the_annots).push_back(blank_annot);
- add_annot_input(annot_count++);
- redraw();
-}
-
-
-void AnnotWindow::print_cb(Fl_Button* o, void* v)
-{
- AnnotWindow* T=(AnnotWindow*)v;
- T->print_cb_real(o,v);
-}
-
-
-void AnnotWindow::print_cb_real(Fl_Button* , void*)
-{
- int i;
-
- for (i = 0; i < annot_count; i++)
- cout << (*the_annots)[i].type << endl;
-}
-
-/*
-void
-cb_annot_in(Fl_Input* o, void* v)
-{
- annot_instance * blah = (annot_instance *) v;
- AnnotWindow* T= blah->mw_ptr;
- T->cb_annot_in_i(o,blah->index);
-}
-
-
-*/
+++ /dev/null
-#ifndef _MUSSA_GUI_ANNOT_WINDOW_H_
-#define _MUSSA_GUI_ANNOT_WINDOW_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <list>
-#include <string>
-#include <vector>
-
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Button.H>
-
-#include <FL/Fl_Input.H>
-#include <FL/Fl_Output.H>
-#include <FL/Fl_Pack.H>
-
-#include "mussa_gui_motif_window.hh"
-
-struct annot_color
-{
- std::string type;
- Fl_Color color;
-};
-
-//typedef annot_ptr *annot;
-
-
-class AnnotWindow : public Fl_Window
-{
- public:
- AnnotWindow(int w, int h, const char* title,
- std::vector<annot_color> * some_annots);
- ~AnnotWindow();
- Fl_Pack * annot_input_pack;
- std::list<Fl_Output*> annot_ins;
- std::vector<Fl_Button*> annot_color_buttons;
- std::list<Fl_Input*> name_ins;
- Fl_Button* test;
- Fl_Button* add_annot;
-
- void cb_annot_in_i(Fl_Input*, int i);
- void cb_annot_color_i(Fl_Button* o, int i);
-
- private:
- std::vector<annot_color> * the_annots;
- int annot_count;
-
- void add_annot_input(int index);
-
- static void add_annot_cb(Fl_Button*, void*);
- inline void add_annot_cb_real(Fl_Button*, void*);
-
- static void print_cb(Fl_Button*, void*);
- inline void print_cb_real(Fl_Button*, void*);
-};
-
-// crazy whacked shite Titus taught me to do to get an index value associated
-// with each instance of an input associated with the callback...
-struct annot_instance
-{
- AnnotWindow * mw_ptr;
- int index;
-};
-
-annot_color new_blank_annot();
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_conn_view.hh"
-
-#include <iomanip>
-#include <math.h>
-using namespace std;
-
-void
-ConnView::setup(string name, int sq_num, int win_len,
- vector<Sequence> *some_seqs,
- Nway_Paths *some_paths)
-{
- int i, i2, seq_length;
- Sequence a_seq;
- motif blank_motif;
- annot_color new_annot;
-
-
- ana_name = name;
- seq_num = sq_num;
- window = win_len;
- S = some_seqs;
- P = some_paths;
-
- cout << "num of paths = " << some_paths->refined_pathz.size() << endl;
-
- cout << "x()=" << x() << " y()=" << y() << " w()=" << w() << " h()=" << h();
- cout << endl;
-
- max_seq_len = 0;
- for(i = 0; i < seq_num; ++i)
- {
- a_seq = (*S)[i];
- cout << a_seq.len() << endl;
- seq_length = a_seq.len();
- seq_lens.push_back(seq_length);
- if (seq_length > max_seq_len)
- max_seq_len = seq_length;
- if (seq_length < 1000)
- seq_scales.push_back(1);
- else if (seq_length < 1000000)
- seq_scales.push_back(2);
- else
- seq_scales.push_back(3);
- }
-
- name_pad = 80;
- y_pad = 20;
-
- x_scale_factor = (float) max_seq_len / (w() - name_pad);
- cout << "scale factor is " << x_scale_factor << endl;
- y_seq_incre = (h()-(y_pad*2)) / (seq_num - 1);
-
-
- drag_start = -1000;
- drag_end = -1000;
- ref_seq_num = 0;
-
- dragging = false;
- selected = false;
-
- highlight.clear();
- show_bars = false;
- show_lines = false;
- bar_interval = max_seq_len / 20;
- line_interval = max_seq_len / 20;
- ref_seq_num = 0;
-
-
- some_motifs.clear();
- for(i = 0; i < 5; ++i)
- {
- blank_motif = new_blank_motif();
- some_motifs.push_back(blank_motif);
- }
-
- // find all unique annotation type ids
- some_annots.clear();
- vector<annot_color>::iterator annot_type_i;
- list<annot>::iterator annot_i;
-
- // loop thru all sequences
- for(i2 = 0; i2 < seq_num; i2++)
- {
- cout << "ConnView: annotation loop\n";
- // loop thru all annotation entries in this sequence
- for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
- {
- cout << annot_i->start << ", " << annot_i->end << " : ";
- cout << annot_i->name << " " << annot_i->type << endl;
- // loop thru annotation types
- annot_type_i = some_annots.begin();
- bool type_unfound = true;
- while ((annot_type_i != some_annots.end()) && type_unfound)
- {
- if (annot_i->type == annot_type_i->type)
- type_unfound = false; // stop search if found
- ++annot_type_i;
- }
- //if unfound, then add to list
- if (type_unfound)
- {
- new_annot = new_blank_annot();
- new_annot.type = annot_i->type;
- some_annots.push_back(new_annot);
- }
- }
- }
-}
-
-
-void
-ConnView::scale_paths()
-{
- vector<int> a_path;
- list<vector<int> >::iterator pathz_i;
- int i2;
-
-
- scaled_pathz.clear();
-
- for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
- {
- a_path = *pathz_i;
- for(i2 = 0; i2 <= seq_num; i2++)
- a_path[i2] = (int) (a_path[i2] / x_scale_factor);
- scaled_pathz.push_back(a_path);
- }
-}
-
-void
-ConnView::toggle_bars()
-{
- show_bars = !show_bars;
- redraw();
-}
-
-void
-ConnView::set_bar_interval(int new_bar_len)
-{
- bar_interval = new_bar_len;
- cout << "bar interval = " << bar_interval << endl;
- redraw();
-}
-
-void
-ConnView::toggle_lines()
-{
- show_lines = !show_lines;
- redraw();
-}
-
-void
-ConnView::set_line_interval(int new_line_len)
-{
- line_interval = new_line_len;
- cout << "line interval = " << line_interval << endl;
- redraw();
-}
-
-
-void
-ConnView::draw()
-{
- // this is temporary - check if new motifs have been added
- check_new_motifs();
-
- // clear drawing area and set background to white
- fl_color(FL_WHITE);
- fl_rectf(x(), y(), w(), h());
-
-
- // draw the scale indicators if they are on
- // put into own method soon...
- int i, div_num, x_loc;
- float div_len_scaled;
-
- if (show_bars)
- {
- div_num = max_seq_len / bar_interval;
- div_len_scaled = ((float) bar_interval) / x_scale_factor;
- fl_color(230,230,230);
- for(i = 0; i <= div_num; i+=2)
- {
- x_loc = (int)(i * div_len_scaled+x());
- fl_rectf(x_loc, y(), (int) div_len_scaled, h());
- }
- }
-
- if (show_lines)
- {
- div_num = max_seq_len / line_interval;
- div_len_scaled = ((float) line_interval) / x_scale_factor;
- fl_color(0,0,0);
- fl_line_style(FL_SOLID, 1, NULL);
- for(i = 0; i <= div_num; i++)
- {
- x_loc = (int)(i * div_len_scaled+x());
- fl_line(x_loc, y(), x_loc, h()+y());
- }
- }
-
-
- // divide up the space with some light blue lines
- fl_color(150,200,255);
- fl_line_style(FL_SOLID, 2, NULL);
- fl_rect(x(), y(), w(), h());
- fl_line(w()+x()-name_pad, y(), w()+x()-name_pad, h()+y());
-
- draw_paths();
-
- // white out any overdraw from path area into name/info area
- fl_color(FL_WHITE);
- fl_rectf(w()+x()-name_pad, y(), w()+x(), h());
-
- draw_sequence_stuff();
-
- // draw selection box
- /*
- if (selected)
- {
- fl_color(FL_BLACK);
- fl_line_style(FL_SOLID, 1, NULL);
- fl_rect(drag_start,(ref_seq_num*y_seq_incre)+y(),drag_end-drag_start,
- 16);
- }
- */
-}
-
-
-void
-ConnView::draw_paths()
-{
- list<vector<int> >::iterator i;
- int i2, i3, y_loc, x_loc, x_start, x_end;
- vector<int> a_path;
- list<bool>::iterator highlight_i;
- int window_size;
- bool rc_color;
- int path_start, path_end;
- //Sequence a_seq;
-
-
- // determine which paths to highlight
- highlight.clear();
- for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
- {
- a_path = *i;
- // determine if path falls within the selected region and mark it for
- // highlighted color
- path_start = abs(a_path[ref_seq_num+1]);
- path_end = path_start + a_path[0];
- if ( ( (path_start >= drag_start-x()) && (path_end <= drag_end-x()) ) ||
- ( (path_start < drag_start-x()) && (path_end > drag_end-x()) ) ||
- ( (path_start < drag_start-x()) && (path_end > drag_start-x()) ) ||
- ( (path_start < drag_end-x()) && (path_end > drag_end-x()) ) )
- highlight.push_back(true);
- else
- highlight.push_back(false);
- }
-
- fl_line_style(FL_SOLID, 1, NULL);
- // draw non-highlight paths (ie not in the selection box)
- highlight_i = highlight.begin();
- for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
- {
- a_path = *i;
- y_loc = y()+y_pad;
-
- // get window size to determine line width
- window_size = a_path[0];
- // make sure width is at least 1 - might be zero to my slack rounding
- if (window_size == 0)
- window_size = 1;
-
- if (!(*highlight_i))
- for(i2 = 1; i2 < seq_num; i2++)
- {
- // RC case handling
- // ugh, an xor...only want blue if one of the nodes is rc
- if ( ((a_path[i2] < 0) || (a_path[i2+1] < 0)) &&
- !((a_path[i2] < 0) && (a_path[i2+1] < 0)) )
- fl_color(200,200,255);
- else
- fl_color(255,200,200);
-
- fl_line_style(FL_SOLID, 1, NULL);
- fl_polygon((int)abs(a_path[i2])+x(), y_loc + 3,
- (int)abs(a_path[i2])+window_size+x(), y_loc + 3,
- (int)abs(a_path[i2+1])+window_size+x(), y_loc + y_seq_incre - 3,
- (int)abs(a_path[i2+1])+x(), y_loc + y_seq_incre - 3);
-
- y_loc += y_seq_incre;
- }
- ++highlight_i;
- }
-
- // draw highlighted paths (ie in or partially in selection)
- // drawing these separately and after other paths so they are on top
- highlight_i = highlight.begin();
- for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
- {
- a_path = *i;
- y_loc = y()+y_pad;
-
- // get window size to determine line width
- window_size = a_path[0];
- // make sure width is at least 1 - might be zero to my slack rounding
- if (window_size == 0)
- window_size = 1;
-
- if (*highlight_i)
- for(i2 = 1; i2 < seq_num; i2++)
- {
- // RC case handling
- // ugh, an xor...only want blue if one of the nodes is rc
- if ( ((a_path[i2] < 0) || (a_path[i2+1] < 0)) &&
- !((a_path[i2] < 0) && (a_path[i2+1] < 0)) )
- fl_color(FL_BLUE);
- else
- fl_color(FL_RED);
-
- fl_polygon((int)abs(a_path[i2])+x(), y_loc + 3,
- (int)abs(a_path[i2])+window_size+x(), y_loc + 3,
- (int)abs(a_path[i2+1])+window_size+x(), y_loc + y_seq_incre - 3,
- (int)abs(a_path[i2+1])+x(), y_loc + y_seq_incre - 3);
-
- y_loc += y_seq_incre;
- }
- ++highlight_i;
- }
-}
-
-/*
- list<vector<int> >::iterator i;
- int window_size;
- bool rc_color;
- int path_start, path_end;
- Sequence a_seq;
- vector<int> a_path;
-*/
-
-void
-ConnView::draw_sequence_stuff()
-{
- int i2, i3, y_loc, y_offset, x_loc, x_start, x_end, mv_offset;
- list<annot>::iterator annot_i;
- string species_name, seq_length;
- stringstream raw_length;
-
-
- // draw sequence representation lines
- fl_font(FL_COURIER, 14);
- //fl_color(FL_BLACK);
- fl_color(100,100,100);
- // normally size 7, adjust for various screenshotage
- fl_line_style(FL_SOLID, 11, NULL);
- y_loc = y()+y_pad;
- y_offset = 5;
- for(i2 = 0; i2 < seq_num; i2++)
- {
- if (i2 == seq_num - 1)
- y_offset = -10;
- x_loc = (int)(seq_lens[i2] / x_scale_factor) + x();
- //report_float("seq scaled len", x_loc);
- fl_line(x(),y_loc,x_loc,y_loc);
-
- species_name = (*S)[i2].species;
- fl_draw(species_name.c_str(), x()+w()-name_pad+5, y_loc+y_offset);
-
- // funkiness to figure out which genomic scale to report size in
- if (seq_scales[i2] == 1)
- raw_length << setprecision(3) << seq_lens[i2] << " bp";
- else if (seq_scales[i2] == 2)
- raw_length << setprecision(3) << seq_lens[i2] / 1000.0 << " Kb";
- else if (seq_scales[i2] == 3)
- raw_length << setprecision(3) << seq_lens[i2] /1000000.0<< " Mb";
- seq_length = raw_length.str();
- fl_draw(seq_length.c_str(), x()+w()-name_pad+5, y_loc+y_offset+15);
- raw_length.str("");
-
- y_loc += y_seq_incre;
- }
-
- //fl_line(x(),y()+y_pad/2,w()-name_pad,y()+y_pad/2);
- //fl_line(x(),y()+h()-y_pad/2,w()-name_pad,y()+h()-y_pad/2);
-
- // draw annotations
- vector<annot_color>::iterator annot_type_i;
-
- fl_color(FL_GREEN);
- fl_line_style(FL_SOLID, 3, NULL);
- y_loc = y()+y_pad;
- for(i2 = 0; i2 < seq_num; i2++)
- {
- // loop thru all annotation entries
- for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
- {
- fl_line_style(FL_SOLID, 7, NULL);
- mv_offset = 0;
-
- // loop thru annotation types to determine color
- annot_type_i = some_annots.begin();
- bool type_unfound = true;
- while ((annot_type_i != some_annots.end()) && type_unfound)
- {
- if (annot_i->type == annot_type_i->type)
- {
- fl_color(annot_type_i->color);
- type_unfound = false;
- }
- else
- fl_color(FL_GREEN);
- ++annot_type_i;
- }
-
- // calculate scaled start and end, and draw
- x_start = (int)(annot_i->start / x_scale_factor) + x();
- x_end = (int)(annot_i->end / x_scale_factor) + x();
- fl_line(x_start,y_loc+mv_offset,x_end,y_loc+mv_offset);
- }
- y_loc += y_seq_incre;
- }
-
-
- // draw motifs found
- vector<motif>::iterator motif_i;
- vector<int> some_motif_locs;
- vector<int>::iterator i_locs;
- int scale_len, motif_len;
-
- fl_color(255,0,255);
- fl_line_style(FL_SOLID, 9, NULL);
- motif_i = some_motifs.begin();
- while (motif_i != some_motifs.end())
- {
- fl_color(motif_i->color);
- motif_len = motif_i->seq.length();
- scale_len = (int) (motif_len / x_scale_factor);
- if (scale_len == 0)
- scale_len = 1;
- y_loc = y()+y_pad;
- if (!motif_i->locations.empty())
- for(i2 = 0; i2 < seq_num; i2++)
- {
- some_motif_locs = (*motif_i).locations[i2];
-
- i_locs = some_motif_locs.begin();
- while (i_locs != some_motif_locs.end())
- {
- x_start = (int)(*i_locs / x_scale_factor) + x();
- fl_line(x_start,y_loc,x_start+scale_len,y_loc);
- ++i_locs;
- }
- y_loc += y_seq_incre;
- }
- ++motif_i;
- }
-}
-
-
-void
-ConnView::resize(int new_x, int new_y, int new_w, int new_h)
-{
-
- x(new_x);
- y(new_y);
- w(new_w);
- h(new_h);
-
- x_scale_factor = (float) max_seq_len / (w() - name_pad);
- cout << "scale factor is " << x_scale_factor << endl;
- y_seq_incre = (h()-(2*y_pad)) / (seq_num - 1);
-
- scale_paths();
-}
-
-
-void
-ConnView::reporter(string var, int value)
-{
- cout << var << " : " << value << endl;
-}
-
-
-void
-ConnView::report_float(string var, float value)
-{
- cout << var << " : " << value << endl;
-}
-
-int
-ConnView::handle(int e)
-{
- int return_value;
- float y_calc_tmp;
-
- // this empty string needs to be put on cout, otherwise the -O optimize
- // compile option seems to throw this function away with the following:
- // gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
- cout << "";
-
- // why do I need a -O for this module? Well, originally I just used the
- // same compile flags for all modules. I changed that. However, on debian
- // systems I need the -O otherwise the behavior I observe on redhat machines
- // with above compiler happens if I don't have that empty cout. WTF
-
- switch(e)
- {
- case FL_PUSH:
- if (Fl::event_button3())
- {
- spawnSeq();
- return_value = 1;
- }
- else if (Fl::event_button2())
- {
- find_motifs();
- return_value = 1;
- }
- break;
- case FL_DRAG:
- if (!dragging)
- {
- drag_start = Fl::event_x();
- y_drag_start = (float) Fl::event_y();
- ref_seq_num = (int) (round ( (y_drag_start/y_seq_incre) ) );
- dragging = true;
- selected = false;
- return_value = 1;
- }
- fl_line_style(FL_SOLID, 1, NULL);
- fl_overlay_rect(drag_start, (ref_seq_num*y_seq_incre)+y(),
- Fl::event_x()-drag_start, 16);
-
- break;
- case FL_RELEASE:
- if (dragging)
- {
- drag_end = Fl::event_x();
- dragging = false;
- selected = true;
- redraw();
- return_value = 1;
- }
- break;
- default:
- return_value = Fl_Widget::handle(e);
- }
-
- return return_value;
-}
-
-
-
-void
-ConnView::check_new_motifs()
-{
- vector<motif>::iterator i;
- int i2;
- vector<int> some_motif_locs;
- vector<int>::iterator i_locs;
-
- i = some_motifs.begin();
- while (i != some_motifs.end())
- {
- if (i->dirty)
- {
- cout << i->seq << " is new\n";
- i->locations.clear();
- //i_locs = i->locations;
- for(i2 = 0; i2 < seq_num; i2++)
- {
- some_motif_locs = (*S)[i2].find_motif(i->seq);
- (*i).locations.push_back(some_motif_locs);
-
-
- i_locs = some_motif_locs.begin();
- while (i_locs != some_motif_locs.end())
- {
- cout << *i_locs << " ";
- ++i_locs;
- }
- cout << endl;
-
- }
-
- i->dirty = false;
- }
- ++i;
- }
-}
-
-
-void
-ConnView::spawnSeq()
-{
- list<vector<int> > selected_paths;
- list<vector<int> >::iterator pathz_i;
- int i2, i3, y_loc, x_loc, x_start, x_end;
- vector<int> a_path;
- list<bool>::iterator highlight_i;
- int y_max;
- string window_name;
-
-
- if (selected)
- {
- // make new list of connections that are highlighted
- selected_paths.clear();
- highlight_i = highlight.begin();
- for(pathz_i = P->refined_pathz.begin(); pathz_i != P->refined_pathz.end(); ++pathz_i)
- {
- if (*highlight_i)
- {
- a_path = *pathz_i;
- selected_paths.push_back(a_path);
- }
- ++highlight_i;
- }
-
- // give 50 pixels of height per sequence
- y_max = seq_num * 50;
- window_name = "Mussa Sequence: " + ana_name;
-
- a_seq_win = new SeqWindow(800, y_max, (const char*) window_name.c_str(),
- seq_num,
- S, selected_paths, seq_lens, &some_motifs);
- }
-}
-
-
-void
-ConnView::find_motifs()
-{
- motif_find_window = new MotifWindow(300, 300, "Motifs", &some_motifs);
-}
-
-void
-ConnView::annot_win()
-{
- annot_color_window = new AnnotWindow(300, 300, "Annotations", &some_annots);
-}
-
-// @!@! special hacked in color coding for the myf5/6 region annots
-
-/*
- if (annot_i->type == "mvista")
- {
- fl_color(255,230,0);
- fl_line_style(FL_SOLID, 8, NULL);
- mv_offset = -4;
- }
- else if (annot_i->type == "reg")
- {
- fl_line_style(FL_SOLID, 10, NULL);
- mv_offset = -8;
-
- if (annot_i->name == "CNS")
- fl_color(255,150,0);
- else if (annot_i->name == "ELA")
- fl_color(0,200,120);
- else if (annot_i->name == "ES")
- fl_color(0,200,200);
- else if (annot_i->name == "NA")
- fl_color(120,120,120);
- else if (annot_i->name == "EA")
- {
- fl_line_style(FL_SOLID, 7, NULL);
- mv_offset = -13;
- fl_color(0,200,120);
- }
- else if (annot_i->name == "VS")
- {
- fl_line_style(FL_SOLID, 7, NULL);
- mv_offset = -6;
- fl_color(255,255,0);
- }
- else if (annot_i->name == "SP")
- {
- fl_line_style(FL_SOLID, 7, NULL);
- mv_offset = -13;
- fl_color(255,230,150);
- }
- else if (annot_i->name == "L")
- {
- fl_line_style(FL_SOLID, 7, NULL);
- mv_offset = -6;
- fl_color(0,0,100);
- }
- else if (annot_i->name == "TCM")
- fl_color(0,130,230);
- }
-*/
+++ /dev/null
-#ifndef _MUSSA_GUI_CONN_VIEW_H_
-#define _MUSSA_GUI_CONN_VIEW_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <list>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include "mussa_gui_annot_window.hh"
-#include "mussa_gui_subana.hh"
-
-
-class ConnView : public Fl_Box
-{
- public:
- ConnView(int x_top,int y_top,int x_bot,int y_bot) :
- Fl_Box(x_top,y_top,x_bot,y_bot)
- {}
-
- void setup(std::string name, int sq_num, int win_len,
- std::vector<Sequence> *, Nway_Paths *);
- void scale_paths();
-
- void spawnSeq();
- void find_motifs();
- void annot_win();
-
- void toggle_bars();
- void set_bar_interval(int new_bar_len);
- void toggle_lines();
- void set_line_interval(int new_line_len);
-
-
- private:
- std::string ana_name;
- int seq_num, window, threshold;
- bool win_append, thres_append;
-
- //this data is passed as pointers to the instantiated classes
- std::vector<Sequence> *S;
- Nway_Paths *P;
-
- int name_pad, y_pad;
- float x_scale_factor;
- int y_seq_incre;
- int drag_start, drag_end;
- float y_drag_start;
- int ref_seq_num, max_seq_len;
- bool dragging, selected;
- std::list<bool> highlight;
-
- //path data scaled for current view size
- std::list<std::vector<int> > scaled_pathz;
- std::vector<int> seq_lens;
- std::vector<int> seq_scales;
- int bar_interval, line_interval;
- bool show_bars, show_lines;
-
- //keeps track of all the motifs the user has inputed
- std::vector<motif> some_motifs;
- MotifWindow *motif_find_window;
-
- //keeps track of the colors assigned to each motif type
- std::vector<annot_color> some_annots;
- AnnotWindow *annot_color_window;
-
- SeqWindow *a_seq_win;
-
- void draw();
- void draw_paths();
- void draw_sequence_stuff();
-
- void resize(int x, int y, int w, int h);
- int handle(int e);
- void check_new_motifs();
-
- //for drawing function debugging
- void reporter(std::string var, int value);
- void report_float(std::string var, float value);
-};
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_conn_window.hh"
-
-#include <iostream>
-using namespace std;
-
-void
-load_ana_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_load_ana_cb();
-}
-
-
-void
-ConnWindow::real_load_ana_cb()
-{
- char *picked_file;
- string a_file_path;
- string err_msg;
-
- cout << "Load! Load! Load, ye yellow-bellied seadogs!\n";
- //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
- picked_file = fl_dir_chooser("Find an Analysis", "", 1);
- if (picked_file != NULL)
- {
- a_file_path = picked_file;
- cout << "doo wah diddy diddy dum diddy doo\n";
- cout << a_file_path << endl;
-
- // load the analysis
- an_analysis = new Mussa();
- err_msg = an_analysis->load(a_file_path);
- //.substr(0,a_file_path.find(".mu")));
-
- if (err_msg == "")
- {
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
- // show the user the analysis
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
- conn_box->scale_paths();
- }
- else
- {
- fl_alert(err_msg.c_str());
- cout << err_msg << endl;
- }
- }
-}
-
-
-void
-do_ana_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_do_ana_cb();
-}
-
-
-void
-ConnWindow::real_do_ana_cb()
-{
- char *picked_file;
- string a_file_path;
- string err_msg;
-
- picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
- if (picked_file != NULL)
- {
- a_file_path = picked_file;
-
- an_analysis = new Mussa();
- err_msg = an_analysis->load_mupa_file(a_file_path);
-
- if (err_msg == "")
- {
- err_msg = an_analysis->analyze(0, 0, 't', 0.0);
- }
-
- if (err_msg == "")
- {
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
- // show the user the analysis
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
- conn_box->scale_paths();
- }
- else
- {
- fl_alert(err_msg.c_str());
- cout << err_msg;
- }
- }
-}
-
-
-void
-setup_ana_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_setup_ana_cb();
-}
-
-void
-ConnWindow::real_setup_ana_cb()
-{
- an_analysis = new Mussa();
- setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
-
- while(setup_win->visible())
- Fl::wait(.1);
- cout << "Like a warm summer day\n";
-
- if (setup_win->done())
- {
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
- // is it this easy? what if setup window encounters an error...??
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
-
- conn_box->scale_paths();
- }
-}
-
-
-void
-subana_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_subana_cb();
-}
-
-void
-ConnWindow::real_subana_cb()
-{
- string subana_name;
-
- sub_analysis = new Mussa();
- subana_win = new SubanaWindow(500,400,"Sub Analysis Setup", sub_analysis,
- an_analysis->the_Seqs);
-
- while(subana_win->visible())
- Fl::wait(.1);
- cout << "Like a warm summer day\n";
-
- if (subana_win->done())
- {
- subana_name = "SubMussa: " + sub_analysis->ana_name;
- sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
- cout << "Like a warm day in may\n";
- sub_conn_win->add_ana(sub_analysis);
- //Fl::visual(FL_DOUBLE|FL_INDEX);
- //sub_conn_box->show();
- }
-}
-
-
-void
-seq_show_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_seq_show_cb();
-}
-
-void
-ConnWindow::real_seq_show_cb()
-{
- show_seq_win = new SeqTextWin(500,400,"Seq Show", an_analysis->the_Seqs);
-}
-
-void
-seq_win_spawn_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_seq_win_spawn_cb();
-}
-
-void
-ConnWindow::real_seq_win_spawn_cb()
-{
- conn_box->spawnSeq();
-}
-
-void
-motif_find_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_motif_find_cb();
-}
-
-void
-ConnWindow::real_motif_find_cb()
-{
- conn_box->find_motifs();
-}
-
-void
-annot_win_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_annot_win_cb();
-}
-
-void
-ConnWindow::real_annot_win_cb()
-{
- conn_box->annot_win();
-}
-
-
-// all the crap needed for dealing with the scale bars
-void
-toggle_scale_bars_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_toggle_bars_cb();
-}
-
-void
-ConnWindow::real_toggle_bars_cb()
-{
- conn_box->toggle_bars();
-}
-
-void
-set_bar_len_cb(Fl_Input* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- cout << "WAAAAAAAAA\n";
- T->real_set_bar_len_cb(o);
-}
-
-void
-ConnWindow::real_set_bar_len_cb(Fl_Input* o)
-{
- int new_bar_len;
-
- new_bar_len = atoi(o->value());
- cout << "new bar len = " << new_bar_len << endl;
- conn_box->set_bar_interval(new_bar_len);
-}
-
-
-// all the crap needed for dealing with the scale lines
-void
-toggle_scale_lines_cb(Fl_Button* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- T->real_toggle_lines_cb();
-}
-
-void
-ConnWindow::real_toggle_lines_cb()
-{
- conn_box->toggle_lines();
-}
-
-void
-set_line_len_cb(Fl_Input* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- cout << "WAAAAAAAAA\n";
- T->real_set_line_len_cb(o);
-}
-
-void
-ConnWindow::real_set_line_len_cb(Fl_Input* o)
-{
- int new_line_len;
-
- new_line_len = atoi(o->value());
- cout << "new line len = " << new_line_len << endl;
- conn_box->set_line_interval(new_line_len);
-}
-
-
-// setting new soft threshold
-
-void
-set_soft_thres_cb(Fl_Input* o, void* v)
-{
- ConnWindow* T=(ConnWindow*)v;
- cout << "WAAAAAAAAA\n";
- T->real_set_soft_thres_cb(o);
-}
-
-void
-ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
-{
- int new_soft_thres;
-
- new_soft_thres = atoi(o->value());
- cout << "new soft thres = " << new_soft_thres << endl;
-
- an_analysis->set_soft_thres(new_soft_thres);
- an_analysis->set_ana_mode('t');
- an_analysis->nway();
- conn_box->scale_paths();
- conn_box->redraw();
-
- // hacked in stuff to save muway files at different thresholds
- string save_path;
- ostringstream append_info;
-
- save_path = an_analysis->ana_name + "/"
- + an_analysis->ana_name.substr(0,an_analysis->ana_name.find("_t"));
- append_info.str("");
- append_info << "_t" << new_soft_thres << ".muway";
- //<< "_w" << an_analysis->window
- save_path += append_info.str();
- cout << "saving as: " << save_path << endl;
- an_analysis->save_muway(save_path);
-}
-
-
-
-
-ConnWindow::ConnWindow(int w, int h, const char* title):
- Fl_Double_Window(w,h,title)
-{
- int button_len = 120;
- Fl_Color a_color = fl_rgb_color(150, 200, 255);
-
- padding = 5;
-
- begin();
- //fl_color(150,200,255);
- color(FL_WHITE);
- resizable(this);
-
-
- // create file menu button
- file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "Analysis");
- file_menu->color(FL_WHITE,a_color);
- file_menu->box(FL_BORDER_BOX);
- file_menu->clear();
-
- // add menu items
- file_menu->add("Do Analysis", 0, (Fl_Callback *) do_ana_cb, this);
- file_menu->add("Load Analysis", 0, (Fl_Callback *) load_ana_cb, this);
- file_menu->add("Setup Analysis", 0, (Fl_Callback *) setup_ana_cb, this);
- file_menu->add("Sub Analysis", 0, (Fl_Callback *) subana_cb, this);
-
-
- view_menu = new Fl_Menu_Button(padding+button_len,2, button_len, 30, "View");
- view_menu->color(FL_WHITE,a_color);
- view_menu->box(FL_BORDER_BOX);
- view_menu->clear();
- view_menu->add("Sequence Zoom", 0, (Fl_Callback*) seq_win_spawn_cb, this);
- view_menu->add("Motif Finder", 0, (Fl_Callback*) motif_find_cb, this);
- view_menu->add("Annotations", 0, (Fl_Callback*) annot_win_cb, this);
- view_menu->add("Copy Seq", 0, (Fl_Callback*) seq_show_cb, this);
- view_menu->add("Toggle Bars", 0, (Fl_Callback*) toggle_scale_bars_cb, this,
- FL_MENU_TOGGLE|FL_MENU_VALUE);
- view_menu->add("Toggle Lines", 0, (Fl_Callback*) toggle_scale_lines_cb, this,
- FL_MENU_TOGGLE|FL_MENU_VALUE);
-
- bar_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
- bar_input->value("");
- bar_input->when(FL_WHEN_ENTER_KEY);
- bar_input->callback((Fl_Callback*)set_bar_len_cb, this);
-
- line_input = new Fl_Input(padding+5*button_len, 2, button_len, 30, "Line Interval (bp)");
- line_input->value("");
- line_input->when(FL_WHEN_ENTER_KEY);
- line_input->callback((Fl_Callback*)set_line_len_cb, this);
-
-
- thres_input = new Fl_Input(padding+7*button_len, 2, button_len, 30, "Threshold");
- thres_input->value("");
- thres_input->when(FL_WHEN_ENTER_KEY);
- thres_input->callback((Fl_Callback*)set_soft_thres_cb, this);
-
-
- // create the connections box
- conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
- //conn_box = new ConnView(padding, padding, w-2*padding, h-2*padding);
-
- end();
- show();
-}
-
-
-ConnWindow::~ConnWindow()
-{}
-
-
-void
-ConnWindow::add_ana(Mussa *the_ana)
-{
- an_analysis = the_ana;
-
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
-
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
- conn_box->scale_paths();
-}
+++ /dev/null
-#ifndef _MUSSA_GUI_CONN_WINDOW_H_
-#define _MUSSA_GUI_CONN_WINDOW_H_
-
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <string>
-
-#include <Fl/Fl_Double_Window.H>
-#include <Fl/Fl_Menu_Item.H>
-
-#include "mussa_gui_conn_view.hh"
-#include "mussa_gui_load_window.hh"
-#include "mussa_gui_subana.hh"
-#include "mussa_gui_seq_text.hh"
-
-class ConnWindow : public Fl_Double_Window
-{
- private:
- Mussa *an_analysis, *sub_analysis;
- ConnWindow *sub_conn_win;
-
- Fl_Menu_Button *file_menu;
- Fl_Menu_Button *view_menu;
- Fl_Input *bar_input;
- Fl_Input *line_input;
- Fl_Input *thres_input;
- ConnView *conn_box;
- SetupWindow *setup_win;
- SubanaWindow *subana_win;
- SeqTextWin *show_seq_win;
- int padding, name_pad;
- std::string window_name;
-
- public:
- ConnWindow(int w, int h, const char* title);
- ~ConnWindow();
- void add_ana(Mussa *the_ana);
-
- void real_load_ana_cb();
- void real_do_ana_cb();
- void real_setup_ana_cb();
- void real_subana_cb();
- void real_resthres();
- void real_seq_show_cb();
-
- void real_seq_win_spawn_cb();
- void real_motif_find_cb();
- void real_annot_win_cb();
-
- void real_toggle_bars_cb();
- void real_set_bar_len_cb(Fl_Input* o);
- void real_toggle_lines_cb();
- void real_set_line_len_cb(Fl_Input* o);
- void real_set_soft_thres_cb(Fl_Input* o);
-};
-
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_load_window.hh"
-
-#include <iostream>
-#include <FL/Fl_File_Chooser.H>
-
-using namespace std;
-
-bool
-SetupWindow::done()
-{
- return all_done;
-}
-
-
-void
-do_analysis_cb(Fl_Button* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->real_do_analysis();
-}
-
-
-// passes the parameters to the mussa class object and orders it to run
-void
-SetupWindow::real_do_analysis()
-{
- int i;
- string err_msg;
-
- // <-- need a check here to make sure all vars have a valid value
-
- an_analysis->clear();
- an_analysis->set_name(ana_name);
- an_analysis->set_seq_num(seq_num);
- an_analysis->set_window(window);
- an_analysis->set_threshold(threshold);
-
- for(i=0; i < seq_num; i++)
- an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
- sub_seq_starts[i], sub_seq_ends[i]);
-
- err_msg = an_analysis->analyze(0,0, 't', 0.0);
- //cout << "Feel the tribal beat\n";
- if (!(err_msg == ""))
- {
- //fl_alert(err_msg.c_str());
- cout << err_msg;
- }
-
- all_done = true;
-
- hide();
-}
-
-
-void
-choose_seq_file_cb(Fl_Button* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_choose_seq_file_cb(blah->index);
-}
-
-
-void
-SetupWindow::real_choose_seq_file_cb(int i)
-{
- char *picked_file;
- string a_file_path;
-
- picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
- a_file_path = picked_file;
- seq_files[i] = a_file_path;
- seq_inputs[i]->value((const char *)picked_file);
-}
-
-
-void
-seq_file_in_cb(Fl_Input* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_seq_file_in_cb(o,blah->index);
-}
-
-
-void
-SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
-{
- seq_files[i] = o->value();
- // leaving this as a reminder that bools will need to be set to determine
- // if all needed fields have been filled with some value before an analysis
- // is attempted
- //(*the_motifs)[i].dirty = true;
-}
-
-//char *picked_file;
-//picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
-
-// *** Annot file selection
-
-void
-choose_annot_file_cb(Fl_Button* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_choose_annot_file_cb(blah->index);
-}
-
-
-void
-SetupWindow::real_choose_annot_file_cb(int i)
-{
- char *picked_file;
- string a_file_path;
-
- picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
- a_file_path = picked_file;
- annot_files[i] = a_file_path;
- annot_inputs[i]->value((const char *)picked_file);
-}
-
-void
-annot_file_in_cb(Fl_Input* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_annot_file_in_cb(o,blah->index);
-}
-
-void
-SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
-{
- annot_files[i] = o->value();
-}
-
-
-// *** fasta index selection
-
-void
-fa_index_in_cb(Fl_Input* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_fa_index_in_cb(o,blah->index);
-}
-
-void
-SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
-{
- fasta_indices[i] = atoi(o->value());
-}
-
-// *** subsequence start select
-
-void
-sub_start_in_cb(Fl_Input* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_sub_start_in_cb(o,blah->index);
-}
-
-void
-SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
-{
- sub_seq_starts[i] = atoi(o->value());
-}
-
-// *** subsequence end select
-
-void
-sub_end_in_cb(Fl_Input* o, void* v)
-{
- seq_data_instance * blah = (seq_data_instance *) v;
- SetupWindow* T= blah->sw_ptr;
- T->real_sub_end_in_cb(o,blah->index);
-}
-
-void
-SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
-{
- sub_seq_ends[i] = atoi(o->value());
-
-}
-
-// *** input analysis name
-
-void
-set_ana_name_cb(Fl_Input* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->real_set_ana_name_cb(o);
-}
-
-void
-SetupWindow::real_set_ana_name_cb(Fl_Input* o)
-{
- ana_name = o->value();
-}
-
-// *** input window size
-
-void
-set_win_size_cb(Fl_Input* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->real_set_win_size_cb(o);
-}
-
-void
-SetupWindow::real_set_win_size_cb(Fl_Input* o)
-{
- window = atoi(o->value());
-}
-
-// *** input threshold
-
-void
-set_threshold_cb(Fl_Input* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->real_set_threshold_cb(o);
-}
-
-void
-SetupWindow::real_set_threshold_cb(Fl_Input* o)
-{
- threshold = atoi(o->value());
-}
-
-void
-set_seq_num_cb(Fl_Input* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->real_set_seq_num_cb(o);
-}
-
-// *** input number of sequences, add appropriate inputs for each sequence
-
-void
-SetupWindow::real_set_seq_num_cb(Fl_Input* o)
-{
- int i;
-
- seq_num = atoi(o->value());
- seq_inputs.clear();
- annot_inputs.clear();
-
- seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
- seq_scroll->color(FL_WHITE);
-
- for (i = 0; i < seq_num; i++)
- {
- seq_files.push_back("");
- annot_files.push_back("");
- fasta_indices.push_back(1);
- sub_seq_starts.push_back(0);
- sub_seq_ends.push_back(0);
- add_seq_input(i);
- }
- seq_scroll->box(FL_DOWN_FRAME);
- add(seq_scroll);
- redraw();
-}
-
-
-SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
-{
- color(FL_WHITE);
-
- an_analysis = the_analysis;
- all_done = false;
-
- begin();
-
- name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
- name_input->value("");
- //name_input->when(FL_WHEN_ENTER_KEY);
- name_input->box(FL_BORDER_BOX);
- name_input->callback((Fl_Callback*)set_ana_name_cb, this);
-
- // add in radio buttons for win_append and thres_append eventually
- win_append = true;
- thres_append = true;
-
- win_input = new Fl_Input(65,45,100,30, "Window ");
- win_input->value("");
- win_input->callback((Fl_Callback*)set_win_size_cb, this);
-
- thres_input = new Fl_Input(250,45,100,30, "Threshold ");
- thres_input->value("");
- thres_input->callback((Fl_Callback*)set_threshold_cb, this);
-
- seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
- seq_num_input->value("");
- seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
-
- // button to launch the analysis
- test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
- test->callback((Fl_Callback*)do_analysis_cb, this);
-
- // test button to make sure setup data is being stored
- test = new Fl_Button(w-200,h-30,100,30,"show setup");
- test->callback((Fl_Callback*)print_cb, this);
-
- // generic input, keeping around as template for future additions
- //_input = new Fl_Input(0, , 30, "");
- //_input->value("");
- //_input->when(FL_WHEN_ENTER_KEY);
- //_input->callback((Fl_Callback*)set__cb, this);
-
- end();
- //resizable(this);
- show();
-}
-
-
-SetupWindow::~SetupWindow(){}
-
-
-void
-SetupWindow::add_seq_input(int i)
-{
- Fl_Input *fasta_input, *start_input, *end_input;
- Fl_Button *seq_browse, *annot_browse;
-
-
- // this remembers what seq index each input is associated with
- seq_data_instance * something;
- something = new seq_data_instance;
- something->sw_ptr = this;
- something->index = i;
-
-
- // setup sequence file input for text input or file browsing
- seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
- seq_inputs[i]->value("");
- seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
-
- seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
- seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
-
- // setup annotation file input for text input or file browsing
- annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
- annot_inputs[i]->value("");
- annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
-
- annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
- annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
-
- // index of fasta seq wanted if more than 1 seq in file
- fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
- fasta_input->value("");
- fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
-
- // subsequence select, index of first bp wanted
- start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
- start_input->value("");
- start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
-
- // subsequence select, index of last bp wanted
- end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
- end_input->value("");
- end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
-
- seq_scroll->add(seq_inputs[i]);
- seq_scroll->add(seq_browse);
- seq_scroll->add(annot_inputs[i]);
- seq_scroll->add(annot_browse);
- seq_scroll->add(fasta_input);
- seq_scroll->add(start_input);
- seq_scroll->add(end_input);
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
-
-void SetupWindow::print_cb(Fl_Button* o, void* v)
-{
- SetupWindow* T=(SetupWindow*)v;
- T->print_cb_real(o,v);
-}
-
-
-void SetupWindow::print_cb_real(Fl_Button* , void*)
-{
- cout << "ana_name: " << ana_name << endl;
- cout << "win: " << window << endl;
- cout << "thres: " << threshold << endl;
- cout << "seq_num: " << seq_num << endl;
- //cout << "win_add: " << win_append << end;
- //cout << "thres_add: " << thres_append << endl;
-
- int i;
-
-
-
- for (i = 0; i < seq_num; i++)
- {
- cout << seq_files[i] << endl;
- cout << annot_files[i] << endl;
- cout << "fasta: " << fasta_indices[i];
- cout << " start: " << sub_seq_starts[i];
- cout << " end: " << sub_seq_ends[i] << endl;
- cout << "blargle!\n";
- }
- cout << "end of inputs\n" << endl;
-}
+++ /dev/null
-#ifndef _MUSSA_GUI_LOAD_WINDOW_H_
-#define _MUSSA_GUI_LOAD_WINDOW_H_
-
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Input.H>
-#include <FL/Fl_Scroll.H>
-#include <FL/Fl_Window.H>
-
-#include "mussa_class.hh"
-#include "mussa_gui_load_window.hh"
-
-class SetupWindow : public Fl_Window
-{
- public:
- SetupWindow(int w, int h, const char* title, Mussa *an_analysis);
- ~SetupWindow();
-
- bool done();
-
- //did I put these in public for a reason?
- Fl_Button* test;
- Fl_Input *name_input;
- Fl_Input *win_input;
- Fl_Input *thres_input;
- Fl_Input *seq_num_input;
- Fl_Scroll *seq_scroll;
- // need to keep track of these so a browsed file search can set the input
- // fields to teh selected file
- std::vector<Fl_Input*> seq_inputs, annot_inputs;
-
-
- // callback receiver functions
-
- void real_do_analysis();
-
- void real_set_ana_name_cb(Fl_Input* o);
- void real_set_win_size_cb(Fl_Input* o);
- void real_set_threshold_cb(Fl_Input* o);
- void real_set_seq_num_cb(Fl_Input* o);
-
- void real_seq_file_in_cb(Fl_Input* o, int i);
- void real_choose_seq_file_cb(int i);
- void real_annot_file_in_cb(Fl_Input* o, int i);
- void real_choose_annot_file_cb(int i);
-
- void real_fa_index_in_cb(Fl_Input* o, int i);
- void real_sub_start_in_cb(Fl_Input* o, int i);
- void real_sub_end_in_cb(Fl_Input* o, int i);
-
- private:
- Mussa *an_analysis;
- std::string ana_name;
- int window, threshold, seq_num;
- std::vector<std::string> seq_files, annot_files;
- std::vector<int> fasta_indices, sub_seq_starts, sub_seq_ends;
- bool win_append, thres_append;
-
- bool all_done;
- static void print_cb(Fl_Button*, void*);
- inline void print_cb_real(Fl_Button*, void*);
-
- void add_seq_input(int index);
-};
-
-// crazy whacked shite Titus taught me to do to get an index value associated
-// with each instance of an input associated with the callback...
-
-struct seq_data_instance
-{
- SetupWindow * sw_ptr;
- int index;
-};
-
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_motif_window.hh"
-
-#include <iostream>
-
-#include <FL/fl_show_colormap.H>
-
-using namespace std;
-
-motif
-new_blank_motif()
-{
- motif *a_motif;
-
- a_motif = new motif;
- a_motif->name = "";
- a_motif->seq = "";
- a_motif->color = (Fl_Color) 5;
- a_motif->locations.clear();
- a_motif->dirty = false;
-
- cout << "name: " << a_motif->name << " seq: " << a_motif->seq << endl;
-
- return *a_motif;
-}
-
-
-void
-cb_motif_in(Fl_Input* o, void* v)
-{
- motif_instance * blah = (motif_instance *) v;
- MotifWindow* T= blah->mw_ptr;
- T->cb_motif_in_i(o,blah->index);
-}
-
-
-void
-cb_motif_color(Fl_Button* o, void* v)
-{
- motif_instance * blah = (motif_instance *) v;
- MotifWindow* T= blah->mw_ptr;
- T->cb_motif_color_i(o,blah->index);
-}
-
-
-MotifWindow::MotifWindow(int w, int h, const char* title,
- vector<motif> * some_motifs):Fl_Window(w,h,title)
-{
- int i;
-
- the_motifs = some_motifs;
- motif_count = 0;
-
- motif_color_buttons.clear();
-
- begin();
- motif_input_pack = new Fl_Pack(0, 0, w, h);
- motif_input_pack->spacing(4);
-
- // button to add new motif inputs
- add_motif = new Fl_Button(0,0,100,24,"Add Motif Slot");
- add_motif->callback((Fl_Callback*)add_motif_cb, this);
- motif_input_pack->add(add_motif);
- // test button to make sure motif data is being stored
- test = new Fl_Button(0,0,100,24,"show motifs");
- test->callback((Fl_Callback*)print_cb, this);
- motif_input_pack->add(test);
- // creat an initial set of motif input widgets and attach to motif vector
- for (i = 0; i < 5; i++)
- {
- add_motif_input(i);
- motif_count++;
- }
-
-
-
-
- add(motif_input_pack);
-
- end();
- resizable(this);
- show();
-}
-
- //tmp_input->user_data((void*) i);
-
-MotifWindow::~MotifWindow(){}
-
-void
-MotifWindow::add_motif_input(int index)
-{
- Fl_Input * new_input;
- Fl_Button *new_color_button;
- motif_instance * something;
- Fl_Pack * motif_hor_pack;
-
-
- something = new motif_instance;
- something->mw_ptr = this;
- something->index = index;
-
- motif_hor_pack = new Fl_Pack(0, 0, w(), 24);
- motif_hor_pack->type(Fl_Pack::HORIZONTAL);
- motif_hor_pack->spacing(4);
-
- // setup the color display/selection button
- new_color_button = new Fl_Button(0, 0, 24, 24, "");
- new_color_button->color((*the_motifs)[index].color);
- new_color_button->box(FL_FLAT_BOX);
- new_color_button->callback((Fl_Callback*)cb_motif_color, (void*) something);
- motif_color_buttons.push_back(new_color_button);
- motif_hor_pack->add(new_color_button);
-
-
- // setup the motif inputs
- new_input = new Fl_Input(0, 0, 200, 24, "");
- new_input->value( ((*the_motifs)[index].seq).c_str() );
- new_input->callback((Fl_Callback*)cb_motif_in, (void*) something);
- motif_ins.push_back(new_input);
- motif_hor_pack->add(new_input);
-
- motif_input_pack->add(motif_hor_pack);
-}
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
-
-void
-MotifWindow::cb_motif_in_i(Fl_Input* o, int i)
-{
- (*the_motifs)[i].seq = o->value();
- (*the_motifs)[i].dirty = true;
-}
-
-void
-MotifWindow::cb_motif_color_i(Fl_Button* o, int i)
-{
- //Fl_Color new_color;
-
- (*the_motifs)[i].color = fl_show_colormap((*the_motifs)[i].color);
- //motif_color_buttons[i]->
- o->color((*the_motifs)[i].color);
- redraw();
-}
-
-void MotifWindow::add_motif_cb(Fl_Button* o, void* v)
-{
- MotifWindow* T=(MotifWindow*)v;
- T->add_motif_cb_real(o,v);
-}
-
-
-void MotifWindow::add_motif_cb_real(Fl_Button* , void*)
-{
- motif blank_motif;
-
- //blank_motif.name = "";
- //blank_motif.seq = "";
- blank_motif = new_blank_motif();
- (*the_motifs).push_back(blank_motif);
- add_motif_input(motif_count++);
- redraw();
-}
-
-
-void MotifWindow::print_cb(Fl_Button* o, void* v)
-{
- MotifWindow* T=(MotifWindow*)v;
- T->print_cb_real(o,v);
-}
-
-
-void MotifWindow::print_cb_real(Fl_Button* , void*)
-{
- int i;
-
- for (i = 0; i < motif_count; i++)
- cout << (*the_motifs)[i].seq << endl;
-}
+++ /dev/null
-#ifndef _MUSSA_GUI_MOTIF_WINDOW_H_
-#define _MUSSA_GUI_MOTIF_WINDOW_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <list>
-#include <string>
-#include <vector>
-
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Button.H>
-
-#include <FL/Fl_Input.H>
-#include <FL/Fl_Pack.H>
-
-#include "mussa_class.hh"
-
-struct motif
-{
- std::string name, seq;
- Fl_Color color;
- std::vector<std::vector<int> > locations;
- bool dirty;
-};
-
-//typedef motif_ptr *motif;
-
-
-class MotifWindow : public Fl_Window
-{
- public:
- MotifWindow(int w, int h, const char* title, std::vector<motif> * some_motifs);
- ~MotifWindow();
- Fl_Pack * motif_input_pack;
- std::list<Fl_Input*> motif_ins;
- std::vector<Fl_Button*> motif_color_buttons;
- std::list<Fl_Input*> name_ins;
- Fl_Button* test;
- Fl_Button* add_motif;
-
- void cb_motif_in_i(Fl_Input*, int i);
- void cb_motif_color_i(Fl_Button* o, int i);
-
- private:
- std::vector<motif> * the_motifs;
- int motif_count;
-
- void add_motif_input(int index);
-
- static void add_motif_cb(Fl_Button*, void*);
- inline void add_motif_cb_real(Fl_Button*, void*);
-
- static void print_cb(Fl_Button*, void*);
- inline void print_cb_real(Fl_Button*, void*);
-};
-
-// crazy whacked shite Titus taught me to do to get an index value associated
-// with each instance of an input associated with the callback...
-struct motif_instance
-{
- MotifWindow * mw_ptr;
- int index;
-};
-
-motif new_blank_motif();
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_seq.hh"
-
-#include <sstream>
-
-#include <FL/Fl.H>
-
-using namespace std;
-
-void
-set_align_cb(Fl_Widget* widg, void* the_data)
-{
- menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
- SeqWindow* T= blah->swm_ptr;
- T->real_set_align_cb(blah->which_align);
-}
-
-
-void
-SeqWindow::real_set_align_cb(int which_align)
-{
- vector<int> a_path;
- int window_length;
-
-
- a_path = *P.begin();
- window_length = a_path[0];
- cout << window_length << endl;
-
- cout << "fum1\n";
- seq_box->align_offsets(which_align);
- seq_box->redraw();
-}
-
-
-void
-show_align_cb(Fl_Widget* widg, void* the_data)
-{
- menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
- SeqWindow* T= blah->swm_ptr;
- T->real_show_align_cb(blah->which_align);
-}
-
-
-void
-SeqWindow::real_show_align_cb(int which_align)
-{
- vector<int> a_path;
- int window_length;
-
-
- cout << "fumish\n";
- seq_box->toggle_align(which_align);
- seq_box->redraw();
-}
-
-
-void
-toggle_bars_cb(Fl_Button* o, void* v)
-{
- SeqWindow* T=(SeqWindow*)v;
- T->real_toggle_bars_cb();
-}
-
-
-void
-SeqWindow::real_toggle_bars_cb()
-{
- seq_box->toggle_bars();
-}
-
-
-void
-toggle_motifs_cb(Fl_Button* o, void* v)
-{
- SeqWindow* T=(SeqWindow*)v;
- T->real_toggle_motifs_cb();
-}
-
-
-void
-SeqWindow::real_toggle_motifs_cb()
-{
- seq_box->toggle_motifs();
-}
-
-
-// main code, window creation
-
-SeqWindow::SeqWindow(int w, int h, const char* title, int sq_num,
- vector<Sequence> *some_seqs,
- list<vector<int> > some_paths,
- vector<int> some_lens,
- vector<motif> *some_motifs):
- Fl_Double_Window(w,h,title)
-{
- menu_align_data_bundle * some_menu_data;
- vector<int> a_path;
- int window_length, align_number;
- int i;
- ostringstream align_id_ostr;
- string align_id_string;
- list<vector<int> >::iterator align_iter;
-
-
-
- // most of this stuff is here just to pass to SeqView object
- // some is needed to setup the window menus
- seq_num = sq_num;
- S = some_seqs;
- P = some_paths;
- seq_lens = some_lens;
- the_motifs = some_motifs;
-
-
- begin();
- color(FL_WHITE);
- resizable(this);
-
- // make the menu that allows alignment selection
- choose_align_menu = new Fl_Menu_Button(5, 2, 180, 30, "Choose Alignment");
- choose_align_menu->color(FL_WHITE,FL_BLUE);
- choose_align_menu->box(FL_BORDER_BOX);
- choose_align_menu->clear();
-
- // make the menu that allows alignment selection
- show_align_menu = new Fl_Menu_Button(190, 2, 180, 30, "Show Alignment");
- show_align_menu->color(FL_WHITE,FL_BLUE);
- show_align_menu->box(FL_BORDER_BOX);
- show_align_menu->clear();
-
-
- // adds menu items for each path
- align_iter = P.begin();
- align_number = 0;
- while(align_iter != P.end())
- {
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = align_number;
- align_id_ostr << (*align_iter)[0] << ": ";
- for(i = 1; i <= seq_num; i++)
- align_id_ostr << (*align_iter)[i] << ", ";
- align_id_string = align_id_ostr.str();
- choose_align_menu->add((const char*)align_id_string.c_str(), 0,
- (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
- show_align_menu->add((const char*)align_id_string.c_str(), 0,
- (Fl_Callback *) show_align_cb,
- (void*) some_menu_data, FL_MENU_TOGGLE|FL_MENU_VALUE);
-
- align_id_ostr.str("");
- ++align_number;
- ++align_iter;
- }
-
- /*
- show_align_menu->add("f&ee");
- show_align_menu->add("f&ie");
- show_align_menu->add("f&oe");
- show_align_menu->add("f&um");
- */
-
- Fl_Button *test_but = new Fl_Button(375, 2, 150, 30, "Toggle Motifs");
- test_but->color(FL_WHITE,FL_BLUE);
- test_but->box(FL_BORDER_BOX);
- test_but->callback((Fl_Callback*) toggle_motifs_cb, this);
-
- toggle_bars = new Fl_Button(530, 2, 150, 30, "Toggle 10bp bars");
- toggle_bars->color(FL_WHITE,FL_BLUE);
- toggle_bars->box(FL_BORDER_BOX);
- toggle_bars->callback((Fl_Callback*) toggle_bars_cb, this);
-
-
- // make the view of the sequence
- seq_box = new SeqView(0, 34, w, h-34);
- seq_box->setup(ana_name, seq_num, S, P, seq_lens, the_motifs);
- //real_set_align_cb(2);
-
- end();
- Fl::visual(FL_DOUBLE|FL_INDEX);
- show();
-}
-
-
-
-/*
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 2;
- choose_align_menu->add("f&ie", FL_ALT+'i', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 3;
- choose_align_menu->add("f&oe", FL_ALT+'o', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-
- some_menu_data = new menu_align_data_bundle;
- some_menu_data->swm_ptr = this;
- some_menu_data->which_align = 4;
- choose_align_menu->add("f&um", FL_ALT+'u', (Fl_Callback *) set_align_cb,
- (void*) some_menu_data);
-*/
-
-
-
-
+++ /dev/null
-#ifndef _MUSSA_GUI_SEQ_H_
-#define _MUSSA_GUI_SEQ_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <iostream>
-#include <list>
-#include <string>
-#include <vector>
-
-#include "mussa_gui_seq_view.hh"
-
-#include <FL/Fl_Menu_Bar.H>
-#include <FL/Fl_Menu_Item.H>
-#include <FL/Fl_Menu_Button.H>
-#include <FL/Fl_Double_Window.H>
-
-class SeqWindow : public Fl_Double_Window
-{
- private:
- std::string ana_name;
- int base_window_len;
-
- //this data is passed as pointers to the instantiated classes
- std::vector<Sequence> *S;
- // list of paths in selection box
- std::list<std::vector<int> > P;
- std::vector<int> seq_lens;
- //pointer to passed motif data
- std::vector<motif> *the_motifs;
-
- int x_max, y_max;
- Fl_Menu_Button *choose_align_menu;
- Fl_Menu_Button *show_align_menu;
- Fl_Button *toggle_bars;
- SeqView *seq_box;
-
- public:
- int seq_num;
-
- SeqWindow(int w, int h, const char* title, int sq_num,
- std::vector<Sequence> *some_seqs,
- std::list<std::vector<int> > some_paths,
- std::vector<int> some_lens,
- std::vector<motif> *some_motifs);
- virtual ~SeqWindow(){ std::cout << "dying\n"; }
-
- void make_choose_menu();
- void make_show_menu();
- void real_set_align_cb(int which_align);
- void real_show_align_cb(int which_align);
- void real_toggle_bars_cb();
- void real_toggle_motifs_cb();
-};
-
-
-struct menu_align_data_bundle
-{
- SeqWindow * swm_ptr;
- int which_align;
-};
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_seq_text.hh"
-
-#include <iostream>
-using namespace std;
-void
-get_seq_cb(Fl_Button* o, void* v)
-{
- SeqTextWin* T=(SeqTextWin*)v;
- T->real_get_seq_cb();
-}
-
-void
-SeqTextWin::real_get_seq_cb()
-{
- string sub_seq_formatted;
- int seq_len, i, line_len;
-
-
- cout << "length = " << seq_end-seq_start << endl;
-
- // make sure inputed values within valid ranges
- if ((seq_end > seq_start) && (seq_id > -1) && (seq_id < the_Seqs.size()) )
- {
- sub_sequence = the_Seqs[seq_id].subseq(seq_start, seq_end-seq_start);
-
- sub_seq_formatted = "";
- seq_len = sub_sequence.size();
- line_len = 40;
- for (i = 0; i < seq_len; i += line_len)
- {
- sub_seq_formatted.append(sub_sequence.substr(i,line_len));
- sub_seq_formatted.append("\n");
- }
-
- seq_display->value((const char *)sub_seq_formatted.c_str());
- }
-}
-
-
-// *** input seq index id
-
-void
-set_seq_id_cb(Fl_Input* o, void* v)
-{
- SeqTextWin* T=(SeqTextWin*)v;
- T->real_set_seq_id_cb(o);
-}
-
-void
-SeqTextWin::real_set_seq_id_cb(Fl_Input* o)
-{
- seq_id = atoi(o->value()) - 1; // -1 since arrays start at 0
-}
-
-
-// *** input seq start index
-
-void
-set_seq_start_cb(Fl_Input* o, void* v)
-{
- SeqTextWin* T=(SeqTextWin*)v;
- T->real_set_seq_start_cb(o);
-}
-
-void
-SeqTextWin::real_set_seq_start_cb(Fl_Input* o)
-{
- seq_start = atoi(o->value());
-}
-
-// *** input seq end index
-
-void
-set_seq_end_cb(Fl_Input* o, void* v)
-{
- SeqTextWin* T=(SeqTextWin*)v;
- T->real_set_seq_end_cb(o);
-}
-
-void
-SeqTextWin::real_set_seq_end_cb(Fl_Input* o)
-{
- seq_end = atoi(o->value());
-}
-
-
-SeqTextWin::SeqTextWin(int w, int h, const char* title,
- vector<Sequence> some_Seqs):Fl_Window(w,h,title)
-{
- string a_name;
- color(FL_WHITE);
- the_Seqs = some_Seqs;
-
-
- seq_id = -1;
- seq_start = 1000000;
- seq_end = -1000000;
-
- begin();
-
- seq_id_input = new Fl_Input(80,10,30,30, "Seq num: ");
- seq_id_input->value("");
- seq_id_input->callback((Fl_Callback*)set_seq_id_cb, this);
-
- seq_start_input = new Fl_Input(160,10,100,30, " start: ");
- seq_start_input->value("");
- seq_start_input->callback((Fl_Callback*)set_seq_start_cb, this);
-
- seq_end_input = new Fl_Input(310,10,100,30, "end: ");
- seq_end_input->value("");
- seq_end_input->callback((Fl_Callback*)set_seq_end_cb, this);
-
- seq_display = new Fl_Multiline_Output(10, 50, w-20, h-60, "");
- seq_display->value("");
-
- //seq_display2 = new Fl_Text_Display(10,100, w-20, h-110,"");
-
- // button to get the sequence
- get_seq_but = new Fl_Button(w-80,10,80,30,"Get Seq");
- get_seq_but->callback((Fl_Callback*)get_seq_cb, this);
-
-
- end();
- //resizable(this);
- show();
-}
-
-
-SeqTextWin::~SeqTextWin(){}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
+++ /dev/null
-#ifndef _MUSSA_GUI_SEQ_TEXT_H_
-#define _MUSSA_GUI_SEQ_TEXT_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <string>
-#include <vector>
-
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Input.H>
-#include <FL/Fl_Text_Buffer.H>
-#include <FL/Fl_Text_Display.H>
-#include <FL/Fl_Multiline_Output.H>
-
-#include "mussa_gui_seq.hh"
-
-class SeqTextWin : public Fl_Window
-{
- public:
- SeqTextWin(int w, int h, const char* title, std::vector<Sequence> some_Seqs);
- ~SeqTextWin();
-
- Fl_Button* get_seq_but;
- Fl_Multiline_Output* seq_display;
- Fl_Text_Buffer* seq_buffer;
- Fl_Text_Display* seq_display2;
- Fl_Input *seq_id_input;
- Fl_Input *seq_start_input;
- Fl_Input *seq_end_input;
-
- // callback receiver functions
-
- void real_get_seq_cb();
- void real_set_seq_id_cb(Fl_Input* o);
- void real_set_seq_start_cb(Fl_Input* o);
- void real_set_seq_end_cb(Fl_Input* o);
-
- private:
- // sequence data
- std::vector<Sequence> the_Seqs;
- std::string sub_sequence;
- int seq_id, seq_start, seq_end;
-};
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_seq.hh"
-#include <sstream>
-
-#include <FL/Fl.H>
-#include <FL/fl_draw.H>
-
-using namespace std;
-
-void
-SeqView::setup(string name, int sq_num,
- vector<Sequence> *some_seqs,
- list<vector<int> > some_paths, vector<int> some_lens,
- vector<motif> *some_motifs)
-{
- int seq_i;
- list<vector<int> >::iterator pathz_i;
-
-
- ana_name = name;
- seq_num = sq_num;
- S = some_seqs;
- P = some_paths;
- seq_lens = some_lens;
- the_motifs = some_motifs;
-
- y_seq_incre = (y_max-10-10) / (seq_num - 1);
-
- fl_font(FL_COURIER, 14);
- cout << "font width: " << fl_width('A') << endl;
-
- index_pad = 6 * (int) fl_width('A') + 5;
-
- align_offsets(0);
-
- raw_sequence.clear();
- for(seq_i = 0; seq_i < seq_num; ++seq_i)
- raw_sequence.push_back( (*S)[seq_i].seq() );
-
- for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
- {
- show_aligns.push_back(true);
- }
-
- dragging = false;
- scroll_offset = 0;
- //scroll_pos = 0;
- drag_change = 0;
-
- cout << "waaaaa!\n";
- cout << x() << " " << y() << " " << w() << " " << h() << endl;
-}
-
-void
-SeqView::resize(int new_x, int new_y, int new_w, int new_h)
-{
- x(new_x);
- y(new_y);
- w(new_w);
- h(new_h);
-
- // hmmm, why do I use these values on the the widgets inherent ones?
- // I think there was a reason...once?
- x_max = new_w;
- y_max = new_h;
- x_min = new_x;
- y_min = new_y;
-
- // things that need to be recalculated
- y_seq_incre = (y_max-10-10) / (seq_num - 1);
-}
-
-
-
-
-void
-SeqView::draw()
-{
- double ch_width;
-
-
- // clear drawing area and set background to white
- fl_color(FL_WHITE);
- fl_rectf(x(), y(), w(), h());
-
-
- fl_font(FL_COURIER, 14);
- //blatantly stolen from FR2
- ch_width = fl_width('A'); // monospaced: all characters are same width
-
-
- if (show_bars)
- {
- int grey_box_num, grey_box_len;
- int i;
- // draw in some light grey boxes every 10bp to delineate for user
- //fl_color(200,235,235);
- fl_color(180,180,180);
- grey_box_num = (((x_max - index_pad) / (int) ch_width) / 10) + 1;
- grey_box_len = 10 * (int) ch_width;
- for(i = 0; i < grey_box_num; i++)
- if ((i % 2) != 0)
- fl_rectf(x()+index_pad-1 + (i * grey_box_len), y(), grey_box_len, h());
- }
-
- if (show_motifs)
- draw_motifs(ch_width);
-
- draw_sequence(ch_width);
-
- draw_match_lines(ch_width);
-
- draw_indices(ch_width);
-
-
- // draw some bounding boxes to visually separate things
- fl_color(150,200,255);
- fl_line_style(FL_SOLID, 2, NULL);
- fl_rect(x(), y(), w(), h());
- fl_rect(x()+index_pad-1, y(), w()-2*(index_pad-1), h());
-}
-
-void
-SeqView::draw_motifs(double ch_width)
-{
- vector<motif>::iterator motif_i;
- vector<int> some_motif_locs;
- vector<int>::iterator i_locs;
- int scale_len, motif_len, i2;
- int y_loc, x_start;
-
- //fl_color(255,0,255);
- fl_line_style(FL_SOLID, 10, NULL);
- motif_i = the_motifs->begin();
- while (motif_i != the_motifs->end())
- {
- fl_color(motif_i->color);
- motif_len = motif_i->seq.length();
- scale_len = (int) (motif_len * ch_width);
- y_loc = y_min + 10;
- if (!motif_i->locations.empty())
- for(i2 = 0; i2 < seq_num; i2++)
- {
- some_motif_locs = (*motif_i).locations[i2];
-
- i_locs = some_motif_locs.begin();
- while (i_locs != some_motif_locs.end())
- {
- x_start = (int) ((*i_locs +scroll_offset - seq_align_offsets[i2])
- * ch_width) + index_pad + x();
-
- //cout << *i_locs << ":" << x_start << " ";
- // don't draw highlights outside of box range, they can wraparound past some boundry
- if ((x_start > 0) && (x_start < w()))
- fl_line(x_start,y_loc,x_start+scale_len,y_loc);
- ++i_locs;
- }
- //cout << endl;
- y_loc += y_seq_incre;
- }
- ++motif_i;
- }
-}
-
-void
-SeqView::draw_sequence(double ch_width)
-{
- int i, seq_i, y_loc;
- Sequence a_seq;
- string sub_seq;
- int seq_len, sub_seq_start, sub_seq_len;
-
-
-
- fl_color(FL_BLACK);
- y_loc = y_min + 10 + 5;
-
- for(seq_i = 0; seq_i < seq_num; seq_i++)
- {
- seq_len = raw_sequence[seq_i].length();
- sub_seq_start = seq_align_offsets[seq_i] - scroll_offset;
- sub_seq_len = (x_max - index_pad) / (int) ch_width;
- //cout << x_max << " index_pad: " << index_pad << " y - ip: " << (x_max - index_pad) << endl;
-
- // gotta check thru boundary conditions to make sure we're producing the
- // right string for the current position (otherwise gonna crash due to
- // illegal indexing into substr
- if (sub_seq_start < 0)
- {
- sub_seq_len = sub_seq_len - sub_seq_start;
- if (sub_seq_len < 0)
- sub_seq_len = 0;
- sub_seq_start = 0;
- }
- else if (sub_seq_start >= seq_len)
- {
- sub_seq_start = seq_len;
- sub_seq_len = 0;
- }
- else if ((sub_seq_start + sub_seq_len) >= seq_len)
- sub_seq_len = seq_len - sub_seq_start;
-
- sub_seq = raw_sequence[seq_i].substr(sub_seq_start, sub_seq_len);
- fl_draw(sub_seq.c_str(), index_pad, y_loc);
- y_loc += y_seq_incre;
- }
-}
-
-
-void
-SeqView::draw_match_lines(double ch_width)
-{
- int i, y_loc;
- vector<int> a_path;
- list<vector<int> >::iterator pathz_i;
- int i2, i3;
- int x_start, y_start, x_end, y_end;
- int window_length, win_i;
- int rc_1 = 0;
- int rc_2 = 0;
- int offset1, offset2;
- float center1, center2;
- bool rc_color;
- vector<bool> rc_list;
- bool full_match;
- vector<bool> matched;
- int align_counter;
-
-
- align_counter = 0;
- for(pathz_i = P.begin(); pathz_i != P.end(); ++pathz_i)
- {
- if (show_aligns[align_counter])
- {
- a_path = *pathz_i;
- window_length = a_path[0];
-
- // determine which parts of the path are RC relative to first species
- rc_list.clear();
- for(i2 = 1; i2 <= seq_num; i2++)
- {
- if (a_path[i2] < 0)
- rc_list.push_back(true);
- else
- rc_list.push_back(false);
- }
-
- // loop over each bp in the conserved region for all sequences
- for(win_i = 0; win_i < window_length; win_i++)
- {
- // determine which exact base pairs match between the sequences
- full_match = true;
- for(i2 = 1; i2 < seq_num; i2++)
- {
- // assume not rc as most likely, adjust below
- rc_1 = 0;
- rc_2 = 0;
- // no matter the case, any RC node needs adjustments
- if (a_path[i2] < 0)
- rc_1 = window_length-1;
- if (a_path[i2+1] < 0)
- rc_2 = window_length-1;
-
- x_start = (abs(a_path[i2]-rc_1+win_i));
- x_end = (abs(a_path[i2+1]-rc_2+win_i));
-
- // RC case handling
- // ugh, and xor...only want rc coloring if just one of the nodes is rc
- // if both nodes are rc, then they are 'normal' relative to each other
- if ( ( rc_list[i2] || rc_list[i2-1] ) &&
- !(rc_list[i2] && rc_list[i2-1] ) )
- { //the hideous rc matching logic - not complex, but annoying
- if ( !( ( (raw_sequence[i2-1][x_start] == 'A') &&
- (raw_sequence[i2][x_end] == 'T') ) ||
- ( (raw_sequence[i2-1][x_start] == 'T') &&
- (raw_sequence[i2][x_end] == 'A') ) ||
- ( (raw_sequence[i2-1][x_start] == 'G') &&
- (raw_sequence[i2][x_end] == 'C') ) ||
- ( (raw_sequence[i2-1][x_start] == 'C') &&
- (raw_sequence[i2][x_end] == 'G') ) ) )
- full_match = false;
- }
- else
- {
- if (!( (raw_sequence[i2-1][x_start] == raw_sequence[i2][x_end]) &&
- (raw_sequence[i2-1][x_start] != 'N') &&
- (raw_sequence[i2][x_end] != 'N') ) )
- full_match = false;
- }
- }
-
- // draw for matches stretching across all sequences
- if (full_match)
- {
- fl_line_style(FL_SOLID, 1, NULL);
-
- // now can draw the line for each bp in this window that matches
- // grrr, need to ask if anyone cares if I switch the seq top-bot order...
- i3 = 0;
- y_loc = y_min + 5;
- for(i2 = 1; i2 < seq_num; i2++)
- {
- // assume not rc as most likely, adjust below
- rc_1 = 0;
- rc_2 = 0;
- // this makes the lines start in the middle of the drawn char/bp
- center1 = 0.5;
- center2 = 0.5;
- // no matter the case, any RC node needs adjustments
- if (a_path[i2] < 0)
- {
- rc_1 = window_length;
- center1 = -center1;
- }
- if (a_path[i2+1] < 0)
- {
- rc_2 = window_length;
- center2 = -center2;
- }
-
- // set offset based on current alignment for which bp to show
- offset1 = seq_align_offsets[i2-1];
- offset2 = seq_align_offsets[i2];
-
- if ( ( rc_list[i2] || rc_list[i2-1] ) &&
- !(rc_list[i2] && rc_list[i2-1] ) )
- fl_color(FL_BLUE);
- else
- fl_color(FL_RED);
-
- // maybe shouldn't recalc these, but store values from first loop
- x_start = (abs((int) (a_path[i2]-rc_1+win_i)));
- x_end = (abs((int) (a_path[i2+1]-rc_2+win_i)));
-
- fl_line( (int)((x_start+center1-offset1+scroll_offset)*ch_width)
- + index_pad, y_loc + 10,
- (int)((x_end+center2-offset2+scroll_offset)*ch_width)
- + index_pad, y_loc+y_seq_incre );
- y_loc += y_seq_incre;
- }
- }
- }
- }
- align_counter++;
- }
-}
-
-void
-SeqView::draw_indices(double ch_width)
-{
- int seq_i;
- Sequence a_seq;
- int y_loc;
- ostringstream an_index;
- int shown_seq_len;
-
-
- // clear out space on sides to draw in index values
- // I block out the sides rather than adding offsets to the drawing of seq
- // and conservation lines since the lines need to draw off the 'edge'
- fl_color(FL_WHITE);
- fl_rectf(0, y_min, index_pad, h()+y_min);
- fl_rectf(w()-index_pad, y_min, index_pad, h()+y_min);
-
- // now can draw in the indices of the start and end of the shown sequence
- fl_color(FL_BLACK);
- y_loc = y_min + 10 + 5;
- for(seq_i = 0; seq_i < seq_num; seq_i++)
- {
- an_index.str("");
- an_index << (seq_align_offsets[seq_i]-scroll_offset);
- fl_draw((an_index.str()).c_str(), 2, y_loc);
-
- shown_seq_len = (w() - 2 * index_pad) / (int) ch_width;
- an_index.str("");
- an_index << (seq_align_offsets[seq_i]-scroll_offset+shown_seq_len);
- fl_draw((an_index.str()).c_str(), w()-index_pad+2, y_loc);
- y_loc += y_seq_incre;
- }
-}
-
-
-void
-SeqView::toggle_align(int align_num)
-{
- //cout << align_num << endl;
- //cout << show_aligns[align_num] << endl;
- show_aligns[align_num] = !show_aligns[align_num];
- //cout << show_aligns[align_num] << endl;
-}
-
-
-void
-SeqView::align_offsets(int align_num)
-{
- list<vector<int> >::iterator pathz_i;
- int i;
- vector<int> a_path;
- int window_length;
-
- cout << "alignment: " << align_num << endl;
-
- if (P.begin() == P.end())
- cout << "crud....\n";
- else
- {
- pathz_i = P.begin();
-
- while(pathz_i != P.end())
- ++pathz_i;
-
- // find the path specified
- i = 0;
- pathz_i = P.begin();
- while( (i < align_num) && (pathz_i != P.end()) )
- {
- ++i;
- ++pathz_i;
- }
-
- // now set the alignment offsets - basically where the path starts
- seq_align_offsets.clear();
- for(i = 0; i < seq_num ; i++)
- {
- //cout << (*pathz_i)[i+1] << endl;
- seq_align_offsets.push_back( abs((*pathz_i)[i+1]) );
- // for testing purposes: to see everything in the short test sequences
- //seq_align_offsets.push_back(0);
- }
- // reset any dragging done, otherwise might be hard to find selected align
- scroll_offset = 0;
- }
-}
-
-
-
-int
-SeqView::handle(int e)
-{
- int return_value;
-
- // this empty string needs to be put on cout, otherwise the -O optimize
- // compile option seems to throw this function away with the following:
- // gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
- cout << "";
-
- switch(e)
- {
- case FL_PUSH:
- if (Fl::event_button3())
- {
- cout << "menu menu menu!\n";
- return_value = 1;
- }
- break;
- case FL_DRAG:
- if (!dragging)
- {
- drag_change = Fl::event_x();
- dragging = true;
- return_value = 1;
- }
- drag_change = Fl::event_x() - drag_change;
- scroll_offset += drag_change;
- drag_change = Fl::event_x();
- redraw();
- break;
- case FL_RELEASE:
- if (dragging)
- {
- //scroll_offset += Fl::event_x() - drag_start;
- //scroll_dist = Fl::event_x() - drag_start;
- //scroll_offset += scroll_dist;
- //scroll_offset += scroll_pos;
- dragging = false;
- redraw();
- return_value = 1;
- }
- break;
- default:
- return_value = Fl_Widget::handle(e);
- }
-
- return return_value;
-}
-
-void
-SeqView::toggle_bars()
-{
- show_bars = !show_bars;
- redraw();
-}
-
-
-void
-SeqView::toggle_motifs()
-{
- show_motifs = !show_motifs;
- redraw();
-}
-
-
-void
-SeqView::reporter(string id, int value)
-{
- cout << id << " : " << value << endl;
-}
-
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
+++ /dev/null
-#ifndef _MUSSA_GUI_SEQ_VIEW_H_
-#define _MUSSA_GUI_SEQ_VIEW_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <list>
-#include <string>
-#include <vector>
-
-#include <FL/Fl_Box.H>
-
-#include "mussa_gui_motif_window.hh"
-#include "mussa_gui_load_window.hh"
-
-class SeqView : public Fl_Box
-{
- public:
- SeqView(int x_top,int y_top,int x_bot,int y_bot) :
- Fl_Box(x_top,y_top,x_bot,y_bot)
- {
- x_max = x_bot;
- y_max = y_bot;
- x_min = x_top;
- y_min = y_top;
- show_bars = true;
- show_motifs = true;
- }
-
- void setup(std::string name, int sq_num, std::vector<Sequence> *some_seqs,
- std::list<std::vector<int> > some_paths,
- std::vector<int> some_lens, std::vector<motif> *some_motifs);
- void align_offsets(int align_num);
- void toggle_align(int align_num);
- void toggle_bars();
- void toggle_motifs();
-
- private:
- std::string ana_name;
- int seq_num;
- int base_window_len;
-
- //this data is passed as pointers to the instantiated classes
- std::vector<Sequence> *S;
- //list of paths in selection box
- std::list<std::vector<int> > P;
- std::vector<int> seq_lens;
- //pointer to passed motif data
- std::vector<motif> *the_motifs;
-
- int x_max, y_max, x_min, y_min;
- int y_seq_incre;
- int index_pad;
- std::vector<int> seq_align_offsets;
- std::vector<std::string> raw_sequence;
- bool dragging;
- int drag_change, scroll_offset;
- bool show_bars, show_motifs;
- std::vector<bool> show_aligns;
-
- void resize(int new_x, int new_y, int new_w, int new_h);
- void draw();
- void draw_motifs(double ch_width);
- void draw_sequence(double ch_width);
- void draw_match_lines(double ch_width);
- void draw_indices(double ch_width);
- int handle(int e);
- void reporter(std::string id, int value);
-};
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_gui_subana.hh"
-
-#include <iostream>
-using namespace std;
-
-void
-do_subana_cb(Fl_Button* o, void* v)
-{
- SubanaWindow* T=(SubanaWindow*)v;
- T->real_do_subana();
-}
-
-
-// passes the parameters to the mussa class object and orders it to run
-void
-SubanaWindow::real_do_subana()
-{
- int i;
- string a_sequence, err_msg;
-
- // <-- need a check here to make sure all vars have a valid value
-
- an_analysis->clear();
- an_analysis->set_name(ana_name);
- an_analysis->set_seq_num(seq_num);
- an_analysis->set_window(window);
- an_analysis->set_threshold(threshold);
-
- for(i=0; i < seq_num; i++)
- {
- a_sequence = the_Seqs[i].seq();
- cout << a_sequence.length() << endl;
- a_sequence = a_sequence.substr(sub_seq_starts[i],
- sub_seq_ends[i] - sub_seq_starts[i] );
- cout << a_sequence.length() << endl;
- an_analysis->add_a_seq(a_sequence);
- }
-
- err_msg = an_analysis->analyze(0,0, 't', 0.0);
-
- cout << "Feel the tribal beat\n";
- if (!(err_msg == ""))
- {
- //fl_alert(err_msg.c_str());
- cout << err_msg;
- }
-
- all_done = true;
-
- hide();
-}
-
-
-
-// *** subsequence start select
-
-void
-sub_start_in_cb1(Fl_Input* o, void* v)
-{
- sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
- SubanaWindow* T= blah->sw_ptr;
- T->real_sub_start_in_cb(o,blah->index);
-}
-
-void
-SubanaWindow::real_sub_start_in_cb(Fl_Input* o, int i)
-{
- sub_seq_starts[i] = atoi(o->value());
-}
-
-// *** subsequence end select
-
-void
-sub_end_in_cb1(Fl_Input* o, void* v)
-{
- sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
- SubanaWindow* T= blah->sw_ptr;
- T->real_sub_end_in_cb(o,blah->index);
-}
-
-void
-SubanaWindow::real_sub_end_in_cb(Fl_Input* o, int i)
-{
- sub_seq_ends[i] = atoi(o->value());
-
-}
-
-// *** input analysis name
-
-void
-set_ana_name_cb1(Fl_Input* o, void* v)
-{
- SubanaWindow* T=(SubanaWindow*)v;
- T->real_set_ana_name_cb(o);
-}
-
-void
-SubanaWindow::real_set_ana_name_cb(Fl_Input* o)
-{
- ana_name = o->value();
-}
-
-// *** input window size
-
-void
-set_win_size_cb1(Fl_Input* o, void* v)
-{
- SubanaWindow* T=(SubanaWindow*)v;
- T->real_set_win_size_cb(o);
-}
-
-void
-SubanaWindow::real_set_win_size_cb(Fl_Input* o)
-{
- window = atoi(o->value());
-}
-
-// *** input threshold
-
-void
-set_threshold_cb1(Fl_Input* o, void* v)
-{
- SubanaWindow* T=(SubanaWindow*)v;
- T->real_set_threshold_cb(o);
-}
-
-void
-SubanaWindow::real_set_threshold_cb(Fl_Input* o)
-{
- threshold = atoi(o->value());
-}
-
-
-bool
-SubanaWindow::done()
-{
- return all_done;
-}
-
-
-SubanaWindow::SubanaWindow(int w, int h, const char* title,Mussa *the_analysis,
- vector<Sequence> some_Seqs):Fl_Window(w,h,title)
-{
- string a_name;
-
- color(FL_WHITE);
-
- an_analysis = the_analysis;
- the_Seqs = some_Seqs;
- all_done = false;
-
- // initialize parameters
- ana_name = "";
- window = -1;
- threshold = -1;
-
- begin();
-
- name_input = new Fl_Input(135, 10, w-140, 30, "SubAnalysis Name ");
- name_input->value("");
- //name_input->when(FL_WHEN_ENTER_KEY);
- name_input->box(FL_BORDER_BOX);
- name_input->callback((Fl_Callback*)set_ana_name_cb1, this);
-
- // add in radio buttons for win_append and thres_append eventually
- win_append = true;
- thres_append = true;
-
- win_input = new Fl_Input(135,45,100,30, "Window: ");
- win_input->value("");
- win_input->callback((Fl_Callback*)set_win_size_cb1, this);
-
- thres_input = new Fl_Input(320,45,100,30, "Threshold: ");
- thres_input->value("");
- thres_input->callback((Fl_Callback*)set_threshold_cb1, this);
-
- // button to launch the analysis
- test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
- test->callback((Fl_Callback*)do_subana_cb, this);
-
- // test button to make sure setup data is being stored
- test = new Fl_Button(w-200,h-30,100,30,"show setup");
- test->callback((Fl_Callback*)print_cb, this);
-
- // add all the inputs for the sub sequence starts & ends
- int i;
-
- seq_num = the_Seqs.size();
-
- seq_scroll = new Fl_Scroll(5,80,w-10,h-115);
- seq_scroll->color(FL_WHITE);
-
- for (i = 0; i < seq_num; i++)
- {
- sub_seq_starts.push_back(0);
- sub_seq_ends.push_back(0);
- a_name = the_Seqs[i].sp_name();
- cout << a_name << endl;
- add_seq_input(i, a_name);
- }
- seq_scroll->box(FL_DOWN_FRAME);
- //add(seq_scroll);
- //redraw();
-
- end();
- //resizable(this);
- show();
-}
-
-
-SubanaWindow::~SubanaWindow(){}
-
-
-void
-SubanaWindow::add_seq_input(int i, string a_name)
-{
- Fl_Input *start_input, *end_input;
-
-
- // this remembers what seq index each input is associated with
- sub_seq_data_instance * something;
- something = new sub_seq_data_instance;
- something->sw_ptr = this;
- something->index = i;
-
-
- // subsequence select, index of first bp wanted
- start_input = new Fl_Input(150, 85+(i*35), 70, 30, "start index: ");
- start_input->value("");
- start_input->callback((Fl_Callback*)sub_start_in_cb1, (void*) something);
-
- // subsequence select, index of last bp wanted
- end_input = new Fl_Input(300, 85+(i*35), 70, 30, "end index: ");
- end_input->value("");
- end_input->callback((Fl_Callback*)sub_end_in_cb1, (void*) something);
-
- seq_scroll->add(start_input);
- seq_scroll->add(end_input);
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe\n";
- cout << "fum\n";
-*/
-
-void SubanaWindow::print_cb(Fl_Button* o, void* v)
-{
- SubanaWindow* T=(SubanaWindow*)v;
- T->print_cb_real(o,v);
-}
-
-
-void SubanaWindow::print_cb_real(Fl_Button* , void*)
-{
- cout << "ana_name: " << ana_name << endl;
- cout << "win: " << window << endl;
- cout << "thres: " << threshold << endl;
- cout << "seq_num: " << seq_num << endl;
- //cout << "win_add: " << win_append << end;
- //cout << "thres_add: " << thres_append << endl;
-
- int i;
-
-
-
- for (i = 0; i < seq_num; i++)
- {
- //cout << seq_files[i] << endl;
- //cout << annot_files[i] << endl;
- //cout << "fasta: " << fasta_indices[i];
- cout << " start: " << sub_seq_starts[i];
- cout << " end: " << sub_seq_ends[i] << endl;
- cout << "blargle!\n";
- }
- cout << "end of inputs\n" << endl;
-}
+++ /dev/null
-#ifndef _MUSSA_GUI_SUBANA_H_
-#define _MUSSA_GUI_SUBANA_H_
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-#include <string>
-#include <vector>
-
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Input.H>
-#include <FL/Fl_File_Chooser.H>
-#include <FL/Fl_Scroll.H>
-
-#include "mussa_class.hh"
-#include "mussa_gui_seq_text.hh"
-
-class SubanaWindow : public Fl_Window
-{
- public:
- SubanaWindow(int w, int h, const char* title, Mussa *an_analysis,
- std::vector<Sequence> some_Seqs);
- ~SubanaWindow();
- bool done();
-
-
- Fl_Button* test;
-
- Fl_Input *name_input;
- Fl_Input *win_input;
- Fl_Input *thres_input;
- Fl_Input *seq_num_input;
- Fl_Scroll *seq_scroll;
- // need to keep track of these so a browsed file search can set the input
- // fields to the selected file
- std::vector<Fl_Input*> seq_inputs, annot_inputs;
-
-
- // callback receiver functions
-
- void real_do_subana();
-
- void real_set_ana_name_cb(Fl_Input* o);
- void real_set_win_size_cb(Fl_Input* o);
- void real_set_threshold_cb(Fl_Input* o);
-
- void real_sub_start_in_cb(Fl_Input* o, int i);
- void real_sub_end_in_cb(Fl_Input* o, int i);
-
- private:
- // sequence data
- std::vector<Sequence> the_Seqs;
- Mussa *an_analysis;
- std::string ana_name;
- int window, threshold, seq_num;
- std::vector<int> sub_seq_starts, sub_seq_ends;
- bool win_append, thres_append;
- bool all_done;
-
- static void print_cb(Fl_Button*, void*);
- inline void print_cb_real(Fl_Button*, void*);
-
- void add_seq_input(int index, std::string a_name);
-};
-
-// crazy whacked shite Titus taught me to do to get an index value associated
-// with each instance of an input associated with the callback...
-
-
-struct sub_seq_data_instance
-{
- SubanaWindow * sw_ptr;
- int index;
-};
-#endif
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// ----------------------------------------
-// ---------- mussa_nway.cc -----------
-// ----------------------------------------
-
-#include "mussa_nway.hh"
-#include <fstream>
-#include <iostream>
-
-using namespace std;
-
-Nway_Paths::Nway_Paths()
-{
-}
-
-void
-Nway_Paths::setup(int sp_num, int w, int t)
-{
- species_num = sp_num;
- threshold = t;
- soft_thres = threshold;
- win_size = w;
- pathz.clear();
-
- cout << "nway: species_num = " << species_num << ", thres = " << threshold
- << ", softo = " << soft_thres << endl;
-}
-
-void
-Nway_Paths::set_soft_thres(int sft_thres)
-{
- soft_thres = sft_thres;
-}
-
-
-
-
-// dumbly goes thru and combines path windows exactly adjacent (ie + 1 index)
-// doesn't deal with interleaved adjacency
-void
-Nway_Paths::simple_refine()
-{
- // ext_path remembers the first window set in an extending path
- vector<int> ext_path, cur_path, next_path, new_path;
- list<vector<int> >::iterator pathz_i;
- int i2, win_ext_len = 0;
- bool extending, end = false;
- int count_loop = 0;
-
-
- refined_pathz.clear();
-
- cout << "path number is: " << pathz.size() << endl;
- pathz_i = pathz.begin();
- ext_path = *pathz_i;
-
- while(pathz_i != pathz.end())
- {
- //cout << "path number is: " << pathz.size() << endl;
- //++count_loop;
- //cout << "glorpagh!!!!!" << count_loop << endl;
-
- // keep track of current path and advance to next path
- cur_path = *pathz_i;
- ++pathz_i;
- if (pathz_i == pathz.end())
- end = true;
- else
- next_path = *pathz_i;
-
- //cout << "S\'Nork!\n";
-
- if (not end)
- {
- // if node for each seq is equal to the next node+1 then for all
- // sequences then we are extending
- extending = true;
- for(i2 = 0; i2 < species_num; i2++)
- {
- //cout << cur_path[i2] << " vs " << endl;
- //cout << next_path[i2] << endl;
- if (cur_path[i2] + 1 != next_path[i2])
- extending = false;
- }
- }
- else
- extending = false;
-
- if (extending)
- {
- //cout << "Raaaawwwrrr! I am extending\n";
- win_ext_len++;
- }
- else
- {
- //cout << "Larfnarg?\n";
- // add the extend window length as first element and add as refined
- new_path = ext_path;
- new_path.insert(new_path.begin(),win_size + win_ext_len);
- for(i2 = 1; i2 <= species_num; i2++)
- {
- if (new_path[i2] < 0)
- {
- //cout << "before: " << new_path[i2];
- new_path[i2] += win_ext_len;
- //cout << " after: " << new_path[i2] << endl;
- }
- }
- refined_pathz.push_back(new_path);
- // reset stuff
- win_ext_len = 0;
- ext_path = next_path;
- }
- }
- cout << "r_path number is: " << refined_pathz.size() << endl;
-}
-
-
-void
-Nway_Paths::add_path(vector<int> loaded_path)
-{
- pathz.push_back(loaded_path);
-}
-
-
-void
-Nway_Paths::save(string save_file_path)
-{
- fstream save_file;
- list<vector<int> >::iterator path_i, paths_end;
- vector<int> a_path;
- int i;
-
- save_file.open(save_file_path.c_str(), ios::out);
-
- save_file << "<Mussa type=flp seq_num=" << species_num;
- save_file << " win=" << win_size;
- // add a function para new_thres defaults to -1 to later deal with
- // reanalysis with higher thres - if statement whether to record base thres
- // or new thres (ie if -1, then base)
- save_file << " thres=" << threshold << " >\n";
-
- path_i = refined_pathz.begin();
- paths_end = refined_pathz.end();
- //path_i = pathz.begin();
- //paths_end = pathz.end();
- while (path_i != paths_end)
- {
- a_path = *path_i;
- //cout << a_path.size() << endl;
- //first entry is the window length of the windows in the path
- save_file << a_path[0] << ":";
- for(i = 1; i <= species_num; ++i)
- {
- save_file << a_path[i];
- if (i != species_num)
- save_file << ",";
- }
- save_file << endl;
- ++path_i;
- }
-
- save_file << "</Mussa>\n";
- save_file.close();
-}
-
-/*
- if (path_i == paths_end)
- cout << "Arrrrrrgggghhhhhh\n";
-*/
-
-int
-Nway_Paths::seq_num()
-{
- return species_num;
-}
-
-
-string
-Nway_Paths::load(string load_file_path)
-{
- fstream load_file;
- string file_data_line, header_data, data, path_node, path_length;
- int i, space_split_i, equal_split_i, comma_split_i, colon_split_i;
- vector<int> loaded_path;
- string err_msg;
-
-
- load_file.open(load_file_path.c_str(), ios::in);
-
- if (!load_file)
- {
- err_msg = "Sequence File: " + load_file_path + " not found";
- cout << "BAM!!!!\n";
- return err_msg;
- }
-
- else
- {
- // get header data
- // grab mussa tag - discard for now...maybe check in future...
- getline(load_file,file_data_line);
- space_split_i = file_data_line.find(" ");
- file_data_line = file_data_line.substr(space_split_i+1);
- // grab type tag - need in future to distinguish between flp and vlp paths
- space_split_i = file_data_line.find(" ");
- file_data_line = file_data_line.substr(space_split_i+1);
- // get species/seq number
- space_split_i = file_data_line.find(" ");
- header_data = file_data_line.substr(0,space_split_i);
- equal_split_i = header_data.find("=");
- data = file_data_line.substr(equal_split_i+1);
- species_num = atoi (data.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
- // get window size
- space_split_i = file_data_line.find(" ");
- header_data = file_data_line.substr(0,space_split_i);
- equal_split_i = header_data.find("=");
- data = file_data_line.substr(equal_split_i+1);
- win_size = atoi (data.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
- // get window size
- space_split_i = file_data_line.find(" ");
- header_data = file_data_line.substr(0,space_split_i);
- equal_split_i = header_data.find("=");
- data = file_data_line.substr(equal_split_i+1);
- threshold = atoi (data.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
-
- cout << "seq_num=" << species_num << " win=" << win_size;
- cout << " thres=" << threshold << endl;
-
- // clear out the current data
- refined_pathz.clear();
-
- int temp;
-
- getline(load_file,file_data_line);
- while ( (!load_file.eof()) && (file_data_line != "</Mussa>") )
- {
- if (file_data_line != "")
- {
- loaded_path.clear();
- colon_split_i = file_data_line.find(":");
- path_length = file_data_line.substr(0,colon_split_i);
- loaded_path.push_back(atoi (path_length.c_str()));
- file_data_line = file_data_line.substr(colon_split_i+1);
- for(i = 0; i < species_num; i++)
- {
- comma_split_i = file_data_line.find(",");
- path_node = file_data_line.substr(0, comma_split_i);
- temp = atoi (path_node.c_str());
- loaded_path.push_back(temp);
- file_data_line = file_data_line.substr(comma_split_i+1);
- }
- refined_pathz.push_back(loaded_path);
- }
- getline(load_file,file_data_line);
- }
-
-
- load_file.close();
-
- return "";
- }
-}
-
-
-
-
-void
-Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth)
-{
- list<int> new_nodes, trans_check_nodes;
- list<int>::iterator new_nodes_i, new_nodes_end;
- int i;
- bool trans_check_good;
-
- new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
- while(new_nodes_i != new_nodes_end)
- {
- //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
- // check transitivity with previous nodes in path
- trans_check_good = true;
- for(i = 0; i < depth - 1; i++)
- {
- trans_check_nodes = all_comparisons[i][depth].matches(path[i]);
- if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
- trans_check_nodes.end(),
- *new_nodes_i) ) &&
- (trans_check_nodes.end() == find(trans_check_nodes.begin(),
- trans_check_nodes.end(),
- *new_nodes_i * -1) ) )
- trans_check_good = false;
- }
-
- if (trans_check_good)
- {
- // this makes sure path nodes are recorded with RC status relative to
- // the base species
- if ( path[depth-1] >= 0)
- path.push_back(*new_nodes_i);
- else
- path.push_back(*new_nodes_i * -1);
-
- if (depth < species_num - 1)
- path_search(all_comparisons, path, depth + 1);
- else
- pathz.push_back(path);
- path.pop_back();
- }
- ++new_nodes_i;
- }
-}
-// cout << " ****I have the power...\n";
-
-/* use this if I ever get the friggin seqcomp match lists to sort...
- if (binary_search(trans_check_nodes.begin(), trans_check_nodes.end(),
- *new_nodes_i))
-*/
-
-void
-Nway_Paths::find_paths_r(vector<vector<FLPs> > all_comparisons)
-{
- vector<int> path;
- int win_i, window_num;
- list<int> new_nodes;
- list<int>::iterator new_nodes_i, new_nodes_end;
-
- pathz.clear();
- window_num = all_comparisons[0][1].win_num();
- cout << window_num << endl;
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- path.clear();
- path.push_back(win_i);
- new_nodes = all_comparisons[0][1].matches(path[0]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
- //if (new_nodes_i != new_nodes_end)
- //cout << "* species 0 node: " << win_i << endl;
- // cout << "foookin hell\n";
- path.push_back(0);
- while(new_nodes_i != new_nodes_end)
- {
- //cout << " * species 1 node: " << *new_nodes_i << endl;
- path[1] = *new_nodes_i;
- path_search(all_comparisons, path, 2);
- ++new_nodes_i;
- }
- }
-}
-
-
-void
-Nway_Paths::save_old(string save_file_path)
-{
- fstream save_file;
- list<vector<int> >::iterator path_i, paths_end;
- vector<int> a_path;
- int i;
-
- save_file.open(save_file_path.c_str(), ios::app);
-
- path_i = pathz.begin();
- paths_end = pathz.end();
- while(path_i != paths_end)
- {
- a_path = *path_i;
- //cout << a_path.size() << endl;
- for(i = 0; i < species_num; ++i)
- save_file << i << "," << a_path[i] << " ";
- save_file << endl;
- ++path_i;
- }
- save_file.close();
-}
-
-
-/*
-void
-Nway_Paths::find_paths(vector<vector<FLPs> > all_comparisons)
-{
- int win_i, sp_i;
- vector<list<list<int> > > path_src_tree;
- list<int> new_nodes;
- list<int>::iterator node_i, node_end;
- <list<list<int> > >::iterator branch_i, branch_end;
-
- pathz.clear();
- path_src_tree.reserve(species_num - 1);
-
-
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- // clear the path search tree
- for(i = 0; i < species_num; i++)
- path_src_tree[i].clear();
-
- // top level kept empty even tho implicity has one entry of the first
- // species at this window - why bother, adds a little speed
-
- // get connection list for first species, creating a list of nodes
- // of second species connected to the first species at this window
- new_nodes = all_comparisons[0][1];
- path_src_tree[1].push_back(new_nodes);
-
- // loop thru rest of species for this window to see if any paths of matches
- // go across all species
- // if path search tree becomes empty, break out of loop, no reason to search further
- sp_i = 1;
- while ((sp_i < species_num) && (path tree not empty))
- {
- branch_i = path_src_tree[1].begin();
- branch_end = path_src_tree[1].end();
- while (branch_i != branch_end)
- {
- node_i = branch_i->begin();
- node_end = branch_i->end();
- }
-
-
- // loop over all current nodes
- // get connection list for each node
- // loop over each previous node in list
- // get those nodes connection list
- // intersect previous node connections with current
-
- ++sp_i;
- }
-
- // insert any of the paths found into the master list of paths
-
- // add no paths if tmp_pathz is empty...
- }
-}
-
-void Nway_Paths::refine()
-{
-}
-
-void Nway_Paths::print()
-{
- list<list<int> >::iterator pathz_i;
-
- cout << "printing list of lists\n";
- for (pathz_i = pathz.begin(); pathz_i != pathz.end(); ++pathz_i)
- {
- for (path_i = pathz_i->begin(); path_i != pathz_i->end(); ++path_i)
- cout << *path_i << " ";
- cout << endl;
- }
-}
-*/
-
-
-
-
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// ----------------------------------------
+// ---------- mussa_nway.cc -----------
+// ----------------------------------------
+
+#include "mussa_nway.hh"
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+
+Nway_Paths::Nway_Paths()
+{
+}
+
+void
+Nway_Paths::setup(int sp_num, int w, int t)
+{
+ species_num = sp_num;
+ threshold = t;
+ soft_thres = threshold;
+ win_size = w;
+ pathz.clear();
+
+ cout << "nway: species_num = " << species_num << ", thres = " << threshold
+ << ", softo = " << soft_thres << endl;
+}
+
+void
+Nway_Paths::set_soft_thres(int sft_thres)
+{
+ soft_thres = sft_thres;
+}
+
+
+
+
+// dumbly goes thru and combines path windows exactly adjacent (ie + 1 index)
+// doesn't deal with interleaved adjacency
+void
+Nway_Paths::simple_refine()
+{
+ // ext_path remembers the first window set in an extending path
+ vector<int> ext_path, cur_path, next_path, new_path;
+ list<vector<int> >::iterator pathz_i;
+ int i2, win_ext_len = 0;
+ bool extending, end = false;
+ int count_loop = 0;
+
+
+ refined_pathz.clear();
+
+ cout << "path number is: " << pathz.size() << endl;
+ pathz_i = pathz.begin();
+ ext_path = *pathz_i;
+
+ while(pathz_i != pathz.end())
+ {
+ //cout << "path number is: " << pathz.size() << endl;
+ //++count_loop;
+ //cout << "glorpagh!!!!!" << count_loop << endl;
+
+ // keep track of current path and advance to next path
+ cur_path = *pathz_i;
+ ++pathz_i;
+ if (pathz_i == pathz.end())
+ end = true;
+ else
+ next_path = *pathz_i;
+
+ //cout << "S\'Nork!\n";
+
+ if (not end)
+ {
+ // if node for each seq is equal to the next node+1 then for all
+ // sequences then we are extending
+ extending = true;
+ for(i2 = 0; i2 < species_num; i2++)
+ {
+ //cout << cur_path[i2] << " vs " << endl;
+ //cout << next_path[i2] << endl;
+ if (cur_path[i2] + 1 != next_path[i2])
+ extending = false;
+ }
+ }
+ else
+ extending = false;
+
+ if (extending)
+ {
+ //cout << "Raaaawwwrrr! I am extending\n";
+ win_ext_len++;
+ }
+ else
+ {
+ //cout << "Larfnarg?\n";
+ // add the extend window length as first element and add as refined
+ new_path = ext_path;
+ new_path.insert(new_path.begin(),win_size + win_ext_len);
+ for(i2 = 1; i2 <= species_num; i2++)
+ {
+ if (new_path[i2] < 0)
+ {
+ //cout << "before: " << new_path[i2];
+ new_path[i2] += win_ext_len;
+ //cout << " after: " << new_path[i2] << endl;
+ }
+ }
+ refined_pathz.push_back(new_path);
+ // reset stuff
+ win_ext_len = 0;
+ ext_path = next_path;
+ }
+ }
+ cout << "r_path number is: " << refined_pathz.size() << endl;
+}
+
+
+void
+Nway_Paths::add_path(vector<int> loaded_path)
+{
+ pathz.push_back(loaded_path);
+}
+
+
+void
+Nway_Paths::save(string save_file_path)
+{
+ fstream save_file;
+ list<vector<int> >::iterator path_i, paths_end;
+ vector<int> a_path;
+ int i;
+
+ save_file.open(save_file_path.c_str(), ios::out);
+
+ save_file << "<Mussa type=flp seq_num=" << species_num;
+ save_file << " win=" << win_size;
+ // add a function para new_thres defaults to -1 to later deal with
+ // reanalysis with higher thres - if statement whether to record base thres
+ // or new thres (ie if -1, then base)
+ save_file << " thres=" << threshold << " >\n";
+
+ path_i = refined_pathz.begin();
+ paths_end = refined_pathz.end();
+ //path_i = pathz.begin();
+ //paths_end = pathz.end();
+ while (path_i != paths_end)
+ {
+ a_path = *path_i;
+ //cout << a_path.size() << endl;
+ //first entry is the window length of the windows in the path
+ save_file << a_path[0] << ":";
+ for(i = 1; i <= species_num; ++i)
+ {
+ save_file << a_path[i];
+ if (i != species_num)
+ save_file << ",";
+ }
+ save_file << endl;
+ ++path_i;
+ }
+
+ save_file << "</Mussa>\n";
+ save_file.close();
+}
+
+/*
+ if (path_i == paths_end)
+ cout << "Arrrrrrgggghhhhhh\n";
+*/
+
+int
+Nway_Paths::seq_num()
+{
+ return species_num;
+}
+
+
+string
+Nway_Paths::load(string load_file_path)
+{
+ fstream load_file;
+ string file_data_line, header_data, data, path_node, path_length;
+ int i, space_split_i, equal_split_i, comma_split_i, colon_split_i;
+ vector<int> loaded_path;
+ string err_msg;
+
+
+ load_file.open(load_file_path.c_str(), ios::in);
+
+ if (!load_file)
+ {
+ err_msg = "Sequence File: " + load_file_path + " not found";
+ cout << "BAM!!!!\n";
+ return err_msg;
+ }
+
+ else
+ {
+ // get header data
+ // grab mussa tag - discard for now...maybe check in future...
+ getline(load_file,file_data_line);
+ space_split_i = file_data_line.find(" ");
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // grab type tag - need in future to distinguish between flp and vlp paths
+ space_split_i = file_data_line.find(" ");
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get species/seq number
+ space_split_i = file_data_line.find(" ");
+ header_data = file_data_line.substr(0,space_split_i);
+ equal_split_i = header_data.find("=");
+ data = file_data_line.substr(equal_split_i+1);
+ species_num = atoi (data.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get window size
+ space_split_i = file_data_line.find(" ");
+ header_data = file_data_line.substr(0,space_split_i);
+ equal_split_i = header_data.find("=");
+ data = file_data_line.substr(equal_split_i+1);
+ win_size = atoi (data.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get window size
+ space_split_i = file_data_line.find(" ");
+ header_data = file_data_line.substr(0,space_split_i);
+ equal_split_i = header_data.find("=");
+ data = file_data_line.substr(equal_split_i+1);
+ threshold = atoi (data.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+
+ cout << "seq_num=" << species_num << " win=" << win_size;
+ cout << " thres=" << threshold << endl;
+
+ // clear out the current data
+ refined_pathz.clear();
+
+ int temp;
+
+ getline(load_file,file_data_line);
+ while ( (!load_file.eof()) && (file_data_line != "</Mussa>") )
+ {
+ if (file_data_line != "")
+ {
+ loaded_path.clear();
+ colon_split_i = file_data_line.find(":");
+ path_length = file_data_line.substr(0,colon_split_i);
+ loaded_path.push_back(atoi (path_length.c_str()));
+ file_data_line = file_data_line.substr(colon_split_i+1);
+ for(i = 0; i < species_num; i++)
+ {
+ comma_split_i = file_data_line.find(",");
+ path_node = file_data_line.substr(0, comma_split_i);
+ temp = atoi (path_node.c_str());
+ loaded_path.push_back(temp);
+ file_data_line = file_data_line.substr(comma_split_i+1);
+ }
+ refined_pathz.push_back(loaded_path);
+ }
+ getline(load_file,file_data_line);
+ }
+
+
+ load_file.close();
+
+ return "";
+ }
+}
+
+
+
+
+void
+Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth)
+{
+ list<int> new_nodes, trans_check_nodes;
+ list<int>::iterator new_nodes_i, new_nodes_end;
+ int i;
+ bool trans_check_good;
+
+ new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+ while(new_nodes_i != new_nodes_end)
+ {
+ //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
+ // check transitivity with previous nodes in path
+ trans_check_good = true;
+ for(i = 0; i < depth - 1; i++)
+ {
+ trans_check_nodes = all_comparisons[i][depth].matches(path[i]);
+ if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ *new_nodes_i) ) &&
+ (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ *new_nodes_i * -1) ) )
+ trans_check_good = false;
+ }
+
+ if (trans_check_good)
+ {
+ // this makes sure path nodes are recorded with RC status relative to
+ // the base species
+ if ( path[depth-1] >= 0)
+ path.push_back(*new_nodes_i);
+ else
+ path.push_back(*new_nodes_i * -1);
+
+ if (depth < species_num - 1)
+ path_search(all_comparisons, path, depth + 1);
+ else
+ pathz.push_back(path);
+ path.pop_back();
+ }
+ ++new_nodes_i;
+ }
+}
+// cout << " ****I have the power...\n";
+
+/* use this if I ever get the friggin seqcomp match lists to sort...
+ if (binary_search(trans_check_nodes.begin(), trans_check_nodes.end(),
+ *new_nodes_i))
+*/
+
+void
+Nway_Paths::find_paths_r(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, window_num;
+ list<int> new_nodes;
+ list<int>::iterator new_nodes_i, new_nodes_end;
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl;
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ path.clear();
+ path.push_back(win_i);
+ new_nodes = all_comparisons[0][1].matches(path[0]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+ //if (new_nodes_i != new_nodes_end)
+ //cout << "* species 0 node: " << win_i << endl;
+ // cout << "foookin hell\n";
+ path.push_back(0);
+ while(new_nodes_i != new_nodes_end)
+ {
+ //cout << " * species 1 node: " << *new_nodes_i << endl;
+ path[1] = *new_nodes_i;
+ path_search(all_comparisons, path, 2);
+ ++new_nodes_i;
+ }
+ }
+}
+
+
+void
+Nway_Paths::save_old(string save_file_path)
+{
+ fstream save_file;
+ list<vector<int> >::iterator path_i, paths_end;
+ vector<int> a_path;
+ int i;
+
+ save_file.open(save_file_path.c_str(), ios::app);
+
+ path_i = pathz.begin();
+ paths_end = pathz.end();
+ while(path_i != paths_end)
+ {
+ a_path = *path_i;
+ //cout << a_path.size() << endl;
+ for(i = 0; i < species_num; ++i)
+ save_file << i << "," << a_path[i] << " ";
+ save_file << endl;
+ ++path_i;
+ }
+ save_file.close();
+}
+
+
+/*
+void
+Nway_Paths::find_paths(vector<vector<FLPs> > all_comparisons)
+{
+ int win_i, sp_i;
+ vector<list<list<int> > > path_src_tree;
+ list<int> new_nodes;
+ list<int>::iterator node_i, node_end;
+ <list<list<int> > >::iterator branch_i, branch_end;
+
+ pathz.clear();
+ path_src_tree.reserve(species_num - 1);
+
+
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // clear the path search tree
+ for(i = 0; i < species_num; i++)
+ path_src_tree[i].clear();
+
+ // top level kept empty even tho implicity has one entry of the first
+ // species at this window - why bother, adds a little speed
+
+ // get connection list for first species, creating a list of nodes
+ // of second species connected to the first species at this window
+ new_nodes = all_comparisons[0][1];
+ path_src_tree[1].push_back(new_nodes);
+
+ // loop thru rest of species for this window to see if any paths of matches
+ // go across all species
+ // if path search tree becomes empty, break out of loop, no reason to search further
+ sp_i = 1;
+ while ((sp_i < species_num) && (path tree not empty))
+ {
+ branch_i = path_src_tree[1].begin();
+ branch_end = path_src_tree[1].end();
+ while (branch_i != branch_end)
+ {
+ node_i = branch_i->begin();
+ node_end = branch_i->end();
+ }
+
+
+ // loop over all current nodes
+ // get connection list for each node
+ // loop over each previous node in list
+ // get those nodes connection list
+ // intersect previous node connections with current
+
+ ++sp_i;
+ }
+
+ // insert any of the paths found into the master list of paths
+
+ // add no paths if tmp_pathz is empty...
+ }
+}
+
+void Nway_Paths::refine()
+{
+}
+
+void Nway_Paths::print()
+{
+ list<list<int> >::iterator pathz_i;
+
+ cout << "printing list of lists\n";
+ for (pathz_i = pathz.begin(); pathz_i != pathz.end(); ++pathz_i)
+ {
+ for (path_i = pathz_i->begin(); path_i != pathz_i->end(); ++path_i)
+ cout << *path_i << " ";
+ cout << endl;
+ }
+}
+*/
+
+
+
+
#include "flp.hh"
-
class Nway_Paths
{
friend class ConnView;
std::list<std::vector<int> > pathz;
std::list<std::vector<int> > refined_pathz;
-
-
public:
Nway_Paths();
void setup(int sp_num, int w, int t);
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-
-#include "mussa_nway.hh"
-#include <math.h>
-#include <iostream>
-using namespace std;
-
-// vars that will be availble to entropy function when in its nway class
-//vector<char *> c_sequences;
-//int window = 5, seq_num;
-
-
-void
-Nway_Paths::setup_ent(double new_entropy_thres, vector<string> some_Seqs)
-{
- int i;
-
- ent_thres = new_entropy_thres;
-
- c_sequences.clear();
- for (i = 0; i < species_num; i++)
- c_sequences.push_back((char *)some_Seqs[i].c_str());
-}
-
-
-double
-Nway_Paths::path_entropy(vector<int> path)
-{
- int bp_occurences[5];
- double bp_prob, frac_ent, avg_entropy;
- vector<double> entropies;
- int i, seq_i, i2;
- int window = win_size;
- int seq_num = species_num;
-
-
- for(i = 0; i < window; i++) // loop thru all bp positions
- {
- for(i2 = 0; i2 < 5; i2++) // clear old occurences
- bp_occurences[i2] = 0;
-
- for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
- if (path[seq_i] > -1)
- switch (c_sequences[seq_i][i+path[seq_i]])
- {
- case 'A':
- ++bp_occurences[0];
- break;
- case 'T':
- ++bp_occurences[1];
- break;
- case 'G':
- ++bp_occurences[2];
- break;
- case 'C':
- ++bp_occurences[3];
- break;
- case 'N':
- ++bp_occurences[4];
- break;
- default:
- cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
- cout << i+path[seq_i] << endl;
- }
- else
- switch (c_sequences[seq_i][-1 * (i + path[seq_i] - window + 1) ])
- {
- case 'A':
- ++bp_occurences[1];
- break;
- case 'T':
- ++bp_occurences[0];
- break;
- case 'G':
- ++bp_occurences[3];
- break;
- case 'C':
- ++bp_occurences[2];
- break;
- case 'N':
- ++bp_occurences[4];
- break;
- default:
- cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
- cout << (i + path[seq_i] - window + 1) << endl;
- }
-
-
- entropies.push_back(0.000);
- for(i2 = 0; i2 < 5; i2++) //calculate entropies
- {
- bp_prob = (double) bp_occurences[i2] / (double) seq_num;
- //cout << bp_prob << "::";
- if (bp_prob == 0.0000)
- frac_ent = 0.0000;
- else
- frac_ent = bp_prob * ( log10(bp_prob) / log10(2.0) );
- //cout << frac_ent << " ";
- entropies[i] += frac_ent;
- }
- //cout << endl;
- }
-
- avg_entropy = 0;
- for(i = 0; i < window; i++)
- {
- avg_entropy += entropies[i];
- //cout << entropies[i] << endl;
- }
-
- avg_entropy = -1.00 * (avg_entropy / (double) window);
- //cout << "average entropy: " << avg_entropy << endl;
- return avg_entropy;
-}
-
-
-
-
-
-void
-Nway_Paths::entropy_path_search(vector<vector<FLPs> > all_comparisons)
-{
- vector<int> path;
- double avg_entropy;
- int win_i, sp_i, sp_depth, window_num, i, cur_node;
- bool some_matches, still_paths, not_advanced, trans_good;
- list<int> new_nodes, trans_check_nodes;
- vector<list<int> > all_matches;
- vector<list<int>::iterator> sp_nodes, sp_nodes_end;
- list<int>::iterator debug_i;
-
-
- pathz.clear();
- window_num = all_comparisons[0][1].win_num();
- cout << window_num << endl; // just a sanity check
-
- sp_nodes.reserve(species_num);
- sp_nodes_end.reserve(species_num);
-
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- // first we see if the first seq has matches to all other seqs at this win
- some_matches = true;
- sp_i = 1;
- all_matches.clear();
- while ( (sp_i < species_num) && (some_matches) )
- {
- new_nodes.clear();
- new_nodes = all_comparisons[0][sp_i].matches(win_i);
- if (new_nodes.empty())
- some_matches = false;
-
- all_matches.push_back(new_nodes);
- sp_i++;
- }
- //cout << "fee\n";
-
- // if 1st seq does match to all others, make all possible paths
- // out of all these matches
- if (some_matches)
- {
- sp_nodes.clear();
- sp_nodes_end.clear();
- // set each species list of matches to beginning
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- sp_nodes.push_back(all_matches[sp_i].begin());
- sp_nodes_end.push_back(all_matches[sp_i].end());
- }
-
- still_paths = true;
- //cout << "fie\n";
- while (still_paths)
- {
- // add path that each species iterator is pointing to
- path.clear();
- path.push_back(win_i);
-
- //cout << win_i;
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- //cout << ", " << *(sp_nodes[sp_i]);
- path.push_back(*(sp_nodes[sp_i]));
- }
- //cout << endl;
-
- // check entropy <---------------------------------------------------
- avg_entropy = path_entropy(path);
- if (avg_entropy <= ent_thres)
- pathz.push_back(path);
-
- // now advance the right iterator
- not_advanced = true;
- sp_depth = species_num - 2; // this roves up & down species list
- while ( (not_advanced) && (sp_depth != -1) )
- {
- //cout << "foe\n";
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
- (sp_nodes[sp_depth])++; // advance iter at current depth
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
-
- // if we reached the end of the list, reset iter & go up one depth
- if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
- {
- //cout << "fum\n";
- sp_nodes[sp_depth] = all_matches[sp_depth].begin();
- sp_depth--;
- //cout << "depth = " << sp_depth << endl;
- }
- else
- not_advanced = false;
- }
-
- if (sp_depth == -1) // jumped up to first species, all paths searched
- still_paths = false;
- else // otherwise just reset to max depth and continue
- sp_depth = species_num - 2;
- }
- }
- }
-}
-
-
-//initial coding testing
-/*
-int main(int argc, char **argv)
-{
- vector<string> sequences;
- vector<int> i_starts;
- double avg_entropy;
- int seq_i;
-
- sequences.clear();
- sequences.push_back("AAAAA");
- sequences.push_back("AAAAT");
- sequences.push_back("AATTG");
- sequences.push_back("ATTGC");
-
- seq_num = 4;
-
- c_sequences.clear();
- i_starts.clear();
- for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
- {
- c_sequences.push_back((char *)sequences[seq_i].c_str());
- i_starts.push_back(0);
- }
-
- avg_entropy = Window_Entropy(i_starts);
-
- cout << "average entropy: " << avg_entropy << endl;
-}
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+
+#include "mussa_nway.hh"
+#include <math.h>
+#include <iostream>
+using namespace std;
+
+// vars that will be availble to entropy function when in its nway class
+//vector<char *> c_sequences;
+//int window = 5, seq_num;
+
+
+void
+Nway_Paths::setup_ent(double new_entropy_thres, vector<string> some_Seqs)
+{
+ int i;
+
+ ent_thres = new_entropy_thres;
+
+ c_sequences.clear();
+ for (i = 0; i < species_num; i++)
+ c_sequences.push_back((char *)some_Seqs[i].c_str());
+}
+
+
+double
+Nway_Paths::path_entropy(vector<int> path)
+{
+ int bp_occurences[5];
+ double bp_prob, frac_ent, avg_entropy;
+ vector<double> entropies;
+ int i, seq_i, i2;
+ int window = win_size;
+ int seq_num = species_num;
+
+
+ for(i = 0; i < window; i++) // loop thru all bp positions
+ {
+ for(i2 = 0; i2 < 5; i2++) // clear old occurences
+ bp_occurences[i2] = 0;
+
+ for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
+ if (path[seq_i] > -1)
+ switch (c_sequences[seq_i][i+path[seq_i]])
+ {
+ case 'A':
+ ++bp_occurences[0];
+ break;
+ case 'T':
+ ++bp_occurences[1];
+ break;
+ case 'G':
+ ++bp_occurences[2];
+ break;
+ case 'C':
+ ++bp_occurences[3];
+ break;
+ case 'N':
+ ++bp_occurences[4];
+ break;
+ default:
+ cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
+ cout << i+path[seq_i] << endl;
+ }
+ else
+ switch (c_sequences[seq_i][-1 * (i + path[seq_i] - window + 1) ])
+ {
+ case 'A':
+ ++bp_occurences[1];
+ break;
+ case 'T':
+ ++bp_occurences[0];
+ break;
+ case 'G':
+ ++bp_occurences[3];
+ break;
+ case 'C':
+ ++bp_occurences[2];
+ break;
+ case 'N':
+ ++bp_occurences[4];
+ break;
+ default:
+ cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
+ cout << (i + path[seq_i] - window + 1) << endl;
+ }
+
+
+ entropies.push_back(0.000);
+ for(i2 = 0; i2 < 5; i2++) //calculate entropies
+ {
+ bp_prob = (double) bp_occurences[i2] / (double) seq_num;
+ //cout << bp_prob << "::";
+ if (bp_prob == 0.0000)
+ frac_ent = 0.0000;
+ else
+ frac_ent = bp_prob * ( log10(bp_prob) / log10(2.0) );
+ //cout << frac_ent << " ";
+ entropies[i] += frac_ent;
+ }
+ //cout << endl;
+ }
+
+ avg_entropy = 0;
+ for(i = 0; i < window; i++)
+ {
+ avg_entropy += entropies[i];
+ //cout << entropies[i] << endl;
+ }
+
+ avg_entropy = -1.00 * (avg_entropy / (double) window);
+ //cout << "average entropy: " << avg_entropy << endl;
+ return avg_entropy;
+}
+
+
+
+
+
+void
+Nway_Paths::entropy_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ double avg_entropy;
+ int win_i, sp_i, sp_depth, window_num, i, cur_node;
+ bool some_matches, still_paths, not_advanced, trans_good;
+ list<int> new_nodes, trans_check_nodes;
+ vector<list<int> > all_matches;
+ vector<list<int>::iterator> sp_nodes, sp_nodes_end;
+ list<int>::iterator debug_i;
+
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl; // just a sanity check
+
+ sp_nodes.reserve(species_num);
+ sp_nodes_end.reserve(species_num);
+
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // first we see if the first seq has matches to all other seqs at this win
+ some_matches = true;
+ sp_i = 1;
+ all_matches.clear();
+ while ( (sp_i < species_num) && (some_matches) )
+ {
+ new_nodes.clear();
+ new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ if (new_nodes.empty())
+ some_matches = false;
+
+ all_matches.push_back(new_nodes);
+ sp_i++;
+ }
+ //cout << "fee\n";
+
+ // if 1st seq does match to all others, make all possible paths
+ // out of all these matches
+ if (some_matches)
+ {
+ sp_nodes.clear();
+ sp_nodes_end.clear();
+ // set each species list of matches to beginning
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ sp_nodes.push_back(all_matches[sp_i].begin());
+ sp_nodes_end.push_back(all_matches[sp_i].end());
+ }
+
+ still_paths = true;
+ //cout << "fie\n";
+ while (still_paths)
+ {
+ // add path that each species iterator is pointing to
+ path.clear();
+ path.push_back(win_i);
+
+ //cout << win_i;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ //cout << ", " << *(sp_nodes[sp_i]);
+ path.push_back(*(sp_nodes[sp_i]));
+ }
+ //cout << endl;
+
+ // check entropy <---------------------------------------------------
+ avg_entropy = path_entropy(path);
+ if (avg_entropy <= ent_thres)
+ pathz.push_back(path);
+
+ // now advance the right iterator
+ not_advanced = true;
+ sp_depth = species_num - 2; // this roves up & down species list
+ while ( (not_advanced) && (sp_depth != -1) )
+ {
+ //cout << "foe\n";
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+ (sp_nodes[sp_depth])++; // advance iter at current depth
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+
+ // if we reached the end of the list, reset iter & go up one depth
+ if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
+ {
+ //cout << "fum\n";
+ sp_nodes[sp_depth] = all_matches[sp_depth].begin();
+ sp_depth--;
+ //cout << "depth = " << sp_depth << endl;
+ }
+ else
+ not_advanced = false;
+ }
+
+ if (sp_depth == -1) // jumped up to first species, all paths searched
+ still_paths = false;
+ else // otherwise just reset to max depth and continue
+ sp_depth = species_num - 2;
+ }
+ }
+ }
+}
+
+
+//initial coding testing
+/*
+int main(int argc, char **argv)
+{
+ vector<string> sequences;
+ vector<int> i_starts;
+ double avg_entropy;
+ int seq_i;
+
+ sequences.clear();
+ sequences.push_back("AAAAA");
+ sequences.push_back("AAAAT");
+ sequences.push_back("AATTG");
+ sequences.push_back("ATTGC");
+
+ seq_num = 4;
+
+ c_sequences.clear();
+ i_starts.clear();
+ for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
+ {
+ c_sequences.push_back((char *)sequences[seq_i].c_str());
+ i_starts.push_back(0);
+ }
+
+ avg_entropy = Window_Entropy(i_starts);
+
+ cout << "average entropy: " << avg_entropy << endl;
+}
+*/
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "mussa_nway.hh"
-#include <iostream>
-
-using namespace std;
-
-void
-Nway_Paths::radiate_path_search(vector<vector<FLPs> > all_comparisons)
-{
- vector<int> path;
- int win_i, sp_i, sp_depth, window_num;
- bool some_matches, still_paths, not_advanced;
- list<int> new_nodes;
- vector<list<int> > all_matches;
- vector<list<int>::iterator> sp_nodes, sp_nodes_end;
- list<int>::iterator debug_i;
-
- pathz.clear();
- window_num = all_comparisons[0][1].win_num();
- cout << window_num << endl; // just a sanity check
-
- sp_nodes.reserve(species_num);
- sp_nodes_end.reserve(species_num);
-
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- // first we see if the first seq has matches to all other seqs at this win
- some_matches = true;
- sp_i = 1;
- all_matches.clear();
- while ( (sp_i < species_num) && (some_matches) )
- {
- new_nodes.clear();
- new_nodes = all_comparisons[0][sp_i].matches(win_i);
- if (new_nodes.empty())
- some_matches = false;
-
- all_matches.push_back(new_nodes);
- sp_i++;
- }
- //cout << "fee\n";
- /*
- if (some_matches)
- {
- cout << win_i << " plrf" << endl;
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- debug_i = all_matches[sp_i].begin();
- while (debug_i != all_matches[sp_i].end())
- {
- cout << *debug_i << " ";
- debug_i++;
- }
- cout << "plrfff"<< endl;
- }
- }
- */
- // if 1st seq does match to all others, make all possible paths
- // out of all these matches
- if (some_matches)
- {
- sp_nodes.clear();
- sp_nodes_end.clear();
- // set each species list of matches to beginning
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- sp_nodes.push_back(all_matches[sp_i].begin());
- sp_nodes_end.push_back(all_matches[sp_i].end());
- }
-
- still_paths = true;
- sp_depth = species_num - 2; // this roves up & down species list
- //cout << "fie\n";
- while (still_paths)
- {
- // add path that each species iterator is pointing to
- path.clear();
- path.push_back(win_i);
-
- //cout << win_i;
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- //cout << ", " << *(sp_nodes[sp_i]);
- path.push_back(*(sp_nodes[sp_i]));
- }
- //cout << endl;
-
- pathz.push_back(path);
-
- // now advance the right iterator
- not_advanced = true;
- while ( (not_advanced) && (sp_depth != -1) )
- {
- //cout << "foe\n";
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
- (sp_nodes[sp_depth])++; // advance iter at current depth
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
-
- // if we reached the end of the list, reset iter & go up one depth
- if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
- {
- //cout << "fum\n";
- sp_nodes[sp_depth] = all_matches[sp_depth].begin();
- sp_depth--;
- //cout << "depth = " << sp_depth << endl;
- }
- else
- not_advanced = false;
- }
-
- if (sp_depth == -1) // jumped up to first species, all paths searched
- still_paths = false;
- else // otherwise just reset to max depth and continue
- sp_depth = species_num - 2;
- }
- }
- }
-}
-
-
-
-
-void
-Nway_Paths::trans_path_search(vector<vector<FLPs> > all_comparisons)
-{
- vector<int> path;
- int win_i, sp_i, sp_depth, window_num, i, cur_node;
- bool some_matches, still_paths, not_advanced, trans_good;
- list<int> new_nodes, trans_check_nodes;
- vector<list<int> > all_matches;
- vector<list<int>::iterator> sp_nodes, sp_nodes_end;
- list<int>::iterator debug_i;
-
- cout << "trans: softhres = " << soft_thres;
- cout << ", window = " << win_size << ", ";
-
- pathz.clear();
- window_num = all_comparisons[0][1].win_num();
- cout << "window number = " << window_num << endl; // just a sanity check
- cout << "trans: species_num = " << species_num << endl;
- sp_nodes.reserve(species_num);
- cout << "trans: fie\n";
- sp_nodes_end.reserve(species_num);
- cout << "trans: foe\n";
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- // first we see if the first seq has matches to all other seqs at this win
- some_matches = true;
- sp_i = 1;
- all_matches.clear();
- while ( (sp_i < species_num) && (some_matches) )
- {
- new_nodes.clear();
- // --thres
- //new_nodes = all_comparisons[0][sp_i].matches(win_i);
- new_nodes = all_comparisons[0][sp_i].thres_matches(win_i, soft_thres);
- if (new_nodes.empty())
- some_matches = false;
-
- all_matches.push_back(new_nodes);
- sp_i++;
- }
- //cout << "fee\n";
- /*
- if (some_matches)
- {
- cout << win_i << " plrf" << endl;
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- debug_i = all_matches[sp_i].begin();
- while (debug_i != all_matches[sp_i].end())
- {
- cout << *debug_i << " ";
- debug_i++;
- }
- cout << "plrfff"<< endl;
- }
- }
- */
- // if 1st seq does match to all others, make all possible paths
- // out of all these matches
- if (some_matches)
- {
- sp_nodes.clear();
- sp_nodes_end.clear();
- // set each species list of matches to beginning
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- sp_nodes.push_back(all_matches[sp_i].begin());
- sp_nodes_end.push_back(all_matches[sp_i].end());
- }
-
- still_paths = true;
- //cout << "fie\n";
- while (still_paths)
- {
- // add path that each species iterator is pointing to
- path.clear();
- path.push_back(win_i);
-
- //cout << win_i;
- for (sp_i = 0; sp_i < species_num-1; sp_i++)
- {
- //cout << ", " << *(sp_nodes[sp_i]);
- path.push_back(*(sp_nodes[sp_i]));
- }
- //cout << endl;
-
- // check transitivity
- sp_depth = 1;
- trans_good = true;
- while ( (sp_depth != species_num-1) && (trans_good) )
- {
- cur_node = path[sp_depth];
- for(i = sp_depth+1; i < species_num; i++)
- {
- // --thres
- //trans_check_nodes = all_comparisons[sp_depth][i].matches(cur_node);
- trans_check_nodes =
- all_comparisons[sp_depth][i].thres_matches(cur_node, soft_thres);
-
- if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
- trans_check_nodes.end(),
- path[i]) ) &&
- (trans_check_nodes.end() == find(trans_check_nodes.begin(),
- trans_check_nodes.end(),
- path[i] * -1) ) )
- trans_good = false;
- }
-
- sp_depth++;
- }
-
- if (trans_good)
- pathz.push_back(path);
-
- // now advance the right iterator
- not_advanced = true;
- sp_depth = species_num - 2; // this roves up & down species list
- while ( (not_advanced) && (sp_depth != -1) )
- {
- //cout << "foe\n";
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
- (sp_nodes[sp_depth])++; // advance iter at current depth
- //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
-
- // if we reached the end of the list, reset iter & go up one depth
- if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
- {
- //cout << "fum\n";
- sp_nodes[sp_depth] = all_matches[sp_depth].begin();
- sp_depth--;
- //cout << "depth = " << sp_depth << endl;
- }
- else
- not_advanced = false;
- }
-
- if (sp_depth == -1) // jumped up to first species, all paths searched
- still_paths = false;
- else // otherwise just reset to max depth and continue
- sp_depth = species_num - 2;
- }
- }
- }
-}
-
-
-
-
-/*
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- path.clear();
- path.push_back(win_i);
- cur_nodes = all_comparisons[0][1].matches(path[0]);
- cur_nodes_i = cur_nodes.begin();
- cur_nodes_end = cur_nodes.end();
- path.push_back(0);
- for (sp_i = 2; sp_i < species_num; sp_i++)
- {
- new_nodes = all_comparisons[0][sp_i].matches(path[0]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
-
- while(cur_nodes_i != cur_nodes_end)
- {
- intersect_bad = false;
- if ( (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
- *cur_nodes_i) ) &&
- (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
- *cur_nodes_i * -1) ) )
- intersect_bad = true;
-
- // if no matches to this sequence, we don't need to check this node
- // against any of the remaining ones
- if (intersect_bad)
- cur_nodes_i = cur_nodes.erase(cur_nodes_i); // this advances the iter
- else
- ++cur_nodes_i; // just advance normally
-
- }
- }
-
- }
-*/
-
-
-/*
- while(new_nodes_i != new_nodes_end)
-
-
- path[1] = *new_nodes_i;
- path_search(all_comparisons, path, 2);
-
-*/
- //if (new_nodes_i != new_nodes_end)
- //cout << "* species 0 node: " << win_i << endl;
- // cout << "foookin hell\n";
-
- //cout << " * species 1 node: " << *new_nodes_i << endl;
-
- //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
- // check transitivity with previous nodes in path
-
-/*
-void
-Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth)
-{
- list<int> new_nodes, trans_check_nodes;
- list<int>::iterator new_nodes_i, new_nodes_end;
- int i;
-
- new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
-
- if (trans_check_good)
- {
- // this makes sure path nodes are recorded with RC status relative to
- // the base species
- if ( path[depth-1] >= 0)
- path.push_back(*new_nodes_i);
- else
- path.push_back(*new_nodes_i * -1);
-
- if (depth < species_num - 1)
- path_search(all_comparisons, path, depth + 1);
- else
- pathz.push_back(path);
- path.pop_back();
- }
- ++new_nodes_i;
- }
-}
-*/
-// cout << " ****I have the power...\n";
-
-/* use this if I ever get the friggin seqcomp match lists to sort...
- if (binary_search(trans_check_nodes.begin(), trans_check_nodes.end(),
- *new_nodes_i))
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "mussa_nway.hh"
+#include <iostream>
+
+using namespace std;
+
+void
+Nway_Paths::radiate_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, sp_i, sp_depth, window_num;
+ bool some_matches, still_paths, not_advanced;
+ list<int> new_nodes;
+ vector<list<int> > all_matches;
+ vector<list<int>::iterator> sp_nodes, sp_nodes_end;
+ list<int>::iterator debug_i;
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl; // just a sanity check
+
+ sp_nodes.reserve(species_num);
+ sp_nodes_end.reserve(species_num);
+
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // first we see if the first seq has matches to all other seqs at this win
+ some_matches = true;
+ sp_i = 1;
+ all_matches.clear();
+ while ( (sp_i < species_num) && (some_matches) )
+ {
+ new_nodes.clear();
+ new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ if (new_nodes.empty())
+ some_matches = false;
+
+ all_matches.push_back(new_nodes);
+ sp_i++;
+ }
+ //cout << "fee\n";
+ /*
+ if (some_matches)
+ {
+ cout << win_i << " plrf" << endl;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ debug_i = all_matches[sp_i].begin();
+ while (debug_i != all_matches[sp_i].end())
+ {
+ cout << *debug_i << " ";
+ debug_i++;
+ }
+ cout << "plrfff"<< endl;
+ }
+ }
+ */
+ // if 1st seq does match to all others, make all possible paths
+ // out of all these matches
+ if (some_matches)
+ {
+ sp_nodes.clear();
+ sp_nodes_end.clear();
+ // set each species list of matches to beginning
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ sp_nodes.push_back(all_matches[sp_i].begin());
+ sp_nodes_end.push_back(all_matches[sp_i].end());
+ }
+
+ still_paths = true;
+ sp_depth = species_num - 2; // this roves up & down species list
+ //cout << "fie\n";
+ while (still_paths)
+ {
+ // add path that each species iterator is pointing to
+ path.clear();
+ path.push_back(win_i);
+
+ //cout << win_i;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ //cout << ", " << *(sp_nodes[sp_i]);
+ path.push_back(*(sp_nodes[sp_i]));
+ }
+ //cout << endl;
+
+ pathz.push_back(path);
+
+ // now advance the right iterator
+ not_advanced = true;
+ while ( (not_advanced) && (sp_depth != -1) )
+ {
+ //cout << "foe\n";
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+ (sp_nodes[sp_depth])++; // advance iter at current depth
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+
+ // if we reached the end of the list, reset iter & go up one depth
+ if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
+ {
+ //cout << "fum\n";
+ sp_nodes[sp_depth] = all_matches[sp_depth].begin();
+ sp_depth--;
+ //cout << "depth = " << sp_depth << endl;
+ }
+ else
+ not_advanced = false;
+ }
+
+ if (sp_depth == -1) // jumped up to first species, all paths searched
+ still_paths = false;
+ else // otherwise just reset to max depth and continue
+ sp_depth = species_num - 2;
+ }
+ }
+ }
+}
+
+
+
+
+void
+Nway_Paths::trans_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, sp_i, sp_depth, window_num, i, cur_node;
+ bool some_matches, still_paths, not_advanced, trans_good;
+ list<int> new_nodes, trans_check_nodes;
+ vector<list<int> > all_matches;
+ vector<list<int>::iterator> sp_nodes, sp_nodes_end;
+ list<int>::iterator debug_i;
+
+ cout << "trans: softhres = " << soft_thres;
+ cout << ", window = " << win_size << ", ";
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << "window number = " << window_num << endl; // just a sanity check
+ cout << "trans: species_num = " << species_num << endl;
+ sp_nodes.reserve(species_num);
+ cout << "trans: fie\n";
+ sp_nodes_end.reserve(species_num);
+ cout << "trans: foe\n";
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // first we see if the first seq has matches to all other seqs at this win
+ some_matches = true;
+ sp_i = 1;
+ all_matches.clear();
+ while ( (sp_i < species_num) && (some_matches) )
+ {
+ new_nodes.clear();
+ // --thres
+ //new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ new_nodes = all_comparisons[0][sp_i].thres_matches(win_i, soft_thres);
+ if (new_nodes.empty())
+ some_matches = false;
+
+ all_matches.push_back(new_nodes);
+ sp_i++;
+ }
+ //cout << "fee\n";
+ /*
+ if (some_matches)
+ {
+ cout << win_i << " plrf" << endl;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ debug_i = all_matches[sp_i].begin();
+ while (debug_i != all_matches[sp_i].end())
+ {
+ cout << *debug_i << " ";
+ debug_i++;
+ }
+ cout << "plrfff"<< endl;
+ }
+ }
+ */
+ // if 1st seq does match to all others, make all possible paths
+ // out of all these matches
+ if (some_matches)
+ {
+ sp_nodes.clear();
+ sp_nodes_end.clear();
+ // set each species list of matches to beginning
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ sp_nodes.push_back(all_matches[sp_i].begin());
+ sp_nodes_end.push_back(all_matches[sp_i].end());
+ }
+
+ still_paths = true;
+ //cout << "fie\n";
+ while (still_paths)
+ {
+ // add path that each species iterator is pointing to
+ path.clear();
+ path.push_back(win_i);
+
+ //cout << win_i;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ //cout << ", " << *(sp_nodes[sp_i]);
+ path.push_back(*(sp_nodes[sp_i]));
+ }
+ //cout << endl;
+
+ // check transitivity
+ sp_depth = 1;
+ trans_good = true;
+ while ( (sp_depth != species_num-1) && (trans_good) )
+ {
+ cur_node = path[sp_depth];
+ for(i = sp_depth+1; i < species_num; i++)
+ {
+ // --thres
+ //trans_check_nodes = all_comparisons[sp_depth][i].matches(cur_node);
+ trans_check_nodes =
+ all_comparisons[sp_depth][i].thres_matches(cur_node, soft_thres);
+
+ if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ path[i]) ) &&
+ (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ path[i] * -1) ) )
+ trans_good = false;
+ }
+
+ sp_depth++;
+ }
+
+ if (trans_good)
+ pathz.push_back(path);
+
+ // now advance the right iterator
+ not_advanced = true;
+ sp_depth = species_num - 2; // this roves up & down species list
+ while ( (not_advanced) && (sp_depth != -1) )
+ {
+ //cout << "foe\n";
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+ (sp_nodes[sp_depth])++; // advance iter at current depth
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+
+ // if we reached the end of the list, reset iter & go up one depth
+ if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
+ {
+ //cout << "fum\n";
+ sp_nodes[sp_depth] = all_matches[sp_depth].begin();
+ sp_depth--;
+ //cout << "depth = " << sp_depth << endl;
+ }
+ else
+ not_advanced = false;
+ }
+
+ if (sp_depth == -1) // jumped up to first species, all paths searched
+ still_paths = false;
+ else // otherwise just reset to max depth and continue
+ sp_depth = species_num - 2;
+ }
+ }
+ }
+}
+
+
+
+
+/*
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ path.clear();
+ path.push_back(win_i);
+ cur_nodes = all_comparisons[0][1].matches(path[0]);
+ cur_nodes_i = cur_nodes.begin();
+ cur_nodes_end = cur_nodes.end();
+ path.push_back(0);
+ for (sp_i = 2; sp_i < species_num; sp_i++)
+ {
+ new_nodes = all_comparisons[0][sp_i].matches(path[0]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+
+ while(cur_nodes_i != cur_nodes_end)
+ {
+ intersect_bad = false;
+ if ( (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
+ *cur_nodes_i) ) &&
+ (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
+ *cur_nodes_i * -1) ) )
+ intersect_bad = true;
+
+ // if no matches to this sequence, we don't need to check this node
+ // against any of the remaining ones
+ if (intersect_bad)
+ cur_nodes_i = cur_nodes.erase(cur_nodes_i); // this advances the iter
+ else
+ ++cur_nodes_i; // just advance normally
+
+ }
+ }
+
+ }
+*/
+
+
+/*
+ while(new_nodes_i != new_nodes_end)
+
+
+ path[1] = *new_nodes_i;
+ path_search(all_comparisons, path, 2);
+
+*/
+ //if (new_nodes_i != new_nodes_end)
+ //cout << "* species 0 node: " << win_i << endl;
+ // cout << "foookin hell\n";
+
+ //cout << " * species 1 node: " << *new_nodes_i << endl;
+
+ //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
+ // check transitivity with previous nodes in path
+
+/*
+void
+Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth)
+{
+ list<int> new_nodes, trans_check_nodes;
+ list<int>::iterator new_nodes_i, new_nodes_end;
+ int i;
+
+ new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+
+ if (trans_check_good)
+ {
+ // this makes sure path nodes are recorded with RC status relative to
+ // the base species
+ if ( path[depth-1] >= 0)
+ path.push_back(*new_nodes_i);
+ else
+ path.push_back(*new_nodes_i * -1);
+
+ if (depth < species_num - 1)
+ path_search(all_comparisons, path, depth + 1);
+ else
+ pathz.push_back(path);
+ path.pop_back();
+ }
+ ++new_nodes_i;
+ }
+}
+*/
+// cout << " ****I have the power...\n";
+
+/* use this if I ever get the friggin seqcomp match lists to sort...
+ if (binary_search(trans_check_nodes.begin(), trans_check_nodes.end(),
+ *new_nodes_i))
+*/
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-PathList
-ExtendPathWindows(PathList raw_list)
-{
- // to keep track of everything, this function acts like a finite state
- // automata: 3 bitfields: reset, extending, scanning - ie 8 states
- int reset = 0, extending = 0, scanning = 0;
-
- int species_num = raw_list.SpeciesNum();
- int win_num = raw_list.WinNum();
-
- int *cur_path, *next_path;
-
- cur_path = new int[species_num];
- next_path = new int[species_num];
-
- raw_list.ResetIndex();
-
- while (no more windows avaible)
- {
- //cur_indices[0] + ref_ext == next_indices[0] + 1:
-
- // state 000 - start/nominal search
- //
- if !reset && !extending && !scanning
- {
- if cur_path[0] == next_path[0]
- {
- scanning = 1; // go to state 001
- raw_list.IncreIndex();
- }
- else if cur_path[0] + 1 == next_path[0]
- {
- extending = 1; // go to state 010
- win_ext = 1;
- raw_list.SetDirty();
- raw_list.IncreIndex();
- }
- else
- reset = 1; // go to state 100
- }
-
- // state 001 - scanning for ext window thru possible interleaving
- //
- else if !reset && !extending && scanning
- {
- if cur_path[0] == next_path[0]
- raw_list.IncreIndex();
- else if cur_path[0] + 1 == next_path[0]
- {
- extending = 1; // go to state 011
- win_ext = 1;
- raw_list.SetDirty();
- raw_list.IncreIndex();
- }
- else
- reset = 1; // go to state 101
- }
-
- // state 010 - extending window with no interleaving
- //
- else if !reset && extending && !scanning
- {
- if (cur_path[0] + win_ext) == next_path[0]
- {
- extending = 1; // go to state 011
- raw_list.IncreIndex();
- }
- else if (cur_path[0] + win_ext + 1) == next_path[0]
- {
- win_ext++;
- raw_list.SetDirty();
- raw_list.IncreIndex();
- }
- else
- reset = 1; // go to state 110
- }
-
- // state 011 - extending window with interleaving
- //
- else if !reset && extending && scanning
- {
- if (cur_path[0] + win_ext) == next_path[0]
- raw_list.IncreIndex();
- else if (cur_path[0] + win_ext + 1) == next_path[0]
- {
- win_ext++;
- raw_list.SetDirty();
- raw_list.IncreIndex();
- }
- else
- reset = 1; // go to state 111
- }
-
-
- // reset condition states, return to 000 after taking appropiate action
-
- // state 100 - no extended window, no scanning happened
- // save basic window to extended window list
- if reset && !extending && !scanning
- {
- // return to start/nominal search state
- reset = 0;
- }
-
- // state 101 - no extended window, scanned for interleaving
- // save basic window to extended window list, return to first clean
- else if reset && !extending && scanning
- {
- // return to start/nominal search state
- reset = 0;
- scanning = 0;
- }
-
- // state 110 - extended window, no interleaving
- // calc extended window, save to extended window list
- else if reset && extending && !scanning
- {
- // return to start/nominal search state
- reset = 0;
- extending = 0;
- }
-
- // state 111 - extended window, interleaved
- // calc extended window, save to ext win list, return to first clean
- else if reset && extending && scanning
- {
- // return to start/nominal search state
- reset = 0;
- extending = 0;
- scanning = 0;
- }
-
- return ext_win;
-}
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+PathList
+ExtendPathWindows(PathList raw_list)
+{
+ // to keep track of everything, this function acts like a finite state
+ // automata: 3 bitfields: reset, extending, scanning - ie 8 states
+ int reset = 0, extending = 0, scanning = 0;
+
+ int species_num = raw_list.SpeciesNum();
+ int win_num = raw_list.WinNum();
+
+ int *cur_path, *next_path;
+
+ cur_path = new int[species_num];
+ next_path = new int[species_num];
+
+ raw_list.ResetIndex();
+
+ while (no more windows avaible)
+ {
+ //cur_indices[0] + ref_ext == next_indices[0] + 1:
+
+ // state 000 - start/nominal search
+ //
+ if !reset && !extending && !scanning
+ {
+ if cur_path[0] == next_path[0]
+ {
+ scanning = 1; // go to state 001
+ raw_list.IncreIndex();
+ }
+ else if cur_path[0] + 1 == next_path[0]
+ {
+ extending = 1; // go to state 010
+ win_ext = 1;
+ raw_list.SetDirty();
+ raw_list.IncreIndex();
+ }
+ else
+ reset = 1; // go to state 100
+ }
+
+ // state 001 - scanning for ext window thru possible interleaving
+ //
+ else if !reset && !extending && scanning
+ {
+ if cur_path[0] == next_path[0]
+ raw_list.IncreIndex();
+ else if cur_path[0] + 1 == next_path[0]
+ {
+ extending = 1; // go to state 011
+ win_ext = 1;
+ raw_list.SetDirty();
+ raw_list.IncreIndex();
+ }
+ else
+ reset = 1; // go to state 101
+ }
+
+ // state 010 - extending window with no interleaving
+ //
+ else if !reset && extending && !scanning
+ {
+ if (cur_path[0] + win_ext) == next_path[0]
+ {
+ extending = 1; // go to state 011
+ raw_list.IncreIndex();
+ }
+ else if (cur_path[0] + win_ext + 1) == next_path[0]
+ {
+ win_ext++;
+ raw_list.SetDirty();
+ raw_list.IncreIndex();
+ }
+ else
+ reset = 1; // go to state 110
+ }
+
+ // state 011 - extending window with interleaving
+ //
+ else if !reset && extending && scanning
+ {
+ if (cur_path[0] + win_ext) == next_path[0]
+ raw_list.IncreIndex();
+ else if (cur_path[0] + win_ext + 1) == next_path[0]
+ {
+ win_ext++;
+ raw_list.SetDirty();
+ raw_list.IncreIndex();
+ }
+ else
+ reset = 1; // go to state 111
+ }
+
+
+ // reset condition states, return to 000 after taking appropiate action
+
+ // state 100 - no extended window, no scanning happened
+ // save basic window to extended window list
+ if reset && !extending && !scanning
+ {
+ // return to start/nominal search state
+ reset = 0;
+ }
+
+ // state 101 - no extended window, scanned for interleaving
+ // save basic window to extended window list, return to first clean
+ else if reset && !extending && scanning
+ {
+ // return to start/nominal search state
+ reset = 0;
+ scanning = 0;
+ }
+
+ // state 110 - extended window, no interleaving
+ // calc extended window, save to extended window list
+ else if reset && extending && !scanning
+ {
+ // return to start/nominal search state
+ reset = 0;
+ extending = 0;
+ }
+
+ // state 111 - extended window, interleaved
+ // calc extended window, save to ext win list, return to first clean
+ else if reset && extending && scanning
+ {
+ // return to start/nominal search state
+ reset = 0;
+ extending = 0;
+ scanning = 0;
+ }
+
+ return ext_win;
+}
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-#include "flp.hh"
-#include <time.h>
-#include <iomanip>
-
-int main(int argc, char **argv)
-{
- Sequence seqA, seqB;
- FLPs analysis;
- string seqA_file, seqB_file, output_file;
- string ana_type;
- int window, threshold;
- int seqA_len, seqB_len;
-
- time_t t1, t2, begin, end;
- double setuptime, comp1time, comp2time, sorttime, savetime, totaltime;
-
- begin = time(NULL);
-
- cout << "fee fie foe fum" << endl;
-
- ana_type = * ++argv;
- seqA_file = * ++argv;
- seqB_file = * ++argv;
- window = atoi(* ++argv);
- threshold = atoi(* ++argv);
- output_file = * ++argv;
-
- t1 = time(NULL);
-
- seqA.load_fasta(seqA_file, 1, 0, 0);
- seqA_len = seqA.len();
- //cout << setw(60) << seqA.hdr() << "\n";
-
- seqB.load_fasta(seqB_file, 1, 0, 0);
- seqB_len = seqB.len();
- //cout << seqB.hdr() << "\n";
-
-
- cout << "Length: Seq A = " << seqA_len;
- cout << "; Seq B = " << seqB_len << "\n";
-
- analysis.setup(ana_type, window, threshold, seqA_len, seqB_len);
-
- t2 = time(NULL);
- setuptime = difftime(t2, t1);
-
- t1 = time(NULL);
- analysis.seqcomp(seqA.seq(), seqB.seq(), false);
- t2 = time(NULL);
- comp1time = difftime(t2, t1);
-
- t1 = time(NULL);
- analysis.seqcomp(seqA.seq(), seqB.rev_comp(), true);
- t2 = time(NULL);
- comp2time = difftime(t2, t1);
- /*
- t1 = time(NULL);
- analysis.sort();
- t2 = time(NULL);
- sorttime = difftime(t2, t1);
- */
- t1 = time(NULL);
- analysis.file_save(output_file);
- t2 = time(NULL);
- savetime = difftime(t2, t1);
-
- end = time(NULL);
- totaltime = difftime(end, begin);
-
- cout << "setup\tcomp\trc_comp\tsave\ttotal\n";
- cout << setuptime << "\t";
- cout << comp1time << "\t";
- cout << comp2time << "\t";
- //cout << sorttime << "\t";
- cout << savetime << "\t";
- cout << totaltime << "\n";
-}
-
-/*
- cout << "fee\n";
- cout << "fie\n";
- cout << "foe ";
- cout << "fum\n";
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+#include "flp.hh"
+#include "sequence.hh"
+#include <time.h>
+#include <iomanip>
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+ Sequence seqA, seqB;
+ FLPs analysis;
+ string seqA_file, seqB_file, output_file;
+ string ana_type;
+ int window, threshold;
+ int seqA_len, seqB_len;
+
+ time_t t1, t2, begin, end;
+ double setuptime, comp1time, comp2time, sorttime, savetime, totaltime;
+
+ begin = time(NULL);
+
+ cout << "fee fie foe fum" << endl;
+
+ ana_type = * ++argv;
+ seqA_file = * ++argv;
+ seqB_file = * ++argv;
+ window = atoi(* ++argv);
+ threshold = atoi(* ++argv);
+ output_file = * ++argv;
+
+ t1 = time(NULL);
+
+ seqA.load_fasta(seqA_file, 1, 0, 0);
+ seqA_len = seqA.len();
+ //cout << setw(60) << seqA.hdr() << "\n";
+
+ seqB.load_fasta(seqB_file, 1, 0, 0);
+ seqB_len = seqB.len();
+ //cout << seqB.hdr() << "\n";
+
+
+ cout << "Length: Seq A = " << seqA_len;
+ cout << "; Seq B = " << seqB_len << "\n";
+
+ analysis.setup(ana_type, window, threshold, seqA_len, seqB_len);
+
+ t2 = time(NULL);
+ setuptime = difftime(t2, t1);
+
+ t1 = time(NULL);
+ analysis.seqcomp(seqA.seq(), seqB.seq(), false);
+ t2 = time(NULL);
+ comp1time = difftime(t2, t1);
+
+ t1 = time(NULL);
+ analysis.seqcomp(seqA.seq(), seqB.rev_comp(), true);
+ t2 = time(NULL);
+ comp2time = difftime(t2, t1);
+ /*
+ t1 = time(NULL);
+ analysis.sort();
+ t2 = time(NULL);
+ sorttime = difftime(t2, t1);
+ */
+ t1 = time(NULL);
+ analysis.file_save(output_file);
+ t2 = time(NULL);
+ savetime = difftime(t2, t1);
+
+ end = time(NULL);
+ totaltime = difftime(end, begin);
+
+ cout << "setup\tcomp\trc_comp\tsave\ttotal\n";
+ cout << setuptime << "\t";
+ cout << comp1time << "\t";
+ cout << comp2time << "\t";
+ //cout << sorttime << "\t";
+ cout << savetime << "\t";
+ cout << totaltime << "\n";
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe ";
+ cout << "fum\n";
+*/
+++ /dev/null
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// This file is part of the Mussa source distribution.
-// http://mussa.caltech.edu/
-// Contact author: Tristan De Buysscher, tristan@caltech.edu
-
-// This program and all associated source code files are Copyright (C) 2005
-// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
-// under the GNU Public License; please see the included LICENSE.txt
-// file for more information, or contact Tristan directly.
-
-
-// ----------------------------------------
-// ---------- sequence.cc -----------
-// ----------------------------------------
-
-#include "sequence.hh"
-#include <iostream>
-
-using namespace std;
-
-Sequence::Sequence()
-{
-}
-
-
-string
-Sequence::load_fasta(string file_path, int seq_num,
- int start_index, int end_index)
-{
- fstream data_file;
- string file_data_line;
- int header_counter = 0;
- bool read_seq = true;
- string rev_comp;
- char conversionTable[257];
- int seq_i, table_i, len;
- string sequence_raw;
- char * seq_tmp; // holds sequence during basic filtering
- string err_msg;
-
- data_file.open(file_path.c_str(), ios::in);
-
- if (!data_file)
- {
- err_msg = "Sequence File: " + file_path + " not found";
- return err_msg;
- }
- // if file opened okay, read it
- else
- {
- // search for the header of the fasta sequence we want
- while ( (!data_file.eof()) && (header_counter < seq_num) )
- {
- getline(data_file,file_data_line);
- if (file_data_line.substr(0,1) == ">")
- header_counter++;
- }
-
- header = file_data_line.substr(1);
-
- sequence_raw = "";
-
- while ( !data_file.eof() && read_seq )
- {
- getline(data_file,file_data_line);
- if (file_data_line.substr(0,1) == ">")
- read_seq = false;
- else sequence_raw += file_data_line;
- }
-
- data_file.close();
-
- // sequence filtering for upcasing agctn and convert non AGCTN to N
-
- len = sequence_raw.length();
- seq_tmp = (char*)sequence_raw.c_str();
-
- sequence = "";
-
- // Make a conversion table
-
- // everything we don't specify below will become 'N'
- for(table_i=0; table_i < 256; table_i++)
- {
- conversionTable[table_i] = 'N';
- }
- // add end of string character for printing out table for testing purposes
- conversionTable[256] = '\0';
-
- // we want these to map to themselves - ie not to change
- conversionTable['A'] = 'A';
- conversionTable['T'] = 'T';
- conversionTable['G'] = 'G';
- conversionTable['C'] = 'C';
- // this is to upcase
- conversionTable['a'] = 'A';
- conversionTable['t'] = 'T';
- conversionTable['g'] = 'G';
- conversionTable['c'] = 'C';
-
- // finally, the actual conversion loop
- for(seq_i = 0; seq_i < len; seq_i++)
- {
- table_i = (int) seq_tmp[seq_i];
- sequence += conversionTable[table_i];
- }
-
-
- // Lastly, if subselection of the sequence was specified we keep cut out
- // and only keep that part
-
- // end_index = 0 means no end was specified, so cut to the end
- if (end_index == 0)
- end_index = len;
-
- // start_index = 0 if no start was specified
- sequence = sequence.substr(start_index, end_index - start_index);
-
- return "";
- }
-}
-
-
- // this doesn't work properly under gcc 3.x ... it can't recognize toupper
- //transform(sequence.begin(), sequence.end(), sequence.begin(), toupper);
-
-
-string
-Sequence::load_annot(string file_path, int start_index, int end_index)
-{
- fstream data_file;
- string file_data_line;
- annot an_annot;
- int space_split_i;
- string annot_value;
- list<annot>::iterator list_i;
- string err_msg;
-
-
- annots.clear();
- data_file.open(file_path.c_str(), ios::in);
-
- if (!data_file)
- {
- err_msg = "Sequence File: " + file_path + " not found";
- return err_msg;
- }
- // if file opened okay, read it
- else
- {
- getline(data_file,file_data_line);
- species = file_data_line;
-
- // end_index = 0 means no end was specified, so cut to the end
- if (end_index == 0)
- end_index = sequence.length();
-
- //cout << "START: " << start_index << " END: " << end_index << endl;
-
- while ( !data_file.eof() )
- {
- getline(data_file,file_data_line);
- if (file_data_line != "")
- {
- // need to get 4 values...almost same code 4 times...
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.start = atoi (annot_value.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot end index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.end = atoi (annot_value.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
-
- cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
- << endl;
-
- // get annot name
- space_split_i = file_data_line.find(" ");
- if (space_split_i == string::npos) // no entries for name & type
- {
- cout << "seq, annots - no name or type\n";
- an_annot.name = "";
- an_annot.type = "";
- }
- else
- {
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.name = annot_value;
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot type
- space_split_i = file_data_line.find(" ");
- if (space_split_i == string::npos) // no entry for type
- an_annot.type = "";
- else
- {
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
- }
- }
-
-
- // add annot to list if it falls within the range of sequence specified
- if ((start_index <= an_annot.start) && (end_index >= an_annot.end))
- {
- an_annot.start -= start_index;
- an_annot.end -= start_index;
- annots.push_back(an_annot);
- }
- else
- cout << "FAILED!!!!!!\n";
- }
- }
-
- data_file.close();
- /*
- // debugging check
- for(list_i = annots.begin(); list_i != annots.end(); ++list_i)
- {
- cout << (*list_i).start << "," << (*list_i).end << "\t";
- cout << (*list_i).name << "\t" << (*list_i).type << endl;
- }
- */
- return "";
- }
-}
-
-
-int
-Sequence::len()
-{
- return sequence.length();
-}
-
-
-string
-Sequence::seq()
-{
- return sequence;
-}
-
-
-string
-Sequence::subseq(int start, int end)
-{
- return sequence.substr(start, end);
-}
-
-
-const char *
-Sequence::c_seq()
-{
- return sequence.c_str();
-}
-
-string
-Sequence::rev_comp()
-{
- string rev_comp;
- char conversionTable[257];
- int seq_i, table_i, len;
-
- len = sequence.length();
- rev_comp.reserve(len);
- // make a conversion table
- // init all parts of conversion table to '~' character
- // '~' I doubt will ever appear in a sequence file (jeez, I hope)
- // and may the fleas of 1000 camels infest the genitals of any biologist (and
- // seven generations of their progeny) who decides to make it mean
- // something special!!!
- // PS - double the curse for any smartass non-biologist who tries it as well
- for(table_i=0; table_i < 256; table_i++)
- {
- conversionTable[table_i] = '~';
- }
- // add end of string character for printing out table for testing purposes
- conversionTable[256] = '\0';
-
- // add in the characters for the bases we want to convert
- conversionTable['A'] = 'T';
- conversionTable['T'] = 'A';
- conversionTable['G'] = 'C';
- conversionTable['C'] = 'G';
- conversionTable['N'] = 'N';
-
- // finally, the actual conversion loop
- for(seq_i = len - 1; seq_i >= 0; seq_i--)
- {
- table_i = (int) sequence[seq_i];
- rev_comp += conversionTable[table_i];
- }
-
- return rev_comp;
-}
-
-
-string
-Sequence::hdr()
-{
- return header;
-}
-
-string
-Sequence::sp_name()
-{
- return species;
-}
-
-
-void
-Sequence::set_seq(string a_seq)
-{
- sequence = a_seq;
-}
-
-
-/*
-string
-Sequence::species()
-{
- return species;
-}
-*/
-
-void
-Sequence::clear()
-{
- sequence = "";
- header = "";
- species = "";
- species_num = -4;
- annots.clear();
-}
-
-void
-Sequence::save(fstream &save_file)
- //string save_file_path)
-{
- //fstream save_file;
- list<annot>::iterator annots_i;
- int i;
-
- // not sure why, or if i'm doing something wrong, but can't seem to pass
- // file pointers down to this method from the mussa control class
- // so each call to save a sequence appends to the file started by mussa_class
- //save_file.open(save_file_path.c_str(), ios::app);
-
- save_file << "<Sequence>" << endl;
- save_file << sequence << endl;
- save_file << "</Sequence>" << endl;
-
- save_file << "<Annotations>" << endl;
- save_file << species << endl;
- for (annots_i = annots.begin(); annots_i != annots.end(); ++annots_i)
- {
- save_file << annots_i->start << " " << annots_i->end << " " ;
- save_file << annots_i->name << " " << annots_i->type << endl;
- }
- save_file << "</Annotations>" << endl;
- //save_file.close();
-}
-
-void
-Sequence::load_museq(string load_file_path, int seq_num)
-{
- fstream load_file;
- string file_data_line;
- int seq_counter;
- annot an_annot;
- int space_split_i;
- string annot_value;
-
- annots.clear();
- load_file.open(load_file_path.c_str(), ios::in);
-
- seq_counter = 0;
- // search for the seq_num-th sequence
- while ( (!load_file.eof()) && (seq_counter < seq_num) )
- {
- getline(load_file,file_data_line);
- if (file_data_line == "<Sequence>")
- seq_counter++;
- }
- getline(load_file, file_data_line);
- sequence = file_data_line;
- getline(load_file, file_data_line);
- getline(load_file, file_data_line);
- if (file_data_line == "<Annotations>")
- {
- getline(load_file, file_data_line);
- species = file_data_line;
- while ( (!load_file.eof()) && (file_data_line != "</Annotations>") )
- {
- getline(load_file,file_data_line);
- if ((file_data_line != "") && (file_data_line != "</Annotations>"))
- {
- // need to get 4 values...almost same code 4 times...
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.start = atoi (annot_value.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot end index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.end = atoi (annot_value.c_str());
-
- if (space_split_i == string::npos) // no entry for type or name
- {
- cout << "seq, annots - no type or name\n";
- an_annot.type = "";
- an_annot.name = "";
- }
- else // else get annot type
- {
- file_data_line = file_data_line.substr(space_split_i+1);
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
- if (space_split_i == string::npos) // no entry for name
- {
- cout << "seq, annots - no name\n";
- an_annot.name = "";
- }
- else // get annot name
- {
- file_data_line = file_data_line.substr(space_split_i+1);
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
- }
- }
- annots.push_back(an_annot); // don't forget to actually add the annot
- }
- cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
- << "-->" << an_annot.type << "::" << an_annot.name << endl;
- }
- }
- load_file.close();
-}
-
-
-string
-Sequence::rc_motif(string a_motif)
-{
- string rev_comp;
- char conversionTable[257];
- int seq_i, table_i, len;
-
- len = a_motif.length();
- rev_comp.reserve(len);
-
- for(table_i=0; table_i < 256; table_i++)
- {
- conversionTable[table_i] = '~';
- }
- // add end of string character for printing out table for testing purposes
- conversionTable[256] = '\0';
-
- // add in the characters for the bases we want to convert (IUPAC)
- conversionTable['A'] = 'T';
- conversionTable['T'] = 'A';
- conversionTable['G'] = 'C';
- conversionTable['C'] = 'G';
- conversionTable['N'] = 'N';
- conversionTable['M'] = 'K';
- conversionTable['R'] = 'Y';
- conversionTable['W'] = 'W';
- conversionTable['S'] = 'S';
- conversionTable['Y'] = 'R';
- conversionTable['K'] = 'M';
- conversionTable['V'] = 'B';
- conversionTable['H'] = 'D';
- conversionTable['D'] = 'H';
- conversionTable['B'] = 'V';
-
- // finally, the actual conversion loop
- for(seq_i = len - 1; seq_i >= 0; seq_i--)
- {
- //cout << "** i = " << seq_i << " bp = " <<
- table_i = (int) a_motif[seq_i];
- rev_comp += conversionTable[table_i];
- }
-
- cout << "seq: " << a_motif << endl;
- cout << "rc: " << rev_comp << endl;
-
- return rev_comp;
-}
-
-string
-Sequence::motif_validate(string a_motif)
-{
- string valid_motif;
- int seq_i, len;
-
- len = a_motif.length();
- valid_motif.reserve(len);
-
- // this just upcases IUPAC symbols. Eventually should return an error if non IUPAC is present.
- // current nonIUPAC symbols are omitted, which is not reported atm
- for(seq_i = 0; seq_i < len; seq_i++)
- {
- if ((a_motif[seq_i] == 'a') || (a_motif[seq_i] == 'A'))
- valid_motif += 'A';
- else if ((a_motif[seq_i] == 't') || (a_motif[seq_i] == 'T'))
- valid_motif += 'T';
- else if ((a_motif[seq_i] == 'g') || (a_motif[seq_i] == 'G'))
- valid_motif += 'G';
- else if ((a_motif[seq_i] == 'c') || (a_motif[seq_i] == 'C'))
- valid_motif += 'C';
- else if ((a_motif[seq_i] == 'n') || (a_motif[seq_i] == 'N'))
- valid_motif += 'N';
- else if ((a_motif[seq_i] == 'm') || (a_motif[seq_i] == 'M'))
- valid_motif += 'M';
- else if ((a_motif[seq_i] == 'r') || (a_motif[seq_i] == 'R'))
- valid_motif += 'R';
- else if ((a_motif[seq_i] == 'w') || (a_motif[seq_i] == 'W'))
- valid_motif += 'W';
- else if ((a_motif[seq_i] == 's') || (a_motif[seq_i] == 'S'))
- valid_motif += 'S';
- else if ((a_motif[seq_i] == 'y') || (a_motif[seq_i] == 'Y'))
- valid_motif += 'Y';
- else if ((a_motif[seq_i] == 'k') || (a_motif[seq_i] == 'K'))
- valid_motif += 'G';
- else if ((a_motif[seq_i] == 'v') || (a_motif[seq_i] == 'V'))
- valid_motif += 'V';
- else if ((a_motif[seq_i] == 'h') || (a_motif[seq_i] == 'H'))
- valid_motif += 'H';
- else if ((a_motif[seq_i] == 'd') || (a_motif[seq_i] == 'D'))
- valid_motif += 'D';
- else if ((a_motif[seq_i] == 'b') || (a_motif[seq_i] == 'B'))
- valid_motif += 'B';
- }
-
- cout << "valid_motif is: " << valid_motif << endl;
-
- return valid_motif;
-}
-
-
-vector<int>
-Sequence::find_motif(string a_motif)
-{
- vector<int> motif_match_starts;
- string a_motif_rc;
-
-
- motif_match_starts.clear();
-
- cout << "motif is: " << a_motif << endl;
- a_motif = motif_validate(a_motif);
- //cout << "motif is: " << a_motif << endl;
-
-
- if (a_motif != "")
- {
- cout << "Sequence: none blank motif\n";
- motif_scan(a_motif, &motif_match_starts);
-
- a_motif_rc = rc_motif(a_motif);
- // make sure not to do search again if it is a palindrome
- if (a_motif_rc != a_motif)
- motif_scan(a_motif_rc, &motif_match_starts);
- }
- return motif_match_starts;
-}
-
-void
-Sequence::motif_scan(string a_motif, vector<int> * motif_match_starts)
-{
- char * seq_c;
- int seq_i, motif_i, motif_len;
-
- // faster to loop thru the sequence as a old c string (ie char array)
- seq_c = (char*)sequence.c_str();
- //cout << "Sequence: motif, seq len = " << sequence.length() << endl;
- motif_len = a_motif.length();
-
- //cout << "motif_length: " << motif_len << endl;
- //cout << "RAAARRRRR\n";
-
- motif_i = 0;
-
- //cout << "motif: " << a_motif << endl;
-
- //cout << "Sequence: motif, length= " << length << endl;
- seq_i = 0;
- while (seq_i < sequence.length())
- {
- cout << seq_c[seq_i];
- //if ((seq_i > 10885) && (seq_i < 10917))
- //cout << seq_c[seq_i] << "?" << a_motif[motif_i] << ":" << motif_i << " ";
- // this is pretty much a straight translation of Nora's python code
- // to match iupac letter codes
- if (a_motif[motif_i] =='N')
- motif_i++;
- else if (a_motif[motif_i] == seq_c[seq_i])
- motif_i++;
- else if ((a_motif[motif_i] =='M') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C')))
- motif_i++;
- else if ((a_motif[motif_i] =='R') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='G')))
- motif_i++;
- else if ((a_motif[motif_i] =='W') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='T')))
- motif_i++;
- else if ((a_motif[motif_i] =='S') &&
- ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='G')))
- motif_i++;
- else if ((a_motif[motif_i] =='Y') &&
- ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='T')))
- motif_i++;
- else if ((a_motif[motif_i] =='K') &&
- ((seq_c[seq_i]=='G') || (seq_c[seq_i]=='T')))
- motif_i++;
- else if ((a_motif[motif_i] =='V') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C') ||
- (seq_c[seq_i]=='G')))
- motif_i++;
- else if ((a_motif[seq_i] =='H') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C') ||
- (seq_c[seq_i]=='T')))
- motif_i++;
- else if ((a_motif[motif_i] =='D') &&
- ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='G') ||
- (seq_c[seq_i]=='T')))
- motif_i++;
- else if ((a_motif[motif_i] =='B') &&
- ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='G') ||
- (seq_c[seq_i]=='T')))
- motif_i++;
-
- else
- {
- seq_i -= motif_i;
- motif_i = 0;
- }
-
- // end Nora stuff, now we see if a match is found this pass
- if (motif_i == motif_len)
- {
- //cout << "!!";
- motif_match_starts->push_back(seq_i - motif_len + 1);
- motif_i = 0;
- }
-
- seq_i++;
- }
- cout << endl;
-}
-
-/*
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.name = annot_value;
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
-*/
--- /dev/null
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// This file is part of the Mussa source distribution.
+// http://mussa.caltech.edu/
+// Contact author: Tristan De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA. It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+// ----------------------------------------
+// ---------- sequence.cc -----------
+// ----------------------------------------
+
+#include "sequence.hh"
+#include <iostream>
+
+using namespace std;
+
+Sequence::Sequence()
+{
+}
+
+//! load a fasta file into a sequence
+/*!
+ * \param file_path the location of the fasta file in the filesystem
+ * \param seq_num which sequence in the file to load
+ * \param start_index starting position in the fasta sequence, 0 for beginning
+ * \param end_index ending position in the fasta sequence, 0 for end
+ * \return error message, empty string if no error. (gag!)
+ */
+string
+Sequence::load_fasta(string file_path, int seq_num,
+ int start_index, int end_index)
+{
+ fstream data_file;
+ string file_data_line;
+ int header_counter = 0;
+ bool read_seq = true;
+ string rev_comp;
+ char conversionTable[257];
+ int seq_i, table_i, len;
+ string sequence_raw;
+ char * seq_tmp; // holds sequence during basic filtering
+ string err_msg;
+
+ data_file.open(file_path.c_str(), ios::in);
+
+ if (!data_file)
+ {
+ err_msg = "Sequence File: " + file_path + " not found";
+ return err_msg;
+ }
+ // if file opened okay, read it
+ else
+ {
+ // search for the header of the fasta sequence we want
+ while ( (!data_file.eof()) && (header_counter < seq_num) )
+ {
+ getline(data_file,file_data_line);
+ if (file_data_line.substr(0,1) == ">")
+ header_counter++;
+ }
+
+ header = file_data_line.substr(1);
+
+ sequence_raw = "";
+
+ while ( !data_file.eof() && read_seq )
+ {
+ getline(data_file,file_data_line);
+ if (file_data_line.substr(0,1) == ">")
+ read_seq = false;
+ else sequence_raw += file_data_line;
+ }
+
+ data_file.close();
+
+ // sequence filtering for upcasing agctn and convert non AGCTN to N
+
+ len = sequence_raw.length();
+ seq_tmp = (char*)sequence_raw.c_str();
+
+ sequence = "";
+
+ // Make a conversion table
+
+ // everything we don't specify below will become 'N'
+ for(table_i=0; table_i < 256; table_i++)
+ {
+ conversionTable[table_i] = 'N';
+ }
+ // add end of string character for printing out table for testing purposes
+ conversionTable[256] = '\0';
+
+ // we want these to map to themselves - ie not to change
+ conversionTable['A'] = 'A';
+ conversionTable['T'] = 'T';
+ conversionTable['G'] = 'G';
+ conversionTable['C'] = 'C';
+ // this is to upcase
+ conversionTable['a'] = 'A';
+ conversionTable['t'] = 'T';
+ conversionTable['g'] = 'G';
+ conversionTable['c'] = 'C';
+
+ // finally, the actual conversion loop
+ for(seq_i = 0; seq_i < len; seq_i++)
+ {
+ table_i = (int) seq_tmp[seq_i];
+ sequence += conversionTable[table_i];
+ }
+
+
+ // Lastly, if subselection of the sequence was specified we keep cut out
+ // and only keep that part
+
+ // end_index = 0 means no end was specified, so cut to the end
+ if (end_index == 0)
+ end_index = len;
+
+ // start_index = 0 if no start was specified
+ sequence = sequence.substr(start_index, end_index - start_index);
+
+ return "";
+ }
+}
+
+
+ // this doesn't work properly under gcc 3.x ... it can't recognize toupper
+ //transform(sequence.begin(), sequence.end(), sequence.begin(), toupper);
+
+
+string
+Sequence::load_annot(string file_path, int start_index, int end_index)
+{
+ fstream data_file;
+ string file_data_line;
+ annot an_annot;
+ int space_split_i;
+ string annot_value;
+ list<annot>::iterator list_i;
+ string err_msg;
+
+
+ annots.clear();
+ data_file.open(file_path.c_str(), ios::in);
+
+ if (!data_file)
+ {
+ err_msg = "Sequence File: " + file_path + " not found";
+ return err_msg;
+ }
+ // if file opened okay, read it
+ else
+ {
+ getline(data_file,file_data_line);
+ species = file_data_line;
+
+ // end_index = 0 means no end was specified, so cut to the end
+ if (end_index == 0)
+ end_index = sequence.length();
+
+ //cout << "START: " << start_index << " END: " << end_index << endl;
+
+ while ( !data_file.eof() )
+ {
+ getline(data_file,file_data_line);
+ if (file_data_line != "")
+ {
+ // need to get 4 values...almost same code 4 times...
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.start = atoi (annot_value.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot end index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.end = atoi (annot_value.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+
+ cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
+ << endl;
+
+ // get annot name
+ space_split_i = file_data_line.find(" ");
+ if (space_split_i == string::npos) // no entries for name & type
+ {
+ cout << "seq, annots - no name or type\n";
+ an_annot.name = "";
+ an_annot.type = "";
+ }
+ else
+ {
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.name = annot_value;
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot type
+ space_split_i = file_data_line.find(" ");
+ if (space_split_i == string::npos) // no entry for type
+ an_annot.type = "";
+ else
+ {
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ }
+ }
+
+
+ // add annot to list if it falls within the range of sequence specified
+ if ((start_index <= an_annot.start) && (end_index >= an_annot.end))
+ {
+ an_annot.start -= start_index;
+ an_annot.end -= start_index;
+ annots.push_back(an_annot);
+ }
+ else
+ cout << "FAILED!!!!!!\n";
+ }
+ }
+
+ data_file.close();
+ /*
+ // debugging check
+ for(list_i = annots.begin(); list_i != annots.end(); ++list_i)
+ {
+ cout << (*list_i).start << "," << (*list_i).end << "\t";
+ cout << (*list_i).name << "\t" << (*list_i).type << endl;
+ }
+ */
+ return "";
+ }
+}
+
+
+int
+Sequence::len()
+{
+ return sequence.length();
+}
+
+
+string
+Sequence::seq()
+{
+ return sequence;
+}
+
+
+string
+Sequence::subseq(int start, int end)
+{
+ return sequence.substr(start, end);
+}
+
+
+const char *
+Sequence::c_seq()
+{
+ return sequence.c_str();
+}
+
+string
+Sequence::rev_comp()
+{
+ string rev_comp;
+ char conversionTable[257];
+ int seq_i, table_i, len;
+
+ len = sequence.length();
+ rev_comp.reserve(len);
+ // make a conversion table
+ // init all parts of conversion table to '~' character
+ // '~' I doubt will ever appear in a sequence file (jeez, I hope)
+ // and may the fleas of 1000 camels infest the genitals of any biologist (and
+ // seven generations of their progeny) who decides to make it mean
+ // something special!!!
+ // PS - double the curse for any smartass non-biologist who tries it as well
+ for(table_i=0; table_i < 256; table_i++)
+ {
+ conversionTable[table_i] = '~';
+ }
+ // add end of string character for printing out table for testing purposes
+ conversionTable[256] = '\0';
+
+ // add in the characters for the bases we want to convert
+ conversionTable['A'] = 'T';
+ conversionTable['T'] = 'A';
+ conversionTable['G'] = 'C';
+ conversionTable['C'] = 'G';
+ conversionTable['N'] = 'N';
+
+ // finally, the actual conversion loop
+ for(seq_i = len - 1; seq_i >= 0; seq_i--)
+ {
+ table_i = (int) sequence[seq_i];
+ rev_comp += conversionTable[table_i];
+ }
+
+ return rev_comp;
+}
+
+
+string
+Sequence::hdr()
+{
+ return header;
+}
+
+string
+Sequence::sp_name()
+{
+ return species;
+}
+
+
+void
+Sequence::set_seq(string a_seq)
+{
+ sequence = a_seq;
+}
+
+
+/*
+string
+Sequence::species()
+{
+ return species;
+}
+*/
+
+void
+Sequence::clear()
+{
+ sequence = "";
+ header = "";
+ species = "";
+ species_num = -4;
+ annots.clear();
+}
+
+void
+Sequence::save(fstream &save_file)
+ //string save_file_path)
+{
+ //fstream save_file;
+ list<annot>::iterator annots_i;
+ int i;
+
+ // not sure why, or if i'm doing something wrong, but can't seem to pass
+ // file pointers down to this method from the mussa control class
+ // so each call to save a sequence appends to the file started by mussa_class
+ //save_file.open(save_file_path.c_str(), ios::app);
+
+ save_file << "<Sequence>" << endl;
+ save_file << sequence << endl;
+ save_file << "</Sequence>" << endl;
+
+ save_file << "<Annotations>" << endl;
+ save_file << species << endl;
+ for (annots_i = annots.begin(); annots_i != annots.end(); ++annots_i)
+ {
+ save_file << annots_i->start << " " << annots_i->end << " " ;
+ save_file << annots_i->name << " " << annots_i->type << endl;
+ }
+ save_file << "</Annotations>" << endl;
+ //save_file.close();
+}
+
+void
+Sequence::load_museq(string load_file_path, int seq_num)
+{
+ fstream load_file;
+ string file_data_line;
+ int seq_counter;
+ annot an_annot;
+ int space_split_i;
+ string annot_value;
+
+ annots.clear();
+ load_file.open(load_file_path.c_str(), ios::in);
+
+ seq_counter = 0;
+ // search for the seq_num-th sequence
+ while ( (!load_file.eof()) && (seq_counter < seq_num) )
+ {
+ getline(load_file,file_data_line);
+ if (file_data_line == "<Sequence>")
+ seq_counter++;
+ }
+ getline(load_file, file_data_line);
+ sequence = file_data_line;
+ getline(load_file, file_data_line);
+ getline(load_file, file_data_line);
+ if (file_data_line == "<Annotations>")
+ {
+ getline(load_file, file_data_line);
+ species = file_data_line;
+ while ( (!load_file.eof()) && (file_data_line != "</Annotations>") )
+ {
+ getline(load_file,file_data_line);
+ if ((file_data_line != "") && (file_data_line != "</Annotations>"))
+ {
+ // need to get 4 values...almost same code 4 times...
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.start = atoi (annot_value.c_str());
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot end index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.end = atoi (annot_value.c_str());
+
+ if (space_split_i == string::npos) // no entry for type or name
+ {
+ cout << "seq, annots - no type or name\n";
+ an_annot.type = "";
+ an_annot.name = "";
+ }
+ else // else get annot type
+ {
+ file_data_line = file_data_line.substr(space_split_i+1);
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ if (space_split_i == string::npos) // no entry for name
+ {
+ cout << "seq, annots - no name\n";
+ an_annot.name = "";
+ }
+ else // get annot name
+ {
+ file_data_line = file_data_line.substr(space_split_i+1);
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ }
+ }
+ annots.push_back(an_annot); // don't forget to actually add the annot
+ }
+ cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
+ << "-->" << an_annot.type << "::" << an_annot.name << endl;
+ }
+ }
+ load_file.close();
+}
+
+
+string
+Sequence::rc_motif(string a_motif)
+{
+ string rev_comp;
+ char conversionTable[257];
+ int seq_i, table_i, len;
+
+ len = a_motif.length();
+ rev_comp.reserve(len);
+
+ for(table_i=0; table_i < 256; table_i++)
+ {
+ conversionTable[table_i] = '~';
+ }
+ // add end of string character for printing out table for testing purposes
+ conversionTable[256] = '\0';
+
+ // add in the characters for the bases we want to convert (IUPAC)
+ conversionTable['A'] = 'T';
+ conversionTable['T'] = 'A';
+ conversionTable['G'] = 'C';
+ conversionTable['C'] = 'G';
+ conversionTable['N'] = 'N';
+ conversionTable['M'] = 'K';
+ conversionTable['R'] = 'Y';
+ conversionTable['W'] = 'W';
+ conversionTable['S'] = 'S';
+ conversionTable['Y'] = 'R';
+ conversionTable['K'] = 'M';
+ conversionTable['V'] = 'B';
+ conversionTable['H'] = 'D';
+ conversionTable['D'] = 'H';
+ conversionTable['B'] = 'V';
+
+ // finally, the actual conversion loop
+ for(seq_i = len - 1; seq_i >= 0; seq_i--)
+ {
+ //cout << "** i = " << seq_i << " bp = " <<
+ table_i = (int) a_motif[seq_i];
+ rev_comp += conversionTable[table_i];
+ }
+
+ cout << "seq: " << a_motif << endl;
+ cout << "rc: " << rev_comp << endl;
+
+ return rev_comp;
+}
+
+string
+Sequence::motif_validate(string a_motif)
+{
+ string valid_motif;
+ int seq_i, len;
+
+ len = a_motif.length();
+ valid_motif.reserve(len);
+
+ // this just upcases IUPAC symbols. Eventually should return an error if non IUPAC is present.
+ // current nonIUPAC symbols are omitted, which is not reported atm
+ for(seq_i = 0; seq_i < len; seq_i++)
+ {
+ if ((a_motif[seq_i] == 'a') || (a_motif[seq_i] == 'A'))
+ valid_motif += 'A';
+ else if ((a_motif[seq_i] == 't') || (a_motif[seq_i] == 'T'))
+ valid_motif += 'T';
+ else if ((a_motif[seq_i] == 'g') || (a_motif[seq_i] == 'G'))
+ valid_motif += 'G';
+ else if ((a_motif[seq_i] == 'c') || (a_motif[seq_i] == 'C'))
+ valid_motif += 'C';
+ else if ((a_motif[seq_i] == 'n') || (a_motif[seq_i] == 'N'))
+ valid_motif += 'N';
+ else if ((a_motif[seq_i] == 'm') || (a_motif[seq_i] == 'M'))
+ valid_motif += 'M';
+ else if ((a_motif[seq_i] == 'r') || (a_motif[seq_i] == 'R'))
+ valid_motif += 'R';
+ else if ((a_motif[seq_i] == 'w') || (a_motif[seq_i] == 'W'))
+ valid_motif += 'W';
+ else if ((a_motif[seq_i] == 's') || (a_motif[seq_i] == 'S'))
+ valid_motif += 'S';
+ else if ((a_motif[seq_i] == 'y') || (a_motif[seq_i] == 'Y'))
+ valid_motif += 'Y';
+ else if ((a_motif[seq_i] == 'k') || (a_motif[seq_i] == 'K'))
+ valid_motif += 'G';
+ else if ((a_motif[seq_i] == 'v') || (a_motif[seq_i] == 'V'))
+ valid_motif += 'V';
+ else if ((a_motif[seq_i] == 'h') || (a_motif[seq_i] == 'H'))
+ valid_motif += 'H';
+ else if ((a_motif[seq_i] == 'd') || (a_motif[seq_i] == 'D'))
+ valid_motif += 'D';
+ else if ((a_motif[seq_i] == 'b') || (a_motif[seq_i] == 'B'))
+ valid_motif += 'B';
+ }
+
+ cout << "valid_motif is: " << valid_motif << endl;
+
+ return valid_motif;
+}
+
+
+vector<int>
+Sequence::find_motif(string a_motif)
+{
+ vector<int> motif_match_starts;
+ string a_motif_rc;
+
+
+ motif_match_starts.clear();
+
+ cout << "motif is: " << a_motif << endl;
+ a_motif = motif_validate(a_motif);
+ //cout << "motif is: " << a_motif << endl;
+
+
+ if (a_motif != "")
+ {
+ cout << "Sequence: none blank motif\n";
+ motif_scan(a_motif, &motif_match_starts);
+
+ a_motif_rc = rc_motif(a_motif);
+ // make sure not to do search again if it is a palindrome
+ if (a_motif_rc != a_motif)
+ motif_scan(a_motif_rc, &motif_match_starts);
+ }
+ return motif_match_starts;
+}
+
+void
+Sequence::motif_scan(string a_motif, vector<int> * motif_match_starts)
+{
+ char * seq_c;
+ int seq_i, motif_i, motif_len;
+
+ // faster to loop thru the sequence as a old c string (ie char array)
+ seq_c = (char*)sequence.c_str();
+ //cout << "Sequence: motif, seq len = " << sequence.length() << endl;
+ motif_len = a_motif.length();
+
+ //cout << "motif_length: " << motif_len << endl;
+ //cout << "RAAARRRRR\n";
+
+ motif_i = 0;
+
+ //cout << "motif: " << a_motif << endl;
+
+ //cout << "Sequence: motif, length= " << length << endl;
+ seq_i = 0;
+ while (seq_i < sequence.length())
+ {
+ cout << seq_c[seq_i];
+ //if ((seq_i > 10885) && (seq_i < 10917))
+ //cout << seq_c[seq_i] << "?" << a_motif[motif_i] << ":" << motif_i << " ";
+ // this is pretty much a straight translation of Nora's python code
+ // to match iupac letter codes
+ if (a_motif[motif_i] =='N')
+ motif_i++;
+ else if (a_motif[motif_i] == seq_c[seq_i])
+ motif_i++;
+ else if ((a_motif[motif_i] =='M') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='R') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='G')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='W') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='T')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='S') &&
+ ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='G')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='Y') &&
+ ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='T')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='K') &&
+ ((seq_c[seq_i]=='G') || (seq_c[seq_i]=='T')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='V') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C') ||
+ (seq_c[seq_i]=='G')))
+ motif_i++;
+ else if ((a_motif[seq_i] =='H') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='C') ||
+ (seq_c[seq_i]=='T')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='D') &&
+ ((seq_c[seq_i]=='A') || (seq_c[seq_i]=='G') ||
+ (seq_c[seq_i]=='T')))
+ motif_i++;
+ else if ((a_motif[motif_i] =='B') &&
+ ((seq_c[seq_i]=='C') || (seq_c[seq_i]=='G') ||
+ (seq_c[seq_i]=='T')))
+ motif_i++;
+
+ else
+ {
+ seq_i -= motif_i;
+ motif_i = 0;
+ }
+
+ // end Nora stuff, now we see if a match is found this pass
+ if (motif_i == motif_len)
+ {
+ //cout << "!!";
+ motif_match_starts->push_back(seq_i - motif_len + 1);
+ motif_i = 0;
+ }
+
+ seq_i++;
+ }
+ cout << endl;
+}
+
+/*
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.name = annot_value;
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+*/
// Sequence data class
-using namespace std;
-
+//! Attach annotation information to a sequence track
struct annot
{
int start, end;
std::string name, type;
};
+//! sequence track for mussa.
class Sequence
{
friend class ConnView;