if data_dict has a non synonymous variant, return string:
        ref_name.change. Otherwise return None
160762
def _get_nonsynonymous_var(data_dict):
        ''''''
        has_nonsyn = SummaryCluster._has_nonsynonymous(data_dict)

        if has_nonsyn == 'no':
            return None
        elif data_dict['known_var_change'] == data_dict['ref_ctg_change'] == '.' == data_dict['ref_ctg_effect']:
            raise Error('Unexpected data in ariba summary... \n' + str(data_dict) + '\n... known_var_change, ref_ctg_change, ref_ctg_effect all equal to ".", but has a non synonymous change. Something is inconsistent. Cannot continue')
        else:
            if '.' not in [data_dict['known_var_change'], data_dict['ref_ctg_change']] and \
              data_dict['known_var_change'] != data_dict['ref_ctg_change']:
                raise Error('Unexpected data in ariba summary... \n' + str(data_dict) + '\n... known_var_change != ref_ctg_change. Cannot continue')

            var_group = 'novel', None

            if data_dict['known_var'] == '1' and data_dict['known_var_change'] != '.':
                var_change = data_dict['known_var_change']
                if data_dict['var_group'] == '.':
                    var_group = 'ungrouped', None
                else:
                    var_group = 'grouped', data_dict['var_group']
            elif data_dict['ref_ctg_change'] != '.':
                var_change = data_dict['ref_ctg_change']
            else:
                var_change = data_dict['ref_ctg_effect']

            return (data_dict['ref_name'], var_change) + var_group
160526
def _FetchRemapping(type_name, mapping_type, python_name=None, json_name=None,
                    mappings=None):
    """"""
    if python_name and json_name:
        raise exceptions.InvalidDataError(
            'Cannot specify both python_name and json_name '
            'for %s remapping' % mapping_type)
    if not (python_name or json_name):
        raise exceptions.InvalidDataError(
            'Must specify either python_name or json_name for %s remapping' % (
                mapping_type,))
    field_remappings = mappings.get(type_name, {})
    if field_remappings:
        if python_name:
            return field_remappings.get(python_name)
        elif json_name:
            if json_name in list(field_remappings.values()):
                return [k for k in field_remappings
                        if field_remappings[k] == json_name][0]
    return None
188414
def _check_names_match(data_names, data_shapes, name, throw):
    """"""
    actual = [x[0] for x in data_shapes]
    if sorted(data_names) != sorted(actual):
        msg = "Data provided by %s_shapes don't match names specified by %s_names (%s vs. %s)"%(
            name, name, str(data_shapes), str(data_names))
        if throw:
            raise ValueError(msg)
        else:
            warnings.warn(msg)
1183613
def _replace_reference(self, var):
        """"""

        if var.type not in "cgmnr":
            raise HGVSUnsupportedOperationError("Can only update references for type c, g, m, n, r")

        if var.posedit.edit.type == "ins":
            # insertions have no reference sequence (zero-width), so return as-is
            return var
        if var.posedit.edit.type == "con":
            # conversions have no reference sequence (zero-width), so return as-is
            return var

        pos = var.posedit.pos
        if ((isinstance(pos.start, hgvs.location.BaseOffsetPosition) and pos.start.offset != 0)
                or (isinstance(pos.end, hgvs.location.BaseOffsetPosition) and pos.end.offset != 0)):
            _logger.info("Can't update reference sequence for intronic variant {}".format(var))
            return var

        # For c. variants, we need coords on underlying sequences
        if var.type == "c":
            tm = self._fetch_AlignmentMapper(
                tx_ac=var.ac, alt_ac=var.ac, alt_aln_method="transcript")
            pos = tm.c_to_n(var.posedit.pos)
        else:
            pos = var.posedit.pos
        seq = self.hdp.get_seq(var.ac, pos.start.base - 1, pos.end.base)

        edit = var.posedit.edit
        if edit.ref != seq:
            _logger.debug("Replaced reference sequence in {var} with {seq}".format(
                var=var, seq=seq))
            edit.ref = seq

        return var
496915
def check_nonstandard_section_name(self):
        '''  '''
        std_sections = ['.text', '.bss', '.rdata', '.data', '.rsrc', '.edata', '.idata',
                        '.pdata', '.debug', '.reloc', '.stab', '.stabstr', '.tls',
                        '.crt', '.gnu_deb', '.eh_fram', '.exptbl', '.rodata']
        for i in range(200):
            std_sections.append('/'+str(i))
        non_std_sections = []
        for section in self.pefile_handle.sections:
            name = convert_to_ascii_null_term(section.Name).lower()
            if (name not in std_sections):
                non_std_sections.append(name)
        if non_std_sections:
            return{'description': 'Section(s) with a non-standard name, tamper indication', 
                   'severity': 3, 'category': 'MALFORMED', 'attributes': non_std_sections}

        return None
217175
def changed(self, name):
        
        if self.first:
            return self.first.changed(name)
        else:
            return False
1147724
def _no_op(name, **kwargs):
    '''
    
    '''
    return dict(name=name, result=True, changes={}, comment='')
729267
def clean_name(self):
        ""
        name = self.cleaned_data['name']
        reserved_names = self._meta.model._meta.get_all_field_names()
        if name not in reserved_names:
            return name
        raise ValidationError(_('Attribute name must not clash with reserved names'
                                ' ("%s")') % '", "'.join(reserved_names))
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
71043
def changes_str(self):
        ''''''
        changes = ''
        for item in self._get_recursive_difference(type='intersect'):
            if item.diffs:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   # Next line should be tabulated even deeper,
                                   #  every change should be tabulated 1 deeper
                                   '\tidentified by {0} {1}:\n\t{2}\n'.format(
                                       self._key,
                                       item.past_dict[self._key],
                                       item.changes_str.replace('\n', '\n\t'))])
        for item in self._get_recursive_difference(type='removed'):
            if item.past_dict:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   '\tidentified by {0} {1}:'
                                   '\n\twill be removed\n'.format(self._key,
                                                                  item.past_dict[self._key])])
        for item in self._get_recursive_difference(type='added'):
            if item.current_dict:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   '\tidentified by {0} {1}:'
                                   '\n\twill be added\n'.format(self._key,
                                                                item.current_dict[self._key])])
        return changes
983605
def get_alter_table_sql(self, diff):
        
        column_sql = []
        query_parts = []

        if diff.new_name is not False:
            query_parts.append('RENAME TO %s' % diff.new_name)

        # Added columns?

        # Removed columns?

        for column_diff in diff.changed_columns.values():
            column = column_diff.column
            column_dict = column.to_dict()

            # Don't propagate default value changes for unsupported column types.
            if column_diff.has_changed('default') \
                    and len(column_diff.changed_properties) == 1 \
                    and (column_dict['type'] == 'text' or column_dict['type'] == 'blob'):
                continue

            query_parts.append('CHANGE %s %s'
                               % (column_diff.get_old_column_name(),
                                  self.get_column_declaration_sql(column.get_name(), column_dict)))

        for old_column_name, column in diff.renamed_columns.items():
            column_dict = column.to_dict()
            query_parts.append('CHANGE %s %s'
                               % (self.quote(old_column_name),
                                  self.get_column_declaration_sql(self.quote(column.get_name()), column_dict)))

        sql = []

        if len(query_parts) > 0:
            sql.append('ALTER TABLE %s %s' % (diff.name, ', '.join(query_parts)))

        return sql
130248
def _get_changes(cls, diff_dict):
        '''
        
        '''
        changes_strings = []
        for p in sorted(diff_dict.keys()):
            if sorted(diff_dict[p].keys()) == ['new', 'old']:
                # Some string formatting
                old_value = diff_dict[p]['old']
                if diff_dict[p]['old'] == cls.NONE_VALUE:
                    old_value = 'nothing'
                elif isinstance(diff_dict[p]['old'], six.string_types):
                    old_value = '\'{0}\''.format(diff_dict[p]['old'])
                elif isinstance(diff_dict[p]['old'], list):
                    old_value = '\'{0}\''.format(
                        ', '.join(diff_dict[p]['old']))
                new_value = diff_dict[p]['new']
                if diff_dict[p]['new'] == cls.NONE_VALUE:
                    new_value = 'nothing'
                elif isinstance(diff_dict[p]['new'], six.string_types):
                    new_value = '\'{0}\''.format(diff_dict[p]['new'])
                elif isinstance(diff_dict[p]['new'], list):
                    new_value = '\'{0}\''.format(', '.join(diff_dict[p]['new']))
                changes_strings.append('{0} from {1} to {2}'.format(
                    p, old_value, new_value))
            else:
                sub_changes = cls._get_changes(diff_dict[p])
                if sub_changes:
                    changes_strings.append('{0}:'.format(p))
                    changes_strings.extend(['  {0}'.format(c)
                                           for c in sub_changes])
        return changes_strings
85887
def case_insensitive(self):
        
        if "--case-ins" in self.flag:
            data_dict = Utils().case_sensitive(self.data)
            for key, value in data_dict.iteritems():
                if key == self.name.lower():
                    self.name = value
841118
def unchanged(self):
        '''
        
        '''
        def _unchanged(current_dict, diffs, prefix):
            keys = []
            for key in current_dict.keys():
                if key not in diffs:
                    keys.append('{0}{1}'.format(prefix, key))
                elif isinstance(current_dict[key], dict):
                    if 'new' in diffs[key]:
                        # There is a diff
                        continue
                    else:
                        keys.extend(
                            _unchanged(current_dict[key],
                                       diffs[key],
                                       prefix='{0}{1}.'.format(prefix, key)))

            return keys
        return sorted(_unchanged(self.current_dict, self._diffs, prefix=''))
497230
def rename(self, new_name, database=None):
        
        m = ddl.fully_qualified_re.match(new_name)
        if not m and database is None:
            database = self._database

        statement = ddl.RenameTable(
            self._qualified_name, new_name, new_database=database
        )

        self._client._execute(statement)

        op = self.op().change_name(statement.new_qualified_name)
        return type(self)(op)
706806
def _clean_name(fname, data):
    
    for to_remove in dd.get_batches(data) + [dd.get_sample_name(data), data["sv"]["variantcaller"]]:
        for ext in ("-", "_"):
            if fname.startswith("%s%s" % (to_remove, ext)):
                fname = fname[len(to_remove) + len(ext):]
        if fname.startswith(to_remove):
            fname = fname[len(to_remove):]
    return fname
162777
def _module_refs(obj, named):
    '''
    '''
     # ignore this very module
    if obj.__name__ == __name__:
        return ()
     # module is essentially a dict
    return _dict_refs(obj.__dict__, named)