Skip to content

Commit fbe621a

Browse files
committed
tests and autodetection for AI pipeline mode
1 parent 7d1182c commit fbe621a

8 files changed

Lines changed: 831 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data/databases/open/test_ML_database_tokenized.csv
1818
genome_parse_results.csv
1919
data/genomes/
2020
data/articles2/
21-
data/test/
21+
data/test/*
2222
benchmark*
2323
OligoMiner
2424

pipeline.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from PROBESt.modeling import run_modeling
4343
from PROBESt.dedegeneration import run_dedegeneration
4444
from PROBESt.prepare_blast import prepare_bases_if_needed
45+
from PROBESt.AI import apply_ai_filtration_to_blast_file
4546

4647
# Functions
4748

@@ -163,6 +164,23 @@ def merge_iter(iter: int):
163164

164165
print("Negative hits counted")
165166

167+
# 2.5. like domain supersecondary organization ----
168+
if getattr(args, 'AI', True): # Default to True if not set
169+
model_path = 'data/AIL.pt'
170+
positive_hits_path = out_dir(iter) + "positive_hits.tsv"
171+
input_size = 14
172+
173+
# Apply AI filtration (function handles all error checking and logging)
174+
# model_architecture=None will auto-detect from saved model
175+
apply_ai_filtration_to_blast_file(
176+
positive_hits_path=positive_hits_path,
177+
model_path=model_path,
178+
fasta_file=prev_merged_fa,
179+
input_size=input_size,
180+
model_architecture=None, # Auto-detect from saved model
181+
threshold_method="median"
182+
)
183+
166184
# 3. multimapping detection and filtering ----
167185
probe_check_iter = probe_check + \
168186
" -o " + out_dir(iter) + "clear_hits.tsv" + \

scripts/generator/ML_filtration.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,29 @@ def main():
358358

359359
# Save the model
360360
os.makedirs('data', exist_ok=True)
361+
# Determine model architecture name from best_model_name
362+
model_architecture = best_model_name
363+
# Map common names to architecture names
364+
if "GAIL_Wide_Extra" in best_model_name or "GAILWideExtra" in best_model_name:
365+
model_architecture = "GAILWideExtra"
366+
elif "GAIL_Wide" in best_model_name:
367+
model_architecture = "GAILWide"
368+
elif "GAIL_Deep" in best_model_name:
369+
model_architecture = "GAILDeep"
370+
elif "GAIL_Narrow" in best_model_name:
371+
model_architecture = "GAILNarrow"
372+
elif "GAIL" in best_model_name:
373+
model_architecture = "GAILDiscriminator"
374+
361375
torch.save({
362376
'model_state_dict': best_model.model.state_dict(),
363377
'scaler': best_model.scaler,
364378
'learning_rate': best_model.learning_rate,
365-
'weight_pos': best_model.criterion.pos_weight.item() if hasattr(best_model.criterion, 'pos_weight') else None
379+
'weight_pos': best_model.criterion.pos_weight.item() if hasattr(best_model.criterion, 'pos_weight') else None,
380+
'model_architecture': model_architecture,
381+
'model_name': best_model_name
366382
}, 'data/GAIL.pt')
367-
print(f"Model saved to data/GAIL.pt")
383+
print(f"Model saved to data/GAIL.pt (architecture: {model_architecture})")
368384

369385
# Re-validate after extended training
370386
final_val_metrics = validate_filtration_AI(

0 commit comments

Comments
 (0)