literature references, they can be organized into collections. A number of operations are available on evidences and their collections, for example they can be combined or filtered. """ from future.utils import iteritems import importlib as imp import copy import pypath.internals.refs as refs import pypath.share.common as common import pypath.share.session as session_mod import pypath.core.entity as entity _logger = session_mod.Logger(name = 'evidence') _log = _logger._log class Evidence(object): """ Represents an evidence supporting a relationship such as molecular interaction, molecular complex, enzyme-PTM interaction, annotation, etc. The evidence consists of two main parts: the database and the literature references. If a relationship is supported by multiple databases, for each one `Evidence` object should be created and :arg pypath.resource.ResourceAttributes resource: An object derived from :py:class:`pypath.resource.ResourceAttributes`. :arg str,list,set,NoneType references:
# See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # import os import re import itertools import pypath.share.curl as curl import pypath.share.session as session import pypath.resources.urls as urls import pypath.inputs.common as inputs_common _logger = session.Logger(name='inputs.kirouac2010') _log = _logger._log def kirouac2010_interactions(): """ Returns tuples of ligand-receptor genesymbol pairs. """ rename = re.compile(r'[A-Z]{2}[A-Z0-9][-A-Z0-9]*') rerange = re.compile(r'([0-9])-([0-9])') reslash = re.compile(r'.*?([A-Z0-9]{1,3}/[/A-Z0-9]+)') def get_names(s): names = set()
# # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import os import collections import pypath.share.curl as curl import pypath.resources.urls as urls import pypath.share.settings as settings import pypath.share.session as session import pypath.utils.mapping as mapping _logger = session.Logger(name='inputs.msigdb') _log = _logger._log def msigdb_download( registered_email=None, collection='msigdb', id_type='symbols', force_download=False, ): """ Downloads and preprocesses a collection of gmt format gene sets from MSigDB. Returns dict of sets with gene set names as keys and molecular identifiers as values. :arg str,NoneType registered_email:
# See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems from past.builtins import xrange, range import sys import xlrd from xlrd.biffh import XLRDError import pypath.share.session as session_mod _logger = session_mod.Logger(name='dataio') _log = _logger._log _console = _logger._console if 'unicode' not in __builtins__: unicode = str def read_xls(xls_file, sheet='', csv_file=None, return_table=True): """ Generic function to read MS Excel XLS file, and convert one sheet to CSV, or return as a list of lists """ try: if hasattr(xls_file, 'read'): book = xlrd.open_workbook( file_contents=xls_file.read(),
# Olga Ivanova # # Distributed under the GPLv3 License. # See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import pypath.omnipath.server._html as _html import pypath.resources.urls as urls import pypath.share.session as session_mod _logger = session_mod.Logger(name='generate_about_page') _log = _logger._log __all__ = ['generate_about_html', 'write_html'] if 'long' not in __builtins__: long = int if 'unicode' not in __builtins__: unicode = str pypath_methods = { 'data': 'Data source (URLs and files)', 'format': 'Data format definition', 'intr': 'Interactions', 'input': 'Data input methods',
# See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # import re import os import collections import pypath.share.session as session_mod import pypath.share.common as common import pypath.share.curl as curl import pypath.resources.urls as urls _logger = session_mod.Logger(name='biomart_input') # for mouse homologues: Filter name = "with_mmusculus_homolog" _filter_xml_template = '<Filter name="%s" excluded="0"/>' _attr_xml_template = '<Attribute name="%s" />' def biomart_query( attrs, filters=None, transcript=False, gene=False, dataset='hsapiens_gene_ensembl', ): """ Use https://www.ensembl.org/biomart/martview/ to check for attribute
# File author(s): Dénes Türei ([email protected]) # Nicolàs Palacio # Olga Ivanova # # Distributed under the GPLv3 License. # See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import pypath.share.session as session_mod _logger = session_mod.Logger(name = 'db_categories') _log = _logger._log categories = { 'Vidal HI-III': 'i', 'CancerCellMap': 'p', 'InnateDB': 'i', 'SPIKE': 'p', 'LMPID': 'm', 'DIP': 'i', 'HPRD': 'i', 'HPRD-phos': 'm', 'PDZBase': 'p', 'dbPTM': 'm', 'MatrixDB': 'i',
from future.utils import iteritems import os import itertools import collections import pypath.inputs.common as inputs_common import pypath.resources.urls as urls import pypath.utils.mapping as mapping import pypath.utils.homology as homology import pypath.share.curl as curl import pypath.share.common as common import pypath.share.session as session _logger = session.Logger(name='inputs.embrace') _log = _logger._log def embrace_raw(): """ Returns Supplementary Table S11 from 10.1016/j.isci.2019.10.026 (Sheikh et al. 2019) as a list of tuples. """ url = urls.urls['embrace']['url'] c_nocall = curl.Curl( url, call=False, setup=False, process=False,
# # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import re import bs4 import warnings import pypath.resources.urls as urls import pypath.share.curl as curl import pypath.share.session as session import pypath.share.settings as settings _logger = session.Logger(name = 'inputs.genecards') _log = _logger._log _respace = re.compile(r'\s+') _summary_sources = { 'Gene Wiki': 'GeneWiki', 'UniProtKB/Swiss-Prot': 'UniProt', } def genecards_datasheet(gene): """ Retrieves a gene (protein) datasheet from GeneCards. Returns HTML as string.
Website: http://pypath.omnipathdb.org/ """ from future.utils import iteritems import itertools import sys from typing import Optional, Set, Union import click import pypath.share.progress as progress import pypath.share.common as common import pypath.share.session as session_mod _logger = session_mod.Logger(name='bel') try: import pybel if hasattr(pybel, 'ob'): _logger._log( 'You have the `openbabel` module installed ' 'instead of `pybel`. ' 'To be able to use `pybel`, create a virtual env and install ' 'it by `pip install pybel`.') # unimport openbabel del sys.modules['pybel'] pybel = None
# See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import copy import pypath.internals.resource as resource import pypath.resources.data_formats as data_formats import pypath.share.session as session_mod import pypath.share.settings as settings _logger = session_mod.Logger(name='network_resources') _log = _logger._log _data_models = { 'interaction': 'interaction', 'interaction_misc': 'interaction', 'interaction_htp': 'interaction', 'ligand_receptor': 'ligand_receptor', 'pathway': 'activity_flow', 'pathway_all': 'activity_flow', 'pathway_noref': 'activity_flow', 'activity_flow': 'activity_flow', 'dorothea': 'activity_flow', 'transcription': 'activity_flow', 'transcription_dorothea': 'activity_flow', 'transcription_onebyone': 'activity_flow',
import pypath.utils.mapping as mapping import pypath.share.common as common import pypath.internals.intera as intera import pypath.resources.urls as urls import pypath.share.curl as curl import pypath.inputs.uniprot as uniprot_input import pypath.utils.seq as _se import pypath.share.session as session_mod import pypath.utils.taxonomy as taxonomy import pypath.share.cache as cache_mod timeloop.app.logging.disable(level=9999) _homology_cleanup_timeloop = timeloop.Timeloop() _logger = session_mod.Logger(name='homology') _log = _logger._log class HomologyManager(session_mod.Logger): def __init__(self, cleanup_period=10, lifetime=300): session_mod.Logger.__init__(self, name='homology') @_homology_cleanup_timeloop.job( interval=datetime.timedelta(seconds=cleanup_period)) def _cleanup(): self._remove_expired() _homology_cleanup_timeloop.start(block=False)
# Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import time import datetime import timeloop timeloop.app.logging.disable(level = 9999) import pypath.share.common as common import pypath.share.session as session import pypath.share.settings as settings import pypath.inputs.uniprot as uniprot_input _logger = session.Logger(name = 'taxonomy') _log = _logger._log db = {} _cleanup_period = settings.get('mapper_cleanup_interval') _lifetime = 300 _last_used = {} # XXX: Shouldn't we keep all functions and variables separated # (together among them)? taxids = { 9606: 'human', 10090: 'mouse', 10116: 'rat', 9031: 'chicken', 9913: 'cow',
# from future.utils import iteritems import re import csv import collections import itertools import functools import pyreadr import pypath.share.curl as curl import pypath.resources.urls as urls import pypath.share.session as session _logger = session.Logger(name='dorothea_input') DorotheaInteraction = collections.namedtuple('DorotheaInteraction', [ 'tf', 'target', 'effect', 'level', 'curated', 'chipseq', 'predicted', 'coexp', 'curated_sources', 'chipseq_sources', 'predicted_sources', 'coexp_sources', 'all_sources',
# Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import json import os import copy import importlib as imp import pypath.share.session as session_mod import pypath.share.common as common import pypath.internals.resource as resource_base import pypath.resources.licenses as licenses _logger = session_mod.Logger(name='resources.controller') class ResourceController(session_mod.Logger): """ Resource controller is aimed to be the central part of pypath communication with resources. 14.01.2020: the initial step for resource controller development: used for /info page generating for the server. 14.02.2020: storing and reading enzyme-substrate resource definitions from the JSON; class inherits from session.Logger """ def __init__( self, resource_info_path=(
# File author(s): Dénes Türei ([email protected]) # Nicolàs Palacio # Olga Ivanova # # Distributed under the GPLv3 License. # See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # import importlib import pypath.share.session as session _logger = session.Logger(name='inputs') _log = _logger._log def get_method(module_name, method_name=None): """ Retrieves a method from a submodule of this module (``inputs``) by its name. E.g. for ``'uniprot.all_uniprots'`` it returns the ``all_uniprots`` method from the ``pypath.inputs.uniprot`` module. """ _log('Selecting input method (step 1): module `%s`, method `%s`.' % ( module_name, method_name, ))
# # Distributed under the GPLv3 License. # See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import os import pypath.share.curl as curl import pypath.share.session as session _logger = session.Logger(name='inputs.cell') _log = _logger._log def cell_supplementary(supp_url, article_url): """ Downloads a supplementary material from the Cell journal webpage. :param str supp_url: URL of the supplementary material. :param str article_url: URL of the article page. :return: The path of the downloaded file. """
import re import time import datetime import collections import itertools import timeloop timeloop.app.logging.disable(level=9999) import pypath.resources.urls as urls import pypath.share.curl as curl import pypath.share.common as common import pypath.share.session as session_mod import pypath.share.settings as settings _logger = session_mod.Logger(name='uniprot_input') db = {} _cleanup_period = settings.get('mapper_cleanup_interval') _lifetime = 300 _last_used = {} _redatasheet = re.compile(r'([A-Z\s]{2})\s*([^\n\r]+)[\n\r]+') # regex for matching UniProt AC format # from https://www.uniprot.org/help/accession_numbers reac = re.compile(r'[OPQ][0-9][A-Z0-9]{3}[0-9]|' r'[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}') _rename = re.compile(r'Name=([\w\(\)-]+)\W') _retaxid = re.compile(r'=(\d+)[^\d]')
# Olga Ivanova # # Distributed under the GPLv3 License. # See accompanying file LICENSE.txt or copy at # http://www.gnu.org/licenses/gpl-3.0.html # # Website: http://pypath.omnipathdb.org/ import os import copy from pypath.share import session as _session_mod from pypath.share import settings as _settings_mod from pypath.omnipath import app as _app_mod _logger = _session_mod.Logger(name='omnipath.init') _log = _logger._log _log('Welcome to the OmniPath database manager app.') def init(**kwargs): param = (copy.deepcopy(globals()['OP_DB_ARGS']) if 'OP_DB_ARGS' in globals() else {}) _log('You can customize the database building process by ' 'setting parameters in the `OP_DB_ARGS` global variable ' 'or by calling `init` again with keyword arguments or after ' 'setting values in the `pypath.share.settings` module.' 'You can define your own databases following the examples in '
# Website: http://pypath.omnipathdb.org/ # from future.utils import iteritems import os import bs4 import pickle import pypath.share.curl as curl import pypath.resources.urls as urls import pypath.share.settings as settings import pypath.share.session as session import pypath.share.common as common _logger = session.Logger(name='inputs.trip') _log = _logger._log def take_a_trip(cachefile=None): """ Downloads TRIP data from webpage and preprocesses it. Saves preprocessed data into `cachefile` and next time loads from this file. :arg cachefile str: Path to pickle dump of preprocessed TRIP database. If does not exist the database will be downloaded and saved to this file. By default the path queried from the ``settings`` module. """