@@ -119,32 +119,32 @@ def read_simulator_single(
119119 contig_name ,
120120 contig_index ,
121121 )
122-
123- # Writing an intermediate bam that is sorted, to make compiling them together at the end easier.
124- bam_handle = local_output_file_writer .files_to_write [local_output_file_writer .bam ]
125- for read_data in reads_to_write :
126- read1 = read_data [0 ]
127- read2 = read_data [1 ]
128- if read1 :
129- local_output_file_writer .write_bam_record (
130- read1 ,
131- contig_index ,
132- bam_handle ,
133- local_options .read_len
134- )
135- if read2 :
136- local_output_file_writer .write_bam_record (
137- read2 ,
138- contig_index ,
139- bam_handle ,
140- local_options .read_len
141- )
142- bam_handle .flush ()
143- bam_handle .close ()
144- sorted_bam = local_output_file_writer .bam .with_suffix (".sorted.bam" )
145- pysam .sort ("-@" , str (local_options .threads ), "-o" , str (sorted_bam ), str (local_output_file_writer .bam ))
146- os .rename (str (sorted_bam ), str (local_output_file_writer .bam ))
147- _LOG .info (f"bam for thread { thread_idx } written" )
122+ if local_options . produce_bam :
123+ # Writing an intermediate bam that is sorted, to make compiling them together at the end easier.
124+ bam_handle = local_output_file_writer .files_to_write [local_output_file_writer .bam ]
125+ for read_data in reads_to_write :
126+ read1 = read_data [0 ]
127+ read2 = read_data [1 ]
128+ if read1 :
129+ local_output_file_writer .write_bam_record (
130+ read1 ,
131+ contig_index ,
132+ bam_handle ,
133+ local_options .read_len
134+ )
135+ if read2 :
136+ local_output_file_writer .write_bam_record (
137+ read2 ,
138+ contig_index ,
139+ bam_handle ,
140+ local_options .read_len
141+ )
142+ bam_handle .flush ()
143+ bam_handle .close ()
144+ sorted_bam = local_output_file_writer .bam .with_suffix (".sorted.bam" )
145+ pysam .sort ("-@" , str (local_options .threads ), "-o" , str (sorted_bam ), str (local_output_file_writer .bam ))
146+ os .rename (str (sorted_bam ), str (local_output_file_writer .bam ))
147+ _LOG .info (f"bam for thread { thread_idx } written" )
148148
149149 local_output_file_writer .flush_and_close_files ()
150150 file_dict = {
0 commit comments