Beispiel #1
0
 def test_complex_query(self):
     """Ensure complicated search term executes and returns results."""
     self.term = """(monomethyl OR MEP OR mono-n-butyl OR MBP OR mono (3-carboxypropyl) OR mcpp OR monobenzyl OR mbzp OR mono-isobutyl OR mibp OR mono (2-ethylhexyl) OR mono (2-ethyl-5-oxohexyl) OR meoph OR mono (2-ethyl-5-carboxypentyl) OR mecpp OR mepp OR mono (2-ethyl-5-hydroxyhexyl) OR mehp OR mono (2-ethyl-5-oxyhexyl) OR mono (2-ethyl-4-hydroxyhexyl) OR mono (2-ethyl-4-oxyhexyl) OR mono (2-carboxymethyl) OR mmhp OR mehp OR dehp OR 2-ethylhexanol OR (phthalic acid)) AND (liver OR hepato* OR hepat*) AND ((cell proliferation) OR (cell growth) OR (dna replication) OR (dna synthesis) OR (replicative dna synthesis) OR mitosis OR (cell division) OR (growth response) OR hyperplasia OR hepatomegaly) AND (mouse OR rat OR hamster OR rodent OR murine OR Mus musculus or Rattus)"""  # noqa
     self.search = pubmed.PubMedSearch(term=self.term)
     self.search.get_ids_count()
     self.search.get_ids()
     self.assertTrue(len(self.search.ids) >= 212)
Beispiel #2
0
 def test_changes_from_previous_search(self):
     self.search = pubmed.PubMedSearch(term=self.term)
     self.search.get_ids_count()
     self.search.get_ids()
     old_ids_list = [999999, 19008416, 18927361, 18787170, 18487186]
     changes = self.search.get_changes_from_previous_search(
         old_ids_list=old_ids_list)
     self.assertEqual(changes["added"], set([18239126, 18239125]))
     self.assertEqual(changes["removed"], set([999999]))
Beispiel #3
0
 def test_changes_from_previous_search(self):
     self.search = pubmed.PubMedSearch(term=self.term)
     self.search.get_ids_count()
     self.search.get_ids()
     old_ids_list = [
         '999999', '19008416', '18927361', '18787170', '18487186'
     ]
     changes = self.search.get_changes_from_previous_search(
         old_ids_list=old_ids_list)
     self.assertEqual(changes['added'], set(['18239126', '18239125']))
     self.assertEqual(changes['removed'], set(['999999']))
Beispiel #4
0
    def run_new_query(self, prior_query):
        # Create a new search
        search = pubmed.PubMedSearch(term=self.search.search_string_text)
        search.get_ids_count()

        if search.id_count > self.MAX_QUERY_SIZE:
            raise TooManyPubMedResults(
                "Too many PubMed references found: {0}; reduce query scope to "
                "fewer than {1}".format(search.id_count, self.MAX_QUERY_SIZE))

        search.get_ids()
        results = {"ids": search.ids, "added": search.ids, "removed": []}

        if prior_query:
            old_ids_list = json.loads(prior_query.results)['ids']
            changes = search.get_changes_from_previous_search(
                old_ids_list=old_ids_list)
            results['added'] = list(changes['added'])
            results['removed'] = list(changes['removed'])

        self.results = json.dumps(results)
        self.save()
        self.create_identifiers()
        return results
Beispiel #5
0
 def test_multiquery(self):
     self.search = pubmed.PubMedSearch(term=self.term, retmax=3)
     self.search.get_ids_count()
     self.search.get_ids()
     self.assertEqual(self.search.request_count, 2)
     self._results_check()
Beispiel #6
0
 def test_standard_query(self):
     self.search = pubmed.PubMedSearch(term=self.term)
     self.search.get_ids_count()
     self.search.get_ids()
     self.assertEqual(self.search.request_count, 1)
     self._results_check()
Beispiel #7
0
#!/usr/bin/env python

'''
This script performs a PubMed search and returns a list of article IDs.
'''

from litter_getter import pubmed

pubmed.connect("PUBMED", '*****@*****.**')

#search_term = """science[journal] AND sorghum AND 2018[pdat]"""
search_term = """science[journal] AND breast cancer AND 2008[pdat]"""
search = pubmed.PubMedSearch(term=search_term)

search.get_ids_count()

print("ID count: {0}".format(search.id_count))

id_list = search.get_ids()

print("IDs: {0}".format(id_list))