Ejemplo n.º 1
0
    def _init_freq_one_hot_coded_seqs(self):
        """Perform a fft on the array of coded sequences.

        Currently disabled because the optimization isnt being used. 
        """
        return None
        if self.seq_len > self.max_fft_seq_len:
            return None
        fshape = ( 
            next_good_fshape(len(self)), 
            next_good_fshape(self.seq_len+self.max_bs_len-1), 
            self.one_hot_coded_seqs.shape[2] 
        )
        return rfftn(self.one_hot_coded_seqs, fshape)
Ejemplo n.º 2
0
    def _clever_score_binding_sites(self, model, reverse_comp):
        """Score binding sites by a cached fft convolve.

        Only works when the sequence length is less than 10kb
        and the binsing site length is less than 
        self.max_bs_len (200 bp).
        
        This has been disabled because it doesn't appear to work
        in a multi-threaded environment and the speedup is minimal
        over the naive implmentation. 
        """
        assert isinstance(model, ConvolutionalDNABindingModel)
        n_channels = model.shape[1]
        assert n_channels == self.one_hot_coded_seqs.shape[2]
        assert model.binding_site_len < self.max_bs_len
        convolutional_filter = model.convolutional_filter
        if reverse_comp: 
            convolutional_filter = np.flipud(np.fliplr(convolutional_filter))
        h_freq = rfftn(
            model.convolutional_filter, 
            (self.freq_one_hot_coded_seqs.shape[1], n_channels))
        conv_freq = self.freq_one_hot_coded_seqs*h_freq[None,:,:]
        return irfftn(conv_freq)[:len(self), :self.seq_len, n_channels-1]