PageRenderTime 24ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/tutorials/simple_tutorial/step4_run_pipeline_graphically_code.rst

https://code.google.com/p/ruffus/
ReStructuredText | 104 lines | 84 code | 20 blank | 0 comment | 0 complexity | adcd2f32dca5923f637c2130840f98f6 MD5 | raw file
  1.. include:: ../../global.inc
  2.. _Simple_Tutorial_4th_step_graphical_code:
  3
  4
  5###################################################################
  6Code for Step 4: Displaying the pipeline visually
  7###################################################################
  8* :ref:`Simple tutorial overview <Simple_Tutorial>` 
  9* :ref:`pipeline functions <pipeline_functions>` in detail
 10* :ref:`Back to Step 4 <Simple_Tutorial_4th_step_graphical>` 
 11
 12************************************
 13Code
 14************************************
 15    ::
 16        
 17        from ruffus import *
 18        import time
 19        
 20        #---------------------------------------------------------------
 21        #
 22        #   first task
 23        #
 24        task1_param = [
 25                            [ None, 'job1.stage1'], # 1st job
 26                            [ None, 'job2.stage1'], # 2nd job
 27                      ]
 28                                            
 29        @files(task1_param)
 30        def first_task(no_input_file, output_file):
 31            open(output_file, "w")
 32
 33
 34        #---------------------------------------------------------------
 35        #
 36        #   second task
 37        #
 38        task2_param = [
 39                            [ 'job1.stage1', "job1.stage2", "    1st_job"], # 1st job
 40                            [ 'job2.stage1', "job2.stage2", "    2nd_job"], # 2nd job
 41                      ]
 42        
 43        @follows(first_task)
 44        @files(task2_param)
 45        def second_task(input_file, output_file, extra_parameter):
 46            open(output_file, "w")
 47            print extra_parameter
 48        
 49        #---------------------------------------------------------------
 50        #
 51        #       Show flow chart and tasks before running the pipeline
 52        #
 53        print "Show flow chart and tasks before running the pipeline"
 54        pipeline_printout_graph ( open("flowchart_before.png", "w"),
 55                                 "png",
 56                                 [second_task],
 57                                 no_key_legend=True)
 58        
 59        #---------------------------------------------------------------
 60        #
 61        #       Run
 62        #
 63        pipeline_run([second_task])
 64    
 65   
 66        # modify job1.stage1
 67        open("job1.stage1", "w").close()
 68   
 69       
 70        #---------------------------------------------------------------
 71        #
 72        #       Show flow chart and tasks after running the pipeline
 73        #
 74        print "Show flow chart and tasks after running the pipeline"
 75        pipeline_printout_graph ( open("flowchart_after.png", "w"),
 76                                 "png",
 77                                 [second_task],
 78                                 no_key_legend=True)
 79        
 80        
 81************************************
 82Resulting Flowcharts
 83************************************
 84   +-------------------------------------------------------------+-----------------------------------------------------------------------+
 85   | .. image:: ../../images/simple_tutorial_stage4_before.png   | .. image::  ../../images/simple_tutorial_stage4_after.png             |
 86   |           :alt: Before running the pipeline                 |     :alt: After running the pipeline                                  |                           
 87   |           :scale: 50                                        |     :scale: 50                                                        |                           
 88   |           :align: center                                    |     :align: center                                                    |                           
 89   |                                                             |                                                                       |                           
 90   | .. centered:: Before                                        | .. centered:: After                                                   |                           
 91   |                                                             |                                                                       |                           
 92   +-------------------------------------------------------------+-----------------------------------------------------------------------+
 93
 94   +-------------------------------------------------------------------------------------------------------------------------------------+
 95   | .. image:: ../../images/tutorial_key.jpg                                                                                            |
 96   |           :alt: Legend key                                                                                                          |                           
 97   |           :scale: 75                                                                                                                |                           
 98   |           :align: center                                                                                                            |                           
 99   |                                                                                                                                     |                           
100   | .. centered:: Legend                                                                                                                |                           
101   |                                                                                                                                     |                           
102   +-------------------------------------------------------------------------------------------------------------------------------------+
103
104