Models

This module contains the SQLAlchemy database models that support the definition cache and graph cache.

class pybel.manager.models.Base(**kwargs)

The most base type

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class pybel.manager.models.Namespace(**kwargs)[source]

Represents a BEL Namespace.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

uploaded

The date of upload

keyword

Keyword that is used in a BEL file to identify a specific namespace

pattern

Contains regex pattern for value identification.

miriam_id

MIRIAM resource identifier matching the regular expression ^MIR:001\d{5}$

version

Version of the namespace

url

BELNS Resource location as URL

name

Name of the given namespace

domain

Domain for which this namespace is valid

species

Taxonomy identifiers for which this namespace is valid

description

Optional short description of the namespace

created

DateTime of the creation of the namespace definition file

query_url

URL that can be used to query the namespace (externally from PyBEL)

author

The author of the namespace

license

License information

contact

Contact information

get_term_to_encodings()[source]

Return the term (db, id, name) to encodings from this namespace.

Return type

Mapping[Tuple[Optional[str], str], str]

to_json(include_id=False)[source]

Return the most useful entries as a dictionary.

Parameters

include_id (bool) – If true, includes the model identifier

Return type

Mapping[str, str]

class pybel.manager.models.NamespaceEntry(**kwargs)[source]

Represents a name within a BEL namespace.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

name

Name that is defined in the corresponding namespace definition file

identifier

The database accession number

encoding

The biological entity types for which this name is valid

to_json(include_id=False)[source]

Describe the namespaceEntry as dictionary of Namespace-Keyword and Name.

Parameters

include_id (bool) – If true, includes the model identifier

Return type

Mapping[str, str]

classmethod name_contains(name_query)[source]

Make a filter if the name contains a certain substring.

class pybel.manager.models.Network(**kwargs)[source]

Represents a collection of edges, specified by a BEL Script.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

name

Name of the given Network (from the BEL file)

version

Release version of the given Network (from the BEL file)

authors

Authors of the underlying BEL file

contact

Contact email from the underlying BEL file

description

Descriptive text from the underlying BEL file

copyright

Copyright information

disclaimer

Disclaimer information

licenses

License information

blob

A pickled version of this network

to_json(include_id=False)[source]

Return this network as JSON.

Parameters

include_id (bool) – If true, includes the model identifier

Return type

Mapping[str, Any]

classmethod name_contains(name_query)[source]

Build a filter for networks whose names contain the query.

classmethod description_contains(description_query)[source]

Build a filter for networks whose descriptions contain the query.

classmethod id_in(network_ids)[source]

Build a filter for networks whose identifiers appear in the given sequence.

as_bel()[source]

Get this network and loads it into a BELGraph.

Return type

BELGraph

store_bel(graph)[source]

Insert a BEL graph.

class pybel.manager.models.Node(**kwargs)[source]

Represents a BEL Term.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

type

The type of the represented biological entity e.g. Protein or Gene

bel

Canonical BEL term that represents the given node

data

PyBEL BaseEntity as JSON

classmethod bel_contains(bel_query)[source]

Build a filter for nodes whose BEL contain the query.

as_bel()[source]

Serialize this node as a PyBEL DSL object.

Return type

pybel.dsl.BaseEntity

to_json()[source]

Serialize this node as a JSON object using as_bel().

class pybel.manager.models.Author(**kwargs)[source]

Contains all author names.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

classmethod name_contains(name_query)[source]

Build a filter for authors whose names contain the given query.

classmethod has_name_in(names)[source]

Build a filter if the author has any of the given names.

class pybel.manager.models.Citation(**kwargs)[source]

The information about the citations that are used to prove a specific relation are stored in this table.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

db

Type of the stored publication e.g. PubMed

db_id

Reference identifier of the publication e.g. PubMed_ID

title

Title of the publication

journal

Journal name

volume

Volume of the journal

issue

Issue within the volume

pages

Pages of the publication

date

Publication date

first_id

First author

last_id

Last author

property is_pubmed

Return if this is a PubMed citation.

Return type

bool

property is_enriched

Return if this citation has been enriched for name, title, and other metadata.

Return type

bool

to_json(include_id=False)[source]

Create a citation dictionary that is used to recreate the edge data dictionary of a BELGraph.

Parameters

include_id (bool) – If true, includes the model identifier

Return type

Mapping[str, Any]

Returns

Citation dictionary for the recreation of a BELGraph.

class pybel.manager.models.Evidence(**kwargs)[source]

This table contains the evidence text that proves a specific relationship and refers the source that is cited.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

text

Supporting text from a given publication

to_json(include_id=False)[source]

Create a dictionary that is used to recreate the edge data dictionary for a BELGraph.

Parameters

include_id (bool) – If true, includes the model identifier

Returns

Dictionary containing citation and evidence for a BELGraph edge.

Return type

dict

class pybel.manager.models.Edge(**kwargs)[source]

Relationships between BEL nodes and their properties, annotations, and provenance.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

bel

Valid BEL statement that represents the given edge

source_modifier

Modifiers for the source of the edge

target_modifier

Modifiers for the target of the edge

md5

The hash of the source, target, and associated metadata

data

The stringified JSON representing this edge

get_annotations_json()[source]

Format the annotations properly.

Return type

Optional[dict[str,dict[str,bool]]

to_json(include_id=False)[source]

Create a dictionary of one BEL Edge that can be used to create an edge in a BELGraph.

Parameters

include_id (bool) – Include the database identifier?

Return type

Mapping[str, Any]

Returns

Dictionary that contains information about an edge of a BELGraph. Including participants and edge data information.

insert_into_graph(graph)[source]

Insert this edge into a BEL graph.

Return type

str