3

我正在使用 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
4

0 回答 0