#!/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/#from__future__importannotationsimportcollectionsfrompypath.shareimportcurlfrompypath.resources.urlsimporturlsfrompypath.shareimportsessionfrompypath.utilsimporttaxonomy_log=session.Logger(name='trrust_input')._log
[docs]deftrrust_interactions(organism:str|int='human',)->list[TrrustInteraction]:""" Gene regulatory interactions from the TRRUST v2 database. https://academic.oup.com/nar/article/46/D1/D380/4566018 Args: organism: Name or NCBI Taxonomy ID of the organism. Human and mouse are available in TRRUST. """organisms={'human','mouse'}_organism=taxonomy.ensure_common_name(organism,lower=True)if_organismnotinorganisms:err=f'Only human and mouse are availble in TRRUST, not `{organism}`.'_log(err)raiseValueError(err)classTrrustInteraction(collections.namedtuple('TrrustInteractionBase',('source_genesymbol','target_genesymbol','effect','references'),)):def__new__(cls,line):line=line.strip('\n ').split('\t')refs=tuple(sorted(line[-1].split(';')))returnsuper().__new__(cls,*line[:-1],refs)url=urls['trrust']['tsv_url']%_organismc=curl.Curl(url,silent=False,large=True,encoding='utf-8',default_mode='r',)interactions=[TrrustInteraction(line)forlineinc.result]returninteractions