@@ -222,7 +222,9 @@ def prepare_bases_if_needed(
222222 true_base: Path to true base (BLAST database or FASTA directory).
223223 false_bases: List of paths to false bases (BLAST databases or FASTA directories).
224224 output_dir: Output directory for created BLAST databases.
225- contig_table_path: Path for the contig names output file.
225+ contig_table_path: Path for the contig names TSV (genome id, sseqid). When
226+ bases are built from FASTA directories, true and all false bases append
227+ into this file, matching repeated ``prep_db.sh -c`` usage.
226228 tmp_dir: Optional temporary directory for intermediate files.
227229 script_path: Path to the directory containing prep_db.sh script.
228230
@@ -231,38 +233,43 @@ def prepare_bases_if_needed(
231233 """
232234 blast_db_dir = os .path .join (output_dir , ".blast_db" )
233235 os .makedirs (blast_db_dir , exist_ok = True )
234-
236+
237+ # One contig table for all JIT-prepared bases (same as repeated prep_db.sh -c file).
238+ shared_contig_table = (
239+ contig_table_path
240+ if os .path .dirname (contig_table_path )
241+ else os .path .join (blast_db_dir , contig_table_path )
242+ )
243+
235244 # Process true base
236245 if is_fasta_directory (true_base ):
237246 dir_name = os .path .basename (true_base .rstrip ('/' ))
238247 processed_true_base = os .path .join (blast_db_dir , f"true_{ dir_name } " )
239- true_contig_table = contig_table_path if os .path .dirname (contig_table_path ) else os .path .join (blast_db_dir , contig_table_path )
240-
248+
241249 print (f"Preparing BLAST database from FASTA directory: { true_base } " )
242250 prepare_blast_database (
243251 fasta_dir = true_base ,
244252 output_db_path = processed_true_base ,
245- contig_table_path = true_contig_table ,
253+ contig_table_path = shared_contig_table ,
246254 tmp_dir = tmp_dir ,
247255 script_path = script_path
248256 )
249257 print (f"Created BLAST database: { processed_true_base } " )
250258 else :
251259 processed_true_base = true_base
252-
260+
253261 # Process false bases
254262 processed_false_bases = []
255263 for i , false_base in enumerate (false_bases ):
256264 if is_fasta_directory (false_base ):
257265 dir_name = os .path .basename (false_base .rstrip ('/' ))
258266 processed_false_base = os .path .join (blast_db_dir , f"false_{ i } _{ dir_name } " )
259- false_contig_table = os .path .join (blast_db_dir , f"contigs_false_{ i } .tsv" )
260-
267+
261268 print (f"Preparing BLAST database from FASTA directory: { false_base } " )
262269 prepare_blast_database (
263270 fasta_dir = false_base ,
264271 output_db_path = processed_false_base ,
265- contig_table_path = false_contig_table ,
272+ contig_table_path = shared_contig_table ,
266273 tmp_dir = tmp_dir ,
267274 script_path = script_path
268275 )
0 commit comments