def get_homolog_position(self, gene, organism, position, ortholog_type="all"): """ :param gene: Can be any of the following: Ensemble gene identifier, Ensemble protein identifier, Ensemble transcript identifier, Entrez gene id, gene symbol, NCBI GI, HGNC Id, International protein index id, NCBI UniGene id, UniProt accession andUniProt id :param organism: a valid taxon ID :param ortholog_type: optional parameter to specify ortholog type of target organism """ if "," in gene: logger.warning( "did not expect a comma. Please provide only one gene name") assert ortholog_type in ['LDO', 'all'] assert position >= 1 params = { "gene": gene, "organism": organism, "pos": position, "orthologType": ortholog_type } res = self.http_get("ortholog/homologpos", params=params, frmt="json") res = res['search']['mapping'] if "mapped" in res.keys(): res = res['mapped'] return res elif "unmapped_ids" in res.keys(): logger.warning("did not find any match for {}".format(gene)) return res["unmapped_ids"]
def get_mapping(self, gene_list, taxon): """Map identifiers Each identifier to be delimited by comma i.e. ',. Maximum of 1000 Identifiers can be any of the following: Ensemble gene identifier, Ensemble protein identifier, Ensemble transcript identifier, Entrez gene id, gene symbol, NCBI GI, HGNC Id, International protein index id, NCBI UniGene id, UniProt accession and UniProt id :param gene_list: see above :param taxon: one taxon ID. See supported :meth:`~bioservices.panther.Panther.get_supported_genomes` If an identifier is not found, information can be found in the unmapped_genes key while found identifiers are in the mapped_genes key. .. warning:: found and not found identifiers are dispatched into unmapped and mapped genes. If there are not found identifiers, the input gene list and the mapped genes list do not have the same length. The input names are not stored in the output. Developpers should be aware of that feature. """ params = {"geneInputList": gene_list, "organism": taxon} res = self.http_post("geneinfo", params=params, frmt='json') if "mapped_genes" in res['search']: mapped_genes = res['search']['mapped_genes']['gene'] # if only one identifier, retuns a dictionary. # if several identifiers, returns a list of dictionary. # We will be consistent and return a list if "accession" in mapped_genes: mapped_genes = [mapped_genes] else: mapped_genes = [{}] if "unmapped_list" in res['search']: unmapped_genes = res['search']['unmapped_list']["unmapped"] if isinstance(unmapped_genes, list): pass else: unmapped_genes = [unmapped_genes] else: unmapped_genes = [] logger.warning("Some identifiers were not found") return {"unmapped": unmapped_genes, "mapped": mapped_genes}