Changeset 89


Ignore:
Timestamp:
Feb 10, 2011, 3:26:21 PM (6 years ago)
Author:
kostas.karasavvas@…
Message:

updated test plus produces better looking XML

Location:
galaxy-taverna/workflow-to-galaxy
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • galaxy-taverna/workflow-to-galaxy/lib/workflow-to-galaxy/generator.rb

    r88 r89  
    8181
    8282    # result as zip input
    83     out.write indent(2) + "<param name=\"results_as_zip\" type=\"select\" label=\"Would you also like the raw results as a zip file\">"
    84     out.write indent(3) + "<option value=\"yes\">Yes</option>"
    85     out.write indent(3) + "<option value=\"no\" selected=\"true\">No</option>"
    86     out.write indent(2) + "</param>"
     83    out.write indent(2) + "<param name=\"results_as_zip\" type=\"select\" label=\"Would you also like the raw results as a zip file\">\n"
     84    out.write indent(3) + "<option value=\"yes\">Yes</option>\n"
     85    out.write indent(3) + "<option value=\"no\" selected=\"true\">No</option>\n"
     86    out.write indent(2) + "</param>\n"
    8787
    8888    out.write indent(1) + "</inputs>\n"
     
    9797
    9898    # result zip output
    99     out.write indent(2) + "<data format=\"zip\" name=\"result_zip\" label=\"Compressed Results (zip)\">"
    100     out.write indent(3) + "<filter>results_as_zip == \"yes\"</filter>"
    101     out.write indent(2) + "</data>"
     99    out.write indent(2) + "<data format=\"zip\" name=\"result_zip\" label=\"Compressed Results (zip)\">\n"
     100    out.write indent(3) + "<filter>results_as_zip == \"yes\"</filter>\n"
     101    out.write indent(2) + "</data>\n"
    102102
    103103    out.write indent(1) + "</outputs>\n"
  • galaxy-taverna/workflow-to-galaxy/test/Expected_BioAID_ProteinDiscovery_rb

    r84 r89  
    44require 't2-server'
    55require 'open-uri'
     6require 'zip/zipfilesystem'
     7
     8
     9# sends the zip file to specified output
     10def output_zip_file(uuid, zip_out)
     11  File.open("/tmp/#{uuid}.zip") do |zip|
     12    while data = zip.read(4096)
     13      zip_out.write data
     14    end
     15  end
     16  File.delete("/tmp/#{uuid}.zip")
     17end
     18
     19
     20#
     21# replicates the directory result structure as constructed by the
     22# taverna server and recreates it in a zip File
     23#
     24def add_to_zip_file(output_dir, data_lists, zip_out)
     25  zip_out.dir.mkdir("#{output_dir}")
     26  data_lists.each_with_index do |item, index|
     27    if item.instance_of? Array
     28      add_to_zip_file("#{output_dir}/#{index+1}", item, zip_out)
     29    else
     30      zip_out.file.open("#{output_dir}/#{index+1}", "w") { |f| f.puts item }
     31    end
     32  end
     33end
    634
    735   
     
    1846
    1947
    20 # method that acquires all the results of the specified output
    21 def get_outputs(run, refs, outfile, dir)
     48#
     49# Method that acquires all the results of the specified output directory.
     50# If valid zip File is passed it also accumulates results as a zip file.
     51#
     52def get_outputs(run, refs, outfile, dir, zip_out=nil)
    2253  data_lists = run.get_output(dir, refs)
    2354  print_flattened_result(outfile, data_lists)
     55  if zip_out
     56    add_to_zip_file(dir, data_lists, zip_out)
     57  end
    2458end
    2559
     
    3670      "'"
    3771    elsif $1 == '__dq__'
    38       '\"'
     72      '\\\"'
    3973    elsif $1 == '__cr____cn__'
    4074      '&#xA;'
     
    74108end
    75109
    76 # get input arguments -- for each input a boolean specifies if it's from history
     110#
     111# Get input arguments -- for each input a boolean specifies if it's from history
    77112# thus, for each me_rest input we have two arguments in the script!
     113#
    78114Query_from_history = ARGV[0].chomp
    79115Query_tmp = ARGV[1].chomp
     
    93129end
    94130
     131# get results_as_zip input and open zip file if appropriate
     132zipped = ARGV[4].chomp == "yes"
     133zip_out = Zip::ZipFile.open("/tmp/#{run.uuid}.zip", Zip::ZipFile::CREATE) if zipped
     134
     135
    95136# start run and wait until it is finished
    96137run.start
     
    98139
    99140# get output arguments and associated them with a file
    100 output4 = File.open(ARGV[4], "w")
    101 begin
    102   get_outputs(run, false, output4, 'ValidatedProtein')
    103 rescue Exception => err
    104   get_outputs(run, false, output4, 'ValidatedProtein.error')
    105 end
    106141output5 = File.open(ARGV[5], "w")
    107142begin
    108   get_outputs(run, false, output5, 'UniProtID')
     143  get_outputs(run, false, output5, 'ValidatedProtein', zip_out)
    109144rescue Exception => err
    110   get_outputs(run, false, output5, 'UniProtID.error')
     145  get_outputs(run, false, output5, 'ValidatedProtein.error', zip_out)
     146ensure
     147  output5.close
     148end
     149output6 = File.open(ARGV[6], "w")
     150begin
     151  get_outputs(run, false, output6, 'UniProtID', zip_out)
     152rescue Exception => err
     153  get_outputs(run, false, output6, 'UniProtID.error', zip_out)
     154ensure
     155  output6.close
     156end
     157
     158# close zip_out (the newly created zip file) if opened
     159zip_out.close if zip_out
     160
     161# open galaxy zip output and write zip file
     162if zipped
     163  galaxy_zip_out = File.open(ARGV[7], "w")
     164  output_zip_file(run.uuid, galaxy_zip_out)
     165  galaxy_zip_out.close
    111166end
    112167
  • galaxy-taverna/workflow-to-galaxy/test/Expected_BioAID_ProteinDiscovery_xml

    r85 r89  
    1212      true  "$maxHits_parameter_source.history_maxHits_parameter"
    1313    #end if
    14     $ValidatedProtein $UniProtID
     14    $results_as_zip
     15    $ValidatedProtein $UniProtID $result_zip
    1516  </command>
    1617  <inputs>
     
    3940      </when>
    4041    </conditional>
     42    <param name="results_as_zip" type="select" label="Would you also like the raw results as a zip file">
     43      <option value="yes">Yes</option>
     44      <option value="no" selected="true">No</option>
     45    </param>
    4146  </inputs>
    4247  <outputs>
    4348    <data format="tabular" name="ValidatedProtein" label="ValidatedProtein"/>
    4449    <data format="tabular" name="UniProtID" label="UniProtID"/>
     50    <data format="zip" name="result_zip" label="Compressed Results (zip)">
     51      <filter>results_as_zip == "yes"</filter>
     52    </data>
    4553  </outputs>
    4654  <help>
Note: See TracChangeset for help on using the changeset viewer.