当前位置: 首页>>代码示例>>Python>>正文


Python Bio.Medline类代码示例

本文整理汇总了Python中Bio.Medline的典型用法代码示例。如果您正苦于以下问题:Python Medline类的具体用法?Python Medline怎么用?Python Medline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Medline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getMedlineList

def getMedlineList(pmids):

    """
    This function takes a list of article-ids and returns a list of
    MedLine articles that contains an abstract.
    """

    records = []
    cleaned_records = []
    listLength = len(pmids)

    Entrez.email = '[email protected]'

    for i in range(0, listLength, 650):
        tempList = pmids[i:i + 650]
        handle = Entrez.efetch(db='pubmed', id=tempList,rettype='medline', retmode='text')
        try:
            records.extend(list(Medline.parse(handle)))
        except:
            IOmodule.writeOutTxt(_mainFolder+'/'+'errordir_medline_records', pmids[i], '')

        print 'Downloaded',len(records),'MedLine articles.',str(listLength-len(records)),'remaining...'

    for article in records:
        if 'AB' in article:
            cleaned_records.append(article)
    
    print 'Returned',len(cleaned_records),'MedLine articles containing an abstract.'
    return cleaned_records
开发者ID:hmbachelor,项目名称:bachelor,代码行数:29,代码来源:PubmedSIR.py

示例2: __init__

    def __init__(self, pmids):
        
         Entrez.email = '[email protected]'

         ## pmids is a list (array of pmid)
         handle = Entrez.efetch(db='pubmed', id=pmids, rettype='medline', retmode='text')
         self.records = Medline.parse(handle)
开发者ID:sweng66,项目名称:lit-review,代码行数:7,代码来源:pubmed.py

示例3: test_medline_from_url

 def test_medline_from_url(self):
     """Test Entrez into Medline.read from URL"""
     efetch = Entrez.efetch(db="pubmed", id="19304878", rettype="medline", retmode="text")
     record = Medline.read(efetch)
     self.assertTrue(isinstance(record, dict))
     self.assertEqual("19304878", record["PMID"])
     self.assertEqual("10.1093/bioinformatics/btp163 [doi]", record["LID"])
开发者ID:janusz005,项目名称:biopython,代码行数:7,代码来源:test_Entrez_online.py

示例4: get_pubmed_document

def get_pubmed_document(pubmed_ids, source='pubmed', include_pubtator=True):
    Entrez.email = settings.ENTREZ_EMAIL

    if type(pubmed_ids) == list:
        ids = [str(doc_id) for doc_id in pubmed_ids]
    else:
        ids = [str(pubmed_ids)]

    h = Entrez.efetch(db='pubmed', id=ids, rettype='medline', retmode='text')
    records = Medline.parse(h)

    # Reference to abbreviations: http://www.nlm.nih.gov/bsd/mms/medlineelements.html
    for record in records:
        if record.get('TI') and record.get('AB') and record.get('PMID') and record.get('CRDT'):
            #if Document.objects.pubmed_count(record.get('PMID')) is 0:
            title = ' '.join( pad_split(record.get('TI')) )
            abstract = ' '.join( pad_split(record.get('AB')) )

            doc, doc_c = Document.objects.get_or_create(document_id=record.get('PMID'))
            doc.title = title
            doc.source = source
            doc.save()

            sec, sec_c = Section.objects.get_or_create(kind='t', document=doc)
            sec.text = title
            sec.save()

            sec, sec_c = Section.objects.get_or_create(kind='a', document=doc)
            sec.text = abstract
            sec.save()

            if include_pubtator:
                doc.init_pubtator()
开发者ID:x0xMaximus,项目名称:YdF2fG2lkPHbCpAiHJpmexo0mnXdbb2NYLYOXIy6Rq,代码行数:33,代码来源:tasks.py

示例5: getMeSH

def getMeSH(url):
        query = urllib.unquote_plus(url)

        if not query:
                return "<h3> No query </h3>"
        
        MAX_COUNT = 10000
         
        Entrez.email = '[email protected]'
        pubmedquery = query.replace('-','\-')
        h = Entrez.esearch(db='pubmed', term=pubmedquery, retmax=MAX_COUNT)
        result = Entrez.read(h)
        ids = result['IdList']
        if not ids:
                return "<h3> geen gevonden resultaten </h3>"
        h = Entrez.efetch(db='pubmed', id=ids, rettype='medline', retmode='text')
        records = Medline.parse(h)

        MeSHCount = 0
        MeSHContent = ""
        
        for record in records:
                try:
                        if "tox" in str(record.get("MH")):
                                MeSHContent += "<h4><a href='http://www.ncbi.nlm.nih.gov/pubmed/"+str(record.get("PMID"))+"'>"
                                MeSHContent += "PMID: "+str(record.get("PMID"))+"</a> is analysed on toxicity. </h4> \n"
                except (TypeError):
                        continue;
                
        return MeSHContent
开发者ID:BjornWouters,项目名称:PubCheck,代码行数:30,代码来源:getMeSH.py

示例6: createTable

def createTable(query):

    if not query:
        return "<h3> No query </h3>"

    MAX_COUNT = 100
    pubmedquery = query.replace("-", "\-")
    Entrez.email = "[email protected]"
    h = Entrez.esearch(db="pubmed", term=pubmedquery, retmax=MAX_COUNT)
    result = Entrez.read(h)
    ids = result["IdList"]
    h = Entrez.efetch(db="pubmed", id=ids, rettype="medline", retmode="text")
    records = Medline.parse(h)

    tableContent = ""

    for record in records:
        try:
            tableContent += (
                "<tr><td width='22%'>" + str(record.get("TI")) + "</td>"
                "<td width='5%'>" + str(record.get("DP")) + "</td>"
                "<td width='5%'>" + str(writers(record.get("FAU"))) + "</td>"
                "<td width='5%'>" + str(record.get("JT")) + "</td>"
                "<td width='5%'>" + str(query) + "</td>"
                "<td>"
                "<a href='http://www.ncbi.nlm.nih.gov/pubmed/"
                + str(record.get("PMID"))
                + "'><img src='PubMed.png' height='75px' width='75px' alt='PubMed' align='right'/></a>"
                + str(record.get("AB"))
                + "</td></tr>"
            )
        except (TypeError):
            continue

    return tableContent
开发者ID:NathanvanDalen,项目名称:PubCheck-1,代码行数:35,代码来源:table.py

示例7: processInput

	def processInput(k):
		print "Querying PMID: "+str(k)+"."
		getall = Medline.read(Entrez.efetch(db="pubmed", id=k, rettype="medline", retmode="text"))
		singlemesh = getall.get("MH")
		singledate = getall.get("EDAT")	
		for j1 in range(len(singlemesh)):
			cur.execute("INSERT INTO MeSH002(PMID, MeSH, Dates) VALUES("+str(k)+",'" + getall.get("MH")[j1][0:24].translate(None, "'*&")+"','" +  str(singledate[0:10]) +"')" )
开发者ID:AldoCP,项目名称:PubMed_databases,代码行数:7,代码来源:MeSH_to_MySQL.py

示例8: get_wikiref

def get_wikiref(pmid):
    """ Returns the Wiki cite journal entry for a given Pubmed ID """
    
    handle = Entrez.efetch(db="pubmed", id=pmid, rettype="medline", retmode="text")
    records = Medline.parse(handle)
    records = list(records)
    
    import datetime
    now = datetime.datetime.now()
    jetzt= now.strftime("%Y-%m-%d")
    
    # generate the {{cite journal}} format
        
    for rec in records:
        aut = rec["AU"]
        firstauthor = aut.pop(0)
        coauthors = ", ".join(aut)
        
        # get date of publication
        # CRDT
        datee = rec["CRDT"][0].split('/')[0]
        #if datee == '':
        #    datee = rec["PD"]
        
        outstring = "{{cite journal|title=%s|journal=%s|year=%s|author=%s|coauthors=%s|volume=%s|pages=%s|id=PMID %s|accessdate=%s}}" % \
                    (rec["TI"], rec["JT"], datee, firstauthor, coauthors, rec["VI"], rec["PG"], pmid, jetzt)
        
        # example:
        #{{cite journal|title=|journal=|date=2008/07/31/|first=Cyril|last=Herry|coauthors=i|volume=454|issue=7204|pages=600-606|id=PMID 18615015 {{doi|10.1038/nature07166}}|url=http://www.fmi.ch/downloads/news/2008.07.11.01.luthi.nature.press.release.pdf|format=|accessdate=2009-09-12 }}
        
    return outstring
开发者ID:unidesigner,项目名称:connectomewiki,代码行数:31,代码来源:parse_songbird.py

示例9: fetch

def fetch(t, s):
    h = Entrez.esearch(db="pubmed", term=t, retmax=10000, sort=s)
    idList = Entrez.read(h)["IdList"]
    results = "Total publications for SA Beatson: **" + str(len(idList)) + "**\n\n"
    results += "Chronologically sorted:\n\n"

    if idList:
        handle = Entrez.efetch(db="pubmed", id=idList, rettype="medline", retmode="text")
        records = Medline.parse(handle)
        max = len(idList) + 1
        for record in records:
            title = record["TI"]
            author = ", ".join(record["AU"])
            source = record["SO"]
            pub_date = datetime.strptime(record["DA"], "%Y%m%d").date()
            pmid = record["PMID"]
            cur_pub = "| **%i.** %s\n| %s\n| %s\n| http://www.ncbi.nlm.nih.gov/pubmed/%s\n|\n" % (
                max - 1,
                title,
                author,
                source,
                pmid,
            )
            results = results + cur_pub
            max = max - 1
    return results
开发者ID:nbenzakour,项目名称:BeatsonLab-MicrobialGenomics.github.io,代码行数:26,代码来源:get_publications.py

示例10: store_abstracts_for_query

def store_abstracts_for_query(query,query_tag,maxN=None,preview_only=False):
	# if query_tag=="":
	# 	simpleQuery=" ".join(map(lambda x:x.name,queryTerms))
	# else:
	# 	simpleQuery=query_tag
	# query=pg.build_query(queryTerms)
	print "will search",query
	Entrez.email = "[email protected]"
	search_results = Entrez.read(Entrez.esearch(db="pubmed",
												term=query,
												reldate=10*365, datetype="pdat",
												usehistory="y"))
	count = int(search_results["Count"])
	print "Found %i results" % count
	if maxN!=None and maxN<count:
		count=maxN
		print "Only keeping first",count,"abstracts"
	if preview_only:
		return
	sys.stdout.flush()
	batch_size = 50
	for start in range(0,count,batch_size):
			end = min(count, start+batch_size)
			print "Going to download record %i to %i" % (start+1, end)
			sys.stdout.flush()
			fetch_handle = Entrez.efetch(db="pubmed",
										 rettype="medline", retmode="text",
										 retstart=start, retmax=batch_size,
										 webenv=search_results["WebEnv"],
										 query_key=search_results["QueryKey"])
			records=Medline.parse(fetch_handle)
			for r in records:
				pubmed_to_pg.store_medline_entry(r,query_tag)
开发者ID:massyah,项目名称:LINK,代码行数:33,代码来源:entrez_pubmed_interface.py

示例11: fetch_pubmed_data

def fetch_pubmed_data(pmid):

    from Bio import Medline,Entrez
    
    try:
        ncbiemail= settings.author_email
    except:
        try:
            ncbiemail= settings.author_email
        except:
            raise Exception('Please set an email to use ncbi services')
    
    Entrez.email = ncbiemail
    Entrez.tool = 'mybiodb'

    try:
        entrez_response=Medline.parse( Entrez.efetch(db="pubmed", id=pmid, rettype="medline",retmode="text",)).next()
        if not entrez_response.has_key('PMID'):
             response.flash='pubmed ID error'
        else:
            return entrez_response
    except IOError:
        session.flash='Remote service not available, please try again.'

       
    return
开发者ID:apierleoni,项目名称:MyBioDb,代码行数:26,代码来源:utilities.py

示例12: top_papers_dict

def top_papers_dict(papers, outpath=None,delim="\t", top=None):
    """This function fetches all the relevent PubMed info for each PMID in 'papers' 
    (at the limit supplied in 'top') and 1) puts it into a dict."""
    #
    # Can be used with SP & GOA data
    
#    papers_annots = [(len(papers_prots[p]), p) for p in papers_prots]
    papers_annots = [(len(papers[p]), p) for p in papers]
    papers_annots2_dict = {}
        
    papers_annots.sort()
    if top is None:
        negTop = 0
    else:
        negTop = -top
    idlist = [p[1] for p in papers_annots[negTop:]]
    Entrez.email = MY_EMAIL
    h = Entrez.efetch(db="pubmed", id=",".join(idlist), 
                          rettype="medline", retmode="text")
    medrecs = list(Medline.parse(h))
    titles = [medrec.get("TI","?") for medrec in medrecs]
    years = [medrec.get("DP","?") for medrec in medrecs]
    journals = [medrec.get("JT", "?") for medrec in medrecs]
    for p, title, year, journal in zip(papers_annots[negTop:], titles,years, journals):
        #papers_annots2_dict[PMID] = [# of total annotations, Title, Year, Journal] 
        papers_annots2_dict[p[1]] = [len(papers[p[1]]), title, year.split()[0].strip(), journal]
    """if outpath:
        fout = open(outpath,"w")
        print >> fout, "num proteins\tpubmed ID\tTitle\tYear\tJournal"
        for p in papers_annots2:
            print >> fout, "%d\t%s\t%s\t%s\t%s" % p
        fout.close()
    """
    return papers_annots2_dict
开发者ID:FriedbergLab,项目名称:Uniprot-Bias,代码行数:34,代码来源:sp_tools.py

示例13: fetch

	def fetch(self, batchSize=100):
		"""Return a batch of results.
		"""
		if self._done:
			return []

		end = min(self._searchCount, self._searchPosition + batchSize)

		log.info("Downloading from %i to %i..." % (self._searchPosition+1, end))

		fetchHandle = Entrez.efetch(db="pubmed", rettype="medline", retmode="text", retstart=self._searchPosition, retmax=batchSize, webenv=self._searchSession, query_key=self._queryKey)
		result = Medline.parse(fetchHandle)

		papers = [paper.Paper(r) for r in result if r.get("PMID") is not None ]

		fetchHandle.close()

		log.info("... downloading done")

		self._searchPosition = self._searchPosition + batchSize

		if self._searchPosition >= self._searchCount:
			self._done = True
			log.info("Search ended.")

		return papers
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:26,代码来源:paperbot.py

示例14: pubsearch

def pubsearch(jids):
    Entrez.email = "[email protected]"
    # always let Entrez know who is calling

    pubterm = ""
    for i in jids:
        pubterm += i + "[JID] or "

    IDhandle = Entrez.esearch(
        db="pubmed", term="peptide AND (" + pubterm + " and ", mindate="2011", maxdate="2014", retmax=2500
    )
    # for documentation on esearch, see
    # http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch
    # max number for retmax is 100k. Use retstart to get more than this.
    # Date range used to limit a search result by the date specified by datetype. These two parameters (mindate, maxdate) must be used together to specify an arbitrary date range. The general date format is YYYY/MM/DD, and these variants are also allowed: YYYY, YYYY/MM.

    record = Entrez.read(IDhandle)
    # record is returned as a dictionary. Lists search terms, all ID numbners etc

    idlist = record["IdList"]
    # return a list of ID numbers from the record dictionary

    recordHandle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="text")
    # search pubmed for records with idlist as input

    records = Medline.parse(recordHandle)
    # create dictionary from recordHandle

    return records
开发者ID:ratiom,项目名称:pubmed,代码行数:29,代码来源:pubmed_scraper_003.py

示例15: search_pubmed

def search_pubmed(term):
    "Searches a term on pubmed"
    print("Searching for", term)
    try:
        # Do a first query
        handle = Entrez.egquery(term=term)
        record = Entrez.read(handle)
        nb_entries = 0
        for row in record["eGQueryResult"]:
            if row["DbName"]=="pubmed":
                nb_entries = row["Count"]
                print(row["Count"], 'results found.')
        if int(nb_entries) == 0:
            return BibDatabase()
        # Search the IDs
        handle = Entrez.esearch(db="pubmed", term=term, retmax=min(int(nb_entries), MAX_RESULTS))
        record = Entrez.read(handle)
        idlist = record["IdList"]
        # Get the descriptions
        handle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="text")
        records = Medline.parse(handle)
        records = list(records)
        return transform_pubmed(records)

    except Exception as e:
        print('The search failed.')
        print(e)
        return []
开发者ID:vitay,项目名称:Biberon,代码行数:28,代码来源:Search.py


注:本文中的Bio.Medline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。