Class: WorkflowToGalaxy::GalaxyTool

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow-to-galaxy/galaxy.rb

Overview

The GalaxyTool class contains a generate public method that generates the required files (XML and script) for a Galaxy tool.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GalaxyTool

- TODO: does initialize appear in rdoc? – these will go to README as well…



40
41
42
# File 'lib/workflow-to-galaxy/galaxy.rb', line 40

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject

config contains data needed in relation to what the tool will do and wkf_object contains the workflow object that will be used to generate the galaxy tool



19
20
21
# File 'lib/workflow-to-galaxy/galaxy.rb', line 19

def config
  @config
end

#wkf_objectObject

config contains data needed in relation to what the tool will do and wkf_object contains the workflow object that will be used to generate the galaxy tool



19
20
21
# File 'lib/workflow-to-galaxy/galaxy.rb', line 19

def wkf_object
  @wkf_object
end

Instance Method Details

#generateObject

Generates the two files needed for a Galaxy tool: a configuration file (XML) and a processing file (in our case a ruby script)

:call-seq:

GalaxyTool.generate() -> nil


582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/workflow-to-galaxy/galaxy.rb', line 582

def generate

  if(config[:params][:response])

    @wkf_object = config[:params][:response]

  else

    # check the type of workflow source and acquire the appropriate data
    if(config[:wkf_source] == Workflows::MYEXPERIMENT_TAVERNA2)

      # TODO: check and add auth stuff -- even more unsafe with session cookies
      # since the myexp username/passwd will be saved in the galaxy ruby script
      # for all to see...

      begin
        # Get workflow data from myexperiment -- a _MyExperimentWorkflow_ object is returned
        @wkf_object = MyExperimentREST::Workflow.from_uri(@config[:params][:url])
      rescue Exception => e
        raise "Problem acquiring workflow data from myExperiment!\n" + e
      end

    elsif(config[:wkf_source] == Workflows::T2FLOW)

      begin
        # Get workflow data from t2flow file -- a _MyExperimentWorkflow_ object is returned
        @wkf_object = populate_taverna_workflow_from_t2flow(@config[:params][:t2flow])
      rescue Exception => e
        raise "Problem acquiring workflow data from t2flow file!\n" + e
      end

    else
      raise "No such workflow source supported!"
    end
  end

  # if an xml_out file handler was not given provide one with the title as the value
  if @config[:params][:xml_out]
    generate_xml(@wkf_object, @config[:params][:xml_out])
  else
    xml_out = open(@wkf_object.title.to_filename + ".xml", "w")
    generate_xml(@wkf_object, xml_out)
    xml_out.close
  end

  # if an rb_out file handler was not given provide one with the title as the value
  if @config[:params][:rb_out]
    generate_rb(@wkf_object, @config[:params][:rb_out], @config[:params][:t2_server])
  else
    rb_out = open(@wkf_object.title.to_filename + ".rb", "w")
    generate_rb(@wkf_object, rb_out, @config[:params][:t2_server])
    rb_out.close
  end

  
end