Converts a drug name to the name of its generic equivalent.
976247
def drug_name_to_generic(drug_name: str,
                         unknown_to_default: bool = False,
                         default: str = None,
                         include_categories: bool = False) -> str:
    
    drug = get_drug(drug_name, include_categories=include_categories)
    if drug is not None:
        return drug.generic_name
    return default if unknown_to_default else drug_name
930712
def normalize_names(names):
    """"""
    if isinstance(names, basestring):
        names = names.split(',')
    names = listify(names)
    return [str(name).strip() for name in names]
384356
def prepend_name_scope(name, import_scope):
  """"""
  # Based on tensorflow/python/framework/ops.py implementation.
  if import_scope:
    try:
      str_to_replace = r"([\^]|loc:@|^)(.*)"
      return re.sub(str_to_replace, r"\1" + import_scope + r"/\2",
                    tf.compat.as_str_any(name))
    except TypeError as e:
      # If the name is not of a type we can process, simply return it.
      logging.warning(e)
      return name
  else:
    return name
632788
protected function _renameToTmp()
    {
        $tmpTableName = $this->_name;
        $tableNames = $this->_database->getTableNames();
        do {
            $tmpTableName .= '_bak';
        } while (in_array($tmpTableName, $tableNames));
        // Use quoteIdentifier() instead of prepareIdentifier() because the
        // temporary name is not identified as a keyword.
        $tmpTableName = $this->_database->quoteIdentifier($tmpTableName);
        $this->alter("RENAME TO $tmpTableName");
        return $tmpTableName;
    }
644529
def source_debianize_name(name):
    ""
    name = name.replace('_','-')
    name = name.replace('.','-')
    name = name.lower()
    return name
1190772
def _remove_prefix(name):
    """"""
    if isinstance(name, str):
        return _do_remove_prefix(name)
    return [_do_remove_prefix(nm) for nm in name]
1030036
def renamecol(self, oldname, newname):
        
        self._renamecol(oldname, newname)
        self._makerow()
399644
def _convert_to_dict(cls, term, replace_value_names=True):
        

        from collections import OrderedDict

        if not term:
            return None

        if term.children:

            d = OrderedDict()

            for c in term.children:

                if c.child_property_type == 'scalar':
                    d[c.record_term_lc] = cls._convert_to_dict(c, replace_value_names)

                elif c.child_property_type == 'sequence':
                    try:
                        d[c.record_term_lc].append(cls._convert_to_dict(c, replace_value_names))
                    except (KeyError, AttributeError):
                        # The c.term property doesn't exist, so add a list
                        d[c.record_term_lc] = [cls._convert_to_dict(c, replace_value_names)]

                elif c.child_property_type == 'sconcat': # Concat with a space

                    if c.record_term_lc in d:
                        s = d[c.record_term_lc] + ' '
                    else:
                        s = ''

                    d[c.record_term_lc] =s + (cls._convert_to_dict(c, replace_value_names) or '')

                elif c.child_property_type == 'bconcat':  # Concat with a blank

                    d[c.record_term_lc] = d.get(c.record_term_lc, '') +  (cls._convert_to_dict(c,
                                                                                               replace_value_names)
                                                                          or '')

                else:
                    try:
                        d[c.record_term_lc].append(cls._convert_to_dict(c, replace_value_names))
                    except KeyError:
                        # The c.term property doesn't exist, so add a scalar or a map
                        d[c.record_term_lc] = cls._convert_to_dict(c, replace_value_names)
                    except AttributeError as e:
                        # d[c.term] exists, but is a scalar, so convert it to a list

                        d[c.record_term_lc] = [d[c.record_term]] + [cls._convert_to_dict(c, replace_value_names)]

            if term.value:
                if replace_value_names:
                    d[term.term_value_name.lower()] = term.value
                else:
                    d['@value'] = term.value

            return d

        else:
            return term.value
751948
def snakify(name, sep='_'):
    '''  '''
    name = re.sub("([A-Z]+)([A-Z][a-z])", r"\1%s\2" % sep, name)
    name = re.sub("([a-z\\d])([A-Z])", r"\1%s\2" % sep, name)
    return name.lower()
605609
def _dict_to_name_value(data):
    '''
    
    '''
    if isinstance(data, dict):
        sorted_data = sorted(data.items(), key=lambda s: s[0])
        result = []
        for name, value in sorted_data:
            if isinstance(value, dict):
                result.append({name: _dict_to_name_value(value)})
            else:
                result.append({name: value})
    else:
        result = data
    return result
940942
def toVName(name, stripNum=0, upper=False):
    
    if upper:
        name = name.upper()
    if stripNum != 0:
        name = name[:-stripNum]
    return name.replace('_', '-')
1246923
def convert_name(name, _class)
    name_index = get_name_index(name)

    # The ptg value depends on the class of the ptg.
    if _class == 0
      ptgName = @ptg['ptgName']
    elsif _class == 1
      ptgName = @ptg['ptgNameV']
    elsif _class == 2
      ptgName = @ptg['ptgNameA']
    end

    [ptgName, name_index].pack('CV')
  end
992737
@Deprecated 
	private String convertDatabaseName(String name) {
		if (propBase.getBooleanProperty("db.useUnderscoreNaming")) {
			name = CamelCaseConverter.camelCaseToUnderscore(name);
		}
		name = truncateLongDatabaseName(name);
		name = name.toUpperCase();
		return name;
	}
487105
def transform_item(self, item):
        
        obj = {
            'id': item['primaryId'],
            'label': item['symbol'],
            'full_name': item['name'],
            'type': item['soTermId'],
            'taxon': {'id': item['taxonId']},
        }
        if 'synonyms' in item:
            obj['synonyms'] = item['synonyms']
        if 'crossReferenceIds' in item:
            obj['xrefs'] = [self._normalize_id(x) for x in item['crossReferenceIds']]

        # TODO: synonyms
        # TODO: genomeLocations
        # TODO: geneLiteratureUrl
        return obj
406709
def getMethName(meth):
    '''
    
    '''
    item = meth.__self__
    mname = item.__module__
    cname = item.__class__.__name__
    fname = meth.__func__.__name__
    return '.'.join((mname, cname, fname))
1075021
def _clean_name(self, prefix, obj):
        """"""
        return '{}{}_{}'.format(prefix, self._uid(), ''.join(c for c in obj.name if c.isalnum()))
1044703
def normalize(cls, name):
        """"""
        name = name.lower() # lower-case
        for _replace in [' ','-','(',')','?']:
            name = name.replace(_replace,'')
        return name