Exemplo n.º 1
0
    def remove_primer(self):
        if not self.settings.get_property('force_retrim'):
            for lib_settings in self.settings.iter_lib_settings():
                if not lib_settings.primerless_reads_exist():
                    break
            else:
                return

        if self.settings.get_property('trim_adaptor'):
            tps_utils.make_dir(self.rdir_path('primer_removed'))
            bzUtils.parmap(lambda lib_setting: self.remove_primer_one_lib(lib_setting), self.settings.iter_lib_settings(), nprocs = self.threads)
Exemplo n.º 2
0
    def remove_primer(self):
        if not self.settings.get_property('force_retrim'):
            for lib_settings in self.settings.iter_lib_settings():
                if not lib_settings.primerless_reads_exist():
                    break
            else:
                return

        if self.settings.get_property('trim_adaptor'):
            tps_utils.make_dir(self.rdir_path('primer_removed'))
            bzUtils.parmap(
                lambda lib_setting: self.remove_primer_one_lib(lib_setting),
                self.settings.iter_lib_settings(),
                nprocs=self.threads)
Exemplo n.º 3
0
 def trim_reads(self):
     """
     Trim reads by given amount, removing potential random barcoding sequences from 5' end
     Trimming from 3' end can also help if mapping is problematic by reducing chance for indels to prevent mapping
     :return:
     """
     self.settings.write_to_log( 'trimming reads')
     if not self.settings.get_property('force_retrim'):
         for lib_settings in self.settings.iter_lib_settings():
             if not lib_settings.trimmed_reads_exist():
                 break
         else:
             return
     tps_utils.make_dir(self.rdir_path('trimmed_reads'))
     bzUtils.parmap(lambda lib_setting: self.trim_one_fasta_file(lib_setting), self.settings.iter_lib_settings(), nprocs = self.threads)
     self.settings.write_to_log( 'trimming reads complete')
Exemplo n.º 4
0
 def collapse_identical_reads(self):
     """
     collapses all identical reads using FASTX toolkit
     :return:
     """
     self.settings.write_to_log('collapsing reads')
     if not self.settings.get_property('force_recollapse'):
         for lib_settings in self.settings.iter_lib_settings():
             if not lib_settings.collapsed_reads_exist():
                 break
         else:
             return
     tps_utils.make_dir(self.rdir_path('collapsed_reads'))
     if self.settings.get_property('collapse_identical_reads'):
         bzUtils.parmap(lambda lib_setting: self.collapse_one_fastq_file(lib_setting), self.settings.iter_lib_settings(), nprocs = self.threads)
     else:
         bzUtils.parmap(lambda lib_setting: self.fastq_to_fasta(lib_setting), self.settings.iter_lib_settings(), nprocs = self.threads)
     self.settings.write_to_log('collapsing reads complete')
Exemplo n.º 5
0
    def map_reads(self):
        """
        map all reads using bowtie
        :return:
        """
        self.settings.write_to_log('mapping reads')
        if not self.settings.get_property('force_remapping'):
            for lib_settings in self.settings.iter_lib_settings():
                if not lib_settings.mapped_reads_exist():
                    break
            else:
                return
        tps_utils.make_dir(self.rdir_path('mapped_reads'))
        tps_utils.make_dir(self.rdir_path('mapping_stats'))
        tps_utils.make_dir(self.rdir_path('unmapped_reads'))

        bzUtils.parmap(lambda lib_setting: self.map_one_library(lib_setting), self.settings.iter_lib_settings(),
                       nprocs = self.threads)
        self.settings.write_to_log( 'finished mapping reads')
Exemplo n.º 6
0
 def trim_reads(self):
     """
     Trim reads by given amount, removing potential random barcoding sequences from 5' end
     Trimming from 3' end can also help if mapping is problematic by reducing chance for indels to prevent mapping
     :return:
     """
     self.settings.write_to_log('trimming reads')
     if not self.settings.get_property('force_retrim'):
         for lib_settings in self.settings.iter_lib_settings():
             if not lib_settings.trimmed_reads_exist():
                 break
         else:
             return
     tps_utils.make_dir(self.rdir_path('trimmed_reads'))
     bzUtils.parmap(
         lambda lib_setting: self.trim_one_fasta_file(lib_setting),
         self.settings.iter_lib_settings(),
         nprocs=self.threads)
     self.settings.write_to_log('trimming reads complete')
Exemplo n.º 7
0
    def map_reads(self):
        """
        map all reads using bowtie
        :return:
        """
        self.settings.write_to_log('mapping reads')
        if not self.settings.get_property('force_remapping'):
            for lib_settings in self.settings.iter_lib_settings():
                if not lib_settings.mapped_reads_exist():
                    break
            else:
                return
        tps_utils.make_dir(self.rdir_path('mapped_reads'))
        tps_utils.make_dir(self.rdir_path('mapping_stats'))
        tps_utils.make_dir(self.rdir_path('unmapped_reads'))

        bzUtils.parmap(lambda lib_setting: self.map_one_library(lib_setting),
                       self.settings.iter_lib_settings(),
                       nprocs=self.threads)
        self.settings.write_to_log('finished mapping reads')
Exemplo n.º 8
0
 def collapse_identical_reads(self):
     """
     collapses all identical reads using FASTX toolkit
     :return:
     """
     self.settings.write_to_log('collapsing reads')
     if not self.settings.get_property('force_recollapse'):
         for lib_settings in self.settings.iter_lib_settings():
             if not lib_settings.collapsed_reads_exist():
                 break
         else:
             return
     tps_utils.make_dir(self.rdir_path('collapsed_reads'))
     if self.settings.get_property('collapse_identical_reads'):
         bzUtils.parmap(
             lambda lib_setting: self.collapse_one_fastq_file(lib_setting),
             self.settings.iter_lib_settings(),
             nprocs=self.threads)
     else:
         bzUtils.parmap(
             lambda lib_setting: self.fastq_to_fasta(lib_setting),
             self.settings.iter_lib_settings(),
             nprocs=self.threads)
     self.settings.write_to_log('collapsing reads complete')