从pubmed获取全文

时间:2016-07-21 08:28:21

标签: python biopython pubmed

我正在使用python api Bio访问pubmed中央数据库但不幸的是我只能从这个api获得摘要 我想知道是否有可能获得全文以及如何

molp5是一个包含下面分子列表的文件

Flavopiridol
4-azapaullone

这是我的代码:

def search(query):
    Entrez.email = 'xxxxx@gmail.com'
    handle = Entrez.esearch(db='pubmed', 
                            sort='relevance', 
                            retmax='3000',
                            retmode='text',
                            rettype='Medline', 
                            term=query)
    results = Entrez.read(handle)
    return results

def fetch_details(id_list):
    ids = ','.join(id_list)
    Entrez.email = 'xxxxx@gmail.com'
    handle = Entrez.efetch(db='pubmed',
                           retmode='xml',
                           id=ids)
    results = Entrez.read(handle)
    return results

if __name__ == '__main__':

    #load the file containing the name of the molecules
    mol = pd.read_csv('/W2V/molp5.csv')


    mol["idx"] = mol["idx"].apply(lambda x:lower(x))

    txt = ""
    retmax = []
    for m in mol["idx"]:
        results = search(m)
            #print the number of article available and the name of the molecule
            print m, results['RetMax']
            id_list = results['IdList']
            papers = fetch_details(id_list)
            for i, paper in enumerate(papers):
        try:
            #concatenate the abstract together
            txt += paper['MedlineCitation']['Article']['ArticleTitle']
            for j in paper['MedlineCitation']['Article']['Abstract']['AbstractText']:
                txt += j+'\n'  
            except KeyError:
            pass

0 个答案:

没有答案