-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
87 lines (69 loc) · 2.53 KB
/
example_usage.py
File metadata and controls
87 lines (69 loc) · 2.53 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
#!/usr/bin/env python3
"""Example usage of AssayExtract."""
from assay_extract import AssayClassifier
# Initialize
classifier = AssayClassifier()
# Example 1: Simple extraction
print("=" * 70)
print("EXAMPLE 1: Extract measures from methods text")
print("=" * 70)
methods = """
We assessed anxiety using the elevated plus maze for 5 minutes.
Social behavior was measured with the three-chamber social approach test.
Spatial learning and memory were tested on the morris water maze over 5 days.
Motor coordination was evaluated on the accelerating rotarod.
"""
print("Input Methods Section:")
print(methods)
results = classifier.extract_measures(methods)
print("\nExtracted Measures:")
for i, result in enumerate(results, 1):
print(f"\n{i}. {result.canonical_name}")
print(f" Domain: {result.outcome_domain}")
if result.subdomain:
print(f" Subdomain: {result.subdomain}")
print(f" Description: {result.measure_description[:80]}...")
# Example 2: Multi-domain extraction
print("\n" + "=" * 70)
print("EXAMPLE 2: Extract from multi-domain methods")
print("=" * 70)
multi_domain_methods = """
Behavioral tests included the elevated plus maze for anxiety assessment and
rotarod for motor coordination. Brain tissue was analyzed using
immunohistochemistry with DAB detection. We also performed 18F-FDG PET imaging
to assess metabolic activity.
"""
print("Input:")
print(multi_domain_methods)
results = classifier.extract_measures(multi_domain_methods)
print(f"\nFound {len(results)} measures:\n")
by_domain = {}
for result in results:
domain = result.outcome_domain
if domain not in by_domain:
by_domain[domain] = []
by_domain[domain].append(result.canonical_name)
for domain, measures in sorted(by_domain.items()):
print(f"{domain}:")
for measure in measures:
print(f" - {measure}")
print()
# Example 3: Access the assay vocabulary
print("\n" + "=" * 70)
print("EXAMPLE 3: Access the assay vocabulary")
print("=" * 70)
# Full vocabulary
vocab = classifier.get_vocabulary()
print(f"Total vocabulary entries: {len(vocab)}")
print("\nFirst 5 vocabulary entries:")
for entry in vocab[:5]:
print(f"- {entry['canonical_name']}")
print(f" Domain: {entry['outcome_domain']}")
print(f" Subdomain: {entry.get('subdomain', 'N/A')}")
print()
# Get all assays from one domain
behavioral = classifier.get_by_domain("Behavioral")
print(f"Number of Behavioral assays: {len(behavioral)}")
print("\nFirst 10 Behavioral assays:")
for entry in behavioral[:10]:
print(f"- {entry['canonical_name']}")