#NEWLINE# @ experimental ( as_of = '0.4.2-dev' ) #NEWLINE# def replace( self , where , character ) : #NEWLINE# #INDENT# "Replace values in this sequence with a different character.\n\n        Parameters\n        ----------\n        where : 1D array_like (bool) or iterable (slices or ints) or str\n            Indicates positions in the sequence to replace with `character`.\n            Can be a boolean vector, an iterable of indices/slices, or a\n            string that is a key in `positional_metadata` pointing to a\n            boolean vector.\n        character : str or bytes\n            Character that will replace chosen items in this sequence.\n\n        Returns\n        -------\n        Sequence\n            Copy of this sequence, with chosen items replaced with chosen\n            character. All metadata is retained.\n\n        Examples\n        --------\n        Let's create and display a Sequence:\n\n        >>> from skbio import Sequence\n        >>> sequence = Sequence('GGTACCAACG')\n        >>> str(sequence)\n        'GGTACCAACG'\n\n        Let's call ``replace`` on the Sequence using a boolean vector for\n        ``where`` and assign it to a new variable:\n\n        >>> seq = sequence.replace([False, False, False, True, False, False,\n        ...                         True, True, False, False], '-')\n\n        Let's take a look at the new Sequence:\n\n        >>> str(seq)\n        'GGT-CC--CG'\n\n        Other types of input are accepted by the ``where`` parameter. Let's\n        pass in a list of indices and slices that is equivalent to the boolean\n        vector we used previously:\n\n        >>> str(seq) == str(sequence.replace([3, slice(6, 8)], '-'))\n        True\n\n        ``where`` also accepts a boolean vector contained in\n        ``Sequence.positional_metadata``:\n\n        >>> sequence.positional_metadata = {'where':\n        ...                                 [False, False, False, True, False,\n        ...                                  False, True, True, False, False]}\n\n        Let's pass in the key ``'where'`` and compare to ``seq``:\n\n        >>> str(seq) == str(sequence.replace('where', '-'))\n        True\n\n        " #NEWLINE# if ( type ( character ) is not bytes ) : #NEWLINE# #INDENT# character = character . encode ( 'ascii' ) #NEWLINE# #UNINDENT# character = ord ( character ) #NEWLINE# index = self . _munge_to_index_array ( where ) #NEWLINE# seq_bytes = self . _bytes . copy ( ) #NEWLINE# seq_bytes [ index ] = character #NEWLINE# return self . __class__ ( seq_bytes , metadata = self . metadata , positional_metadata = self . positional_metadata )