fetch the ensembl transcript IDs for a given ensembl gene ID.
        
        Args:
            gene_ids: list of Ensembl gene IDs for the gene
            hgnc_symbols: list of possible HGNC symbols for gene
976365
def get_transcript_ids_for_ensembl_gene_ids(self, gene_ids, hgnc_symbols):
        
        
        chroms = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", \
             "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", \
              "X", "Y"}
        
        headers = {"content-type": "application/json"}
        
        transcript_ids = []
        for gene_id in gene_ids:
            self.attempt = 0
            ext = "/overlap/id/{}?feature=transcript".format(gene_id)
            r = self.ensembl_request(ext, headers)
            
            for item in json.loads(r):
                # ignore non-coding transcripts
                if item["biotype"] not in ["protein_coding", "polymorphic_pseudogene"]:
                    continue
                
                # ignore transcripts not on the standard chromosomes
                # (non-default chroms fail to map the known de novo variants
                # to the gene location
                if item["Parent"] != gene_id or item["seq_region_name"] not in \
                        chroms or \
                        all([symbol not in item["external_name"] for symbol in hgnc_symbols]):
                    continue
                transcript_ids.append(item["id"])
        
        return transcript_ids
156058
def genes_by_name(self, gene_name):
        
        gene_ids = self.gene_ids_of_gene_name(gene_name)
        return [self.gene_by_id(gene_id) for gene_id in gene_ids]
505278
def add_gene_ids(self, genes_list):
        
        orig_num_genes = len(self.genes)

        for g in list(set(genes_list)):
            if not self.genes.has_id(g):
                new_gene = GenePro(id=g, pdb_file_type=self.pdb_file_type, root_dir=self.genes_dir)
                if self.model:
                    self.model.genes.append(new_gene)
                else:
                    self.genes.append(new_gene)

        log.info('Added {} genes to GEM-PRO project'.format(len(self.genes)-orig_num_genes))
78286
def get_protein_seq_for_transcript(self, transcript_id):
        
        
        headers = {"content-type": "text/plain"}
        
        self.attempt = 0
        ext = "/sequence/id/{}?type=protein".format(transcript_id)
        
        return self.ensembl_request(ext, headers)
700150
def gene_names(self):
        
        # Iterate through all the target names in the formatted targets file
        for record in SeqIO.parse(self.targets, 'fasta'):
            # Append all the gene names to the list of names
            self.genes.append(record.id)
1208784
def gene_by_protein_id(self, protein_id):
        
        gene_id = self.gene_id_of_protein_id(protein_id)
        return self.gene_by_id(gene_id)
1129459
def _add_vertex_attributes_by_genes(self, genes: List[Gene]) -> None:
        
        for gene in genes:
            try:
                vertex = self.graph.vs.find(name=str(gene.entrez_id)).index
                self.graph.vs[vertex]['l2fc'] = gene.log2_fold_change
                self.graph.vs[vertex]['symbol'] = gene.symbol
                self.graph.vs[vertex]['padj'] = gene.padj
            except ValueError:
                pass
920333
def get_deprecated_gene_ids(filename):
    
    
    deprecated = {}
    with open(filename) as handle:
        for line in handle:
            line = line.strip().split()
            old = line[0]
            new = line[1]
            deprecated[old] = new
    
    return deprecated
396978
def protein_sequence(self, protein_id):
        
        if self.protein_sequences is None:
            raise ValueError(
                "No protein FASTA supplied to this Genome: %s" % self)
        return self.protein_sequences.get(protein_id)
494180
def get_transcript_source_set(gtf):
    
    gene_to_source = get_gene_source_set(gtf)
    transcript_to_source = {}
    db = get_gtf_db(gtf)
    for feature in complete_features(db):
        gene_id = feature['gene_id'][0]
        transcript_to_source[feature['transcript_id'][0]] = gene_to_source[gene_id]
    return transcript_to_source
232169
def get_chrom_for_transcript(self, transcript_id, hgnc_id):
        
        
        headers = {"content-type": "application/json"}
        
        self.attempt = 0
        ext = "/overlap/id/{}?feature=gene".format(transcript_id)
        r =  self.ensembl_request(ext, headers)
        
        for gene in json.loads(r):
            if gene["external_name"] == hgnc_id:
                return gene["seq_region_name"]
        
        return None
421485
def get_exon_ranges_for_transcript(self, transcript_id):
        
        
        headers = {"content-type": "application/json"}
        
        self.attempt = 0
        ext = "/overlap/id/{}?feature=exon".format(transcript_id)
        r = self.ensembl_request(ext, headers)
        
        exon_ranges = []
        for exon in json.loads(r):
            if exon["Parent"] != transcript_id:
                continue
            
            start = exon["start"]
            end = exon["end"]
            
            exon_ranges.append((start, end))
        
        return exon_ranges
232579
private String extractGeneSymbol(Xref xref)
	{
		if (xref.getDb() != null && (
			xref.getDb().equalsIgnoreCase("HGNC Symbol") ||
			xref.getDb().equalsIgnoreCase("Gene Symbol") ||
			xref.getDb().equalsIgnoreCase("HGNC")))
		{
			String ref = xref.getId();

			if (ref != null) {
				ref = ref.trim();
				if (ref.contains(":")) ref = ref.substring(ref.indexOf(":") + 1);
				if (ref.contains("_")) ref = ref.substring(ref.indexOf("_") + 1);
				// if the reference is an HGNC ID, then convert it to a symbol
				if (!HGNC.containsSymbol(ref) && Character.isDigit(ref.charAt(0))) {
					ref = HGNC.getSymbol(ref);
				}
			}

			return ref;
		}

		return null;
	}
1236455
def get_neighbor_expression_vector(neighbors, gene_expression_dict):
    
    expressions = []  # Expression vector.
    for gene in neighbors:
        try:
            expression = gene_expression_dict[gene]
        except KeyError:
            continue

        expressions.append(expression)
    return expressions
1136850
def _try_parse_gene_association(self, reaction_id, s):
        
        s = s.strip()
        if s == '':
            return None

        try:
            return boolean.Expression(s)
        except boolean.ParseError as e:
            msg = 'Failed to parse gene association for {}: {}'.format(
                reaction_id, text_type(e))
            if e.indicator is not None:
                msg += '\n{}\n{}'.format(s, e.indicator)
            logger.warning(msg)

        return s
79644
def fetch_aliases(self, seq_id, current_only=True, translate_ncbi_namespace=None):
        """"""
        return [dict(r) for r in self.find_aliases(seq_id=seq_id,
                                                   current_only=current_only,
                                                   translate_ncbi_namespace=translate_ncbi_namespace)]
79767
def get_transcript(self,exon_bounds='max'):
    """"""
    out = Transcript()
    out.junctions = [x.get_junction() for x in self.junction_groups]
    # check for single exon transcript
    if len(out.junctions) == 0:
      leftcoord = min([x.exons[0].range.start for x in self.transcripts])
      rightcoord = max([x.exons[-1].range.end for x in self.transcripts])
      e = Exon(GenomicRange(x.exons[0].range.chr,leftcoord,rightcoord))
      e.set_is_leftmost()
      e.set_is_rightmost()
      out.exons.append(e)
      return out
    # get internal exons
    self.exons = []
    for i in range(0,len(self.junction_groups)-1):
      j1 = self.junction_groups[i].get_junction()
      j2 = self.junction_groups[i+1].get_junction()
      e = Exon(GenomicRange(j1.right.chr,j1.right.end,j2.left.start))
      e.set_left_junc(j1)
      e.set_right_junc(j2)
      #print str(i)+" to "+str(i+1)
      out.exons.append(e)
    # get left exon
    left_exons = [y for y in [self.transcripts[e[0]].junctions[e[1]].get_left_exon() for e in self.junction_groups[0].evidence] if y]
    if len(left_exons) == 0:
      sys.stderr.write("ERROR no left exon\n")
      sys.exit()
    e_left = Exon(GenomicRange(out.junctions[0].left.chr,\
                               min([x.range.start for x in left_exons]),
                               out.junctions[0].left.start))
    e_left.set_right_junc(out.junctions[0])
    out.exons.insert(0,e_left)
    # get right exon
    right_exons = [y for y in [self.transcripts[e[0]].junctions[e[1]].get_right_exon() for e in self.junction_groups[-1].evidence] if y]
    if len(right_exons) == 0:
      sys.stderr.write("ERROR no right exon\n")
      sys.exit()
    e_right = Exon(GenomicRange(out.junctions[-1].right.chr,\
                               out.junctions[-1].right.end,\
                               max([x.range.end for x in right_exons])))
    e_right.set_left_junc(out.junctions[-1])
    out.exons.append(e_right)
    return out