KazusaAPI開発日誌 このページをアンテナに追加 RSSフィード

2009-02-04Gendoo multi

Gendoo Galaxy Tool にヒストリから入力できるようにする

|  Gendoo Galaxy Tool にヒストリから入力できるようにする - KazusaAPI開発日誌 を含むブックマーク はてなブックマーク -  Gendoo Galaxy Tool にヒストリから入力できるようにする - KazusaAPI開発日誌  Gendoo Galaxy Tool にヒストリから入力できるようにする - KazusaAPI開発日誌 のブックマークコメント

Filter and Sort ツールの Filter (Tools/stats/filter1.xml) を参考にしました。


tool_conf.xml の変更分
  <section name="DBCLS Tools" id="dbcls_tools">
   <tool file="dbcls/gendoo.xml" />
   <tool file="dbcls/gendoo_multi.xml" />
<tool id="GendooTable" name="Gendoo Table">
  <description>table browser</description>
  <command interpreter="ruby">gendoo_multi.rb $input $dsn $out_file</command>
    <param format="tabular" name="input" type="data" label="Query" help="Query missing? See TIP below."/>
    <param name="dsn" type='select'>
       <label>Data Source Name (DSN)</label>
       <option value='human'>Homo sapiense</option>
       <option value='synecho'>Synechocystis sp. PCC 6803</option>
       <option value='meso'>Mesorhizobium loti MAFF303099</option>
       <option value='lotus'>Lotus japonicas</option>
    <data format="input" name="out_file" metadata_source="input" />

.. class:: infomark

**TIP:** Attempting to apply a filtering condition may throw exceptions if the data type (e.g., string, integer) in every line of the columns being filtered is not app
ropriate for the condition (e.g., attempting certain numerical calculations on strings).  If an exception is thrown when applying the condition to a line, that line is
 skipped as invalid for the filter condition.  The number of invalid skipped lines is documented in the resulting history item as a "Condition/data issue".

.. class:: infomark

**TIP:** If your data is not TAB delimited, use *Text Manipulation-&gt;Convert*



require 'open-uri'

class Matcher
  def self.ig_and_pvalue
    /<td class="\S+" title="IG=(\d.*?), p-value=(\d.*?)">/

  def self.meshid_and_term(dsn)
  def self.aspect
    /<h2><a name="\w+">(\w+.*?\w+)<\/a><\/h2>/

input_file, dsn, out_file = ARGV
input = File.open(input_file).read.split("\s").map {|x| x.strip }

# http://gendoo.dbcls.jp/pre/cgi-bin/gendoo.cgi?geneid=slr1311%0D%0Aslr1312&genename=&taxonomy=synecho&submit=Search
queries = input.join("%0D%0A")
url = "http://gendoo.dbcls.jp/pre/cgi-bin/gendoo.cgi?geneid=#{queries}&genename=&taxonomy=#{dsn}&submit=Search"

text = open(url).read
i = 0
File.open(out_file, 'w') do |f|                     
  aspect = ''
  meshid = ''
  term = ''
  text.split("\n").each do |line|
    case line
    when Matcher.ig_and_pvalue
      ig = $1
      pvalue = $2
      query = input[i]
      i += 1
      i = 0 if i == input.size
      f.puts [dsn, query, meshid, aspect, term, ig, pvalue].join("\t")
    when Matcher.meshid_and_term(dsn)
      meshid = $1
      term = $2
    when Matcher.aspect
      aspect = $1
puts "Gendoo: #{input.join(',')} related diseases, drugs, ..."


トラックバック - http://kdri.g.hatena.ne.jp/nakao_mitsuteru/20090204