LoginSignup
0
1

More than 5 years have passed since last update.

GeneOntrogyのchild termをすべて取得する

Last updated at Posted at 2017-09-01

Amigoの標準ブラウザでは、なぜか、特定termのChild termを全部取ってくるということができなかった。
そういうときはgooseをつかって直接sqlセレクト文と叩いて取ってくることができる
gooseのページ
http://amigo.geneontology.org/goose
構文例集
http://wiki.geneontology.org/index.php/Example_LEAD_Queries

けど、sqlにはあんま慣れてないのでできればpythonに直で流したい
そこでpythonをつかってGoSqlに入って、データを取ってくるスクリプトを作ったのでメモっとく。

以下のサイトを参考にした
https://biology.stackexchange.com/questions/35188/how-do-i-find-the-number-of-child-terms-associated-with-a-specific-go-term

go_child_get_mysql.py

# -*- coding: utf-8 -*-
import MySQLdb

# DBに接続しカーソルを取得する
connect = MySQLdb.connect(host='mysql-amigo.ebi.ac.uk', port=4085, user='go_select', passwd='amigo' , db='go_latest', charset='utf8')
cursor = connect.cursor()


sql = (
    'SELECT DISTINCT descendant.acc, descendant.name, descendant.term_type '
    'FROM'
    ' term'
    ' INNER JOIN graph_path ON (term.id=graph_path.term1_id)'
    ' INNER JOIN term AS descendant ON (descendant.id=graph_path.term2_id) '
    "WHERE term.name='nucleus' AND distance <> 0;"
#IDで調べるときはterm.acc='GO:0015979'など
)

cursor.execute(sql)  # select文を実行

for row in cursor:
    print row[0], row[1]

cursor.close()
connect.close()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1