#!/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/#importcollectionsimportpypath.resources.urlsasurlsimportpypath.share.curlascurl
[docs]deflincs_compounds():""" The returned dict has names, brand names or company specific IDs of compounds as keys, and tuples of PubChem, ChEMBL, ChEBI, InChi, InChi Key, SMILES and LINCS as values. """LincsCompound=collections.namedtuple('LincsCompound',('lincs','chembl','chebi','inchi','inchi_key','smiles','alternatives',))c=curl.Curl(urls.urls['lincs-compounds']['url'],silent=False)returndict([(key,pair[1])forpairin[([itforslin[filter(lambdaz:len(z)>0,y.split(';'))foryinx[1:4]iflen(y)>0]foritinsl],LincsCompound(lincs=x[4],chembl='CHEMBL%s'%x[7]ifx[7]elseNone,chebi='CHEBI:%s'%x[8]ifx[8]elseNone,inchi=x[9],inchi_key=x[10],smiles=x[11],alternatives=x[3],))forxin[[b.strip()forbina.split('\t')]forain''.join([s.replace(',','\t')ifi%2==0elses.replace('\n','')fori,sinenumerate(c.result.split('"'))]).split('\n')[1:]iflen(a)>0]]forkeyinpair[0]])