pypath.core.entity.Entity§

class pypath.core.entity.Entity(identifier, entity_type=None, id_type=None, taxon=9606, attrs=None)[source]§

Bases: Logger, AttributeHandler

Represents a molecular entity such as protein, miRNA, lncRNA or small molecule.

Parameters:
  • identifier (str) – An identifier from the reference database e.g. UniProt ID for proteins.

  • entity_type (str) – The type of the molecular entity, defaults to 'protein'.

  • id_type (str) – The type of the identifier (the reference database), default is 'uniprot'.

  • taxon (int) – The NCBI Taxonomy Identifier of the molecular entity, e.g. 9606 for human. Use 0 for non taxon specific molecules e.g. metabolites or drug compounds.

  • attrs (NoneType,dict) – A dictionary of additional attributes.

__init__(identifier, entity_type=None, id_type=None, taxon=9606, attrs=None)[source]§

Make this instance a logger.

Parameters:
  • name – The label of this instance that will be prepended to all messages it sends to the logger.

  • module – Send the messages by the logger of this module.

Methods

__init__(identifier[, entity_type, id_type, ...])

Make this instance a logger.

count_entity_type(entities, entity_type)

Counts elements in an iterable of entities or identifiers of type(s) in entity_type.

entity_info(identifier)

entity_name_str(entity)

filter_entity_type(entities, entity_type)

Filters an iterable of entities or identifiers keeping only the ones of type(s) in entity_type.

get_entity_type()

igraph_vertex_label(igraph_v)

igraph_vertex_name(igraph_v)

igraph_vertex_name_label(igraph_v)

info()

is_complex()

is_mirna()

is_protein()

is_small_molecule()

only_complexes(entities)

only_mirnas(entities)

only_proteins(entities)

reload()

serialize(**kwargs)

Generates a JSON string with the full contents of the attributes, without any whitespace or line break.

set_label()

update_attrs([attrs])

Updates the attributes stored here.

Attributes

identifier

entity_type

id_type

taxon

label

key

attrs

classmethod count_entity_type(entities, entity_type)[source]§

Counts elements in an iterable of entities or identifiers of type(s) in entity_type.

Parameters:
  • entities (iterable) – A list, set, tuple or other iterable yielding entities or identifiers.

  • entity_type (str,set) – One or more entity types e.g. {'protein', 'mirna'}.

Returns:

int

classmethod filter_entity_type(entities, entity_type)[source]§

Filters an iterable of entities or identifiers keeping only the ones of type(s) in entity_type.

Parameters:
  • entities (iterable) – A list, set, tuple or other iterable yielding entities or identifiers.

  • entity_type (str,set) – One or more entity types e.g. {'protein', 'mirna'}.

Returns:

Same type of object as entities if the type of the object is list, set or tuple, otherwise a generator.

serialize(**kwargs)§

Generates a JSON string with the full contents of the attributes, without any whitespace or line break.

Returns

(str): The attributes JSON serialized.

update_attrs(attrs=None, **kwargs)§

Updates the attributes stored here. The attributes with identical keys are merged using the pypath.share.common.combine_attrs() function.

The new attributes can be provided three ways: an object with an attribute called attrs; a dictionary of attributes; or the attributes as keyword arguments.