determine if genes are present in the API

    Args:
        my_clue_api_client:
        gene_symbols: collection of gene symbols to query the API with

    Returns: set of the found gene symbols
321349
def are_genes_in_api(my_clue_api_client, gene_symbols):
    
    if len(gene_symbols) > 0:
        query_gene_symbols = gene_symbols if type(gene_symbols) is list else list(gene_symbols)

        query_result = my_clue_api_client.run_filter_query(resource_name,
            {"where":{"gene_symbol":{"inq":query_gene_symbols}}, "fields":{"gene_symbol":True}})
        logger.debug("query_result:  {}".format(query_result))

        r = set([x["gene_symbol"] for x in query_result])
        return r
    else:
        logger.warning("provided gene_symbols was empty, cannot run query")
        return set()
510355
def is_gene_list(bed_file):
    
    with utils.open_gzipsafe(bed_file) as in_handle:
        for line in in_handle:
            if not line.startswith("#"):
                if len(line.split()) == 1:
                    return True
                else:
                    return False
372600
def recognise(self, string, line_num):
		
		symbols = []
		unknown = []

		for char in string:
			if char == SPACE:
				continue

			try:
				name = unicodedata.name(char)
			except ValueError:
				name = 'UNNAMED CHARACTER {}'.format(ord(char))

			if char in self.ipa:
				symbol = Symbol(char, name, self.ipa[char])
				symbols.append(symbol)
				self.ipa_symbols[symbol].append(line_num)
			else:
				symbol = UnknownSymbol(char, name)
				unknown.append(symbol)
				self.unk_symbols[symbol].append(line_num)

		return tuple(symbols), tuple(unknown)
246735
def grep_full_py_identifiers(tokens):
    
    global py_keywords
    tokens = list(tokens)
    i = 0
    while i < len(tokens):
        token_type, token = tokens[i]
        i += 1
        if token_type != "id":
            continue
        while i+1 < len(tokens) and tokens[i] == ("op", ".") and tokens[i+1][0] == "id":
            token += "." + tokens[i+1][1]
            i += 2
        if token == "":
            continue
        if token in py_keywords:
            continue
        if token[0] in ".0123456789":
            continue
        yield token
821150
def build_pmid_inclusion_filter(pmids: Strings) -> EdgePredicate:
    
    if isinstance(pmids, str):
        @edge_predicate
        def pmid_inclusion_filter(edge_data: EdgeData) -> bool:
            """Pass for edges with PubMed citations matching the contained PubMed identifier."""
            return has_pubmed(edge_data) and edge_data[CITATION][CITATION_REFERENCE] == pmids

    elif isinstance(pmids, Iterable):
        pmids = set(pmids)

        @edge_predicate
        def pmid_inclusion_filter(edge_data: EdgeData) -> bool:
            """Pass for edges with PubMed citations matching one of the contained PubMed identifiers."""
            return has_pubmed(edge_data) and edge_data[CITATION][CITATION_REFERENCE] in pmids

    else:
        raise TypeError

    return pmid_inclusion_filter
324741
def _diagnose_prefixes(self):
        
        from peyotl.phylesystem import STUDY_ID_PATTERN
        p = set()
        for name in os.listdir(self.doc_dir):
            if STUDY_ID_PATTERN.match(name):
                p.add(name[:3])
        return p
330631
def missing_representative_sequence(self):
        """"""
        return [x.id for x in self.genes if not self.genes_with_a_representative_sequence.has_id(x.id)]
1125494
def LookupClients(self, keywords):
    
    if isinstance(keywords, string_types):
      raise ValueError(
          "Keywords should be an iterable, not a string (got %s)." % keywords)

    start_time, end_time, filtered_keywords, unversioned_keywords = (
        self._AnalyzeKeywords(keywords))

    last_seen_map = None
    if unversioned_keywords:
      last_seen_map = {}

    # TODO(user): Make keyword index datetime aware so that
    # AsMicrosecondsSinceEpoch is unnecessary.

    raw_results = self.Lookup(
        list(map(self._NormalizeKeyword, filtered_keywords)),
        start_time=start_time.AsMicrosecondsSinceEpoch(),
        end_time=end_time.AsMicrosecondsSinceEpoch(),
        last_seen_map=last_seen_map)
    if not raw_results:
      return []

    if unversioned_keywords:
      universal_last_seen_raw = {}
      self.ReadPostingLists(
          list(map(self._NormalizeKeyword, raw_results)),
          start_time=start_time.AsMicrosecondsSinceEpoch(),
          end_time=end_time.AsMicrosecondsSinceEpoch(),
          last_seen_map=universal_last_seen_raw)

      universal_last_seen = {}
      for (_, client_id), ts in iteritems(universal_last_seen_raw):
        universal_last_seen[client_id] = ts

      old_results = set()
      for keyword in unversioned_keywords:
        for result in raw_results:
          if last_seen_map[(keyword, result)] < universal_last_seen[result]:
            old_results.add(result)
      raw_results -= old_results

    return [rdf_client.ClientURN(result) for result in raw_results]
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
1326123
def get_identifiers(source_code):
    ''''''
    tokens = set(re.split(r"[^0-9a-zA-Z_.]", source_code))
    valid = re.compile(r'[a-zA-Z_]')
    return [token for token in tokens if re.match(valid, token)]
746317
def missing_kegg_mapping(self):
        """"""
        kegg_missing = []
        for g in self.genes:
            keggs = g.protein.filter_sequences(KEGGProp)
            no_sequence_file_available = True
            for k in keggs:
                if k.sequence_file:
                    no_sequence_file_available = False
                    break
            if no_sequence_file_available:
                kegg_missing.append(g.id)
        return list(set(kegg_missing))
1140196
def genestatus(args):
    
    p = OptionParser(genestatus.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    idsfile, = args
    data = get_tags(idsfile)
    key = lambda x: x[0].split(".")[0]
    for gene, cc in groupby(data, key=key):
        cc = list(cc)
        tags = [x[-1] for x in cc]
        if "complete" in tags:
            tag = "complete"
        elif "partial" in tags:
            tag = "partial"
        else:
            tag = "pseudogene"
        print("\t".join((gene, tag)))
1348481
def parse_gene_set(gene_set_fp):
    
    group_gene_set_dict = OrderedDict()

    with open(gene_set_fp) as inFile:
        for line in inFile.readlines():
            tokens = line.strip().split('\t')
            group = tokens[0]
            gene_set = set(tokens[1:])

            group_gene_set_dict[group] = gene_set

    return group_gene_set_dict
499037
def gene_ids(self, contig=None, strand=None):
        
        return self._all_feature_values(
            column="gene_id",
            feature="gene",
            contig=contig,
            strand=strand)
809486
def _get_genes(self, variant):
        
        transcripts = variant['transcripts']
        ensembl_ids = [transcript['ensembl_id'] for transcript in
                       transcripts if transcript['ensembl_id']]
        hgnc_symbols = [transcript['hgnc_symbol'] for transcript in
                        transcripts if transcript['hgnc_symbol']]
        genes = get_gene_info(ensembl_ids, hgnc_symbols)
        return genes
1030759
def fetch(cls, client, symbol):
        
        assert(type(symbol) is str)

        url = ("https://api.robinhood.com/instruments/?symbol={0}".
               format(symbol))
        data = client.get(url)
        return data["results"][0]
656027
def _check_dna(self, dna):
        
        valid_chars = set(self.GENETIC_MATERIAL_OPTIONS)
        assert all(char in valid_chars for char in dna)