Query ChEMBL API target by id

    Parameters
    ----------
    target_chembl_id : str

    Returns
    -------
    target : dict
        dict parsed from json that is unique for the target
185781
def query_target(target_chembl_id):
    
    query_dict = {'query': 'target',
                  'params': {'target_chembl_id': target_chembl_id,
                             'limit': 1}}
    res = send_query(query_dict)
    target = res['targets'][0]
    return target
1228149
def filter(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/filters/{0}'.format(str(id))
        return self.__api_request('GET', url)
32928
def find(self, id):
        
        url = "{}/{}/{}".format(__endpoint__, self.type.RESOURCE, id)
        response = RestClient.get(url)[self.type.RESOURCE[:-1]]
        return self.type(response)
1010762
def get_by_id(cls, id):
        

        if any((isinstance(id, basestring) and id.isdigit(), isinstance(id,
               (int, float)))):
            return cls.query.get(int(id))
        return None
778346
def retrieve(self, identifier, *criterion):
        
        return self._retrieve(
            self.model_class.id == identifier,
            *criterion
        )
557355
def get(self, id):
        
        rv = self.db.execute(
            'SELECT * FROM comments WHERE id=?', (id, )).fetchone()
        if rv:
            return dict(zip(Comments.fields, rv))

        return None
818145
def target_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/targets/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
545385
async def _has_id(self, *args, **kwds):
        
        # if there is only one positional argument
        if len(args) == 1:
            # parse the appropriate query
            result = await parse_string(
                self._query,
                self.service.object_resolver,
                self.service.connection_resolver,
                self.service.mutation_resolver,
                obey_auth=False
            )
            # go to the bottom of the result for the list of matching ids
            return self._find_id(result['data'], args[0])
        # otherwise
        else:
            # treat the attribute like a normal filter
            return self._has_id(**kwds)
1029519
def _id_or_key(list_item):
    '''
    
    '''
    if isinstance(list_item, dict):
        if 'id' in list_item:
            return list_item['id']
        if 'key' in list_item:
            return list_item['key']
    return list_item
824160
def targeting_criteria(self, id=None, **kwargs):
        
        self._validate_loaded()
        if id is None:
            return TargetingCriteria.all(self.account, self.id, **kwargs)
        else:
            return TargetingCriteria.load(self.account, id, **kwargs)
668466
def key(self, id_num):
        
        json = None
        if int(id_num) > 0:
            url = self._build_url('keys', str(id_num), base_url=self._api)
            json = self._json(self._get(url), 200)
        return Key(json, self) if json else None
824482
def find_by_id(cls, id):
        
        obj = cls.find_one(cls._id_spec(id))
        if not obj:
            raise NotFoundException(cls.collection, id)
        return obj
445694
def find_in_list_by_name(haystack, target_name, target_package, nodetype):
    """"""
    for model in haystack:
        name = model.get('unique_id')
        if id_matches(name, target_name, target_package, nodetype, model):
            return model

    return None
841837
def _get_one(self, id):
        
        try:
            return self._to_dict(models.User.objects.get(pk=id))
        except models.User.DoesNotExist:
            raise errors.NotFound()
437555
def get(self, targetId):
        
        result = self._targetController.analyse(targetId)
        if result:
            if len(result) == 2:
                if result[1] == 404:
                    return result
                else:
                    return {'name': targetId, 'data': self._jsonify(result)}, 200
            else:
                return None, 404
        else:
            return None, 500
542209
def get_learning_objective_ids(self):
        
        if 'learningObjectiveIds' not in self._my_map:  # Will this ever be the case?
            collection = JSONClientValidated('assessment',
                                             collection='Item',
                                             runtime=self._runtime)
            item_map = collection.find_one({'_id': ObjectId(Id(self._my_map['itemId']).get_identifier())})
            self._my_map['learningObjectiveIds'] = list(item_map['learningObjectiveIds'])
        return IdList(self._my_map['learningObjectiveIds'])
1209986
def list_scans(self, source_id=None):
        
        if source_id:
            target_url = self.client.get_url('SCAN', 'GET', 'multi', {'source_id': source_id})
        else:
            target_url = self.client.get_ulr('SCAN', 'GET', 'all')
        return base.Query(self.client.get_manager(Scan), target_url)