Ejemplo n.º 1
0
 def generator(self):
     '''
     The main method in the class
     1. Draw Mbias plot and generate Mbias table fore per read length in per strand
     2. Decide the trimming positions based on the Mbias plot and generate the trimming file
     '''
     if len(self.trim_file) != 0:
         info(
             "Used the trimming file from the user defined!! Ignore the step of automatically deciding trimming."
         )
         return self.user_defined_trimming()
     ref = GR.get_ref(self.ref_file)
     info("Calculate the M fraction for every position...")
     # check: are the input SAM files paired-end or single-end
     strand_p = {}
     if self.single_on:
         strand_p['++'] = {}
         strand_p['-+'] = {}
     else:
         strand_p['++'] = {}
         strand_p['-+'] = {}
         strand_p['+-'] = {}
         strand_p['--'] = {}
     strand_p = self.parser_sambam(strand_p, ref)
     #modify in 2013-06-04
     strand_t_raw = []
     name_context = [self.name + '_CG', self.name + '_nonCG']
     for i in range(len(strand_p)):
         strand_t_each = self.decide_trim_bp(strand_p[i])
         strand_t_raw.append(strand_t_each)
         MR.mbias_generator(strand_p[i], strand_t_each, name_context[i])
     strand_t = self.decide_final_trimming(strand_t_raw)
     self.produce_final_trim_file(strand_t)
     return strand_t
Ejemplo n.º 2
0
 def generator(self):
     '''
     The main method in the class
     1. Draw Mbias plot and generate Mbias table fore per read length in per strand
     2. Decide the trimming positions based on the Mbias plot and generate the trimming file
     '''
     if len(self.trim_file) != 0:
         info("Used the trimming file from the user defined!! Ignore the step of automatically deciding trimming.")
         return self.user_defined_trimming()
     ref = GR.get_ref(self.ref_file)
     info("Calculate the M fraction for every position...")
     # check: are the input SAM files paired-end or single-end
     strand_p = {}
     if self.single_on:
         strand_p['++'] = {}
         strand_p['-+'] = {}
     else:
         strand_p['++'] = {}
         strand_p['-+'] = {}
         strand_p['+-'] = {}
         strand_p['--'] = {}
     strand_p = self.parser_sambam(strand_p, ref)
     #modify in 2013-06-04
     strand_t_raw = []
     name_context = [self.name + '_CG', self.name + '_nonCG']
     for i in range(len(strand_p)):
         strand_t_each = self.decide_trim_bp(strand_p[i])
         strand_t_raw.append(strand_t_each)
         MR.mbias_generator(strand_p[i], strand_t_each, name_context[i])
     strand_t = self.decide_final_trimming(strand_t_raw)
     self.produce_final_trim_file(strand_t)
     return strand_t
Ejemplo n.º 3
0
    def generator(self):
        '''
        The main method in the class
        1. Draw Mbias plot and generate Mbias table fore per read length in per strand
        2. Decide the trimming positions based on the Mbias plot and generate the trimming file
        3. Show the duplicate reads distribution
        '''

        ref = GR.get_ref(self.ref_file)
        # check: are the input SAM files paired-end or single-end
        strand_p = {}
        if self.single_on:
            strand_p['++'] = {}
            strand_p['-+'] = {}
        else:
            strand_p['++'] = {}
            strand_p['-+'] = {}
            strand_p['+-'] = {}
            strand_p['--'] = {}

        if len(self.trim_file) != 0:
            info("Used the trimming file from the user defined!!")
            info("Ignore both Mbias assessment and trimming decision.")
            loc_dict = self.parser_sambam(strand_p, ref)
            strand_t = self.user_defined_trimming()
        else:
            #modify in 2013-06-04
            strand_t_raw = []
            name_context = [self.name + '_CG', self.name + '_nonCG']
            strand_p, loc_dict = self.parser_sambam(strand_p, ref)
            for i in range(len(strand_p)):
                strand_t_each = self.decide_trim_bp(strand_p[i])
                strand_t_raw.append(strand_t_each)
                MR.mbias_generator(strand_p[i], strand_t_each, name_context[i])
            strand_t = self.decide_final_trimming(strand_t_raw)
            self.produce_final_trim_file(strand_t)
        max_cov = DR.duplicate_report(loc_dict, self.gsize, self.p_poisson,
                                      self.name)
        return strand_t, loc_dict, max_cov
Ejemplo n.º 4
0
    def generator(self):
        '''
        The main method in the class
        1. Draw Mbias plot and generate Mbias table fore per read length in per strand
        2. Decide the trimming positions based on the Mbias plot and generate the trimming file
        3. Show the duplicate reads distribution
        '''

        ref = GR.get_ref(self.ref_file)
        # check: are the input SAM files paired-end or single-end
        strand_p = {}
        if self.single_on:
            strand_p['++'] = {}
            strand_p['-+'] = {}
        else:
            strand_p['++'] = {}
            strand_p['-+'] = {}
            strand_p['+-'] = {}
            strand_p['--'] = {}

        if len(self.trim_file) != 0:
            info("Used the trimming file from the user defined!!")
            info("Ignore both Mbias assessment and trimming decision.")
            loc_dict = self.parser_sambam(strand_p, ref)
            strand_t = self.user_defined_trimming()
        else:
            #modify in 2013-06-04
            strand_t_raw = []
            name_context = [self.name + '_CG', self.name + '_nonCG']
            strand_p, loc_dict = self.parser_sambam(strand_p, ref)
            for i in range(len(strand_p)):
                strand_t_each = self.decide_trim_bp(strand_p[i])
                strand_t_raw.append(strand_t_each)
                MR.mbias_generator(strand_p[i], strand_t_each, name_context[i])
            strand_t = self.decide_final_trimming(strand_t_raw)
            self.produce_final_trim_file(strand_t)
        max_cov = DR.duplicate_report(loc_dict, self.gsize, self.p_poisson, self.name)
        return strand_t, loc_dict, max_cov