Skip to content
tfuji edited this page Feb 14, 2017 · 10 revisions

2016/10/28

API案

メソッド1

  • 入力: String
  • 出力: JSON

メソッド2

  • 入力: Stringのリスト
  • 出力: JSON

ユーザ向けサービス

  • DDBJ登録アノテーションファイルを入力したときの便利なもの

DDBJ登録形式をパース

#!perl

#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use Data::Dumper;

my $hash = {};
my $cache = {};
my $line = 1;
while (<>){
    chomp;
    my ($entry, $feature, $location, $qualifier, $qualifier_value) = split /\t/, $_, -1;
    my $feature_id = '';
    if ($line == 1) {
        $cache = {'entry' => $entry, 'feature' => $feature, 'location' => $location };
        $feature_id = $entry."#feature:".$location.":".$feature;
        $hash->{$entry}->{$feature_id} = $cache;
    }else{
        my $idx = '';
        $cache->{'entry'} = $entry if $entry;
        $cache->{'feature'} = $feature if $feature;
        $cache->{'location'} = $location if $location;
        $feature_id = $cache->{'entry'}."#feature:".$cache->{'location'}.":".$cache->{'feature'}.".". $idx;
        $hash->{$cache->{'entry'}}->{$feature_id}->{'location'} = $cache->{'location'};
        $hash->{$cache->{'entry'}}->{$feature_id}->{'feature'} = $cache->{'feature'};
        $hash->{$cache->{'entry'}}->{$feature_id}->{'entry'} = $cache->{'entry'};
        #$hash->{$cache->{'entry'}}->{$feature_id} = $cache;

        if ($qualifier eq 'product'){
            print $qualifier_value."\n";
        }
    }
    #$hash->{$cache->{'entry'}}->{$feature_id} = $cache;
    push( @{$hash->{$cache->{'entry'}}->{$feature_id}->{'qualifiers'}}, {'key'=> $qualifier, 'value' => $qualifier_value}, 'line' => $line++);
    #$line +=1;

}
#print Dumper $hash;

2016/11/29

Plackを用いてAPIサーバ試作

  • annotation.psgiを実装

起動方法

plackup -a annotation.psgi

パラメーター

query (複数指定OK)

[火 11 29 16:58] tf@/tmp
%curl -s -d 'query=XXX protein' -d 'query=YYY protein' http://togo.genes.nig.ac.jp:5000 |jq
[
  {
    "info": "SxtX protein [-1:sxtx] @@ GvpX protein [10001:gvpx] @@ PipX protein [10001:pipx] @@ Mvn protein [10001:mvn] @@ Doc protein [10001:doc]",
    "query": "XXX protein",
    "match": "cs",
    "result_array": [
      "SxtX protein",
      "GvpX protein",
      "PipX protein",
      "Mvn protein",
      "Doc protein"
    ],
    "result": "SxtX protein"
  },
  {
    "info": "Gp3 protein [-1:gp3] @@ ChpY protein [10001:chpy] @@ Mvn protein [10001:mvn] @@ Doc protein [10001:doc] @@ Bdr protein [10001:bdr]",
    "query": "YYY protein",
    "match": "cs",
    "result_array": [
      "Gp3 protein",
      "ChpY protein",
      "Mvn protein",
      "Doc protein",
      "Bdr protein"
    ],
    "result": "Gp3 protein"
  }
]

list=【@file】

  • サンプルデータ: misc/annotation_list.txt
%curl -s -F 'list=@annotation_list.txt'  http://togo.genes.nig.ac.jp:5000 |jq
[
  {
    "info": "in_dictionary : abc transporter",
    "query": "ABC transporter",
    "match": "ex",
    "result_array": [
      "ABC transporter"
    ],
    "result": "ABC transporter"
  },
  {
    "info": "in_dictionary : histidine kinase [Enzyme name]",
    "query": "histidine kinase",
    "match": "ex",
    "result_array": [
      "Histidine kinase"
    ],
    "result": "Histidine kinase"
  },
  {
    "info": "in_dictionary : hypothetical protein",
    "query": "hypothetical protein",
    "match": "ex",
    "result_array": [
      "hypothetical protein"
    ],
    "result": "hypothetical protein"
  }
]

ddbj=【@file】

サンプルデータ: misc/NIES39_v17.ddbj

%curl -s -F 'ddbj=@/Users/tf/Dropbox/apl/DDBJ/NIES39_v17.ddbj'  http://togo.genes.nig.ac.jp:5000 |jq
[
  {
    "info": "in_dictionary : hypothetical protein",
    "query": "hypothetical protein",
    "match": "ex",
    "result_array": [
      "hypothetical protein"
    ],
    "result": "hypothetical protein"
  },
  {
    "info": "in_dictionary : hypothetical protein",
    "query": "hypothetical protein",
    "match": "ex",
    "result_array": [
      "hypothetical protein"
    ],
    "result": "hypothetical protein"
  },
  {
    "info": "in_dictionary (prefix=putative ): hydrolase",
    "query": "putative hydrolase",
    "match": "ex",
    "result_array": [
      "putative hydrolase"
    ],
    "result": "putative hydrolase"
  },
(略)

2016/12/12

Mojoliciousで利用している機能の関連リンク

API

  • 出力はJSON
  • 入力1 (一つの入力):
#!sh
$ curl -s 'http://togoannotator.dbcls.jp/annotate/gene/XXX%20protein' | jq
{
  "info": "Gp3 protein [-1:gp3] @@ GvpX protein [10001:gvpx] @@ SxtX protein [10001:sxtx] @@ PipX protein [10001:pipx] @@ Mvn protein [10001:mvn]",
  "match": "cs",
  "query": "XXX protein",
  "result": "Gp3 protein",
  "result_array": [
    "Gp3 protein",
    "GvpX protein",
    "SxtX protein",
    "PipX protein",
    "Mvn protein"
  ]
}
  • 入力2 (リストファイルをアップロード):
#!sh
$ curl -s -F 'upload=@/opt/services2/togoannot/togoannotator/misc/annotation_list.txt' 'http://togoannotator.dbcls.jp/annotate/genes' | jq
[
  {
    "info": "in_dictionary : abc transporter",
    "match": "ex",
    "query": "ABC transporter",
    "result": "ABC transporter",
    "result_array": [
      "ABC transporter"
    ]
  },
  {
    "info": "in_dictionary : histidine kinase [Enzyme name]",
    "match": "ex",
    "query": "histidine kinase",
    "result": "Histidine kinase",
    "result_array": [
      "Histidine kinase"
    ]
  },
  {
    "info": "in_dictionary : hypothetical protein",
    "match": "ex",
    "query": "hypothetical protein",
    "result": "hypothetical protein",
    "result_array": [
      "hypothetical protein"
    ]
  }
]
  • 入力3 (DDBJファイルをアップロード):
#!sh
$ curl -s -F 'upload=@/opt/services2/togoannot/togoannotator/misc/NIES39_v17.ddbj' 'http://togoannotator.dbcls.jp/annotate/ddbj' | jq

2016/12/22

OpenAPIとその実証を利用して、APIドキュメントおよび動作環境をMojolicious::Liteで実装したウェブサイトに組込む

手順

Mojoliciousで利用している機能の関連リンク

2017.02.14

Clone this wiki locally