@@ -141,10 +141,10 @@ def plot_logo2(pssm_df, output_file):
141141 plt .close (fig )
142142
143143
144- def run_consensus_generation (align_folder : str , output_folder : str , run_id : str = "" ):
144+ def run_consensus_generation (align_folder : str , output_folder : str , run_id : str = "" , skip_plots : bool = False ):
145145 """
146146 Core logic: Process all .afa files from alignment folder.
147- Generate consensus sequences, heatmaps, and logos.
147+ Generate consensus sequences, and optionally heatmaps and logos.
148148 """
149149 align_path = Path (align_folder )
150150 output_path = Path (output_folder )
@@ -155,12 +155,13 @@ def run_consensus_generation(align_folder: str, output_folder: str, run_id: str
155155 raise FileNotFoundError (f"Alignment folder not found: { align_path } " )
156156
157157 consensus_fasta_dir = output_path / "consensus_fasta"
158- heatmap_dir = output_path / "heatmap"
159- logo_dir = output_path / "logo"
160-
161158 consensus_fasta_dir .mkdir (exist_ok = True )
162- heatmap_dir .mkdir (exist_ok = True )
163- logo_dir .mkdir (exist_ok = True )
159+
160+ if not skip_plots :
161+ heatmap_dir = output_path / "heatmap"
162+ logo_dir = output_path / "logo"
163+ heatmap_dir .mkdir (exist_ok = True )
164+ logo_dir .mkdir (exist_ok = True )
164165
165166 alignment_files = [f for f in sorted (os .listdir (align_path )) if f .endswith (".afa" )]
166167
@@ -190,11 +191,12 @@ def run_consensus_generation(align_folder: str, output_folder: str, run_id: str
190191 consensus_fasta_path = consensus_fasta_dir / f"{ base_filename } _consensus.fasta"
191192 Bio .SeqIO .write ([consensus_record ], consensus_fasta_path , "fasta" )
192193
193- heatmap_path = heatmap_dir / f"{ base_filename } _heatmap.svg"
194- plot_heatmap2 (pssm_df , heatmap_path )
194+ if not skip_plots :
195+ heatmap_path = heatmap_dir / f"{ base_filename } _heatmap.svg"
196+ plot_heatmap2 (pssm_df , heatmap_path )
195197
196- logo_path = logo_dir / f"{ base_filename } _logo.svg"
197- plot_logo2 (pssm_df , logo_path )
198+ logo_path = logo_dir / f"{ base_filename } _logo.svg"
199+ plot_logo2 (pssm_df , logo_path )
198200
199201 logger .info ("All consensus tasks completed." )
200202 return consensus_fasta_dir
@@ -248,7 +250,7 @@ def generate_consensus_stats(consensus_base_folder):
248250 logger .info (f"Consensus statistics saved to: { stats_path } " )
249251
250252
251- def main (input_alignment_folder : str , output_consensus_folder : str , run_id : str = "" ):
253+ def main (input_alignment_folder : str , output_consensus_folder : str , run_id : str = "" , skip_plots : bool = False ):
252254 """
253255 Main function to run the consensus generation script.
254256 """
@@ -259,13 +261,16 @@ def main(input_alignment_folder: str, output_consensus_folder: str, run_id: str
259261
260262 logger .info (f"Alignment Folder (Input): { align_folder_in } " )
261263 logger .info (f"Consensus Folder (Output): { consensus_folder_out } " )
264+ if skip_plots :
265+ logger .info ("Skipping heatmap and logo generation (--skip-plots)" )
262266
263- # --- Step 1: Generate consensus, heatmaps, and logos ---
267+ # --- Step 1: Generate consensus, and optionally heatmaps and logos ---
264268 logger .info ("Running consensus generation from alignment files..." )
265269 consensus_fasta_dir = run_consensus_generation (
266270 align_folder = str (align_folder_in ),
267271 output_folder = str (consensus_folder_out ),
268272 run_id = run_id ,
273+ skip_plots = skip_plots ,
269274 )
270275
271276 # --- Step 2: Generate statistics on the consensus files ---
@@ -300,13 +305,19 @@ def cli():
300305 default = "" ,
301306 help = "Optional ID to display in the progress bar." ,
302307 )
308+ parser .add_argument (
309+ "--skip-plots" ,
310+ action = "store_true" ,
311+ help = "Skip generating heatmap and logo SVG plots." ,
312+ )
303313
304314 args = parser .parse_args ()
305315
306316 main (
307317 input_alignment_folder = args .input_folder ,
308318 output_consensus_folder = args .output_folder ,
309319 run_id = args .run_id ,
320+ skip_plots = args .skip_plots ,
310321 )
311322
312323
0 commit comments