Convert list of taxids to Latin names
198873
def batch_taxonomy(list_of_taxids):
    
    for taxid in list_of_taxids:
        handle = Entrez.efetch(db='Taxonomy', id=taxid, retmode="xml")
        records = Entrez.read(handle)
        yield records[0]["ScientificName"]
864495
def batch_taxids(list_of_names):
    
    for name in list_of_names:
        handle = Entrez.esearch(db='Taxonomy', term=name, retmode="xml")
        records = Entrez.read(handle)
        yield records["IdList"][0]
1143289
def _format_name_map(self, lon, lat):
        '''  '''

        if self.ppd in [4, 16, 64, 128]:
            lolaname = '_'.join(['LDEM', str(self.ppd)])
        elif self.ppd in [512]:
            lolaname = '_'.join(
                ['LDEM', str(self.ppd), lat[0], lat[1], lon[0], lon[1]])
        return lolaname
230621
function getNames (resourceType) {
  const aliases = [resourceType];
  if (resourceAliases[resourceType]) {
    return aliases.concat(resourceAliases[resourceType]);
  }
  return alias(resourceType);
}
446345
def _get_dsnames(cls, data, ignore_keys=['attrs', 'plotter', 'ds'],
                     concat_dim=False):
        """"""
        def filter_ignores(item):
            return item[0] not in ignore_keys and isinstance(item[1], dict)
        if 'fname' in data:
            return {tuple(
                [data['fname'], data['store']] +
                ([data.get('concat_dim')] if concat_dim else []))}
        return set(chain(*map(partial(cls._get_dsnames, concat_dim=concat_dim,
                                      ignore_keys=ignore_keys),
                              dict(filter(filter_ignores,
                                          six.iteritems(data))).values())))
827882
def _get_names(names, types):
    
    if types == "":
        try:
            names, types = names.split(":")
        except:
            pass
    return names.split(","), types
395283
def list_names(cls):
        """"""
        response = subwrap.run(['lxc-ls'])
        output = response.std_out
        return map(str.strip, output.splitlines())
1075021
def _clean_name(self, prefix, obj):
        """"""
        return '{}{}_{}'.format(prefix, self._uid(), ''.join(c for c in obj.name if c.isalnum()))
668991
def convert_fus(ast):
    """"""

    parent_fn_name = ast.name_short
    prefix_list = {"p": "p.", "r": "r.", "g": "c."}
    prefix = prefix_list[parent_fn_name]

    fus1_ns = ast.args[0].namespace
    fus1_val = ast.args[0].value

    arg_fus = ast.args[1]
    fus_args = [None, "?", "?"]
    for idx, arg in enumerate(arg_fus.args):
        fus_args[idx] = arg

    fus2_ns = fus_args[0].namespace
    fus2_val = fus_args[0].value

    if fus_args[1] == "?":
        fus1_range = fus_args[1]
    else:
        fus1_range = f'"{prefix}1_{fus_args[1].value}"'

    if fus_args[2] == "?":
        fus2_range = fus_args[2]
    else:
        fus2_range = f'"{prefix}{fus_args[2].value}_?"'

    fus = Function("fus", spec, parent_function=ast)
    fus.args = [
        NSArg(fus1_ns, fus1_val, fus),
        StrArg(fus1_range, fus),
        NSArg(fus2_ns, fus2_val, fus),
        StrArg(fus2_range, fus),
    ]

    # Remove BEL
    ast_args = ast.args
    ast_args.pop(0)
    ast_args.pop(0)

    if ast_args == [None]:
        ast_args = []

    ast.args = []
    ast.add_argument(fus)

    if len(ast_args) > 0:
        ast.args.extend(ast_args)

    return ast
414646
def get_id2gos(self, **kws):
    #### def get_annotations_dct(self, taxid, options):
        """"""
        if len(self.taxid2asscs) == 1:
            taxid = next(iter(self.taxid2asscs.keys()))
            return self._get_id2gos(self.taxid2asscs[taxid], **kws)
        assert 'taxid' in kws, "**FATAL: 'taxid' NOT FOUND IN Gene2GoReader::get_id2gos({KW})".format(KW=kws)
        taxid = kws['taxid']
        assert taxid in self.taxid2asscs, '**FATAL: TAXID({T}) DATA MISSING'.format(T=taxid)
        return self._get_id2gos(self.taxid2asscs[taxid], **kws)
769428
def camel_to_underscore(name):
    
    as_list = []
    length = len(name)
    for index, i in enumerate(name):
        if index != 0 and index != length - 1 and i.isupper():
            as_list.append('_%s' % i.lower())
        else:
            as_list.append(i.lower())

    return ''.join(as_list)
2511
def remove_empty_ranks(self, tax_list):
        '''
        
        '''
        new_tax_list = []
        for rank in tax_list:
            if rank not in self.meaningless_taxonomic_names:
                new_tax_list.append(rank)
        return new_tax_list
723356
def latinize(mapping, bind, values):
    
    for v in values:
        if isinstance(v, six.string_types):
            v = transliterate(v)
        yield v
1326511
def get_name(self):
        """"""
        if len(self.taxid2asscs) == 1:
            return '{BASE}_{TAXID}'.format(
                BASE=self.name, TAXID=next(iter(self.taxid2asscs.keys())))
        return '{BASE}_various'.format(BASE=self.name)
670600
def get_taxid2asscs(self, taxids=None, **kws):
        """"""
        # WAS: get_annotations_taxid2dct
        taxid2asscs = cx.defaultdict(lambda: cx.defaultdict(lambda: cx.defaultdict(set)))
        options = AnnoOptions(self.evobj, **kws)
        for taxid in self._get_taxids(taxids):
            nts = self.taxid2asscs[taxid]
            assc = self.reduce_annotations(nts, options)
            taxid2asscs[taxid]['ID2GOs'] = self._get_dbid2goids(assc)
            taxid2asscs[taxid]['GO2IDs'] = self._get_goid2dbids(assc)
        return taxid2asscs
231567
def namelist(self):
        """"""
        l = []
        for data in self.filelist:
            l.append(data.filename)
        return l
1315483
def pluralize(data_type):
    
    known = {
             u"address": u"addresses", 
             u"company": u"companies"
    }
    if data_type in known.keys():
        return known[data_type]
    else:
        return u"%ss" % data_type