def test_rdf(self): pub_uri = D["n123"] article = Publication() meta = article.prep(self.meta, pub_uri=pub_uri) g = article.to_graph(meta) g.namespace_manager = ns_mgr # ids pmid = g.value(subject=pub_uri, predicate=BCITE.pmid) self.eq(u"23910982", pmid.toPython()) doi = g.value(subject=pub_uri, predicate=BCITE.doi) self.eq(u"10.1016/j.jpeds.2013.06.032", doi.toPython()) # check venue rq = """ select ?issn ?vtype where { ?p bcite:hasVenue ?venue . ?venue bcite:issn ?issn ; a ?vtype . } """ for row in g.query(rq): self.eq(u"0022-3476", row.issn.toPython()) self.eq(row.vtype, BCITE.Venue) date = g.value(subject=pub_uri, predicate=BCITE.date) dtv = date.toPython() # Make sure our dates are datetime.date and not datetime.datetime. assert type(dtv) == datetime.date assert dtv.year == 2013 assert dtv.month == 12
def test_rdf(self): pub_uri = D["n123"] article = Publication() meta = article.prep(self.meta, pub_uri=pub_uri) g = article.to_graph(meta) g.namespace_manager = ns_mgr # ids pmid = g.value(subject=pub_uri, predicate=BCITE.pmid) self.eq(self.pmid, pmid.toPython()) doi = g.value(subject=pub_uri, predicate=BCITE.doi) self.eq(u"10.1182/blood-2014-05-574871", doi.toPython()) title = g.value(subject=pub_uri, predicate=RDFS.label) assert title.toPython().startswith(u"Survival trends in Waldenström macroglobulinemia:")
def test_rdf_venue_uri(self): venue_uri = D["v123"] article = Publication() meta = article.prep(self.meta, venue_uri=venue_uri) g = article.to_graph(meta) g.namespace_manager = ns_mgr # check venue rq = """ select ?venue where { ?p bcite:hasVenue ?v . ?v rdfs:label ?venue . } """ for row in g.query(rq): self.eq(u"The Journal of pediatrics", row.venue.toPython())
def test_rdf(self): pub_uri = D["n123"] book = Publication() meta = book.prep(self.meta, pub_uri=pub_uri) g = book.to_graph(meta) g.namespace_manager = ns_mgr # ids pmid = g.value(subject=pub_uri, predicate=BCITE.pmid) self.eq(self.pmid, pmid.toPython()) # No venue venue = g.value(subject=pub_uri, predicate=BCITE.hasVenue) assert venue == None ctype = g.value(subject=pub_uri, predicate=RDF.type) self.eq(ctype, BCITE.BookSection) title = g.value(subject=pub_uri, predicate=RDFS.label) assert title.toPython().startswith(u"Epidemiology") book = g.value(subject=pub_uri, predicate=BCITE.book) assert book.toPython().startswith(u"Medical Microbiology")
def test_contrib(self): b = {} uri = D["n123"] b["articleids"] = [{"idtype": "pubmed", "value": "pm1234"}] b["title"] = "Sample article" # Try coauthors created as just strings with @baseuris and # as RDFLib URI objects. ca1 = ["jsmith", "jjones"] ca2 = [D["jsmith"], D["jjones"]] for coauthors in [ca1, ca2]: pub = Publication() prepped = pub.prep(b, pub_uri=uri, contributors=coauthors) assert coauthors[0] in prepped["contributor"] assert coauthors[1] in prepped["contributor"] g = pub.to_graph(prepped) # Test that all coathors are in the outputted RDF.. for ob in g.objects(subject=D["n123"], predicate=BCITE.hasContributor): ca2.index(ob) > -1 assert type(ob) == URIRef
def test_rdf(self): pub_uri = D["n123"] book = Publication() meta = book.prep(self.meta, pub_uri=pub_uri) g = book.to_graph(meta) g.namespace_manager = ns_mgr # ids pmid = g.value(subject=pub_uri, predicate=BCITE.pmid) self.eq(self.pmid, pmid.toPython()) # No venue venue = g.value(subject=pub_uri, predicate=BCITE.hasVenue) assert venue == None ctype = g.value(subject=pub_uri, predicate=RDF.type) self.eq(ctype, BCITE.Book) title = g.value(subject=pub_uri, predicate=RDFS.label) assert title.toPython().startswith( u"Comprehensive Overview of Methods and Reporting of Meta-Analyses of Test Accuracy" ) url = g.value(subject=pub_uri, predicate=BCITE.url) assert url.toPython() == u"http://www.ncbi.nlm.nih.gov/books/NBK92422/"