1+ #!/usr/bin/env python3
2+ """
3+ DNA Similarity Demo - End-to-End Implementation with IntegratedML Framework
4+
5+ This script demonstrates DNA sequence classification and similarity search using
6+ the IntegratedML Flexible Model Integration Framework.
7+ """
8+
9+ import os
10+ import sys
11+ import logging
12+ import time
13+ from pathlib import Path
14+
15+ # Add project root to path
16+ project_root = Path (__file__ ).parent
17+ sys .path .insert (0 , str (project_root ))
18+
19+ # Configure logging
20+ logging .basicConfig (
21+ level = logging .INFO ,
22+ format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
23+ )
24+ logger = logging .getLogger (__name__ )
25+
26+
27+ def print_banner (text ):
28+ """Print a formatted banner."""
29+ print ("\n " + "=" * 80 )
30+ print (f" { text } " )
31+ print ("=" * 80 )
32+
33+
34+ def print_step (step_num , description ):
35+ """Print a formatted step."""
36+ print (f"\n 🧬 Step { step_num } : { description } " )
37+ print ("-" * 60 )
38+
39+
40+ def wait_for_user ():
41+ """Wait for user input to continue."""
42+ input ("\n Press Enter to continue..." )
43+
44+
45+ def main ():
46+ """Run the complete DNA Similarity demo."""
47+ print_banner ("INTEGRATEDML DNA SIMILARITY & CLASSIFICATION DEMO" )
48+ print ("This demo showcases DNA sequence classification and similarity search" )
49+ print ("using the IntegratedML Flexible Model Integration Framework." )
50+
51+ try :
52+ # Step 1: Framework Introduction
53+ print_step (1 , "IntegratedML Framework Introduction" )
54+
55+ print ("🎯 This demo demonstrates how the IntegratedML framework solves" )
56+ print (" the original DNA similarity project challenges:" )
57+ print ()
58+ print (" Challenge #1: Hardcoded Vectorization" )
59+ print (" ✓ Solution: Configurable vectorization strategies" )
60+ print ()
61+ print (" Challenge #2: Hardcoded Algorithm Selection" )
62+ print (" ✓ Solution: Pluggable algorithms via YAML configuration" )
63+ print ()
64+ print (" Challenge #3: Mixed Database Logic" )
65+ print (" ✓ Solution: Clean database abstraction layer" )
66+
67+ wait_for_user ()
68+
69+ # Step 2: Demo Setup and Configuration
70+ print_step (2 , "Demo Setup and Configuration" )
71+
72+ print ("🔧 Initializing DNA similarity demo..." )
73+
74+ # Check if demo files exist
75+ demo_dir = project_root / "demos" / "dna_similarity"
76+ config_path = demo_dir / "config" / "dna_model_config.yaml"
77+ demo_script = demo_dir / "dna_demo.py"
78+
79+ if not demo_dir .exists ():
80+ logger .error ("❌ DNA similarity demo directory not found!" )
81+ print ("Please ensure the demos/dna_similarity directory exists." )
82+ return False
83+
84+ if not config_path .exists ():
85+ logger .error ("❌ DNA demo configuration file not found!" )
86+ print (f"Please ensure { config_path } exists." )
87+ return False
88+
89+ if not demo_script .exists ():
90+ logger .error ("❌ DNA demo script not found!" )
91+ print (f"Please ensure { demo_script } exists." )
92+ return False
93+
94+ print ("✅ Demo directory structure verified" )
95+ print (f"📁 Demo location: { demo_dir } " )
96+ print (f"⚙️ Configuration: { config_path .name } " )
97+ print (f"🐍 Demo script: { demo_script .name } " )
98+
99+ wait_for_user ()
100+
101+ # Step 3: Import and Initialize Demo Components
102+ print_step (3 , "Loading Demo Components" )
103+
104+ print ("📦 Importing DNA similarity demo modules..." )
105+
106+ try :
107+ # Import the demo runner
108+ sys .path .insert (0 , str (demo_dir ))
109+ from dna_demo import DNADemoRunner
110+
111+ print ("✅ DNA demo modules imported successfully" )
112+
113+ # Initialize demo runner
114+ print ("🧬 Initializing DNA demo runner..." )
115+ demo_runner = DNADemoRunner (str (config_path ))
116+
117+ print ("✅ DNA demo runner initialized" )
118+ print (f"📊 Configuration loaded from: { config_path .name } " )
119+
120+ except ImportError as e :
121+ logger .error (f"❌ Failed to import DNA demo modules: { e } " )
122+ print ("Please ensure all required dependencies are installed:" )
123+ print (" pip install pandas scikit-learn sentence-transformers pyyaml numpy" )
124+ return False
125+ except Exception as e :
126+ logger .error (f"❌ Failed to initialize demo runner: { e } " )
127+ print (f"Error: { e } " )
128+ return False
129+
130+ wait_for_user ()
131+
132+ # Step 4: Run Vectorization Strategy Demonstration
133+ print_step (4 , "Vectorization Strategy Demonstration" )
134+
135+ print ("🔬 Demonstrating multiple vectorization approaches..." )
136+ print ("This addresses Challenge #1: Hardcoded Vectorization" )
137+ print ()
138+
139+ try :
140+ # Create sample data for demonstrations
141+ sample_data = demo_runner ._create_sample_data ()
142+ print (f"✅ Created sample dataset with { len (sample_data )} DNA sequences" )
143+ print (f"📊 Classes represented: { sample_data ['class' ].nunique ()} " )
144+
145+ # Run vectorization demonstration
146+ demo_runner .demonstrate_vectorization_strategies (sample_data )
147+
148+ except Exception as e :
149+ logger .error (f"❌ Vectorization demonstration failed: { e } " )
150+ print (f"Error during vectorization demo: { e } " )
151+
152+ wait_for_user ()
153+
154+ # Step 5: Run Algorithm Selection Demonstration
155+ print_step (5 , "Algorithm Selection Demonstration" )
156+
157+ print ("🤖 Demonstrating pluggable algorithm selection..." )
158+ print ("This addresses Challenge #2: Hardcoded Algorithm Selection" )
159+ print ()
160+
161+ try :
162+ # Run algorithm demonstration
163+ demo_runner .demonstrate_algorithm_selection (sample_data )
164+
165+ except Exception as e :
166+ logger .error (f"❌ Algorithm demonstration failed: { e } " )
167+ print (f"Error during algorithm demo: { e } " )
168+
169+ wait_for_user ()
170+
171+ # Step 6: Database Integration Demonstration
172+ print_step (6 , "Database Integration Demonstration" )
173+
174+ print ("🗃️ Demonstrating clean IRIS database integration..." )
175+ print ("This addresses Challenge #3: Mixed Database Logic" )
176+ print ()
177+
178+ try :
179+ # Run database integration demonstration
180+ demo_runner .demonstrate_iris_integration ()
181+
182+ except Exception as e :
183+ logger .error (f"❌ Database integration demonstration failed: { e } " )
184+ print (f"Error during database demo: { e } " )
185+
186+ wait_for_user ()
187+
188+ # Step 7: Similarity Search Demonstration
189+ print_step (7 , "DNA Similarity Search Demonstration" )
190+
191+ print ("🔍 Demonstrating vector-based DNA similarity search..." )
192+ print ("This shows advanced framework capabilities for sequence analysis" )
193+ print ()
194+
195+ try :
196+ # Run similarity search demonstration
197+ demo_runner .demonstrate_similarity_search (sample_data )
198+
199+ except Exception as e :
200+ logger .error (f"❌ Similarity search demonstration failed: { e } " )
201+ print (f"Error during similarity search demo: { e } " )
202+
203+ wait_for_user ()
204+
205+ # Step 8: Complete Framework Demonstration
206+ print_step (8 , "Complete Framework Integration" )
207+
208+ print ("🚀 Running complete IntegratedML framework demonstration..." )
209+ print ("This shows all components working together seamlessly" )
210+ print ()
211+
212+ try :
213+ # Run the complete demo
214+ print ("=" * 60 )
215+ print ("RUNNING COMPLETE DNA SIMILARITY FRAMEWORK DEMO" )
216+ print ("=" * 60 )
217+
218+ # Execute the full demo
219+ demo_runner .run_complete_demo ()
220+
221+ print ("=" * 60 )
222+ print ("DNA SIMILARITY FRAMEWORK DEMO COMPLETED" )
223+ print ("=" * 60 )
224+
225+ except Exception as e :
226+ logger .error (f"❌ Complete demo failed: { e } " )
227+ print (f"Error during complete demo: { e } " )
228+
229+ wait_for_user ()
230+
231+ # Final summary
232+ print_banner ("DNA SIMILARITY DEMO COMPLETED! 🎉" )
233+ print ("Key accomplishments:" )
234+ print ("✅ Demonstrated configurable vectorization strategies" )
235+ print ("✅ Showed pluggable algorithm selection" )
236+ print ("✅ Illustrated clean database abstraction" )
237+ print ("✅ Performed DNA sequence classification" )
238+ print ("✅ Executed vector-based similarity search" )
239+ print ("✅ Showcased framework flexibility and extensibility" )
240+ print ()
241+ print ("🧬 Framework Benefits Demonstrated:" )
242+ print (" 📊 Configuration-driven development" )
243+ print (" 🔧 Clean separation of concerns" )
244+ print (" 🚀 Enterprise-ready deployment" )
245+ print (" 🎯 Improved developer productivity" )
246+ print ()
247+ print ("This demo shows how the IntegratedML framework transforms" )
248+ print ("hardcoded bioinformatics solutions into flexible, maintainable," )
249+ print ("and production-ready applications!" )
250+
251+ return True
252+
253+ except Exception as e :
254+ logger .error (f"❌ Demo failed with error: { e } " )
255+ print (f"Demo execution failed: { e } " )
256+ print ()
257+ print ("💡 Troubleshooting tips:" )
258+ print (" 1. Ensure all dependencies are installed:" )
259+ print (" pip install pandas scikit-learn sentence-transformers pyyaml numpy" )
260+ print (" 2. Verify demo files exist in demos/dna_similarity/" )
261+ print (" 3. Check that configuration file is present" )
262+ print (" 4. Run from the project root directory" )
263+ return False
264+
265+
266+ if __name__ == "__main__" :
267+ success = main ()
268+ sys .exit (0 if success else 1 )
0 commit comments