Exemplo n.º 1
0
    def test_evidence_asserts_all_about(self):
        """ Test that we can assert_all_about a containing object and
        then get evidence for contained objects.
        """
        import random
        random.seed()
        v = values('all')

        def make_syn():
            import struct
            u = struct.pack("=2f", random.random(), random.random())
            z = struct.pack("=2f", random.random(), random.random())
            a = Neuron(u.encode('hex'))
            b = Neuron(z.encode('hex'))
            v.value(a.neighbor(b))
            return (a, b)

        for x in range(200):
            make_syn()

        # the one we'll check for
        a, b = make_syn()
        ev = Evidence(author="Homer")
        ev.asserts_all_about(ev)
        ev.save()
        eve = Evidence()
        eve.asserts(a.neighbor(b))
Exemplo n.º 2
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')
        ar = DataObject(key='aref')
        br = DataObject(key='bref')

        e = self.ctx.Evidence(key="a", reference=ar)
        e.supports(r)
        self.save()

        e1 = self.ctx.Evidence(key="b", reference=br)
        e1.supports(r)
        self.save()

        e0 = Evidence()
        e0.supports(r)
        for x in e0.load():
            lar = x.reference.one()
            lbr = x.reference.one()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(lbr, br)
            elif x.idl == e.idl:
                self.assertEqual(lar, ar)
            else:
                self.fail("Unknown object returned from load")
Exemplo n.º 3
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')
        ar = DataObject(key='aref')
        br = DataObject(key='bref')

        e = self.ctx.Evidence(key="a", reference=ar)
        e.supports(r)
        self.save()

        e1 = self.ctx.Evidence(key="b", reference=br)
        e1.supports(r)
        self.save()

        e0 = Evidence()
        e0.supports(r)
        for x in e0.load():
            lar = x.reference.one()
            lbr = x.reference.one()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(lbr, br)
            elif x.idl == e.idl:
                self.assertEqual(lar, ar)
            else:
                self.fail("Unknown object returned from load")
Exemplo n.º 4
0
 def test_1(self):
     import bibtex
     bt = bibtex.parse("my.bib")
     n1 = Neuron("AVAL")
     n2 = Neuron("DA3")
     c = Connection(pre_cell=n1, post_cell=n2, synclass="synapse")
     e = Evidence(bibtex=bt['white86'])
     e.asserts(c)
     print(list(e.load()))
Exemplo n.º 5
0
 def test_1(self):
     import bibtex
     bt = bibtex.parse("my.bib")
     n1 = Neuron("AVAL")
     n2 = Neuron("DA3")
     c = Connection(pre_cell=n1, post_cell=n2, synclass="synapse")
     e = Evidence(bibtex=bt['white86'])
     e.asserts(c)
     print(list(e.load()))
Exemplo n.º 6
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600')
     r = DataObject(key="context_data_object")
     e.supports(r)
     s = list(e.supports.get())
     self.assertIn(r, s)
Exemplo n.º 7
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600')
     r = DataObject(key="context_data_object")
     e.supports(r)
     s = list(e.supports.get())
     self.assertIn(r, s)
Exemplo n.º 8
0
    def test_get_evidence(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        e = Evidence()
        # Create an Evidence search-object
        e.asserts(c)

        # look for all of the evidence for the connection 'c'
        for x in e.load():
            print (x.author())
Exemplo n.º 9
0
    def test_evidence_asserts_all_about(self):
        """ Test that we can assert_all_about a containing object and
        then get evidence for contained objects.
        """
        import random
        random.seed()
        v = values('all')

        def make_syn():
            import struct
            u = struct.pack("=2f", random.random(), random.random())
            z = struct.pack("=2f", random.random(), random.random())
            a = Neuron(u.encode('hex'))
            b = Neuron(z.encode('hex'))
            v.value(a.neighbor(b))
            return (a, b)

        for x in range(200):
            make_syn()

        # the one we'll check for
        a, b = make_syn()
        ev = Evidence(author="Homer")
        ev.asserts_all_about(ev)
        ev.save()
        eve = Evidence()
        eve.asserts(a.neighbor(b))
Exemplo n.º 10
0
    def test_get_evidence(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        e = Evidence()
        # Create an Evidence search-object
        e.asserts(c)

        # look for all of the evidence for the connection 'c'
        for x in e.load():
            print(x.author())
Exemplo n.º 11
0
 def test_asserts_query(self):
     """ Show that we can store the evidence on an object and later retrieve it """
     e = Evidence(key="a", author='*****@*****.**')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     e0 = Evidence()
     e0.asserts(r)
     s = list(e0.load())
     author = s[0].author.one()
     self.assertIn('*****@*****.**', author)
Exemplo n.º 12
0
 def test_doi_init2(self):
     """
     Just the identifier, no URI
     """
     self.assertEqual(
         [u'Elizabeth R. Chen', u'Michael Engel', u'Sharon C. Glotzer'],
         list(Evidence(doi='10.1007/s00454-010-9273-0').author()))
Exemplo n.º 13
0
def parse_bibtex_into_evidence(file_name, context=None):
    return {
        k: Evidence.contextualize(context)(
            reference=v,
            supports=v.contextualize(context).as_context.rdf_object)
        for k, v in parse_bibtex_into_documents(file_name, context).items()
    }
Exemplo n.º 14
0
 def test_doi_init1(self):
     """
     Full dx.doi.org uri
     """
     self.assertEqual(
         [u'Elizabeth R. Chen', u'Michael Engel', u'Sharon C. Glotzer'],
         list(
             Evidence(doi='http://dx.doi.org/10.1007%2Fs00454-010-9273-0').
             author()))
Exemplo n.º 15
0
    def test_evidence_retrieves_instead_of_overwrites(self):
        """
        Test that creating a new Evidence with the same attributes of an
        already-saved Evidence does not overwrite the previous Evidence,
        but instead retrieves it.
        """
        e = Evidence(key="NBK",
                     author='Rodney Dangerfield',
                     title="Natural Born Killers")
        r = DataObject(key='Dangerfields_dramatic_range')
        e.asserts(r)
        e.save()

        e1 = Evidence(author='Rodney Dangerfield')
        facts = list(e1.asserts())
        self.assertIn(r, facts)
Exemplo n.º 16
0
 def test_pubmed_multiple_authors_list(self):
     """
     When multiple authors are on a paper, all of their names should be returned in an iterator. Publication order not necessarily preserved
     """
     pmid = "24098140"
     alist = [
         u"Frédéric MY", "Lundin VF", "Whiteside MD", "Cueva JG", "Tu DK",
         "Kang SY", "Singh H", "Baillie DL", "Hutter H", "Goodman MB",
         "Brinkman FS", "Leroux MR"
     ]
     self.assertEqual(set(alist), set(Evidence(pmid=pmid).author()))
Exemplo n.º 17
0
    def test_2(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        c_id = c.identifier
        # Attach some evidence for the connection
        e = Evidence(author="Danny Glover")
        e.asserts(c)
        # look at what else this evidence has stated
        e.save()
        e = Evidence(author="Danny Glover")
        r = e.asserts()
        ids = set(x.identifier for x in r)
        self.assertIn(c_id, ids)
Exemplo n.º 18
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600', wormbase='WBPaper00044600')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     l = list(e.asserts())
     self.assertIn(r, l)
Exemplo n.º 19
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600', wormbase='WBPaper00044600')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     l = list(e.asserts())
     self.assertIn(r, l)
Exemplo n.º 20
0
    def test_evidence_retrieves_instead_of_overwrites(self):
        """
        Test that creating a new Evidence with the same attributes of an
        already-saved Evidence does not overwrite the previous Evidence,
        but instead retrieves it.
        """
        e = Evidence(key="NBK", author='Rodney Dangerfield', title="Natural Born Killers")
        r = DataObject(key='Dangerfields_dramatic_range')
        e.asserts(r)
        e.save()

        e1 = Evidence(author='Rodney Dangerfield')
        facts = list(e1.asserts())
        self.assertIn(r, facts)
Exemplo n.º 21
0
 def test_bibtex_init(self):
     bibtex = u"""@ARTICLE{Cesar2013,
       author = {Jean César},
       title = {An amazing title},
       year = {2013},
       month = jan,
       volume = {12},
       pages = {12--23},
       journal = {Nice Journal},
       abstract = {This is an abstract. This line should be long enough to test
          multilines...},
       comments = {A comment},
       keywords = {keyword1, keyword2},
     }
     """
     self.assertEqual(u"Jean César", next(Evidence(bibtex=bibtex).author()))
Exemplo n.º 22
0
    def test_2(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        c_id = c.identifier
        # Attach some evidence for the connection
        e = Evidence(author="Danny Glover")
        e.asserts(c)
        # look at what else this evidence has stated
        e.save()
        e = Evidence(author="Danny Glover")
        r = e.asserts()
        ids = set(x.identifier for x in r)
        self.assertIn(c_id, ids)
Exemplo n.º 23
0
 def test_doi_init_fail_on_request_suffix(self):
     """
     Requesting only the prefix
     """
     with self.assertRaises(EvidenceError):
         Evidence(doi='http://dx.doi.org/s00454-010-9273-0')
Exemplo n.º 24
0
 def test_wormbase_year(self):
     """ Just make sure we can extract something without crashing """
     for i in range(600, 610):
         wbid = 'WBPaper00044' + str(i)
         e = Evidence(wormbase=wbid)
         e.year()
Exemplo n.º 25
0
    def test_multiple_evidence_for_single_fact(self):
        """
        Can we assert the same fact with two distinct pieces of Evidence?
        """

        e1 = Evidence()
        e1.pmid('777')

        e2 = Evidence()
        e2.pmid('888')

        c = DataObject(key=23)
        e1.asserts(c)
        e2.asserts(c)

        e1.save()
        e2.save()

        evs = Evidence()
        evs.asserts(c)

        saved_pmids = set(['777', '888'])
        loaded_pmids = set([x.pmid() for x in evs.load()])

        self.assertTrue(saved_pmids.issubset(loaded_pmids))
Exemplo n.º 26
0
    def test_asserts_query_multiple_author_matches(self):
        """ Show that setting the evidence with distinct objects yields
        distinct results even if there are matching values """
        e = Evidence(key="k", author='*****@*****.**')
        r = DataObject(key="a_statement")
        e.asserts(r)
        e.save()

        e1 = Evidence(key="j", author='*****@*****.**')
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        self.assertEqual(2, len(list(e0.load())))
Exemplo n.º 27
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')

        e = Evidence(key="a", author='*****@*****.**')
        e.asserts(r)
        e.save()

        e1 = Evidence(key="b", year=1999)
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        for x in e0.load():
            a = x.author.one()
            y = x.year()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(y, 1999)
            elif x.idl == e.idl:
                self.assertEqual(a, '*****@*****.**')
            else:
                self.fail("Unknown object returned from load")
Exemplo n.º 28
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')

        e = Evidence(key="a", author='*****@*****.**')
        e.asserts(r)
        e.save()

        e1 = Evidence(key="b", year=1999)
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        for x in e0.load():
            a = x.author.one()
            y = x.year()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(y, 1999)
            elif x.idl == e.idl:
                self.assertEqual(a, '*****@*****.**')
            else:
                self.fail("Unknown object returned from load")
Exemplo n.º 29
0
    def test_asserts_query_multiple_author_matches(self):
        """ Show that setting the evidence with distinct objects yields
        distinct results even if there are matching values """
        e = Evidence(key="k", author='*****@*****.**')
        r = DataObject(key="a_statement")
        e.asserts(r)
        e.save()

        e1 = Evidence(key="j", author='*****@*****.**')
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        self.assertEqual(2, len(list(e0.load())))
Exemplo n.º 30
0
    def test_multiple_evidence_for_single_fact(self):
        """
        Can we assert the same fact with two distinct pieces of Evidence?
        """

        e1 = Evidence()
        e1.pmid('777')

        e2 = Evidence()
        e2.pmid('888')

        c = DataObject(key=23)
        e1.asserts(c)
        e2.asserts(c)

        e1.save()
        e2.save()

        evs = Evidence()
        evs.asserts(c)

        saved_pmids = set(['777', '888'])
        loaded_pmids = set([x.pmid() for x in evs.load()])

        self.assertTrue(saved_pmids.issubset(loaded_pmids))
Exemplo n.º 31
0
 def test_asserts_query(self):
     """ Show that we can store the evidence on an object and later retrieve it """
     e = Evidence(key="a", author='*****@*****.**')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     e0 = Evidence()
     e0.asserts(r)
     s = list(e0.load())
     author = s[0].author.one()
     self.assertIn('*****@*****.**', author)
Exemplo n.º 32
0
 def test_pubmed_init1(self):
     """
     A pubmed uri
     """
     uri = "http://www.ncbi.nlm.nih.gov/pubmed/24098140?dopt=abstract"
     self.assertIn(u"Frédéric MY", list(Evidence(pmid=uri).author()))
Exemplo n.º 33
0
 def test_wormbase_year(self):
     """ Just make sure we can extract something without crashing """
     for i in range(600, 610):
         wbid = 'WBPaper00044' + str(i)
         e = Evidence(wormbase=wbid)
         e.year()
Exemplo n.º 34
0
 def test_pubmed_init2(self):
     """
     A pubmed id
     """
     pmid = "24098140"
     self.assertIn(u"Frédéric MY", list(Evidence(pmid=pmid).author()))
Exemplo n.º 35
0
 def test_doi_init_fail_on_request_prefix(self):
     """
     Requesting only the prefix
     """
     with self.assertRaises(EvidenceError):
         Evidence(doi='http://dx.doi.org/10.1126')
Exemplo n.º 36
0
 def test_wormbase_init(self):
     """ Initialize with wormbase source """
     # Wormbase lacks anything beyond the author,date format for a lot of
     # papers
     self.assertIn(u'Frederic et al., 2013',
                   list(Evidence(wormbase="WBPaper00044287").author()))