예제 #1
0
    def compute_stratified_mean_enrichments(self,
                                            min_means=[0.1],
                                            num_around=100,
                                            exclude_from_edges=[(90, 90),
                                                                (200, 200),
                                                                (200, 0),
                                                                (300, 0),
                                                                (0, 0),
                                                               ],
                                            do_anisomycin=False,
                                            do_stringent=False,
                                           ):

        specific_keys = {'relaxed', 'identities'}
        if do_anisomycin:
            specific_keys.add('anisomycin')
        if do_stringent:
            specific_keys.add('stringent')

        codon_counts = self.read_file('buffered_codon_counts',
                                      specific_keys=specific_keys,
                                     )

        enrichments = pausing.fast_stratified_mean_enrichments(codon_counts,
                                                               exclude_from_edges,
                                                               min_means,
                                                               num_around,
                                                               count_type='relaxed',
                                                              )
        self.write_file('stratified_mean_enrichments', enrichments)

        if do_stringent:
            enrichments = pausing.fast_stratified_mean_enrichments(codon_counts,
                                                                   exclude_from_edges,
                                                                   min_means,
                                                                   num_around,
                                                                   count_type='stringent',
                                                                  )
            self.write_file('stratified_mean_enrichments_stringent', enrichments)

        if do_anisomycin:
            enrichments = pausing.fast_stratified_mean_enrichments(codon_counts,
                                                                   exclude_from_edges,
                                                                   min_means,
                                                                   num_around,
                                                                   count_type='anisomycin',
                                                                  )
            self.write_file('stratified_mean_enrichments_anisomycin', enrichments)
예제 #2
0
    def compute_stratified_mean_enrichments(self, min_means=[0.1, 0]):
        ''' Ugly duplication of code in ribosome_profiling_experiment '''
        num_before = 90
        num_after = 90

        def find_breakpoints(sorted_names, means, min_means):
            breakpoints = {}

            zipped = zip(sorted_names, means)
            for min_mean in min_means:
                name = [name for name, mean in zipped if mean > min_mean][-1]
                breakpoints[name] = '{0:0.2f}'.format(min_mean)

            return breakpoints

        codon_counts = self.read_file('simulated_codon_counts',
                                      specific_keys={'relaxed', 'identities'},
                                     )

        sorted_names, means = pausing.order_by_mean_density(codon_counts,
                                                            count_type='relaxed',
                                                            num_before=num_before,
                                                            num_after=num_after,
                                                           )
        breakpoints = find_breakpoints(sorted_names, means, min_means)

        enrichments = pausing.fast_stratified_mean_enrichments(codon_counts,
                                                               sorted_names,
                                                               breakpoints,
                                                               num_before,
                                                               num_after,
                                                               count_type='relaxed',
                                                              )

        self.write_file('stratified_mean_enrichments', enrichments)