Data Manager Reference¶
Database Manager¶
-
class
pyctd.manager.database.DbManager(connection=None)[source]¶ Implements functions to upload CTD files into a database. Preferred SQL Alchemy database is MySQL with
pymysql.Parameters: connection (str) – custom database connection SQL Alchemy string -
db_import(urls=None, force_download=False)[source]¶ Updates the CTD database
- downloads all files from CTD
- drops all tables in database
- creates all tables in database
- import all data from CTD files
Parameters: Returns: SQL Alchemy model instance, populated with data from URL
Return type: models.Namespace
-
classmethod
download_urls(urls, force_download=False)[source]¶ Downloads all CTD URLs that don’t exist
Parameters:
-
static
get_column_names_from_file(file_path)[source]¶ returns column names from CTD download file
Parameters: file_path (str) – path to CTD download file
-
classmethod
get_index_and_columns_order(columns_in_file_expected, columns_dict, file_path)[source]¶ Parameters: - columns_in_file_expected –
- columns_dict –
- file_path –
Returns:
-
classmethod
get_index_of_column(column, file_path)[source]¶ Get index of a specific column name in a CTD file
Parameters: - column –
- file_path –
Returns: int or None
-
classmethod
get_path_to_file_from_url(url)[source]¶ standard file path
Parameters: url (str) – CTD download URL
-
import_one_to_many(file_path, column_index, parent_table, column_in_one2many_table)[source]¶ Parameters: - file_path –
- column_index –
- parent_table –
- column_in_one2many_table –
Returns:
-
import_table(table)[source]¶ import table by Table object
Parameters: table (manager.table_conf.Table) – Table object
-
import_table_in_db(file_path, use_columns_with_index, column_names_in_db, table)[source]¶ Imports data from CTD file into database
Parameters:
-
import_tables(only_tables=None, exclude_tables=None)[source]¶ Imports all data in database tables
Parameters:
-
mapper¶ returns a dictionary with keys of pyctd.manager.table_con.domains_to_map and pandas.DataFrame as values.
DataFrames column names:
- domain_id (represents the domain identifier of e.g. chemical)
- domain__id (represents the primary key in domain table)
Returns: dict of pandas DataFrames (keys:domain_name, values:DataFrame) Return type: dict of pandas.DataFrame
-
Database Models¶
Not all database models are documented here in order to keep the documentation simple. In general Query
should be used to query the content of the database
SQLAlchemy database models in this module describes all tables the database and fits the description in the table_conf module
-
class
pyctd.manager.models.Action(**kwargs)[source]¶ Chemical–gene interaction types
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
pyctd.manager.models.ChemGeneIxn(**kwargs)[source]¶ Chemical–gene interactions
- reference:
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
pyctd.manager.models.ChemGeneIxnGeneForm(**kwargs)[source]¶ Gene forms of Chemical–gene interactions
- reference:
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
pyctd.manager.models.ChemGeneIxnInteractionAction(**kwargs)[source]¶ Chemical–gene interactions actions
- reference:
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
pyctd.manager.models.ChemGeneIxnPubmed(**kwargs)[source]¶ Chemical–gene interactions PubMed links
- reference.
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
pyctd.manager.models.ChemGoEnriched(**kwargs)[source]¶ Chemical–GO enriched associations
- reference:
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
pyctd.manager.models.ChemPathwayEnriched(**kwargs)[source]¶ Chemical–pathway enriched associations
- reference:
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
pyctd.manager.models.Chemical(**kwargs)[source]¶ Chemical vocabulary
- reference:
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
pyctd.manager.models.ChemicalDisease(**kwargs)[source]¶ Chemical–disease associations
- reference:
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
pyctd.manager.models.ChemicalDiseaseOmim(**kwargs)[source]¶ Online Mendelian Inheritance in Man (OMIM) mappings to Chemical–disease associations
- reference:
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
pyctd.manager.models.ChemicalDiseasePubmedid(**kwargs)[source]¶ PubMed Literature references to Chemical–disease associations
- reference:
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
pyctd.manager.models.ChemicalDrugbank(**kwargs)[source]¶ DrugBank identifiers to Chemical vocabulary
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
pyctd.manager.models.ChemicalParentid(**kwargs)[source]¶ Parent IDs of Chemical vocabulary
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
pyctd.manager.models.ChemicalParenttreenumber(**kwargs)[source]¶ Parent tree numbers of Chemical vocabulary
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
pyctd.manager.models.ChemicalSynonym(**kwargs)[source]¶ Synonymy to Chemical vocabulary
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
pyctd.manager.models.ChemicalTreenumber(**kwargs)[source]¶ Tree numbers of Chemical vocabulary
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
pyctd.manager.models.Disease(**kwargs)[source]¶ Disease vocabulary (MEDIC)
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.
-
definition¶ definition of disease (str)
-
disease_id¶ MeSH or OMIM identifier (str)
-
disease_name¶ Disease name (str)
-
parent_ids¶ identifiers of the parent terms; ‘|’-delimited list
-
parent_tree_numbers¶ identifiers of the parent nodes; ‘|’-delimited list
-
tree_numbers¶ identifiers of the disease’s nodes; ‘|’-delimited list
-
-
class
pyctd.manager.models.DiseaseAltdiseaseid(**kwargs)[source]¶ Alternative disease identifiers to Disease vocabulary (MEDIC)
- reference:
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
pyctd.manager.models.DiseasePathway(**kwargs)[source]¶ Disease–pathway associations
- reference:
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
pyctd.manager.models.DiseaseSlimmapping(**kwargs)[source]¶ MEDIC-Slim mappings to Disease vocabulary (MEDIC)
- reference:
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
pyctd.manager.models.DiseaseSynonym(**kwargs)[source]¶ Synonyms to Disease vocabulary (MEDIC)
- reference:
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
pyctd.manager.models.ExposureEvent(**kwargs)[source]¶ Exposure–event associations
- reference:
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
pyctd.manager.models.Gene(**kwargs)[source]¶ Gene vocabulary
- reference:
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.
-
alt_gene_ids¶ list of alternative NCBI Gene identifiers
-
biogrid_ids¶ list of BioGRID identifier
-
gene_id¶ NCBI Gene identifier
-
gene_name¶ gene name
-
gene_symbol¶ gene_symbol”“”
-
pharmgkb_ids¶ list of PharmGKB identifiers
-
synonyms¶ list of synonyms
-
uniprot_ids¶
-
class
pyctd.manager.models.GeneAltGeneId(**kwargs)[source]¶ Alternative gene identifiers to Gene vocabulary
- reference:
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
pyctd.manager.models.GeneBiogrid(**kwargs)[source]¶ BioGRID mappings to Gene vocabulary
- reference:
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
pyctd.manager.models.GeneDisease(**kwargs)[source]¶ Gene–disease associations
- reference:
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
pyctd.manager.models.GeneDiseaseOmim(**kwargs)[source]¶ Online Mendelian Inheritance in Man (OMIM) mappings to Gene–disease associations
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
pyctd.manager.models.GeneDiseasePubmed(**kwargs)[source]¶ PubMed references to Gene–disease associations
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
pyctd.manager.models.GenePathway(**kwargs)[source]¶ Gene–pathway associations
- reference:
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
pyctd.manager.models.GenePharmgkb(**kwargs)[source]¶ PharmGKB mapping to Gene vocabulary
- reference:
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
pyctd.manager.models.GeneSynonym(**kwargs)[source]¶ Synonyms to Gene vocabulary
- reference:
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
pyctd.manager.models.GeneUniprot(**kwargs)[source]¶ UniProt mappings to Gene vocabulary
- reference:
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
pyctd.manager.models.Pathway(**kwargs)[source]¶ Pathway vocabulary
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.