Skip to main content

oxirs_core/molecular/
regulatory.rs

1//! Regulatory systems for controlling molecular processes
2
3use super::types::*;
4use crate::error::OxirsResult;
5use std::collections::HashMap;
6use std::time::{Duration, Instant};
7
8/// Regulatory protein for controlling cellular processes
9#[derive(Debug, Clone)]
10pub struct RegulatoryProtein {
11    /// Protein name
12    pub name: String,
13    /// Function
14    pub function: RegulatoryFunction,
15    /// Activity level
16    pub activity_level: f64,
17    /// Binding sites
18    pub binding_sites: Vec<BindingSite>,
19    /// Post-translational modifications
20    pub modifications: Vec<PostTranslationalModification>,
21    /// Half-life
22    pub half_life: Duration,
23    /// Last activity timestamp
24    pub last_activity: Option<Instant>,
25}
26
27/// Binding site for protein interactions
28#[derive(Debug, Clone)]
29pub struct BindingSite {
30    /// Site identifier
31    pub id: String,
32    /// Binding affinity
33    pub affinity: f64,
34    /// Specificity
35    pub specificity: BindingSpecificity,
36    /// Occupied status
37    pub occupied: bool,
38    /// Bound ligand
39    pub bound_ligand: Option<String>,
40}
41
42/// Binding specificity
43#[derive(Debug, Clone)]
44#[allow(clippy::upper_case_acronyms)]
45pub enum BindingSpecificity {
46    DNA,
47    RNA,
48    Protein,
49    SmallMolecule,
50    Metabolite,
51}
52
53/// Post-translational modification
54#[derive(Debug, Clone)]
55pub struct PostTranslationalModification {
56    /// Modification type
57    pub modification_type: ModificationType,
58    /// Position
59    pub position: usize,
60    /// Intensity
61    pub intensity: f64,
62    /// Modification time
63    pub timestamp: Instant,
64    /// Enzyme responsible
65    pub enzyme: Option<String>,
66}
67
68/// Comprehensive checkpoint system
69#[derive(Debug, Clone)]
70pub struct CheckpointSystem {
71    /// Spindle checkpoint
72    pub spindle_checkpoint: SpindleCheckpoint,
73    /// DNA damage checkpoint
74    pub dna_damage_checkpoint: DnaDamageCheckpoint,
75    /// Replication checkpoint
76    pub replication_checkpoint: ReplicationCheckpoint,
77    /// Metabolic checkpoint
78    pub metabolic_checkpoint: MetabolicCheckpoint,
79    /// Quality control checkpoint
80    pub quality_control_checkpoint: QualityControlCheckpoint,
81}
82
83/// Spindle checkpoint for mitosis control
84#[derive(Debug, Clone)]
85pub struct SpindleCheckpoint {
86    /// Mad proteins
87    pub mad_proteins: Vec<MadProtein>,
88    /// Bub proteins
89    pub bub_proteins: Vec<BubProtein>,
90    /// APC/C regulation
91    pub apc_c_regulation: ApcCRegulation,
92    /// Kinetochore signals
93    pub kinetochore_signals: Vec<KinetochoreSignal>,
94}
95
96/// Mad protein (Mitotic arrest deficient)
97#[derive(Debug, Clone)]
98pub struct MadProtein {
99    /// Protein type
100    pub protein_type: MadProteinType,
101    /// Activity level
102    pub activity_level: f64,
103    /// Localization
104    pub localization: ProteinLocalization,
105    /// Binding partners
106    pub binding_partners: Vec<String>,
107}
108
109/// Bub protein (Budding uninhibited by benzimidazoles)
110#[derive(Debug, Clone)]
111pub struct BubProtein {
112    /// Protein type
113    pub protein_type: BubProteinType,
114    /// Activity level
115    pub activity_level: f64,
116    /// Kinetochore binding
117    pub kinetochore_binding: bool,
118    /// Phosphorylation state
119    pub phosphorylation_state: PhosphorylationState,
120}
121
122/// APC/C regulation system
123#[derive(Debug, Clone)]
124pub struct ApcCRegulation {
125    /// Cdc20 level
126    pub cdc20_level: f64,
127    /// Cdh1 level
128    pub cdh1_level: f64,
129    /// Activity state
130    pub activity_state: ApcCActivityState,
131    /// Substrate recognition
132    pub substrate_recognition: SubstrateRecognition,
133}
134
135/// Kinetochore signal
136#[derive(Debug, Clone)]
137pub struct KinetochoreSignal {
138    /// Signal type
139    pub signal_type: KinetochoreSignalType,
140    /// Strength
141    pub strength: f64,
142    /// Duration
143    pub duration: Duration,
144    /// Source kinetochore
145    pub source: String,
146}
147
148/// DNA damage checkpoint
149#[derive(Debug, Clone)]
150pub struct DnaDamageCheckpoint {
151    /// ATM activity
152    pub atm_activity: f64,
153    /// ATR activity
154    pub atr_activity: f64,
155    /// p53 level
156    pub p53_level: f64,
157    /// DNA repair mechanisms
158    pub repair_mechanisms: Vec<DnaRepairMechanism>,
159    /// Damage sensors
160    pub damage_sensors: Vec<DamageSensor>,
161}
162
163/// DNA repair mechanism
164#[derive(Debug, Clone)]
165pub struct DnaRepairMechanism {
166    /// Repair type
167    pub repair_type: DnaRepairType,
168    /// Efficiency
169    pub efficiency: f64,
170    /// Active proteins
171    pub active_proteins: Vec<String>,
172}
173
174/// Damage sensor
175#[derive(Debug, Clone)]
176pub struct DamageSensor {
177    /// Sensor type
178    pub sensor_type: DamageSensorType,
179    /// Sensitivity
180    pub sensitivity: f64,
181    /// Response time
182    pub response_time: Duration,
183}
184
185/// Replication checkpoint
186#[derive(Debug, Clone)]
187pub struct ReplicationCheckpoint {
188    /// Replication forks
189    pub replication_forks: Vec<ReplicationFork>,
190    /// Checkpoint active
191    pub checkpoint_active: bool,
192    /// Fork protection complex
193    pub fork_protection_complex: ForkProtectionComplex,
194}
195
196/// Replication fork
197#[derive(Debug, Clone)]
198pub struct ReplicationFork {
199    /// Position
200    pub position: usize,
201    /// Stalled
202    pub stalled: bool,
203    /// Associated proteins
204    pub proteins: Vec<String>,
205    /// Replication speed
206    pub speed: f64,
207    /// Fork integrity
208    pub integrity: f64,
209}
210
211/// Fork protection complex
212#[derive(Debug, Clone)]
213pub struct ForkProtectionComplex {
214    /// Complex components
215    pub components: Vec<String>,
216    /// Activity level
217    pub activity: f64,
218    /// Protection efficiency
219    pub protection_efficiency: f64,
220}
221
222/// Metabolic checkpoint
223#[derive(Debug, Clone)]
224pub struct MetabolicCheckpoint {
225    /// Energy levels
226    pub energy_levels: EnergyLevels,
227    /// Nutrient availability
228    pub nutrient_availability: NutrientAvailability,
229    /// Metabolic sensors
230    pub metabolic_sensors: Vec<MetabolicSensor>,
231}
232
233/// Energy levels in the cell
234#[derive(Debug, Clone)]
235pub struct EnergyLevels {
236    /// ATP concentration
237    pub atp: f64,
238    /// ADP concentration
239    pub adp: f64,
240    /// AMP concentration
241    pub amp: f64,
242    /// Energy charge
243    pub energy_charge: f64,
244}
245
246/// Nutrient availability
247#[derive(Debug, Clone)]
248pub struct NutrientAvailability {
249    /// Glucose level
250    pub glucose: f64,
251    /// Amino acid levels
252    pub amino_acids: HashMap<String, f64>,
253    /// Lipid levels
254    pub lipids: f64,
255    /// Vitamin levels
256    pub vitamins: HashMap<String, f64>,
257}
258
259/// Metabolic sensor
260#[derive(Debug, Clone)]
261pub struct MetabolicSensor {
262    /// Sensor type
263    pub sensor_type: MetabolicSensorType,
264    /// Sensitivity
265    pub sensitivity: f64,
266    /// Target metabolite
267    pub target_metabolite: String,
268}
269
270/// Quality control checkpoint
271#[derive(Debug, Clone)]
272pub struct QualityControlCheckpoint {
273    /// Protein quality control
274    pub protein_qc: ProteinQualityControl,
275    /// RNA quality control
276    pub rna_qc: RnaQualityControl,
277    /// Organelle quality control
278    pub organelle_qc: OrganelleQualityControl,
279}
280
281/// Protein quality control
282#[derive(Debug, Clone)]
283pub struct ProteinQualityControl {
284    /// Chaperone systems
285    pub chaperones: Vec<ChaperoneSystem>,
286    /// Proteasome activity
287    pub proteasome_activity: f64,
288    /// Autophagy activity
289    pub autophagy_activity: f64,
290}
291
292/// Chaperone system
293#[derive(Debug, Clone)]
294pub struct ChaperoneSystem {
295    /// Chaperone type
296    pub chaperone_type: ChaperoneType,
297    /// Activity level
298    pub activity: f64,
299    /// Client proteins
300    pub client_proteins: Vec<String>,
301}
302
303/// RNA quality control
304#[derive(Debug, Clone)]
305pub struct RnaQualityControl {
306    /// Nonsense-mediated decay
307    pub nmd_activity: f64,
308    /// RNA surveillance
309    pub surveillance_activity: f64,
310    /// Exosome activity
311    pub exosome_activity: f64,
312}
313
314/// Organelle quality control
315#[derive(Debug, Clone)]
316pub struct OrganelleQualityControl {
317    /// Mitochondrial quality
318    pub mitochondrial_qc: MitochondrialQC,
319    /// ER quality control
320    pub er_qc: ErQualityControl,
321}
322
323/// Mitochondrial quality control
324#[derive(Debug, Clone)]
325pub struct MitochondrialQC {
326    /// Mitophagy activity
327    pub mitophagy_activity: f64,
328    /// Membrane potential
329    pub membrane_potential: f64,
330    /// ROS levels
331    pub ros_levels: f64,
332}
333
334/// ER quality control
335#[derive(Debug, Clone)]
336pub struct ErQualityControl {
337    /// UPR activity
338    pub upr_activity: f64,
339    /// ERAD activity
340    pub erad_activity: f64,
341    /// ER stress level
342    pub stress_level: f64,
343}
344
345// Supporting enums
346
347#[derive(Debug, Clone)]
348pub enum MadProteinType {
349    Mad1,
350    Mad2,
351    Mad3,
352    BubR1,
353}
354
355#[derive(Debug, Clone)]
356pub enum BubProteinType {
357    Bub1,
358    Bub3,
359    BubR1,
360}
361
362#[derive(Debug, Clone)]
363pub enum ProteinLocalization {
364    Kinetochore,
365    SpindlePole,
366    Cytoplasm,
367    Nucleus,
368    Centrosome,
369    Membrane,
370}
371
372#[derive(Debug, Clone)]
373pub enum ApcCActivityState {
374    Active,
375    Inactive,
376    PartiallyActive(f64),
377}
378
379#[derive(Debug, Clone)]
380pub struct SubstrateRecognition {
381    pub destruction_box: bool,
382    pub ken_box: bool,
383    pub abba_motif: bool,
384}
385
386#[derive(Debug, Clone)]
387pub enum KinetochoreSignalType {
388    Tension,
389    Attachment,
390    Detachment,
391    Error,
392}
393
394#[derive(Debug, Clone)]
395pub enum PhosphorylationState {
396    Phosphorylated,
397    Dephosphorylated,
398    PartiallyPhosphorylated(f64),
399}
400
401#[derive(Debug, Clone)]
402pub enum DnaRepairType {
403    HomologousRecombination,
404    NonHomologousEndJoining,
405    BaseExcisionRepair,
406    NucleotideExcisionRepair,
407    MismatchRepair,
408}
409
410#[derive(Debug, Clone)]
411#[allow(clippy::upper_case_acronyms)]
412pub enum DamageSensorType {
413    ATM,
414    ATR,
415    DNAPKcs,
416    PARP1,
417}
418
419#[derive(Debug, Clone)]
420#[allow(clippy::upper_case_acronyms)]
421pub enum MetabolicSensorType {
422    AMPK,
423    MTor,
424    SIRT1,
425    HIF1a,
426}
427
428#[derive(Debug, Clone)]
429pub enum ChaperoneType {
430    Hsp70,
431    Hsp90,
432    Hsp60,
433    SmallHSPs,
434}
435
436impl RegulatoryProtein {
437    /// Create a new regulatory protein
438    pub fn new(name: String, function: RegulatoryFunction) -> Self {
439        Self {
440            name,
441            function,
442            activity_level: 1.0,
443            binding_sites: Vec::new(),
444            modifications: Vec::new(),
445            half_life: Duration::from_secs(3600), // 1 hour default
446            last_activity: None,
447        }
448    }
449
450    /// Activate the protein
451    pub fn activate(&mut self) -> OxirsResult<()> {
452        self.activity_level = 1.0;
453        self.last_activity = Some(Instant::now());
454        Ok(())
455    }
456
457    /// Deactivate the protein
458    pub fn deactivate(&mut self) -> OxirsResult<()> {
459        self.activity_level = 0.0;
460        Ok(())
461    }
462
463    /// Add a post-translational modification
464    pub fn add_modification(&mut self, mod_type: ModificationType, position: usize) {
465        let modification = PostTranslationalModification {
466            modification_type: mod_type,
467            position,
468            intensity: 1.0,
469            timestamp: Instant::now(),
470            enzyme: None,
471        };
472        self.modifications.push(modification);
473    }
474
475    /// Remove a modification
476    pub fn remove_modification(&mut self, position: usize) {
477        self.modifications.retain(|m| m.position != position);
478    }
479
480    /// Check if protein is active
481    pub fn is_active(&self) -> bool {
482        self.activity_level > 0.1
483    }
484
485    /// Calculate current activity based on modifications and time
486    pub fn calculate_current_activity(&self) -> f64 {
487        let base_activity = self.activity_level;
488
489        // Apply modification effects
490        let modification_factor: f64 = self
491            .modifications
492            .iter()
493            .map(|m| match m.modification_type {
494                ModificationType::Phosphorylation => 1.2, // Increase activity
495                ModificationType::Methylation => 0.8,     // Decrease activity
496                ModificationType::Acetylation => 1.1,     // Slight increase
497                _ => 1.0,
498            })
499            .product();
500
501        // Apply time decay
502        let time_factor = if let Some(last_active) = self.last_activity {
503            let elapsed = last_active.elapsed();
504            if elapsed < self.half_life {
505                1.0
506            } else {
507                0.5_f64.powf(elapsed.as_secs_f64() / self.half_life.as_secs_f64())
508            }
509        } else {
510            1.0
511        };
512
513        base_activity * modification_factor * time_factor
514    }
515}
516
517impl CheckpointSystem {
518    /// Create new comprehensive checkpoint system
519    pub fn new() -> Self {
520        Self {
521            spindle_checkpoint: SpindleCheckpoint::new(),
522            dna_damage_checkpoint: DnaDamageCheckpoint::new(),
523            replication_checkpoint: ReplicationCheckpoint::new(),
524            metabolic_checkpoint: MetabolicCheckpoint::new(),
525            quality_control_checkpoint: QualityControlCheckpoint::new(),
526        }
527    }
528
529    /// Perform comprehensive checkpoint evaluation
530    pub fn evaluate_checkpoints(&self) -> OxirsResult<CheckpointResult> {
531        let spindle_ok = self.spindle_checkpoint.check_alignment()?;
532        let dna_ok = self.dna_damage_checkpoint.check_integrity()?;
533        let replication_ok = self.replication_checkpoint.check_completion()?;
534        let metabolic_ok = self.metabolic_checkpoint.check_resources()?;
535        let quality_ok = self.quality_control_checkpoint.check_quality()?;
536
537        Ok(CheckpointResult {
538            spindle_checkpoint: spindle_ok,
539            dna_damage_checkpoint: dna_ok,
540            replication_checkpoint: replication_ok,
541            metabolic_checkpoint: metabolic_ok,
542            quality_control_checkpoint: quality_ok,
543            overall_pass: spindle_ok && dna_ok && replication_ok && metabolic_ok && quality_ok,
544        })
545    }
546
547    /// Get checkpoint status summary
548    pub fn get_status_summary(&self) -> CheckpointStatusSummary {
549        CheckpointStatusSummary {
550            active_checkpoints: vec![
551                "Spindle".to_string(),
552                "DNA Damage".to_string(),
553                "Replication".to_string(),
554                "Metabolic".to_string(),
555                "Quality Control".to_string(),
556            ],
557            critical_issues: Vec::new(),
558            warnings: Vec::new(),
559        }
560    }
561}
562
563impl Default for SpindleCheckpoint {
564    fn default() -> Self {
565        Self::new()
566    }
567}
568
569impl SpindleCheckpoint {
570    /// Create new spindle checkpoint
571    pub fn new() -> Self {
572        Self {
573            mad_proteins: vec![
574                MadProtein {
575                    protein_type: MadProteinType::Mad1,
576                    activity_level: 0.1, // Low activity for aligned chromosomes
577                    localization: ProteinLocalization::Kinetochore,
578                    binding_partners: vec!["Mad2".to_string()],
579                },
580                MadProtein {
581                    protein_type: MadProteinType::Mad2,
582                    activity_level: 0.1, // Low activity for aligned chromosomes
583                    localization: ProteinLocalization::Kinetochore,
584                    binding_partners: vec!["Mad1".to_string(), "Cdc20".to_string()],
585                },
586            ],
587            bub_proteins: vec![
588                BubProtein {
589                    protein_type: BubProteinType::Bub1,
590                    activity_level: 1.0,
591                    kinetochore_binding: true,
592                    phosphorylation_state: PhosphorylationState::Phosphorylated,
593                },
594                BubProtein {
595                    protein_type: BubProteinType::Bub3,
596                    activity_level: 1.0,
597                    kinetochore_binding: true,
598                    phosphorylation_state: PhosphorylationState::Phosphorylated,
599                },
600            ],
601            apc_c_regulation: ApcCRegulation {
602                cdc20_level: 0.5,
603                cdh1_level: 0.1,
604                activity_state: ApcCActivityState::Active, // Active for healthy checkpoint
605                substrate_recognition: SubstrateRecognition {
606                    destruction_box: true,
607                    ken_box: true,
608                    abba_motif: false,
609                },
610            },
611            kinetochore_signals: Vec::new(),
612        }
613    }
614
615    /// Check chromosome alignment
616    pub fn check_alignment(&self) -> OxirsResult<bool> {
617        // Check Mad protein activity (should be low when aligned)
618        let mad_activity: f64 = self.mad_proteins.iter().map(|p| p.activity_level).sum();
619
620        // Check APC/C activity (should be active when aligned)
621        let apc_active = matches!(
622            self.apc_c_regulation.activity_state,
623            ApcCActivityState::Active
624        );
625
626        Ok(mad_activity < 0.5 && apc_active)
627    }
628}
629
630impl Default for DnaDamageCheckpoint {
631    fn default() -> Self {
632        Self::new()
633    }
634}
635
636impl DnaDamageCheckpoint {
637    /// Create new DNA damage checkpoint
638    pub fn new() -> Self {
639        Self {
640            atm_activity: 0.0,
641            atr_activity: 0.0,
642            p53_level: 0.1,
643            repair_mechanisms: vec![
644                DnaRepairMechanism {
645                    repair_type: DnaRepairType::HomologousRecombination,
646                    efficiency: 0.95,
647                    active_proteins: vec![
648                        "BRCA1".to_string(),
649                        "BRCA2".to_string(),
650                        "RAD51".to_string(),
651                    ],
652                },
653                DnaRepairMechanism {
654                    repair_type: DnaRepairType::NonHomologousEndJoining,
655                    efficiency: 0.85,
656                    active_proteins: vec![
657                        "DNA-PKcs".to_string(),
658                        "Ku70".to_string(),
659                        "Ku80".to_string(),
660                    ],
661                },
662            ],
663            damage_sensors: vec![
664                DamageSensor {
665                    sensor_type: DamageSensorType::ATM,
666                    sensitivity: 0.99,
667                    response_time: Duration::from_millis(100),
668                },
669                DamageSensor {
670                    sensor_type: DamageSensorType::ATR,
671                    sensitivity: 0.95,
672                    response_time: Duration::from_millis(50),
673                },
674            ],
675        }
676    }
677
678    /// Check DNA integrity
679    pub fn check_integrity(&self) -> OxirsResult<bool> {
680        let damage_level = self.atm_activity + self.atr_activity;
681        Ok(damage_level < 0.1) // Low damage threshold
682    }
683}
684
685impl Default for ReplicationCheckpoint {
686    fn default() -> Self {
687        Self::new()
688    }
689}
690
691impl ReplicationCheckpoint {
692    /// Create new replication checkpoint
693    pub fn new() -> Self {
694        Self {
695            replication_forks: Vec::new(),
696            checkpoint_active: false,
697            fork_protection_complex: ForkProtectionComplex {
698                components: vec!["RPA".to_string(), "Rad9".to_string(), "Rad1".to_string()],
699                activity: 1.0,
700                protection_efficiency: 0.95,
701            },
702        }
703    }
704
705    /// Check replication completion
706    pub fn check_completion(&self) -> OxirsResult<bool> {
707        let stalled_forks = self.replication_forks.iter().filter(|f| f.stalled).count();
708        Ok(stalled_forks == 0)
709    }
710}
711
712impl Default for MetabolicCheckpoint {
713    fn default() -> Self {
714        Self::new()
715    }
716}
717
718impl MetabolicCheckpoint {
719    /// Create new metabolic checkpoint
720    pub fn new() -> Self {
721        Self {
722            energy_levels: EnergyLevels {
723                atp: 5.0,
724                adp: 1.0,
725                amp: 0.1,
726                energy_charge: 0.9,
727            },
728            nutrient_availability: NutrientAvailability {
729                glucose: 5.0,
730                amino_acids: HashMap::new(),
731                lipids: 2.0,
732                vitamins: HashMap::new(),
733            },
734            metabolic_sensors: vec![
735                MetabolicSensor {
736                    sensor_type: MetabolicSensorType::AMPK,
737                    sensitivity: 0.95,
738                    target_metabolite: "AMP".to_string(),
739                },
740                MetabolicSensor {
741                    sensor_type: MetabolicSensorType::MTor,
742                    sensitivity: 0.90,
743                    target_metabolite: "Amino acids".to_string(),
744                },
745            ],
746        }
747    }
748
749    /// Check resource availability
750    pub fn check_resources(&self) -> OxirsResult<bool> {
751        Ok(self.energy_levels.energy_charge > 0.7 && self.nutrient_availability.glucose > 1.0)
752    }
753}
754
755impl Default for QualityControlCheckpoint {
756    fn default() -> Self {
757        Self::new()
758    }
759}
760
761impl QualityControlCheckpoint {
762    /// Create new quality control checkpoint
763    pub fn new() -> Self {
764        Self {
765            protein_qc: ProteinQualityControl {
766                chaperones: vec![
767                    ChaperoneSystem {
768                        chaperone_type: ChaperoneType::Hsp70,
769                        activity: 1.0,
770                        client_proteins: Vec::new(),
771                    },
772                    ChaperoneSystem {
773                        chaperone_type: ChaperoneType::Hsp90,
774                        activity: 1.0,
775                        client_proteins: Vec::new(),
776                    },
777                ],
778                proteasome_activity: 1.0,
779                autophagy_activity: 0.8,
780            },
781            rna_qc: RnaQualityControl {
782                nmd_activity: 1.0,
783                surveillance_activity: 1.0,
784                exosome_activity: 1.0,
785            },
786            organelle_qc: OrganelleQualityControl {
787                mitochondrial_qc: MitochondrialQC {
788                    mitophagy_activity: 0.8,
789                    membrane_potential: 180.0,
790                    ros_levels: 0.2,
791                },
792                er_qc: ErQualityControl {
793                    upr_activity: 0.1,
794                    erad_activity: 1.0,
795                    stress_level: 0.1,
796                },
797            },
798        }
799    }
800
801    /// Check overall quality
802    pub fn check_quality(&self) -> OxirsResult<bool> {
803        let protein_ok = self.protein_qc.proteasome_activity > 0.5;
804        let rna_ok = self.rna_qc.nmd_activity > 0.5;
805        let organelle_ok = self.organelle_qc.mitochondrial_qc.membrane_potential > 150.0;
806
807        Ok(protein_ok && rna_ok && organelle_ok)
808    }
809}
810
811/// Checkpoint evaluation result
812#[derive(Debug, Clone)]
813pub struct CheckpointResult {
814    pub spindle_checkpoint: bool,
815    pub dna_damage_checkpoint: bool,
816    pub replication_checkpoint: bool,
817    pub metabolic_checkpoint: bool,
818    pub quality_control_checkpoint: bool,
819    pub overall_pass: bool,
820}
821
822/// Checkpoint status summary
823#[derive(Debug, Clone)]
824pub struct CheckpointStatusSummary {
825    pub active_checkpoints: Vec<String>,
826    pub critical_issues: Vec<String>,
827    pub warnings: Vec<String>,
828}
829
830impl Default for RegulatoryProtein {
831    fn default() -> Self {
832        Self::new("Unknown".to_string(), RegulatoryFunction::Loading)
833    }
834}
835
836impl Default for CheckpointSystem {
837    fn default() -> Self {
838        Self::new()
839    }
840}
841
842#[cfg(test)]
843mod tests {
844    use super::*;
845
846    #[test]
847    fn test_regulatory_protein_creation() {
848        let protein =
849            RegulatoryProtein::new("TestProtein".to_string(), RegulatoryFunction::Loading);
850        assert_eq!(protein.name, "TestProtein");
851        assert!(protein.is_active());
852    }
853
854    #[test]
855    fn test_checkpoint_system() {
856        let checkpoint = CheckpointSystem::new();
857        let result = checkpoint
858            .evaluate_checkpoints()
859            .expect("operation should succeed");
860        assert!(result.overall_pass);
861    }
862
863    #[test]
864    fn test_protein_modification() {
865        let mut protein =
866            RegulatoryProtein::new("TestProtein".to_string(), RegulatoryFunction::Loading);
867        protein.add_modification(ModificationType::Phosphorylation, 100);
868        assert_eq!(protein.modifications.len(), 1);
869
870        protein.remove_modification(100);
871        assert_eq!(protein.modifications.len(), 0);
872    }
873
874    #[test]
875    fn test_protein_activity_calculation() {
876        let mut protein =
877            RegulatoryProtein::new("TestProtein".to_string(), RegulatoryFunction::Loading);
878        protein.activate().expect("operation should succeed");
879
880        let activity = protein.calculate_current_activity();
881        assert!(activity > 0.0);
882    }
883}