askomics.libaskomics package¶
Subpackages¶
- askomics.libaskomics.integration package
- askomics.libaskomics.rdfdb package
- Submodules
- askomics.libaskomics.rdfdb.FederationQueryLauncher module
- askomics.libaskomics.rdfdb.MultipleQueryLauncher module
- askomics.libaskomics.rdfdb.QueryLauncher module
- askomics.libaskomics.rdfdb.SparqlQueryAuth module
- askomics.libaskomics.rdfdb.SparqlQueryBuilder module
- askomics.libaskomics.rdfdb.SparqlQueryGraph module
- askomics.libaskomics.rdfdb.SparqlQueryStats module
- Module contents
- askomics.libaskomics.source_file package
- Submodules
- askomics.libaskomics.source_file.SourceFile module
- askomics.libaskomics.source_file.SourceFileBed module
- askomics.libaskomics.source_file.SourceFileGff module
- askomics.libaskomics.source_file.SourceFileTsv module
- askomics.libaskomics.source_file.SourceFileTtl module
- askomics.libaskomics.source_file.SourceFileURL module
- Module contents
Submodules¶
askomics.libaskomics.DatabaseConnector module¶
-
class
askomics.libaskomics.DatabaseConnector.
DatabaseConnector
(settings, session)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
Manage Database connection
-
create_endpoints_table
()¶
-
create_galaxy_table
()¶
-
create_integration_table
()¶
-
create_query_table
()¶
-
create_user_table
()¶
-
execute_sql_query
(query, variables=None, get_id=False)¶ execute a sql query
-
askomics.libaskomics.EndpointManager module¶
-
class
askomics.libaskomics.EndpointManager.
EndpointManager
(settings, session)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
-
disable
(id, message)¶
-
disable_by_url
(url, message)¶
-
enable
(id)¶
-
list_active_endpoints
()¶
-
list_endpoints
()¶
-
remove_endpoint
(id)¶
-
save_endpoint
(name, url, auth='BASIC', isenable=False)¶
-
askomics.libaskomics.GalaxyConnector module¶
-
class
askomics.libaskomics.GalaxyConnector.
GalaxyConnector
(settings, session, url, apikey)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
Connection with a Galaxy instance
Contain method to connect to a Galaxy instance with URL and APIkey and to get and send datasets to a Galaxy history
-
check_galaxy_instance
()¶ Check if the galaxy instance
Check if the Galaxy url and the API key :raises: e
-
get_datasets_and_histories
(allowed_files, history_id=None)¶ Get Galaxy datasets of current history and all histories of a user
Returns: a list of datasets Return type: dict
-
get_file_content
(dataset_id)¶ Get the content of a Galaxy dataset
Parameters: dataset_id (string) – the dataset id Returns: the dataset content Return type: sring
-
send_json_to_history
(json)¶ Send json data into the last used galaxy history
Parameters: json (string) – json data to send
-
send_to_history
(path, name, filetype)¶ Send a file into the most recent Galaxy history
Parameters: path (string) – path of file to load into Galaxy
-
upload_files
(files_id)¶ Upload galaxy datasets into AskOmics server
Parameters: files_id (list) – Ids of Galaxy datasets to upload
-
askomics.libaskomics.JobManager module¶
-
class
askomics.libaskomics.JobManager.
JobManager
(settings, session)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
Manage Askomics jobs inside a sqlite database
-
done_integration_job
(jobid)¶
-
done_query_job
(jobid, nrows, data, file)¶
-
list_integration_jobs
()¶
-
list_query_jobs
()¶
-
remove_job
(table, jobid)¶
-
save_integration_job
(filename)¶
-
save_query_job
(request_graph, variates)¶
-
set_error_message
(table, message, jobid)¶
-
askomics.libaskomics.ParamManager module¶
-
class
askomics.libaskomics.ParamManager.
ParamManager
(settings, session)¶ Bases:
object
Manage static file and template sparql queries
-
static
Bool
(result)¶
-
static
decode
(toencode)¶
-
static
decode_to_rdf_uri
(todecode, prefix='')¶
-
static
encode
(toencode)¶
-
static
encode_to_rdf_uri
(toencode, prefix=None)¶
-
get_directory
(name, force_username=None)¶ Get a named directory of a user, create it if not exist
-
get_param
(key)¶
-
get_rdf_directory
()¶
-
get_rdf_user_directory
()¶
-
get_sparql_prefixes
(sparqlrequest)¶
-
get_turtle_prefixes
(ttl)¶ Parse the ttl string, looking for prefix. add them to ASKOMICS_prefix if they exist. Then return the prefixes as ttl header.
-
get_turtle_template
(ttl)¶
-
get_upload_directory
()¶ Get the upload directory of a user, create it if not exist
Returns: The path of the user upload directory Return type: string
-
get_user_csv_directory
()¶
-
header_sparql_config
(sparqlrequest)¶
-
is_defined
(key)¶
-
remove_prefix
(obj)¶
-
reverse_prefix
(uri)¶
-
send_mails
(host_url, dests, subject, text)¶
-
set_param
(key, value)¶
-
update_list_prefix
(listPrefix)¶
-
static
askomics.libaskomics.Security module¶
-
class
askomics.libaskomics.Security.
Security
(settings, session, username, email, password, password2)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
[summary]
[description]
-
add_galaxy
(url, key)¶ Connect a galaxy account to Askomics
add triples for the url of galaxy, and the user api key
Parameters: - url (self;) – the galaxy url
- key (string) – the galaxy user api key
-
admin_user
(new_status, username)¶ adminify a user
-
check_email
()¶ Return true if email is a valid one
-
check_email_in_database
()¶ Check if the email is present in the DB
-
check_email_password
()¶ check if the password is the good password associate with the email
-
check_galaxy
()¶ Check if user have a galaxy account
-
check_password_length
()¶ Return true if password have at least 8 char
-
check_passwords
()¶ Return true if the 2 passwd are identical
-
check_username_in_database
()¶ Check if the username is present in the DB
-
check_username_password
()¶ check if the password is the good password associate with the username
-
ckeck_key_belong_user
(key)¶ Check if a key belong to a user
-
create_user_graph
()¶ Create a subgraph for the user. All his data will be inserted in this subgraph
-
delete_galaxy
()¶ Delete galaxy account for the user
-
delete_user
(username)¶ delete a user
-
get_admin_blocked_by_email
()¶ get the admin status of the user by his username
-
get_admin_blocked_by_username
()¶ get the admin status of the user by his username
-
get_admins_emails
()¶ Get all admins emails
-
get_galaxy_infos
()¶ Get Galaxy url and apikey of a user
-
get_number_of_users
()¶ get the number of users in the TS
-
get_owner_of_apikey
(key)¶ Get the owner of an API kei
[description] :param key: The API key :type key: string
-
static
get_random_string
(number)¶ return a random string of n character
-
get_sha256_pw
()¶ Get the hashed-salted password
Returns: the hashed-salted password Return type: string
-
get_user_id_by_username
()¶ get user id by is username
-
get_user_infos
()¶ get all about a user
-
get_username
()¶ get the username
-
get_users_infos
()¶ get all about all user
-
lock_user
(new_status, username)¶ lock a user
-
log_user
(request)¶ log the user using pyramid’s session
-
persist_user
(host_url)¶ Persist all user infos in the TS
-
renew_apikey
()¶ renew apikey of user
-
set_admin
(admin)¶ set self.admin at True if user is an admin
-
set_blocked
(blocked)¶ set self.blocked at True if user is a blocked
-
set_galaxy
(galaxy)¶ set self.galaxy at True if user has a connected galaxy account
-
set_username_by_email
()¶ Get the username of a user by his email
-
update_email
()¶ change the mail of a user
-
update_passwd
()¶ Change the password of a user, and his randomsalt
-
askomics.libaskomics.SourceFileConvertor module¶
-
class
askomics.libaskomics.SourceFileConvertor.
SourceFileConvertor
(settings, session)¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
- A SourceFileConvertor instance provides methods to:
- display an overview of the tabulated files the user want to convert in AskOmics.
- convert the tabulated files in turtle files, taking care of:
- the format of the data already in the database (detection of new and missing headers in the user files).
- the abstraction generation corresponding to the header of the user files.
- the generation of the part of the domain code that wan be automatically generated.
-
get_source_files
(selectedFiles, forced_type=None, uri_set=None)¶ Get all source files
Returns: a list of source file Return type: list
-
static
guess_file_type
(filepath)¶ Guess the file type in function of their extention
Parameters: filepath (string) – path of file Returns: file type Return type: string
askomics.libaskomics.TripleStoreExplorer module¶
-
class
askomics.libaskomics.TripleStoreExplorer.
TripleStoreExplorer
(settings, session, dico={})¶ Bases:
askomics.libaskomics.ParamManager.ParamManager
- Use the different Sparql template queries in order to:
- get special settings:
- relation between two classes (nodes) specified by another class (hidden node).
- virtual relation adding special Where clauses specified in the database domain.
- get the suggestion list for classes listed as Categories and displayed as node attributes by AskOmics.
- get the startpoints to begin a query building.
- get the neighbor nodes and the attributes of a node.
-
build_recursive_block
(tabul, constraints)¶ build SPARQL Block following this grammar : B ==> [ A , KEYWORKD ] . KEYWORKD is a string prefix for BLOCK (ex: OPTIONAL, SERVICE) A ==> [ ((B|F),)+ ] . a list of Block or constraints leafs F ==> [ CONSTRAINT1, CONSTRAINT2,…. ] an array contains only constraints
-
build_sparql_query_from_json
(list_endpoints, typeEndpoints, fromgraphs, variates, constraintes_relations, limit, send_request_to_tps=True)¶ Build a sparql query from JSON constraints
-
getUserAbstraction
()¶ Get the user abstraction (relation and entity as subject and object)
Returns: Return type:
-
get_prefix_uri
()¶
-
get_start_points
()¶ Get the possible starting points for your graph.
Returns: List of starting points Return type: Node list
askomics.libaskomics.utils module¶
Some reusable utilities : Bases, decorators, utility functions, etc. Also a place to isolate “python magic” tricks.
-
askomics.libaskomics.utils.
pformat_generic_object
(obj)¶ Pretty print a object and its attributes to string
-
askomics.libaskomics.utils.
intersperse_chain
(delimiter, iterators)¶ yield delimiter between the elements of each iterators. >>> list(intersperse_chain(‘sep’, [[‘str1’, ‘str2’], [‘str3’, ‘str4’], [‘str5’]])) [‘str1’, ‘str2’, ‘sep’, ‘str3’, ‘str4’, ‘sep’, ‘str5’]
-
askomics.libaskomics.utils.
prefix_lines
(prefix, strings)¶ >>> list(prefix_lines('\t', ['line1', 'line2'])) ['\tline1', '\tline2']
-
class
askomics.libaskomics.utils.
cached_property
(func)¶ Bases:
object
Like @property on a member function, but also cache the calculation in self.__dict__[function name]. The function is called only once since the cache stored as an instance attribute override the property residing in the class attributes. Following accesses cost no more than standard Python attribute access. If the instance attribute is deleted the next access will re-evaluate the function. Source: https://blog.ionelmc.ro/2014/11/04/an-interesting-python-descriptor-quirk/ usage:
class Shape(object):
@cached_property def area(self):
# compute value return value-
func
¶
-
-
class
askomics.libaskomics.utils.
HaveCachedProperties
¶ Bases:
object
Provide cache management for classes with @cached_property attributes.
-
cache
¶ Explicit access (as a dictionary) to all the values cached in the attributes of this object.
-
get_cache
()¶ Explicit access (as a dictionary) to all the values cached in the attributes of this object. Return the subset of self.__dict__ for keys in self.get_cached_properties().
-
classmethod
get_cached_properties
()¶ cached_property instances are in the class dict with other class attributes
-
reset_cache
()¶ Equivalent to self.set_cache({}, reset=True) or del self.cache
-
set_cache
(cache_dict, reset=True)¶ Set the cache. If reset is True, reset caches not present in cache_dict keys(). With reset = False, a reset is still possible if cache_dict[key] is None
self.cache = cache_dict- is equivalent to:
- self.set_cache(cache_dict, reset=True)
-