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に入って、データを取ってくるスクリプトを作ったのでメモっとく。
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()