#!/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/#importitertoolsimportcollectionsimportpypath.resources.urlsasurlsimportpypath.share.curlascurl
[docs]defccmap_interactions(organism=9606):""" Downloads and processes CancerCellMap. Returns list of interactions. @organism : int NCBI Taxonomy ID to match column #7 in nodes file. """CancercellmapInteraction=collections.namedtuple('CancercellmapInteraction',('source_uniprot','target_uniprot','directed','references',),)organism='%u'%organisminteractions=[]nodes_url=urls.urls['ccmap']['nodes']edges_url=urls.urls['ccmap']['edges']c=curl.Curl(nodes_url,silent=False,files_needed=['cell-map-node-attributes.txt'],)nodes=c.resultc=curl.Curl(edges_url,silent=False,files_needed=['cell-map-edge-attributes.txt'],)edges=c.resultnodes=dict(map(lambdal:(l[1],l[2].split(':')),filter(lambdal:l[5]=='protein'andl[6]==organism,filter(lambdal:len(l)==7,map(lambdal:l.strip().split('\t'),nodes['cell-map-node-attributes.txt'].split('\n')[1:])))))edges=filter(lambdal:len(l)==7,map(lambdal:l.strip().split('\t'),edges['cell-map-edge-attributes.txt'].split('\n')[1:]))foreinedges:ife[1]!='IN_SAME_COMPONENT'ande[3]innodesande[4]innodes:forsrc,tgtinitertools.product(nodes[e[3]],nodes[e[4]]):interactions.append(CancercellmapInteraction(source_uniprot=src,target_uniprot=tgt,directed=e[1]=='STATE_CHANGE',references=e[6].strip(';').replace('PUBMED:',''),))returninteractions