Galaxy ツールを作る/外部サイト連携Galaxyツール

提供:TogoWiki

移動: 案内, 検索

目次

外部サイトと連携を行うGalaxyツールの作り方

外部のサイトをGalaxyと連携させることで、通常のGalaxyツールでは実現できないリッチなパラメータ入力画面を作成することができます。「UCSC Table Browser」や「BioMart」などのツールは外部サイトを利用しています。

外部サイトとGalaxyとを連携するには以下を行う必要があります。

  • 外部サイトを利用するGalaxyツールを追加
  • Galaxyと連携する外部サイトを作成

Galaxyツールを追加

tool_conf.xmlに「tools/external_tool/dbsearch.xml」を追加する。

tool_conf.xml

<?xml version="1.0"?>
<toolbox>
...
 <section name="External Tool" id="external_tool">
   <tool file="external_tool/dbsearch.xml" />               
 </section>
...

tools/external_tool/dbsearch.xml

<?xml version="1.0"?>
<tool name="DBSearch" id="dbsearch" tool_type="data_source" is_multi_byte="true">
    <description>横断検索ツール</description>
    <command interpreter="python">../data_source/data_source.py $output $__app__.config.output_size_limit</command>
    <inputs action="http://ubuntu.local:3000/db_search/index" check_values="false" method="get">
         <display>検索画面へ引き渡されるパラメータ</display>
         <param name="GALAXY_URL" type="baseurl" value="/tool_runner" />
         <param name="tool_id" type="hidden" value="dbsearch" />
    </inputs>
    <request_param_translation>
       <request_param galaxy_name="URL_method" remote_name="URL_method" missing="post" />
    </request_param_translation>
    <uihints minwidth="800"/>
    <outputs>
         <data name="output" format="tabular" />
    </outputs>
    <options sanitize="False" refresh="True"/>
</tool>

外部サイトで「検索画面」と「検索API」を作成

次は、外部サイトを作成します。以下はRails2.3.8での外部サイトの作成手順です。

# 本当は横断検索( http://lifesciencedb.jp/dbsearch/ )を実装したかったのですが間に合いませんでした><


$ rails dbsearch
$ cd dbsearch
$ ruby script/generate controller dbsearch index search
(以下のソースを編集)
$ ruby script/server

app/controllers/dbsearch_controller.rb

class DbsearchController < ApplicationController
 def index
   @galaxy_url = params['GALAXY_URL']
   @tool_id = params['tool_id']
   # 検索APIのURL
   # 生成されるURL例: http://localhost:3000/dbsearch/search
   @search_url = url_for :action => 'search'
 end

 def search
   search_param = params['search_param']
   render :text => "#{search_param}"
 end
end

app/views/dbsearch/index.html.erb

<h1>Galaxy連携する外部サイト</h1>

<form method="POST" action="<%= @galaxy_url %>" >
 <input type="hidden" name="tool_id" value="<%= h @tool_id %>" />
 <input type="hidden" name="URL" value="<%= @search_url %>" />
 <input type="text" name="search_param" value="" />
 <input type="submit" value="Send to Galaxy">
</form>

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # この行をコメントアウト
  # protect_from_forgery
end

動かし方

GalaxyとRailsを起動し、作成したツールを選択し、テキストボックへ適当な文字を入力し(英数字以外を入れると現状のGalaxyではエラーが発生するので注意)、「Send to Galaxy」ボタンを押すと、入力した文字がデータセットへと追加されます。