#!/usr/bin/env python# -*- coding: utf-8 -*-## This file is part of the `pypath` python module## Copyright 2014-2023# EMBL, EMBL-EBI, Uniklinik RWTH Aachen, Heidelberg University## Authors: see the file `README.rst`# Contact: Dénes Türei (turei.denes@gmail.com)## Distributed under the GPLv3 License.# See accompanying file LICENSE.txt or copy at# https://www.gnu.org/licenses/gpl-3.0.html## Website: https://pypath.omnipathdb.org/#fromfuture.utilsimportiteritemsimportcollectionsimportpypath.share.curlascurlimportpypath.share.settingsassettingsimportpypath.resources.urlsasurlsimportpypath.utils.taxonomyastaxonomy
[docs]defget_exocarta(organism=9606,types=None):""" :param set types: Molecule types to retrieve. Possible values: `protein`, `mrna`. """return_get_exocarta_vesiclepedia(database='exocarta',organism=organism,types=types,)
[docs]defget_vesiclepedia(organism=9606,types=None):""" :param set types: Molecule types to retrieve. Possible values: `protein`, `mrna`. """return_get_exocarta_vesiclepedia(database='vesiclepedia',organism=organism,types=types,)
def_get_exocarta_vesiclepedia(database='exocarta',organism=9606,types=None):""" :param str database: Which database to download: ExoCarta or Vesiclepedia. :param set types: Molecule types to retrieve. Possible values: `protein`, `mrna`. """database=database.lower()types=typesor{'protein'}organism=taxonomy.phosphoelm_taxids[organism]taxid_rev=dict((v,k)fork,viniteritems(taxonomy.phosphoelm_taxids))# collecting the referencesurl_s=urls.urls[database]['url_study']c=curl.Curl(url_s,large=True,silent=False)_=next(c.result)studies={}forsinc.result:s=s.split('\t')organisms=tuple(taxid_rev[t.strip()]fortins[2].split('|')ift.strip()intaxid_rev)ifnotorganisms:continuestud=(s[1]ifs[1]!='0'elseNone,# PubMed IDorganisms,# organisms[4],# sample source (cell type, tissue))ifdatabase=='vesiclepedia':vtype=s[11].strip()stud+=(tuple(vtype.split('/'))ifvtypeelse(),)studies[int(s[0])]=tuple(stud)# processing proteinsurl_p=urls.urls[database]['url_protein']c=curl.Curl(url_p,large=True,silent=False,slow=True)_=next(c.result)forsinc.result:s=s.split('\t')ifs[4]!=organismors[1]notintypes:continueyield(s[2],# Entrez IDs[3],# Gene Symboltaxid_rev[s[4]],# NCBI Taxonomy IDstudies[int(s[5])],# study reference)