forked from buhrmann/elegans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubmed.py
25 lines (21 loc) · 936 Bytes
/
pubmed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from Bio import Entrez
Entrez.email = 'thomas.buehrmann@gmail.com'
def num_articles_for_neuron(neuron, query):
search_term = "\"Caenorhabditis elegans\"[All Fields] AND \"" + query + "\"[All Fields] AND \"" + neuron + "\"[All Fields]"
print "Searching pubmed for: "
print search_term
handle = Entrez.esearch(db="pubmed", term=search_term, retmax=1000, rettype='count')
record = Entrez.read(handle)
print "Result:"
print record
return int(record['Count'])
def neurons_for_query(neuron_names, query, threshold=1):
filtered_neurons = []
num_neurons = len(neuron_names)
for i, n in enumerate(neuron_names):
print "Checking neuron %i of %i: %s" % (i, num_neurons, n)
num_articles = num_articles_for_neuron(n, query)
if num_articles >= threshold:
print "Found %i articles." % (num_articles)
filtered_neurons.append(n)
return filtered_neurons