#!/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/#importreimportcollectionsimportpypath.share.curlascurlimportpypath.resources.urlsasurlsimportpypath.utils.taxonomyastaxonomy
[docs]deforeganno_raw():""" Downloads TF-target data from the ORegAnnO database. Yields: Tuples of raw records. """url=urls.urls['oreganno']['url']c=curl.Curl(url,silent=False,large=True,slow=True)data=c.result_=next(data)forlindata:ifnotl:continueyieldtuple(x.strip()forxinl.split('\t'))
[docs]deforeganno_interactions(organism=9606):""" Downloads TF-target interactions from the ORegAnnO database. Yields: Named tuples of TF, target and literature references. """OregannoInteraction=collections.namedtuple('OregannoInteraction',('tf','target','pmid'),)taxids=taxonomy.phosphoelm_taxidsiforganismintaxids:organism=taxids[organism]nsep=re.compile(r'([-A-Za-z0-9]{3,})[\s/\(]*.*')nrem=re.compile(r'[-/]')forlinoreganno_raw():if(l[1]==organismandl[3]=='TRANSCRIPTION FACTOR BINDING SITE'andl[2]=='POSITIVE OUTCOME'andl[4]!='N/A'andl[7]!='N/A'):yieldOregannoInteraction(tf=(l[7]iflen(l[7])<3elsenrem.sub('',nsep.findall(l[7])[0])),target=(l[4]iflen(l[4])<3elsenrem.sub('',nsep.findall(l[4])[0])),pmid=l[11]ifl[11]!='N/A'else'',)