askomics.libaskomics.rdfdb package

Submodules

askomics.libaskomics.rdfdb.FederationQueryLauncher module

class askomics.libaskomics.rdfdb.FederationQueryLauncher.FederationQueryLauncher(settings, session, lendpoints)

Bases: askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher

The QueryLauncher process sparql queries:
  • execute_query send the query to the sparql endpoint specified in params.
  • parse_results preformat the query results
  • format_results_csv write in the tabulated result file a table obtained from these preformated results using a ResultsBuilder instance.
process_query(query)

Execute query and parse the results if exist

askomics.libaskomics.rdfdb.MultipleQueryLauncher module

class askomics.libaskomics.rdfdb.MultipleQueryLauncher.MultipleQueryLauncher(settings, session)

Bases: askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher

The MultipleQueryLauncher process sparql queries. Send SPARQL query on multiple endpoint. Useful to reach several AskOmics Endpoint

process_query(query, lendpoints, indexByEndpoint=False)

Execute query and parse the results if exist

askomics.libaskomics.rdfdb.QueryLauncher module

exception askomics.libaskomics.rdfdb.QueryLauncher.EndpointError(ep_uri, msg='')

Bases: RuntimeError

exception askomics.libaskomics.rdfdb.QueryLauncher.NotEndpoint(ep_uri, msg='')

Bases: askomics.libaskomics.rdfdb.QueryLauncher.EndpointError

class askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher(settings, session, name=None, endpoint=None, username=None, password=None, urlupdate=None, auth='Basic')

Bases: askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher_

Specialization of QueryLauncher_. For now, insert/load query are kept here.

Public endpoint may not be writable. This can change in future version.
insert_data(ttl_string, graph, ttl_header='')

Load a ttl string into the triple store using INSERT DATA method

Parameters:
  • ttl_string – ttl content to load
  • ttl_header – the ttl header associated with ttl_string
Returns:

The status

load_data(url, graphName)

Load a ttl file accessible from http into the triple store using LOAD method

Parameters:url – URL of the file to load
Returns:The status
setUserDatastore()

initialize endpoint with user configuration file

setupSPARQLWrapper()

Setup SPARQLWrapper to reach url endpoint

upload_data(filename, graphName)

Load a ttl file into the triple store using requests module and Fuseki upload method which allows upload of big data into Fuseki (instead of LOAD method).

Parameters:filename – name of the file, fp.name from Source.py
Returns:response of the request and queryTime

Not working for Virtuoso because there is no upload files url.

class askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher_(settings, session, name=None, endpoint=None, username=None, password=None, urlupdate=None)

Bases: askomics.libaskomics.ParamManager.ParamManager

The QueryLauncher_ process sparql queries:
  • execute_query send the query to the sparql endpoint specified in params.
  • parse_results preformat the query results
  • format_results_csv write in the tabulated result file a table obtained from these preformated results using a ResultsBuilder instance.

It is a generalization of QueryLauncher, but that fit any endpoint

debug()
format_results_csv(data)

write the csv result file from a data ist

Parameters:data (list) – the data to process
Returns:The path of the created file
Return type:string
parse_results(json_res)

parse answer results from TPS

process_query(query, parseResults=True)

Execute query and parse the results if exist

setUserDatastore()

initialize endpoint with user configuration file

setupSPARQLWrapper()

Setup SPARQLWrapper to reach url endpoint

setup_opener(proxy_config)

Sets up a urllib OpenerDirector to be used for requests behind a proxy. :param proxy_config:

  • Nothing to do if proxy_config == “auto” (use the system’s proxy if any).
  • Set an empty ProxyHandler if proxy_config == “noproxy”.
  • Specify the proxy parameters according to the configuration ini file if proxy_config == “custom”. We handle Basic and Digest Auth. No ntlm support, try “noproxy” if the triplestore runs on the same server as AskOmics.
test_endpoint()

Test endpoint existance by sending a dummy query.

exception askomics.libaskomics.rdfdb.QueryLauncher.SPARQLError(response)

Bases: RuntimeError

The SPARQLError returns an error message when a query sends by requests module encounters an error.

askomics.libaskomics.rdfdb.SparqlQueryAuth module

class askomics.libaskomics.rdfdb.SparqlQueryAuth.SparqlQueryAuth(settings, session)

Bases: askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder

This class contain method to build a sparql query to extract data from the users graph

add_apikey(username, keyname)

Insert a new api key

add_galaxy(username, url, key)

Insert a galaxy instance (url + api key)

check_email_presence(email)

Check if an email is present in users graph

check_galaxy(username)

Check if user have a galaxy

check_username_presence(username)

Check if a username is present in users graph

ckeck_key_belong_user(username, key)

Chek if a key belong to a user

delete_apikey(key)

Delet all info of a user

delete_galaxy(username)

delete galaxy triples of a user

get_admin_blocked_by_email(email)

get if a user is admin, by his email

get_admin_blocked_by_username(username)

get if a user is admin, by his username

get_admins_emails()

Get emails of all admins

get_galaxy_infos(username)

Get Galaxy url and apikey of a user

get_number_of_users()

Get the number of users

get_owner_apikey(key)

Get the owner of the API key

get_password_with_email(email)

Check the password of a user by his email

get_password_with_username(username)

Check the password of a user by his username

static get_random_string(number)

return a random string of n character

get_user_infos(username)

Get infos about one user

get_username_by_email(email)

Get usermail of a user by his email

get_users_infos(username)

Get users infos exept me

update_mail(username, email)

update the email of user

update_passwd(username, shapw, salt)

update the email of user

askomics.libaskomics.rdfdb.SparqlQueryBuilder module

class askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder(settings, session)

Bases: askomics.libaskomics.ParamManager.ParamManager

SparqlQueryBuilder generate a Sparql query string containing the query corresponding to an AskOmics graph (with load_from_query_json) or the pre-written query of a template file (with load_from_file).

build_query_on_the_fly(replacement, adminrequest=False, externalrequest=False)

Build a query from the private or public template

custom_query(fromgraph, select, query, externalrequest=False, adminrequest=False)

launch a custom query.

delete_user(username)

Delet all info of a user

getExternalServiceEndpoint()

Get all external endpoint finding in all askomics endpoint

getGraphUser(removeGraph=[])
get_delete_metadatas_of_graph(graph)

Delte metadata linkd to a graph

get_delete_query_string(graph)

clear a graph

get_drop_named_graph(graph)

remove a graph

get_graph_of_user(username)

Get all subgraph of a user

prepare_query(template, replacement={})

Prepare a query from a template and a substitution dictionary. The $graph variable is the public graph The $graph2 variable is user graph or public graph if no user logged

update_admin_status(admin, username)

Change the admin status of a user!

update_blocked_status(blocked, username)

hello!

askomics.libaskomics.rdfdb.SparqlQueryGraph module

Classes to query triplestore on property of entity (attributes and relations).

information on build_query_on_the_fly:

  • When querying as asdmin : build_query_on_the_fly(QUERY, True)

==> The query have to contains GRAPH ?g { … } because all data are store on a Graph

  • When querying as a classic user : build_query_on_the_fly(QUERY) or build_query_on_the_fly(QUERY, False)

=> The query can not contain the GRAPH keyword because ‘FROM’ clauses cause all triplets are merged in the unique DEFAULT graph !!

class askomics.libaskomics.rdfdb.SparqlQueryGraph.SparqlQueryGraph(settings, session)

Bases: askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder

This class contain method to build a sparql query to extract data from public and private graph It replace the template files

get_abstraction_positionable_entity()

Get all positionable entities

get_all_taxons()

Get the list of all taxon

get_class_info_from_abstraction(node_class)

get

get_if_positionable(uri)

Get if an entity is positionable

get_isa_relation_entities()

Get the association list of entities and subclass

get_prefix_uri()

Get list of uri defined as metadata for a entities list

get_public_abstraction_attribute_entity()

Get all attributes of an entity

get_public_abstraction_category_entity()

Get the category of an entity

get_public_abstraction_entity()

Get theproperty of an entity

get_public_abstraction_relation(prop)

Get the relation of an entity

get_public_graphs()

Get the list of public named graph

get_public_start_point()

Get the start point and in which public graph they are

get_user_abstraction_attribute_entity()

Get all attributes of an entity

get_user_abstraction_category_entity()

Get the category of an entity

get_user_abstraction_entity()

Get theproperty of an entity

get_user_abstraction_relation(prop)

Get the relation of an entity

get_user_graph_infos_with_count()

Get infos of all datasets owned by a user

get_user_start_point()

Get the start point and in which private graph they are

query_exemple()

Query exemple. used for testing

askomics.libaskomics.rdfdb.SparqlQueryStats module

Classes to query triplestore on stats data.

information on build_query_on_the_fly:

  • When querying as asdmin : build_query_on_the_fly(QUERY, True)

==> The query have to contains GRAPH ?g { … } because all data are store on a Graph

  • When querying as a classic user : build_query_on_the_fly(QUERY) or build_query_on_the_fly(QUERY, False)

=> The query can not contain the GRAPH keyword because ‘FROM’ clauses cause all triplets are merged in the unique DEFAULT graph !!

class askomics.libaskomics.rdfdb.SparqlQueryStats.SparqlQueryStats(settings, session)

Bases: askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder

This class contain method to build a sparql query to extract data from the users graph

condition_query(access_level)

return the query according the accessLevel

get_attr_of_classes(access_level)

Get all the attributes of a class

get_number_of_classes(access_level)

Get number of triples in public graph

get_number_of_entities(access_level)

Get number of triples in public graph

get_number_of_subgraph(access_level)

Get number of triples in public graph

get_number_of_triples(access_level)

Get number of triples in public graph

get_rel_of_classes(access_level)

Get all the attributes of a class

get_subgraph_infos(access_level)

Get number of triples in public graph

Module contents