示例#1
0
    def callpeaks(self, peakscaller, controlsample=None, name=None):
        '''
        This will call the peak caller of choice on selected lane.
        :param peakscaller:
        :param controlsample:
        :param name:
        :return:
        '''
        if not hasattr(peakscaller, 'run_peakcaller'):
            raise AttributeError(
                'First parameter to call peaks should be a peak caller and %s was missing %s'
                % (peakscaller, 'run_peakcaller')
            )

        temp_dir = os.path.join(self.lane.base_path, 'cache', peakscaller.peakcaller_name, name)
        alignment.commons.ensure_path(temp_dir)
        peakscaller.run_peakcaller(self, controlsample, temp_dir)
        #print(temp_dir)
        res = peakscaller.load_peaks(temp_dir)
        annotation = annotate.AnnotatePeaks(res, self.genome.data_path)
        anno_peaks = annotation.call_me()
        if name is None:
            name = self.name + '_peaks_' + peakscaller.peakcaller_name
            if controlsample:
                name += '_vs_' + controlsample.name
        peak_file_path = os.path.join(self.lane.base_path, 'results', 'Peaks', name)
        alignment.commons.ensure_path(peak_file_path)
        anno_peaks.to_csv(os.path.join(peak_file_path, name+'.tsv'), sep='\t', header=True, index=False)