Пример #1
0
def main(options):
    warn("getting pmid list..." % ())
    idlist = get_pmidlist(options)
    warn("processing %d ids: %s" % (len(idlist), idlist))
    if options.dry_run: exit(0)

    fuse = options.fuse
    for pmid in idlist:
        pubmed = Pubmed(pmid)
        warn("pmid is %s" % (pmid))
        continue
        try:
            pubmed.store()  # does the fetching automatically
        except Exception as e:
            warn("%d: caught %s" % (pmid, e))

        fuse -= 1
        if (fuse == 0): break

    exit(0)
Пример #2
0
def main(options):
    warn("getting pmid list..." % ())
    idlist=get_pmidlist(options)
    warn("processing %d ids: %s" % (len(idlist), idlist))
    if options.dry_run: exit(0)

    fuse=options.fuse
    for pmid in idlist:
        pubmed=Pubmed(pmid)
        warn("pmid is %s" % (pmid))
        continue
        try: 
            pubmed.store()      # does the fetching automatically
        except Exception as e:
            warn("%d: caught %s" % (pmid, e))

        fuse-=1
        if (fuse==0): break
                
    exit(0)
Пример #3
0
def get_pubmed_words(pubmed_id):
    ''' 
    return a dict in the same format as get_field_words: k=field, v=sanitized list of words
    '''
    words=dict()
    pubmed=Pubmed(pubmed_id).populate()
    for tag in Pubmed.text_tags:
        try: 
            words[tag]=getattr(pubmed, tag)
#            warn("fu %d: %s -> %s" % (pubmed_id, tag, words[tag]))
        except AttributeError as ae:
            pass

    return words
Пример #4
0
    def test_store(self):
        pmid = 18297132
        pubmed = Pubmed(pmid)
        self.assertEqual(pubmed.pubmed_id, pmid)

        try:
            os.unlink(pubmed.path())
        except OSError:
            pass

        pubmed.fetch()
        self.assertTrue(os.access(pubmed.path(), os.R_OK))
        self.assertEqual(os.path.getsize(pubmed.path()), 17990)
Пример #5
0
    def test_store(self):
        pmid=18297132
        pubmed=Pubmed(pmid)
        self.assertEqual(pubmed.pubmed_id, pmid)

        try: os.unlink(pubmed.path())
        except OSError: pass

        pubmed.fetch()
        self.assertTrue(os.access(pubmed.path(), os.R_OK))
        self.assertEqual(os.path.getsize(pubmed.path()), 17990)
Пример #6
0
    def test_store(self):
        warn("\n")
        pmid = 18297132
        pubmed = Pubmed(pmid)
        self.assertIsInstance(pubmed, Pubmed)
        self.assertEqual(pubmed.pubmed_id, pmid)

        pubmed.remove()
        pubmed.store()
        self.assertTrue(os.access(pubmed.path(), os.R_OK))
        cursor = Pubmed.mongo().find({'pubmed_id': pmid})
        self.assertEqual(cursor.count(), len(Pubmed.text_tags))

        tag2count = {
            'MeshHeading': 22,
            'AbstractText': 247,
            'ArticleTitle': 15
        }
        for record in cursor:
            tag = record['tag']
            self.assertEqual(len(record['words']), tag2count[tag])
Пример #7
0
    def test_store(self):
        warn("\n")
        pmid=18297132
        pubmed=Pubmed(pmid)
        self.assertIsInstance(pubmed, Pubmed)
        self.assertEqual(pubmed.pubmed_id, pmid)

        pubmed.remove()
        pubmed.store()
        self.assertTrue(os.access(pubmed.path(), os.R_OK))
        cursor=Pubmed.mongo().find({'pubmed_id':pmid})
        self.assertEqual(cursor.count(), len(Pubmed.text_tags))
        
        tag2count={'MeshHeading':22,
                   'AbstractText':247,
                   'ArticleTitle':15}
        for record in cursor:
            tag=record['tag']
            self.assertEqual(len(record['words']), tag2count[tag])