-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
178 lines (150 loc) · 6.29 KB
/
example.py
File metadata and controls
178 lines (150 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
"""
Minimal example showing how Model converts biological hypotheses to sample_spec.
"""
import json
from typing import List, Dict, Any
def claude_hypothesis_to_sample_spec(hypothesis: str) -> List[Dict[str, Any]]:
"""
Claude processes natural language hypothesis and generates sample_spec JSONs.
In practice, this would call Claude API with biological reasoning prompts.
"""
# Mock Claude's biological reasoning for: "p53 accumulation varies with cell density"
if "p53" in hypothesis.lower() and "cell density" in hypothesis.lower():
# Claude identifies key experimental parameters
base_spec = {
"schema_version": "1.0.0",
"biological_context": {
"cell_line": "HeLa",
"passage_number": 12,
"culture_age": 24
},
"culture_conditions": {
"media_type": "DMEM",
"media_supplements": ["10% FBS", "1% Pen/Strep"],
"co2_percentage": 5,
"temperature_celsius": 37
},
"treatments": {
"compounds": [],
"physical_perturbations": []
},
"sample_preparation": {
"fixation_method": "paraformaldehyde",
"fixation_duration": 15,
"permeabilization": True,
"blocking_agent": "5% goat_serum"
},
"staining_protocol": {
"primary_antibodies": [{
"target": "p53",
"clone": "DO-1",
"concentration": 1,
"incubation_time": 60,
"temperature": 4
}],
"secondary_antibodies": [{
"fluorophore": "Alexa488",
"concentration": 2,
"incubation_time": 45
}],
"nuclear_stain": "DAPI"
},
"imaging_parameters": {
"microscope_type": "confocal",
"objective_magnification": 63,
"channels": [
{"name": "DAPI", "excitation": 405, "emission": 450},
{"name": "Alexa488", "excitation": 488, "emission": 519}
]
}
}
# Generate sample_specs for different cell densities
densities = [25000, 50000, 75000, 100000] # cells/cm²
sample_specs = []
for i, density in enumerate(densities):
import copy
spec = copy.deepcopy(base_spec)
spec["sample_id"] = f"p53_density_exp_{i+1}"
spec["biological_context"]["cell_density"] = density
sample_specs.append(spec)
return sample_specs
else:
raise NotImplementedError(f"Hypothesis not implemented: {hypothesis}")
def simulate_experimental_results(sample_specs: List[Dict[str, Any]]) -> Dict[str, float]:
"""
Simulate experimental results for generated sample_specs.
In practice, this data would come from laboratory automation systems.
"""
results = {}
for spec in sample_specs:
sample_id = spec["sample_id"]
density = spec["biological_context"]["cell_density"]
# Simulate p53 intensity increasing with density (mock biological response)
# Adding some noise to make it realistic
import random
base_intensity = density * 0.001 # Arbitrary scaling
noise = random.uniform(-0.1, 0.1) * base_intensity
p53_intensity = base_intensity + noise
results[sample_id] = p53_intensity
return results
def analyze_results(hypothesis: str, results: Dict[str, float]) -> Dict[str, Any]:
"""
Analyze experimental results to validate/refute hypothesis.
"""
sample_ids = sorted(results.keys())
intensities = [results[sid] for sid in sample_ids]
# Simple trend analysis
increasing_trend = all(intensities[i] <= intensities[i+1] for i in range(len(intensities)-1))
analysis = {
"hypothesis": hypothesis,
"results": results,
"trend_increasing": increasing_trend,
"conclusion": "Hypothesis supported" if increasing_trend else "Hypothesis not supported",
"next_steps": []
}
if increasing_trend:
analysis["next_steps"] = [
"Test mechanism: contact inhibition vs nutrient depletion",
"Validate with different cell lines",
"Test temporal dynamics of p53 accumulation"
]
else:
analysis["next_steps"] = [
"Re-examine experimental conditions",
"Test alternative hypotheses"
]
return analysis
def main():
print("=== Model: Hypothesis Testing Example ===\n")
# Step 1: Input biological hypothesis
hypothesis = "p53 accumulation varies with cell density"
print(f"Hypothesis: {hypothesis}\n")
# Step 2: Claude converts hypothesis to sample_specs
print("Generating sample_specs...")
sample_specs = claude_hypothesis_to_sample_spec(hypothesis)
print(f"Generated {len(sample_specs)} sample specifications:\n")
for spec in sample_specs:
density = spec["biological_context"]["cell_density"]
print(f" {spec['sample_id']}: {density} cells/cm²")
# Step 3: Simulate experimental execution
print("\nExecuting experiments...")
results = simulate_experimental_results(sample_specs)
print("Results:")
for sample_id, intensity in results.items():
print(f" {sample_id}: p53 intensity = {intensity:.3f}")
# Step 4: Analyze results
print("\nAnalyzing results...")
analysis = analyze_results(hypothesis, results)
print(f"Conclusion: {analysis['conclusion']}")
print("Next experimental steps:")
for step in analysis['next_steps']:
print(f" - {step}")
# Step 5: Show sample_spec for follow-up (if hypothesis supported)
if analysis['trend_increasing']:
print("\nGenerating follow-up experiment...")
followup_hypothesis = "p53 accumulation is mediated by contact inhibition"
print(f"Next hypothesis: {followup_hypothesis}")
# In practice, this would generate new sample_specs for mechanism testing
if __name__ == "__main__":
main()