#!/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/#importreimportpypath.share.curlascurlimportpypath.resources.urlsasurls
[docs]defget_hprd(in_vivo=True):""" Downloads and preprocesses HPRD data. """url=urls.urls['hprd_all']['url_rescued']files=[urls.urls['hprd_all']['ptm_file']]c=curl.Curl(url,silent=False,files_needed=files)data=c.resultiflen(data)==0:return[]data=[l.split('\t')forlindata[files[0]].split('\n')][:-1]ifin_vivo:data=[iforiindataif'in vivo'ini[9].split(';')]returndata
[docs]defhprd_interactions(in_vivo=True):""" Processes HPRD data and extracts interactions. Returns list of interactions. """return[iforiinget_hprd(in_vivo=in_vivo)ifi[6]!='-']
[docs]defhprd_enzyme_substrate(in_vivo=True):""" Processes HPRD data and extracts PTMs. Returns list of kinase-substrate interactions. """ptms=[]non_digit=re.compile(r'[^\d]+')data=get_hprd(in_vivo=in_vivo)forptmindata:ifptm[6]!='-':resnums=[int(nn)fornnin[non_digit.sub('',n)forninptm[4].split(';')]iflen(nn)>0]forresnuminresnums:modtype=ptm[8].lower().replace('proteolytic','').strip()ptms.append({'resaa':ptm[5],'resnum':resnum,'typ':modtype,'references':ptm[10].split(','),'kinase':ptm[6],'substrate_refseqp':ptm[3],'substrate':ptm[1],'start':max(resnum-7,1),'end':resnum+7,'instance':None})returnptms