コード例 #1
0
ファイル: pump.py プロジェクト: senrabc/vivo-pump
 def __init__(
         self,
         json_def_filename="data/pump_def.json",
         out_filename="data/pump_data.txt",
         verbose=False,
         nofilters=False,
         inter='\t',
         intra=';',
         query_parms={
             'query_uri': 'http://localhost:8080/vivo/api/sparqlQuery',
             'username': '******',
             'password': '******'
         },
         uri_prefix='http://vivo.school.edu/individual/'):
     """
     Initialize the pump
     :param json_def_filename:  File name of file containing JSON pump definition
     """
     from vivopump import read_update_def
     self.update_def = read_update_def(json_def_filename)
     self.update_data = None
     self.original_graph = None
     self.update_graph = None
     self.filter = not nofilters
     self.enum = load_enum(self.update_def)
     self.json_def_filename = json_def_filename
     self.verbose = verbose
     self.intra = intra
     self.inter = inter
     self.out_filename = out_filename
     self.query_parms = query_parms
     self.uri_prefix = uri_prefix
コード例 #2
0
    def __init__(self, json_def_filename="pump_def.json", out_filename="pump_data.txt", verbose=False,
                 nofilters=False, inter='\t', intra=';', rdfprefix="pump",
                 query_parms={'queryuri': 'http://localhost:8080/vivo/api/sparqlQuery',
                              'username': '******',
                              'password': '******',
                              'uriprefix': 'http://vivo.school.edu/individual/n',
                              'prefix':
    '''
PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:     <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:      <http://www.w3.org/2001/XMLSchema#>
PREFIX owl:      <http://www.w3.org/2002/07/owl#>
PREFIX swrl:     <http://www.w3.org/2003/11/swrl#>
PREFIX swrlb:    <http://www.w3.org/2003/11/swrlb#>
PREFIX vitro:    <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>
PREFIX wgs84:    <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX bibo:     <http://purl.org/ontology/bibo/>
PREFIX c4o:      <http://purl.org/spar/c4o/>
PREFIX cito:     <http://purl.org/spar/cito/>
PREFIX event:    <http://purl.org/NET/c4dm/event.owl#>
PREFIX fabio:    <http://purl.org/spar/fabio/>
PREFIX foaf:     <http://xmlns.com/foaf/0.1/>
PREFIX geo:      <http://aims.fao.org/aos/geopolitical.owl#>
PREFIX obo:      <http://purl.obolibrary.org/obo/>
PREFIX ocrer:    <http://purl.org/net/OCRe/research.owl#>
PREFIX ocresd:   <http://purl.org/net/OCRe/study_design.owl#>
PREFIX skos:     <http://www.w3.org/2004/02/skos/core#>
PREFIX uf:       <http://vivo.school.edu/ontology/uf-extension#>
PREFIX vcard:    <http://www.w3.org/2006/vcard/ns#>
PREFIX vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#>
PREFIX vivo:     <http://vivoweb.org/ontology/core#>
PREFIX scires:   <http://vivoweb.org/ontology/scientific-research#>
    '''
                             }):
        """
        Initialize the pump
        :param json_def_filename:  File name of file containing JSON pump definition
        """
        from vivopump import read_update_def, load_enum

        self.update_def = read_update_def(json_def_filename, query_parms['prefix'])
        self.update_data = None
        self.original_graph = None
        self.update_graph = None
        self.filter = not nofilters
        self.enum = load_enum(self.update_def)
        self.json_def_filename = json_def_filename
        self.verbose = verbose
        self.intra = intra
        self.inter = inter
        self.rdfprefix = rdfprefix
        self.out_filename = out_filename
        self.query_parms = query_parms
コード例 #3
0
ファイル: pump.py プロジェクト: KevinHanson/vivo-pump
 def __init__(self, json_def_filename="data/pump_def.json", out_filename="data/pump_data.txt", verbose=False,
              nofilters=False, inter='\t', intra=';',
              query_parms={'query_uri': 'http://localhost:8080/vivo/api/sparqlQuery',
                           'username': '******', 'password': '******'},
              uri_prefix='http://vivo.school.edu/individual/'):
     """
     Initialize the pump
     :param json_def_filename:  File name of file containing JSON pump definition
     """
     from vivopump import read_update_def
     self.update_def = read_update_def(json_def_filename)
     self.update_data = None
     self.original_graph = None
     self.update_graph = None
     self.filter = not nofilters
     self.enum = load_enum(self.update_def)
     self.json_def_filename = json_def_filename
     self.verbose = verbose
     self.intra = intra
     self.inter = inter
     self.out_filename = out_filename
     self.query_parms = query_parms
     self.uri_prefix = uri_prefix
コード例 #4
0
ファイル: pump.py プロジェクト: naveenpent/vivo-pump
    def __init__(self, defn="pump_def.json", src="pump_data.txt"):
        """
        Initialize the pump
        :param defn:  File name of file containing JSON pump definition
        :param src: file name of the csv file to contain VIVO data (get), or csv containing data to update VIVO (update)
        """
        from vivopump import read_update_def, load_enum, DefNotFoundException

        self.update_data = None
        self.original_graph = None
        self.update_graph = None
        self.entity_uri = None  # the entity_uri of the current row being processed in the update_data
        self.out_filename = src
        self.json_def_filename = defn

        #   Simple public instance variables

        self.filter = True
        self.intra = ';'
        self.inter = '\t'
        self.rdfprefix = 'pump'
        self.uriprefix="http://vivo.school.edu/individual/n"

        # Query parms should be properties of the query, not the Pump.  Refactor this

        self.queryuri="http://localhost:8080/vivo/api/sparqlQuery"
        self.username="******"
        self.password="******"
        self.prefix=('PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n'
                     'PREFIX rdfs:     <http://www.w3.org/2000/01/rdf-schema#>\n'
                     'PREFIX xsd:      <http://www.w3.org/2001/XMLSchema#>\n'
                     'PREFIX owl:      <http://www.w3.org/2002/07/owl#>\n'
                     'PREFIX swrl:     <http://www.w3.org/2003/11/swrl#>\n'
                     'PREFIX swrlb:    <http://www.w3.org/2003/11/swrlb#>\n'
                     'PREFIX vitro:    <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>\n'
                     'PREFIX wgs84:    <http://www.w3.org/2003/01/geo/wgs84_pos#>\n'
                     'PREFIX bibo:     <http://purl.org/ontology/bibo/>\n'
                     'PREFIX c4o:      <http://purl.org/spar/c4o/>\n'
                     'PREFIX cito:     <http://purl.org/spar/cito/>\n'
                     'PREFIX event:    <http://purl.org/NET/c4dm/event.owl#>\n'
                     'PREFIX fabio:    <http://purl.org/spar/fabio/>\n'
                     'PREFIX foaf:     <http://xmlns.com/foaf/0.1/>\n'
                     'PREFIX geo:      <http://aims.fao.org/aos/geopolitical.owl#>\n'
                     'PREFIX obo:      <http://purl.obolibrary.org/obo/>\n'
                     'PREFIX ocrer:    <http://purl.org/net/OCRe/research.owl#>\n'
                     'PREFIX ocresd:   <http://purl.org/net/OCRe/study_design.owl#>\n'
                     'PREFIX skos:     <http://www.w3.org/2004/02/skos/core#>\n'
                     'PREFIX uf:       <http://vivo.school.edu/ontology/uf-extension#>\n'
                     'PREFIX vcard:    <http://www.w3.org/2006/vcard/ns#>\n'
                     'PREFIX vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#>\n'
                     'PREFIX vivo:     <http://vivoweb.org/ontology/core#>\n'
                     'PREFIX scires:   <http://vivoweb.org/ontology/scientific-research#>\n')

        #   Ugly mutable param.  Refactor this

        self.query_parms = {'queryuri': self.queryuri, 'username': self.username, 'password': self.password,
                            'uriprefix': self.uriprefix, 'prefix': self.prefix}

        #   Create the update_def and enumerations

        try:
            self.update_def = read_update_def(defn, self.prefix)
        except IOError:
            raise DefNotFoundException(defn)
        else:
            self.enum = load_enum(self.update_def)  # When the def changes, the enum must be updated
コード例 #5
0
ファイル: pump.py プロジェクト: ctsit/vivo-pump
    def __init__(self, defn="pump_def.json", src="pump_data.txt"):
        """
        Initialize the pump
        :param defn:  File name of file containing JSON pump definition
        :param src: file name of the csv file to contain VIVO data (get), or csv containing data to update VIVO (update)
        """
        from vivopump import read_update_def, load_enum, DefNotFoundException

        self.update_data = None
        self.original_graph = None
        self.update_graph = None
        self.out_filename = src
        self.json_def_filename = defn

        #   Simple public instance variables

        self.filter = True
        self.intra = ';'
        self.inter = '\t'
        self.rdfprefix = 'pump'
        self.uriprefix="http://vivo.school.edu/individual/n"

        # Query parms should be properties of the query, not the Pump.  Refactor this

        self.queryuri="http://localhost:8080/vivo/api/sparqlQuery"
        self.username="******"
        self.password="******"
        self.prefix=('PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n'
                     'PREFIX rdfs:     <http://www.w3.org/2000/01/rdf-schema#>\n'
                     'PREFIX xsd:      <http://www.w3.org/2001/XMLSchema#>\n'
                     'PREFIX owl:      <http://www.w3.org/2002/07/owl#>\n'
                     'PREFIX swrl:     <http://www.w3.org/2003/11/swrl#>\n'
                     'PREFIX swrlb:    <http://www.w3.org/2003/11/swrlb#>\n'
                     'PREFIX vitro:    <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>\n'
                     'PREFIX wgs84:    <http://www.w3.org/2003/01/geo/wgs84_pos#>\n'
                     'PREFIX bibo:     <http://purl.org/ontology/bibo/>\n'
                     'PREFIX c4o:      <http://purl.org/spar/c4o/>\n'
                     'PREFIX cito:     <http://purl.org/spar/cito/>\n'
                     'PREFIX event:    <http://purl.org/NET/c4dm/event.owl#>\n'
                     'PREFIX fabio:    <http://purl.org/spar/fabio/>\n'
                     'PREFIX foaf:     <http://xmlns.com/foaf/0.1/>\n'
                     'PREFIX geo:      <http://aims.fao.org/aos/geopolitical.owl#>\n'
                     'PREFIX obo:      <http://purl.obolibrary.org/obo/>\n'
                     'PREFIX ocrer:    <http://purl.org/net/OCRe/research.owl#>\n'
                     'PREFIX ocresd:   <http://purl.org/net/OCRe/study_design.owl#>\n'
                     'PREFIX skos:     <http://www.w3.org/2004/02/skos/core#>\n'
                     'PREFIX uf:       <http://vivo.school.edu/ontology/uf-extension#>\n'
                     'PREFIX vcard:    <http://www.w3.org/2006/vcard/ns#>\n'
                     'PREFIX vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#>\n'
                     'PREFIX vivo:     <http://vivoweb.org/ontology/core#>\n'
                     'PREFIX scires:   <http://vivoweb.org/ontology/scientific-research#>\n')

        #   Ugly mutable param.  Refactor this

        self.query_parms = {'queryuri': self.queryuri, 'username': self.username, 'password': self.password,
                            'uriprefix': self.uriprefix, 'prefix': self.prefix}

        #   Create the update_def and enumerations

        try:
            self.update_def = read_update_def(defn, self.prefix)
        except IOError:
            raise DefNotFoundException(defn)
        else:
            self.enum = load_enum(self.update_def)  # When the def changes, the enum must be updated
コード例 #6
0
 def test_make_query(self):
     update_def = read_update_def('data/grant_def.json')
     for path in update_def['column_defs'].values():
         update_query = make_update_query(update_def['entity_def']['entity_sparql'], path)
         print update_query
         self.assertTrue(len(update_query) > 0)
コード例 #7
0
 def test_update_def_order(self):
     update_def = read_update_def('data/grant_def.json')
     self.assertEqual(update_def['entity_def']['order'][0:4], [u'deptid', u'direct_costs', u'cois', u'end_date'])
コード例 #8
0
 def test_read_normal_def(self):
     update_def = read_update_def('data/grant_def.json')
     self.assertTrue(update_def.keys() == ['entity_def', 'column_defs'])
コード例 #9
0
 def test_normal_case(self):
     update_def = read_update_def('data/grant_def.json')
     a = get_graph(update_def)
     print len(a)
     self.assertTrue(len(a) == 241611)