我想通过Python从月光蛋白数据库(www.moonlightingproteins.org/results.php?search_text=)中提取具有氨基酸序列的FASTA文件,因为它是一个迭代过程,我宁愿学习如何编程而不是手动执行,b / c来了,我们在2016年。问题是我不知道如何编写代码,因为我是一个新手程序员:(。基本的伪代码将是:< / p>
for protein_name in site: www.moonlightingproteins.org/results.php?search_text=:
go to the uniprot option
download the fasta file
store it in a .txt file inside a given folder
提前致谢!
答案 0 :(得分:0)
我强烈建议向作者询问数据库。来自FAQ:
我想在项目中使用MoonProt数据库来分析 使用生物信息学的氨基酸序列或结构。
如果您愿意,请通过bioinformatics@moonlightingproteins.org与我们联系 有兴趣使用MoonProt数据库分析序列和/或 兼职蛋白质结构。
假设您发现了一些有趣的内容,您将如何在论文或论文中引用它? &#34;未经作者同意,从公共网页上删除序列&#34;。更好地归功于原始研究人员。
这是scraping
的一个很好的介绍但回到你原来的问题。
import requests
from lxml import html
#let's download one protein at a time, change 3 to any other number
page = requests.get('http://www.moonlightingproteins.org/detail.php?id=3')
#convert the html document to something we can parse in Python
tree = html.fromstring(page.content)
#get all table cells
cells = tree.xpath('//td')
for i, cell in enumerate(cells):
if cell.text:
#if we get something which looks like a FASTA sequence, print it
if cell.text.startswith('>'):
print(cell.text)
#if we find a table cell which has UniProt in it
#let's print the link from the next cell
if 'UniProt' in cell.text_content():
if cells[i + 1].find('a') is not None and 'href' in cells[i + 1].find('a').attrib:
print(cells[i + 1].find('a').attrib['href'])