Ignore:
Timestamp:
Jan 24, 2011, 4:24:17 PM (6 years ago)
Author:
kostas.karasavvas@…
Message:

added chomp_last_newline and removes indendation from description in xml file

File:
1 edited

Legend:

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

    r76 r78  
    7878    out.write "**What it does**\n\n"
    7979
     80    description = me_rest.workflow.description + "\n\n"
     81
    8082    # Sometimes the workflow description contains HTML tags that are not allowed
    8183    # in Galaxy's xml interface specification and thus are removed! Same for
    8284    # HTML entities!
    83     out.write me_rest.workflow.description.gsub(/<.*?>|&.*?;/, '') + "\n\n"
     85    # TODO go through tags and find Galaxy's equivalent to include
     86    description.gsub!(/<.*?>|&.*?;/, '')
     87
     88    # To remove ^M (cntl-v + cntl-m) characters that DOS files might have
     89    description.gsub!(/\r/, '')
     90   
     91    # TODO that works as a literal too but font changes to courier!
     92    #out.write "::\n\n"   # Start Galaxy's literal block to ignore indendation
     93
     94    # remove indendation from all description lines since Galaxy is confused by it
     95    description.split(/[\n]/).each { |l| out.write "#{l.gsub(/^\s+/, '')}\n" }
     96
     97    # endline makes the following be parsed as a Galaxy GUI construct
     98    out.write "\n"       
    8499
    85100    if me_rest.workflow.inputs.size >= 1
     
    96111          out.write "Examples include:\n\n"
    97112          i.examples.each do |ex|
    98             out.write "  - " + ex.to_s + "\n"
     113            # some examples have a newline between them that breaks Galaxy's GUI
     114            # so we remove it
     115            out.write "  - " + ex.to_s.gsub(/[\n]/, ' ') + "\n"
    99116          end
    100117        end
     
    196213end
    197214
     215#
     216# Deletes last new line of file if it exists! It is needed for t2 workflows that
     217# do not sanitize properly, i.e. via a user-provided beanshell script
     218#
     219def chomp_last_newline(file)
     220
     221  if File.file?(file) and File.size(file) > 1
     222    f = open(file, "rb+")
     223    f.seek(-1, File::SEEK_END)
     224    f.truncate(File.size(file) - 1) if f.read(1) == "\\n"
     225    f.close
     226  end
     227
     228end
     229
     230
    198231UTIL_METHODS
    199232
     
    229262      out.write "#{i_name}_tmp = ARGV[#{i*2+1}].chomp\n"
    230263      out.write "if #{i_name}_from_history == \"true\"\n"
    231       out.write "  run.upload_input_file('#{i_name}', #{i_name}_tmp)\n" #{i_name}_arg = IO.read(#{i_name}_tmp)\n"
     264      out.write "  chomp_last_newline(#{i_name}_tmp)\n"
     265      out.write "  run.upload_input_file('#{i_name}', #{i_name}_tmp)\n"
    232266      out.write "else\n"
    233       out.write "  run.set_input('#{i_name}', sanitize(#{i_name}_tmp))\n"  #{i_name}_arg = #{i_name}_tmp\n"
     267      out.write "  run.set_input('#{i_name}', sanitize(#{i_name}_tmp))\n"
    234268      out.write "end\n"
    235       #out.write "run.set_input('#{i_name}', sanitize(#{i_name}_arg))\n"
    236269    end
    237270
Note: See TracChangeset for help on using the changeset viewer.