python 获取wormbase菌株信息#wormbase

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 获取wormbase菌株信息#wormbase相关的知识,希望对你有一定的参考价值。

from pprint import pprint as pp
import requests

# Get strain list

strains = requests.get("https://docs.google.com/spreadsheets/d/1V6YHzblaDph01sFDI8YK_fP0H7sVebHQTXypGdiQIjI/pub?output=tsv")
strains =  filter(len,set([x.split("\t")[1] for x in strains.text.splitlines()[1:]]))


for x in strains:
	url = "http://api.wormbase.org/rest/field/strain/" + x + "/origin"
	r = requests.get(url, headers = {"content-type":"application/json"})
	if r.status_code == 200:
		x = r.json()["origin"]
		strain = x["name"]["data"]["label"]
		place = x["place"]["data"]
		landscape = x["landscape"]["data"]
		substrate = x["substrate"]["data"]
		place = x["landscape"]["data"]
		date_isolated = x["date_isolated"]["data"]
		sampled_by = x["landscape"]["data"]
		isolated_by = x["laboratory"]["data"][0]["representative"][0]["label"]
		out = [strain, landscape, substrate, place, date_isolated, sampled_by, isolated_by]
		out = ["" if x==None else x for x in out]
		print "\t".join(out)

以上是关于python 获取wormbase菌株信息#wormbase的主要内容,如果未能解决你的问题,请参考以下文章

r 使用R #API对wormbase发出请求

sh 从wormbase基因组序列生成blast基因组

sh 下载Wormbase Genomes并为bwa,blast等设置#fasta

利用Python-docx 读写 Word 文档中的正文表格段落字体等

sh 重命名菌株.sh

R语言聚类分析之基于划分的聚类KMeans实战:基于菌株数据