API Reference: yatel package

Submodules

yatel.cli module

Launcher of Yatel Command Line Interface (cli) tools.

class yatel.cli.Backup(*args, **kwargs)[source]

Bases: Command

Like dump but always creates a new file with the format backup_file<TIMESTAMP>.EXT.

class yatel.cli.Copy(*args, **kwargs)[source]

Bases: Command

Copy a Yatel network to another database.

class yatel.cli.CreateConf(*args, **kwargs)[source]

Bases: Command

Creates a new configuration file for Yatel.

class yatel.cli.CreateETL(*args, **kwargs)[source]

Bases: Command

Creates a template file to write your own ETL.

class yatel.cli.CreateWSGI(*args, **kwargs)[source]

Bases: Command

Creates a new WSGI file for a given configuration.

class yatel.cli.Database(mode)[source]

Bases: object

This class parses and validates the open mode of a database.

class yatel.cli.Describe(*args, **kwargs)[source]

Bases: Command

Prints information about the network.

class yatel.cli.DescribeETL(*args, **kwargs)[source]

Bases: Command

Return a list of parameters and documentation about the ETL. The argument is in the format path/to/module.py The BaseETL subclass must be named after ETL.

class yatel.cli.Dump(*args, **kwargs)[source]

Bases: Command

Exports the given database to a file. The extension of the file determines the format.

class yatel.cli.List(*args, **kwargs)[source]

Bases: Command

Lists all available connection strings in yatel.

class yatel.cli.Load(*args, **kwargs)[source]

Bases: Command

Import the given file to the given database.

class yatel.cli.PyShell(*args, **kwargs)[source]

Bases: Shell

Run a python shell with a Yatel Network context.

class yatel.cli.QBJShell(*args, **kwargs)[source]

Bases: Command

Runs interactive console to execute QBJ queries.

class yatel.cli.RunETL(*args, **kwargs)[source]

Bases: Command

Runs one or more ETL inside of a given script. The first argument is in the format path/to/module.py second onwards parameters are of the setup method of the given class.

class yatel.cli.Runserver(*args, **kwargs)[source]

Bases: Command

Run Yatel as a development http server with a given config file.

class yatel.cli.Test(*args, **kwargs)[source]

Bases: Command

Run all Yatel test suites.

class yatel.cli.Version(*args, **kwargs)[source]

Bases: Command

Show Yatel version and exit.

yatel.cli.command(name)[source]

Clean way to register class based commands.

yatel.client module

Client library for yatel

class yatel.client.QBJClient(url, nwname)[source]

Bases: object

Handles query execution and parsing its response.

execute(query)[source]

Executes the query given in the server.

parse_response(response)[source]

Response parser.

exception yatel.client.QBJClientError(qbjresponse)[source]

Bases: exceptions.Exception

Custom exception for failed executions.

class yatel.client.QBJResponse

Bases: tuple

Response structure tuple.

error

Alias for field number 4

error_msg

Alias for field number 5

id

Alias for field number 0

json

Alias for field number 2

response

Alias for field number 1

stack_trace

Alias for field number 6

yatel

Alias for field number 3

yatel.db module

Database abstraction layer.

yatel.db.EDGES = 'edges'

The name of the edges table

yatel.db.ENGINES = ('sqlite', 'memory', 'mysql', 'postgres')

Available engines

yatel.db.ENGINE_URIS = {'sqlite': 'sqlite:///${database}', 'mysql': 'mysql://${user}:${password}@${host}:${port}/${database}', 'postgres': 'postgres://${user}:${password}@${host}:${port}/${database}', 'memory': 'sqlite://'}

Connection uris for the existing engines

yatel.db.ENGINE_VARS = {'sqlite': ['database'], 'mysql': ['user', 'password', 'host', 'port', 'database'], 'postgres': ['user', 'password', 'host', 'port', 'database'], 'memory': []}

Variables of the uris

yatel.db.FACTS = 'facts'

The name of the facts table

yatel.db.HAPLOTYPES = 'haplotypes'

The name of the haplotypes table

yatel.db.MODES = ('r', 'w', 'a')

The 3 modes to open the databases

yatel.db.MODE_APPEND = 'a'

Constant of append mode

yatel.db.MODE_READ = 'r'

Constant of read-only mode

yatel.db.MODE_WRITE = 'w'

Constant of write mode (Destroy the existing database)

yatel.db.PYTHON_TYPES = {<class 'BigInteger'>: <function <lambda> at 0x7f9eb5b6ac08>, <class 'Float'>: <function <lambda> at 0x7f9eb5b6acf8>, <class 'Numeric'>: <function <lambda> at 0x7f9eb5b6ae60>, <class 'Integer'>: <function <lambda> at 0x7f9eb5b6ac80>, <class 'Boolean'>: <function <lambda> at 0x7f9eb5b6ab90>, <class 'DateTime'>: <function <lambda> at 0x7f9eb5b6aa28>, <class 'Time'>: <function <lambda> at 0x7f9eb5b6aaa0>, <class 'Text'>: <function <lambda> at 0x7f9eb5b6ade8>, <class 'Date'>: <function <lambda> at 0x7f9eb5b6ab18>, <class 'String'>: <function <lambda> at 0x7f9eb5b6ad70>}

This dictionary maps sqlalchemy Column types to functions, converts the given Column class to python type. To retrieve all suported columns use db.PYTHON_TYPES.keys()

yatel.db.SQL_ALCHEMY_TYPES = {<type 'datetime.datetime'>: <function <lambda> at 0x7f9eb5b6a578>, <class 'decimal.Decimal'>: <function <lambda> at 0x7f9eb5b6a9b0>, <type 'datetime.date'>: <function <lambda> at 0x7f9eb5b6a668>, <type 'float'>: <function <lambda> at 0x7f9eb5b6a848>, <type 'long'>: <function <lambda> at 0x7f9eb5b6a7d0>, <type 'datetime.time'>: <function <lambda> at 0x7f9eb5b6a5f0>, <type 'unicode'>: <function <lambda> at 0x7f9eb5b6a938>, <type 'bool'>: <function <lambda> at 0x7f9eb5b6a6e0>, <type 'str'>: <function <lambda> at 0x7f9eb5b6a8c0>, <type 'int'>: <function <lambda> at 0x7f9eb5b6a758>}

This dictionary maps Python types to functions, converts the given type instance to a correct sqlalchemy column type. To retrieve all suported types use db.SQL_ALCHEMY_TYPES.keys()

yatel.db.TABLES = ('haplotypes', 'facts', 'edges')

A collection with the 3 table names

class yatel.db.YatelNetwork(engine, mode='r', log=None, **kwargs)[source]

Bases: object

Abstraction layer for yatel network databases.

add_element(elem)[source]

Add single instance of yatel.dom.Haplotype or yatel.dom.Fact or yatel.dom.Edge. The network must be in w or a mode.

REQUIRE MODE: w|a

Parameters:

elems : instance of yatel.dom.Haplotype or yatel.dom.Fact or yatel.dom.Edge.

Element to add.

Examples

>>> nw = db.YatelNetwork("sqlite", mode="w", log=False, database="nw.db")
>>> nw.add_element(dom.Fact(3, att0="foo"))
add_elements(elems)[source]

Add multiple instaces of yatel.dom.Haplotype or yatel.dom.Fact or yatel.dom.Edge instance. The network must be in w or a mode.

Parameters:

elems : iterable of yatel.dom.Haplotype or yatel.dom.Fact or yatel.dom.Edge instances.

Elements to be added in the network.

Examples

>>> nw = db.YatelNetwork("sqlite", mode="w", log=False, database="nw.db")
>>> nw.add_element([dom.Haplotype(3), dom.Fact(3, att0="foo")])
confirm_changes()[source]

Creates the subjacent structures to store the elements added and changes to read mode.

Examples

>>> from yatel import db, dom
>>> nw = db.YatelNetwork("sqlite", mode="w", log=False, database="nw.db")
>>> nw.add_element(dom.Haplotype(3, att0="foo"))
>>> nw.confirm_changes()
>>> nw.haplotype_by_id(3)
<Haplotype '3' at 0x37a9890>
describe()[source]

Returns a yatel.dom.Descriptor object with all the information about the network.

The descriptor object is a dictionary like with keys:

edges_attributes : dict
Dictionary contains always 2 keys : max_nodes How many nodes connect the edge with maximun number of connections. And weight the time of weight attribute
fact_attributes : dict
Contains an arbitrary number of keys, with keys as attributes name, and value as attribute type.
haplotype_atributes : dict
Contains an arbitrary number of keys, with keys as attributes name, and value as attribute type.
mode : str
Actual mode of the network
size : dict
Has the number of elements in the network discrimined by type haplotypes, facts and edges.

Examples

>>> nw = db.YatelNetwork(...)
>>> nw.describe()
... {
...     u'edge_attributes': {
...         u'max_nodes': 2,
...         u'weight': <type 'float'>
...     },
...     u'fact_attributes': {
...         u'align': <type 'int'>,
...         u'category': <type 'str'>,
...         u'coso': <type 'str'>,
...         u'hap_id': <type 'int'>,
...     }
...     u'haplotype_attributes': {
...         u'color': <type 'str'>,
...         u'description': <type 'str'>,
...         u'hap_id': <type 'int'>,
...     }
...     u'mode': 'r',
...     u'size': {u'edges': 10, u'facts': 20, u'haplotypes': 5}
... }
edges()[source]

Iterates over all yatel.dom.Edge instances stored in the database.

REQUIRE MODE: r

Returns:

iterator

Iterator of yatel.dom.Edge instances.

edges_by_environment(env=None, **kwargs)[source]

Iterates over all yatel.dom.Edge instances of a given environment please see yatel.db.YatelNetwork.haplotypes_enviroment for more documentation about environment.

REQUIRE MODE: r

Parameters:

env : dict

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribute.

kwargs : dict

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribte.

Returns:

iterator

Iterator of yatel.dom.Edge.

edges_by_haplotype(hap)[source]

Iterates over all the edges of a given yatel.dom.Haplotype.

REQUIRE MODE: r

Parameters:

hap : yatel.dom.Haplotype

Haplotype to search with.

Returns:

iterator

Iterator of yatel.dom.Edge.

environments(facts_attrs=None)[source]

Iterates over all combinations of environments of the given attrs.

REQUIRE MODE: r

Parameters:

fact_attrs : iterable

Collection of existing fact attribute names.

Returns:

iterator

Iterator of dictionaries with all valid combinations of values of a given fact_attrs names

Examples

>>> for env in nw.enviroments(["native", "place"]):
···     print env
{u'place': None, u'native': True}
{u'place': u'Hogwarts', u'native': False}
{u'place': None, u'native': False}
{u'place': u'Mordor', u'native': True}
{u'place': None, u'native': None}
...
execute(query)[source]

Execute a given query to the backend.

REQUIRE MODE: r

Parameters:

query : a query for the backend

A valid query for the backend.

facts()[source]

Iterates over all yatel.dom.Fact instances stored in the database.

facts_by_environment(env=None, **kwargs)[source]

Iterates over all yatel.dom.Fact instances of a given environment please see yatel.db.YatelNetwork.haplotypes_environment for more documentation about environment.

REQUIRE MODE: r

Parameters:

env : dict

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribute.

kwargs : dict of keywords arguments

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribute.

Returns:

iterator

Iteratorterator of yatel.dom.Fact.

facts_by_haplotype(hap)[source]

Return a iterator of all facts of a given yatel.dom.Haplotype.

Parameters:

hap : yatel.dom.Haplotype

Haplotype to search with.

Returns:

iterator

Iterator of yatel.dom.Fact.

haplotype_by_id(hap_id)[source]

Return a dom.Haplotype instace stored in the dabase with the given hap_id.

REQUIRE MODE: r

Parameters:

hap_id : id of the haplotypes type table.

Returns:

yatel.dom.Haplotype

haplotypes()[source]

Iterates over all yatel.dom.Haplotype instances stored in the database.

REQUIRE MODE: r

Returns:

iterator

iterator of yatel.dom.Haplotypes instances.

haplotypes_by_environment(env=None, **kwargs)[source]

Return an iterator of yatel.dom.Haplotype related to a yatel.dom.Fact with attribute and value specified in env and kwargs.

REQUIRE MODE: r

Parameters:

env : dict

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribute.

kwargs : a dict of keywords arguments

Keys are yatel.dom.Fact attributes name, and value is a possible value of the given attribute.

Returns:

iterator

Iterator of yatel.dom.Haplotype.

Examples

>>> from yatel import db, dom
>>> nw = db.YatelNetwork("sqlite", mode=db.MODE_WRITE, database="nw.db")
>>> nw.add_elements([dom.Haplotype("hap1"),
···                  dom.Haplotype("hap2"),
···                  dom.Fact("hap1", a=1, c="foo"),
···                  dom.Fact("hap2", a=1, b=2),
···                  dom.Edge(1, ("hap1", "hap2"))])
>>> nw.confirm_changes()
>>> tuple(nw.haplotypes_enviroment(a=1))
(<Haplotype 'hap1' at 0x2463250>, <Haplotype 'hap2' at 0x2463390>)
>>> tuple(nw.haplotypes_enviroment({"c": "foo"}))
(<Haplotype 'hap1' at 0x2463250>, )
>>> tuple(nw.haplotypes_enviroment({"a": 1}, b=2))
(<Haplotype 'hap2' at 0x2463390>, )
mode[source]

Returns mode of the database.

uri[source]

Returns uri of the database.

validate_read()[source]

Raise a YatelNetworkError if the network is not in read mode.

Raises:

YatelNetworkError

if the network is not in read mode.

exception yatel.db.YatelNetworkError[source]

Bases: exceptions.Exception

Error to use when some Yatel logic fails in the database.

yatel.db.copy(from_nw, to_nw)[source]

Copy all the network in from_nw to the network to_nw.

from_nw must be in read-only mode and to_nw in write or append mode. Is your responsability to call to_nw.confirm_changes() after the copy.

Parameters:

from_nw : yatel.db.YatelNetwork

Network in r mode.

to_nw : yatel.db.YatelNetwork

Network in w or a mode.

Examples

>>> from yatel import db, dom
>>> from_nw = db.YatelNetwork("memory", mode=db.MODE_WRITE)
>>> from_nw.add_elements([dom.Haplotype("hap1"),
···                       dom.Haplotype("hap2"),
···                       dom.Fact("hap1", a=1, c="foo"),
···                       dom.Fact("hap2", a=1, b=2),
···                       dom.Edge(1, ("hap1", "hap2"))])
>>> from_nw.confirm_changes()
>>> to_nw = db.YatelNetwork("sqlite", mode=db.MODE_WRITE, database="nw.db")
>>> db.copy(from_nw, to_nw)
>>> to_nw.confirm_changes()
>>> list(from_nw.haplotypes()) == list(to_nw.haplotypes())
True
yatel.db.exists(engine, **kwargs)[source]

Returns True if exists a yatel.db.YatelNetwork database in that connection.

Parameters:

engine : str

A value of the current engine used (see valid yatel.db.ENGINES)

kwargs : a dict of variables for the engine.

Returns:

existsdb : bool

This function return False if:
  • The database does not exists.
  • The hap_id column has diferent types in haplotypes, facts or edges tables.
  • The edges table hasn’t a column weight with type float.

Examples

>>> from yatel import db, dom
>>> db.exists("sqlite", mode="r", database="nw.db")
False
>>> from_nw = db.YatelNetwork("memory", mode=db.MODE_WRITE)
>>> from_nw.add_elements([dom.Haplotype("hap1"),
···                       dom.Haplotype("hap2"),
···                       dom.Fact("hap1", a=1, c="foo"),
···                       dom.Fact("hap2", a=1, b=2),
···                       dom.Edge(1, ("hap1", "hap2"))])
>>> from_nw.confirm_changes()
>>> db.exists("sqlite", mode="r", database="nw.db")
True
yatel.db.parse_uri(uri, mode='r', log=None)[source]

Creates a dictionary to use in creation of a YatelNetwork.

parsed = db.parse_uri("mysql://tito:pass@localhost:2525/mydb",
                       mode=db.MODE_READ, log=None)
nw = db.YatelNetwork(**parsed)

is equivalent to

::
nw = db.YatelNetwork(“mysql”, database=”mydb”, user=”tito”,
password=”pass”, host=”localhost”, port=2525, mode=db.MODE_READ, log=None)
yatel.db.qfilter(query, flt)[source]

Filters a Yatel query by a given filter.

Parameters:

query : iterator of Yatel DOM

Data to apply filter on.

flt : Lambda expression

Filter expression.

yatel.db.to_uri(engine, **kwargs)[source]

Create a correct uri for a given engine ignoring all unused parameters.

Parameters:

engine: str

The engine name.

kwargs : dict

Variables for the engine.

Examples

>>> from yatel import db
>>> db.to_uri("sqlite", database="nw.db")
'sqlite:///nw.db'
>>> db.to_uri("mysql", database="nw", host="localhost", port=3306,
···           user="root", password="secret")
'mysql://root:secret@localhost:3306/nw'

yatel.dom module

Domain Object Model for Yatel.

class yatel.dom.Descriptor(mode, fact_attributes, haplotype_attributes, edge_attributes, size)[source]

Bases: yatel.dom.YatelDOM

Represents detailed information of a network.

class yatel.dom.Edge(weight, haps_id)[source]

Bases: yatel.dom.YatelDOM

Represents a relation between 2 or more haplotypes.

class yatel.dom.Environment(**attrs)[source]

Bases: yatel.dom.YatelDOM

Represents an iterable dictionary of dictionaries with valid combinations of values of the attributes given when the instance is created.

class yatel.dom.Fact(hap_id, **attrs)[source]

Bases: yatel.dom.YatelDOM

Fact represents a metadata of the haplotype.

For example if you gather in two places the same haplotype, the characteristics of these places correspond to different facts of the same haplotype.

class yatel.dom.Haplotype(hap_id, **attrs)[source]

Bases: yatel.dom.YatelDOM

Represents an individual class or group with similar characteristics to be analized.

class yatel.dom.YatelDOM(**attrs)[source]

Bases: _abcoll.Mapping

Base class for yatel objects, handling arbitrary keys.

yatel.etl module

Functionality to create and execute an ETL. ETLs

class yatel.etl.BaseETL[source]

Bases: object

Defines the basic structure of an ETL and methods to be implemented.

HAPLOTYPES_CACHE

alias of dict

edge_gen()[source]

Creation of data to edge like style.

fact_gen()[source]

Creation of data to fact like style.

haplotype_gen()[source]

Creation of data to haplotype like style.

yatel.etl.etlcls_from_module(filepath, clsname)[source]

Return a class of a given filepath.

yatel.etl.execute(nw, etl, *args)[source]

Execute an ETL instance.

yatel.etl.get_template()[source]

Return the template of a base ETL as a string.

yatel.etl.scan_dir(dirpath)[source]

Retrieve all python files from a given directory.

yatel.etl.scan_file(filepath)[source]

Retrieve all yatel.etl.BaseETL subclass of a given file.

yatel.server module

Http server for querying, using QBJ or YQL (Yatel Query Languaje).

yatel.server.CONF_SCHEMA = {'type': 'object', 'properties': {'CONFIG': {'additionalProperties': True, 'type': 'object', 'properties': {'DEBUG': {'type': 'boolean'}}}, 'NETWORKS': {'patternProperties': {'^[a-zA-Z0-9_-]$': {'additionalProperties': False, 'type': 'object', 'properties': {'qbj': {'type': 'boolean'}, 'uri': {'type': 'string'}}}}, 'type': 'object'}}, 'schema': 'yatel server configuration schema'}

JSON schema to validate configuration

yatel.server.WSGI_BASE_TPL = <string.Template object at 0x7f9eb5b49790>

Template for WSGI configuration

class yatel.server.YatelHttpServer(**config)[source]

Bases: Flask

Yatel server class.

add_nw(nwname, nw, enable_qbj)[source]

Adds the given nw to the server.

nw(name)[source]

Returns the context network.

qbj(nwname)[source]

It handles the server query calls.

yatel.server.from_dict(data)[source]

Returns a server created with a dictionary as configuration.

data keys:

  • Path to the configuration file.
  • IP and port where the service will be listening separated by a :
yatel.server.get_conf_template()[source]

Returns a JSON configuration template as a String.

yatel.server.get_wsgi_template(confpath)[source]

Returns WSGI configuration template as a String.

Parameters:

confpath: string

Path to configuration file.

yatel.server.validate_conf(confdata)[source]

Validates that the configuration structure given as JSON is correct.

yatel.stats module

Statistic functions to calculate weight statistics over Yatel enviroments.

yatel.stats.amax(nw, env=None, **kwargs)[source]

Return the maximum in a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.amin(nw, env=None, **kwargs)[source]

Return the minimum in a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.average(nw, env=None, **kwargs)[source]

Compute the weighted average on a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.env2weightarray(nw, env=None, **kwargs)[source]

This function always return a numpy.ndarray with this conditions:

  • If nw is instance of numpy.ndarray the same array is returned.
  • If nw is instance of yatel.db.YatelNetwork and an environment is given return all the edges in this environment.
  • If nw is instance of yatel.db.YatelNetwork and no environment is given then return all edges.
  • In the last case the function tries to convert nw to numpy.ndarray instance.
yatel.stats.kurtosis(nw, env=None, **kwargs)[source]

Computes the kurtosis (Fisher’s definition) of a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.max(nw, env=None, **kwargs)[source]

Return the maximum in a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.median(nw, env=None, **kwargs)[source]

Compute the median on a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.min(nw, env=None, **kwargs)[source]

Return the minimum in a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.mode(nw, env=None, **kwargs)[source]

Calculates mode on a network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.percentile(nw, q, env=None, **kwargs)[source]

Compute the q-th percentile of the network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.range(nw, env=None, **kwargs)[source]

Computes the distance between the maximum and minimum.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.std(nw, env=None, **kwargs)[source]

Compute the standard deviation of the network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.sum(nw, env=None, **kwargs)[source]

Sum of the elements on the network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.var(nw, env=None, **kwargs)[source]

Compute the variance of the network.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.variation(nw, env=None, **kwargs)[source]

Computes the coefficient of variation.

Parameters:

nw : yatel.db.YatelNetwork

Network to which apply the operation.

env : yatel.dom.Enviroment or dict like

Environment for filtering.

yatel.stats.weights2array(edges)[source]

Create a numpy.ndarray with all the weights of yatel.dom.Edge

yatel.typeconv module

Contains functions to convert various support types of Yatel to more easily serializable types.

yatel.typeconv.HASHED_TYPES = (<type 'dict'>, <class 'yatel.dom.Haplotype'>, <class 'yatel.dom.Fact'>, <class 'yatel.dom.Edge'>, <class 'yatel.dom.Environment'>, <class 'yatel.dom.Descriptor'>)

Dictionary of yatel domain object model.

yatel.typeconv.LITERAL_TYPE = 'literal'

Constant to retrieve value as is.

yatel.typeconv.NAMES_TO_TYPES = {'set': <type 'set'>, 'int': <type 'int'>, 'float': <type 'float'>, 'datetime': <type 'datetime.datetime'>, 'Environment': <class 'yatel.dom.Environment'>, 'unicode': <type 'str'>, 'generator': <type 'generator'>, 'long': <type 'long'>, 'complex': <type 'complex'>, 'dict': <type 'dict'>, 'bool': <type 'bool'>, 'type': <type 'type'>, 'tuple': <type 'tuple'>, 'Decimal': <class 'decimal.Decimal'>, 'Descriptor': <class 'yatel.dom.Descriptor'>, 'Edge': <class 'yatel.dom.Edge'>, 'frozenset': <type 'frozenset'>, 'date': <type 'datetime.date'>, 'Fact': <class 'yatel.dom.Fact'>, 'Haplotype': <class 'yatel.dom.Haplotype'>, 'list': <type 'list'>, 'time': <type 'datetime.time'>, 'NoneType': <type 'NoneType'>}

This dictionary maps names to data type.

yatel.typeconv.TO_PYTHON_TYPES = {<type 'complex'>: <type 'complex'>, <type 'datetime.time'>: <function <lambda> at 0x7f9eb5e43e60>, <type 'unicode'>: <type 'unicode'>, <type 'str'>: <type 'unicode'>, <type 'long'>: <type 'long'>, <type 'datetime.datetime'>: <function <lambda> at 0x7f9eb5e43de8>, <type 'datetime.date'>: <function <lambda> at 0x7f9eb5e43ed8>, <class 'decimal.Decimal'>: <class 'decimal.Decimal'>, <type 'NoneType'>: <function <lambda> at 0x7f9eb5e4a050>, <type 'float'>: <type 'float'>, <type 'bool'>: <function <lambda> at 0x7f9eb5e43f50>, <type 'int'>: <type 'int'>}

This dictionary maps types to python types.

yatel.typeconv.TO_SIMPLE_TYPES = {<type 'complex'>: <function <lambda> at 0x7f9eb5e43d70>, <type 'datetime.time'>: <function <lambda> at 0x7f9eb5e43938>, <type 'unicode'>: <function <lambda> at 0x7f9eb5e43c08>, <type 'str'>: <type 'unicode'>, <type 'NoneType'>: <function <lambda> at 0x7f9eb5e43cf8>, <type 'datetime.datetime'>: <function <lambda> at 0x7f9eb5e43050>, <type 'datetime.date'>: <function <lambda> at 0x7f9eb5e439b0>, <class 'decimal.Decimal'>: <function <lambda> at 0x7f9eb5e43c80>, <type 'long'>: <function <lambda> at 0x7f9eb5e43b18>, <type 'float'>: <function <lambda> at 0x7f9eb5e43b90>, <type 'bool'>: <function <lambda> at 0x7f9eb5e43a28>, <type 'int'>: <function <lambda> at 0x7f9eb5e43aa0>}

This dictionary maps types to it’s most simple representation.

yatel.typeconv.TYPES_TO_NAMES = {<class 'yatel.dom.Fact'>: 'Fact', <type 'datetime.time'>: 'time', <type 'list'>: 'list', <type 'long'>: 'long', <class 'yatel.dom.Haplotype'>: 'Haplotype', <type 'complex'>: 'complex', <type 'set'>: 'set', <type 'tuple'>: 'tuple', <type 'NoneType'>: 'NoneType', <type 'dict'>: 'dict', <class 'yatel.dom.Environment'>: 'Environment', <type 'frozenset'>: 'frozenset', <type 'int'>: 'int', <type 'datetime.datetime'>: 'datetime', <class 'yatel.dom.Edge'>: 'Edge', <type 'unicode'>: 'unicode', <type 'datetime.date'>: 'date', <type 'type'>: 'type', <type 'generator'>: 'generator', <type 'str'>: 'unicode', <class 'yatel.dom.Descriptor'>: 'Descriptor', <class 'decimal.Decimal'>: 'Decimal', <type 'float'>: 'float', <type 'bool'>: 'bool'}

This dictionary maps data types to their name.

yatel.typeconv.np2py(obj)[source]

Converts a numpy number to it´s closest respresentation of Python traditional objects.

yatel.typeconv.parse(obj)[source]

Parses an objects type and value, according to the dictionary maps.

yatel.typeconv.simplifier(obj)[source]

Translates obj given to a Python dictionary.

Returns:

dictionary: dict

a dictionary representation of obj.

Module contents

Yatel allows the creation of user-profile-distance-based of OLAP Network and their multidimensional analysis through a process of exploration.

In the process of analyzing data from heterogeneous sources - like data regarding biology, social studies, marketing, etc. -, it is often possible to identify individuals or classes (groups of individuals that share some characteristic). This individuals or groups are identified by attributes that were measured and stored in the data data base. For instance, in a biological analysis, the profile can be defined by some certain properties of the nucleic acid, in a social analysis by the data from people and in a sales analysis by the data from sales point tickets.