def _create_coverage_files_for_lib(self, lib_name, bam_path, no_of_aligned_reads, min_no_of_aligned_reads): """Perform the coverage calculation for a given library.""" if not self._args.non_strand_specific: strands = ["forward", "reverse"] else: strands = ["forward_and_reverse"] if self._all_coverage_file_exist(lib_name, strands, no_of_aligned_reads, min_no_of_aligned_reads): return read_count_splitting = True if self._args.skip_read_count_splitting: read_count_splitting = False coverage_calculator = CoverageCalculator( read_count_splitting=read_count_splitting, uniquely_aligned_only=self._args.unique_only, coverage_style=self._args.coverage_style, clip_length=self._args.clip_length, non_strand_specific=self._args.non_strand_specific, ) ( coverage_writers_raw, coverage_writers_tnoar_min_norm, coverage_writers_tnoar_mil_norm, ) = self._wiggle_writers(lib_name, strands, no_of_aligned_reads, min_no_of_aligned_reads) for ref_seq, coverages in coverage_calculator.ref_seq_and_coverages( bam_path): for strand in strands: coverage_writers_raw[strand].write_replicons_coverages( ref_seq, coverages[strand]) coverage_writers_tnoar_min_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=min_no_of_aligned_reads / no_of_aligned_reads, ) coverage_writers_tnoar_mil_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=1000000 / no_of_aligned_reads, ) for strand in strands: coverage_writers_raw[strand].close_file()
def _create_coverage_files_for_lib( self, lib_name, bam_path, no_of_aligned_reads, min_no_of_aligned_reads): """Perform the coverage calculation for a given library.""" if not self._args.non_strand_specific: strands = ["forward", "reverse"] else: strands = ["forward_and_reverse"] if self._all_coverage_file_exist( lib_name, strands, no_of_aligned_reads, min_no_of_aligned_reads): return read_count_splitting = True if self._args.skip_read_count_splitting: read_count_splitting = False coverage_calculator = CoverageCalculator( read_count_splitting=read_count_splitting, uniquely_aligned_only=self._args.unique_only, coverage_style=self._args.coverage_style, clip_length=self._args.clip_length, non_strand_specific=self._args.non_strand_specific) (coverage_writers_raw, coverage_writers_tnoar_min_norm, coverage_writers_tnoar_mil_norm) = self._wiggle_writers( lib_name, strands, no_of_aligned_reads, min_no_of_aligned_reads) for ref_seq, coverages in coverage_calculator.ref_seq_and_coverages( bam_path): for strand in strands: coverage_writers_raw[strand].write_replicons_coverages( ref_seq, coverages[strand]) coverage_writers_tnoar_min_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=min_no_of_aligned_reads/no_of_aligned_reads) coverage_writers_tnoar_mil_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=1000000/no_of_aligned_reads) for strand in strands: coverage_writers_raw[strand].close_file()
def create_coverage_files_TK( self, no_of_aligned_reads, min_no_of_aligned_reads): if not self._args.non_strand_specific: strands = ["forward", "reverse"] else: strands = ["forward_and_reverse"] if self._args.skip_read_count_splitting: read_count_splitting = False else: read_count_splitting = True from reademptionlib.coveragecalculator import CoverageCalculator coverage_calculator = CoverageCalculator( read_count_splitting=read_count_splitting, uniquely_aligned_only=self._args.unique_only, coverage_style=self._args.coverage_style, clip_length=self._args.clip_length, non_strand_specific=self._args.non_strand_specific) (coverage_writers_raw, coverage_writers_tnoar_min_norm, coverage_writers_tnoar_mil_norm) = self._wiggle_writers( strands, no_of_aligned_reads, min_no_of_aligned_reads) for ref_seq, coverages in coverage_calculator.ref_seq_and_coverages( self._args.input_coverage): for strand in strands: coverage_writers_raw[strand].write_replicons_coverages( ref_seq, coverages[strand]) for strand in strands: coverage_writers_tnoar_min_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=min_no_of_aligned_reads/no_of_aligned_reads) for strand in strands: coverage_writers_tnoar_mil_norm[ strand].write_replicons_coverages( ref_seq, coverages[strand], factor=self._args.factor/no_of_aligned_reads) for strand in strands: coverage_writers_raw[strand].close_file()