Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Non-GUI access to "Report Mutations"?

John Major
2005-10-05
2013-04-18
  • John Major
    John Major
    2005-10-05

    Is it possible to directly access the function behind the contig editor GUI command->"Report Mutations" which builds the HTML mutation reports?

    I have pregap running in batch mode to identify potential mutations, and would like to finish my processing by building the detailed HTML reports with associated images(png files).

    I grep'd/hunted through the gap4/lib files, and couldn't follow the code to anything I could tell was responsible for building these reports....

    advice on what this function(functions?) is called, or on how to best traverse the code would be much appreciated.

    Thanks-
    John

     
    • James Bonfield
      James Bonfield
      2005-10-06

      The code to do this is in C, but it has a tcl interface too. The gotcha here though is that it's a contig editor function, meaning tyhat you have to have an editor up. This in turn meas that under unix you need to have an X windows display which makes automatic scripting via crontabs and the like very tricky (you'd need xvfb or similar). Under windows it's probably not such an issue as you can't do that sort of thing trivially anyway.

      See https://sourceforge.net/tracker/index.php?func=detail&aid=1224167&group_id=100316&atid=749480 for an example script to drive the editor from Tcl instead of interactively. This is using the editor's dump_contig command, but you could replace that with another method.

      The available methods for the editor are best documented in the tkEditor.c source, available via CVS:

      http://cvs.sourceforge.net/viewcvs.py/staden/staden/src/gap4/tkEditor.c?view=markup

      (See the EditorWidgetCmd() function).

      The call you're interested in is "report_mutations".

      James

      PS. Note that the latest code linked above has a minconf argument. This is new and will not exist in your version. It's an optional argument though so your script will still work with the newer version when released.

       
    • John Major
      John Major
      2005-10-07

      Great!  Thanks James.

      FYI:  here is my script to auto-generate the mutation reports.

      #!/bin/sh
      #\ exec stash $0 ${@+"$@"}

      # Globals
      set line_width 50
      set name_width 15
      set prefix contig

      proc report_mutations {io ed mode sort_by detail dir} {
           global line_width name_width

          set err ""
          set blah [$ed report_mutations $mode $sort_by $dir $detail $err]
          puts $err

          return $blah
      }

      # Various setup stuff
      load_package gap
      tkinit
      wm withdraw .
      InitTagArray
      InitLists
      tk_utils_init

      # Parse args & open the db
      if {"$argc" < 1 } {
          puts stderr "Usage: dump_contig database.version \      \[path for output\] \[contig_identifier ...\]"
          exit
      }
      foreach {name version} [split [lindex $argv 0] .] {}
      set io [open_db -name $name -version $version]

      set work_path [lrange $argv 1 2]
      set contigs [lrange $argv 2 end]

      if {$contigs == {}} {
         set contigs [ListGet allcontigs]
      }

      # Loop through contigs dumping the output

      foreach c $contigs {
              set w [edit_contig -io $io -contig $c]

          set mode "1"
          set sort_by "0"
          set detail "2"
          set dir $work_path

          set html [report_mutations $io $w $mode $sort_by $detail $dir]

          set html_file [open $dir./index.html w];
          puts $html_file $html;
          close $html_file;   

              destroy $w   
      }

      exit