scitex 2.15.1__py3-none-any.whl → 2.15.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scitex/__init__.py +68 -61
- scitex/_mcp_tools/introspect.py +42 -23
- scitex/_mcp_tools/template.py +24 -0
- scitex/ai/classification/timeseries/_TimeSeriesSlidingWindowSplit.py +30 -1550
- scitex/ai/classification/timeseries/_sliding_window_core.py +467 -0
- scitex/ai/classification/timeseries/_sliding_window_plotting.py +369 -0
- scitex/audio/__init__.py +2 -2
- scitex/audio/_tts.py +18 -10
- scitex/audio/engines/base.py +17 -10
- scitex/audio/engines/elevenlabs_engine.py +1 -1
- scitex/canvas/editor/flask_editor/_core/__init__.py +27 -0
- scitex/canvas/editor/flask_editor/_core/_bbox_extraction.py +200 -0
- scitex/canvas/editor/flask_editor/_core/_editor.py +173 -0
- scitex/canvas/editor/flask_editor/_core/_export_helpers.py +353 -0
- scitex/canvas/editor/flask_editor/_core/_routes_basic.py +190 -0
- scitex/canvas/editor/flask_editor/_core/_routes_export.py +332 -0
- scitex/canvas/editor/flask_editor/_core/_routes_panels.py +252 -0
- scitex/canvas/editor/flask_editor/_core/_routes_save.py +218 -0
- scitex/canvas/editor/flask_editor/_core.py +25 -1684
- scitex/cli/introspect.py +112 -74
- scitex/cli/main.py +2 -0
- scitex/cli/plt.py +357 -0
- scitex/cli/repro.py +15 -8
- scitex/cli/resource.py +15 -8
- scitex/cli/scholar/__init__.py +15 -8
- scitex/cli/social.py +6 -6
- scitex/cli/stats.py +15 -8
- scitex/cli/template.py +129 -12
- scitex/cli/tex.py +15 -8
- scitex/cli/writer.py +15 -8
- scitex/cloud/__init__.py +41 -2
- scitex/config/_env_registry.py +84 -19
- scitex/context/__init__.py +22 -0
- scitex/dev/__init__.py +20 -1
- scitex/gen/__init__.py +50 -14
- scitex/gen/_list_packages.py +4 -4
- scitex/introspect/__init__.py +16 -9
- scitex/introspect/_core.py +7 -8
- scitex/{gen/_inspect_module.py → introspect/_list_api.py} +43 -54
- scitex/introspect/_mcp/__init__.py +10 -6
- scitex/introspect/_mcp/handlers.py +37 -12
- scitex/introspect/_members.py +7 -3
- scitex/introspect/_signature.py +3 -3
- scitex/introspect/_source.py +2 -2
- scitex/io/_save.py +1 -2
- scitex/logging/_formatters.py +19 -9
- scitex/mcp_server.py +1 -1
- scitex/os/__init__.py +4 -0
- scitex/{gen → os}/_check_host.py +4 -5
- scitex/plt/__init__.py +11 -14
- scitex/session/__init__.py +26 -7
- scitex/session/_decorator.py +1 -1
- scitex/sh/__init__.py +7 -4
- scitex/social/__init__.py +10 -8
- scitex/stats/_mcp/_handlers/__init__.py +31 -0
- scitex/stats/_mcp/_handlers/_corrections.py +113 -0
- scitex/stats/_mcp/_handlers/_descriptive.py +78 -0
- scitex/stats/_mcp/_handlers/_effect_size.py +106 -0
- scitex/stats/_mcp/_handlers/_format.py +94 -0
- scitex/stats/_mcp/_handlers/_normality.py +110 -0
- scitex/stats/_mcp/_handlers/_posthoc.py +224 -0
- scitex/stats/_mcp/_handlers/_power.py +247 -0
- scitex/stats/_mcp/_handlers/_recommend.py +102 -0
- scitex/stats/_mcp/_handlers/_run_test.py +279 -0
- scitex/stats/_mcp/_handlers/_stars.py +48 -0
- scitex/stats/_mcp/handlers.py +19 -1171
- scitex/stats/auto/_stat_style.py +175 -0
- scitex/stats/auto/_style_definitions.py +411 -0
- scitex/stats/auto/_styles.py +22 -620
- scitex/stats/descriptive/__init__.py +11 -8
- scitex/stats/descriptive/_ci.py +39 -0
- scitex/stats/power/_power.py +15 -4
- scitex/str/__init__.py +2 -1
- scitex/str/_title_case.py +63 -0
- scitex/template/__init__.py +25 -10
- scitex/template/_code_templates.py +147 -0
- scitex/template/_mcp/handlers.py +81 -0
- scitex/template/_mcp/tool_schemas.py +55 -0
- scitex/template/_templates/__init__.py +51 -0
- scitex/template/_templates/audio.py +233 -0
- scitex/template/_templates/canvas.py +312 -0
- scitex/template/_templates/capture.py +268 -0
- scitex/template/_templates/config.py +43 -0
- scitex/template/_templates/diagram.py +294 -0
- scitex/template/_templates/io.py +107 -0
- scitex/template/_templates/module.py +53 -0
- scitex/template/_templates/plt.py +202 -0
- scitex/template/_templates/scholar.py +267 -0
- scitex/template/_templates/session.py +130 -0
- scitex/template/_templates/session_minimal.py +43 -0
- scitex/template/_templates/session_plot.py +67 -0
- scitex/template/_templates/session_stats.py +77 -0
- scitex/template/_templates/stats.py +323 -0
- scitex/template/_templates/writer.py +296 -0
- scitex/ui/_backends/_email.py +10 -2
- scitex/ui/_backends/_webhook.py +5 -1
- scitex/web/_search_pubmed.py +10 -6
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/METADATA +1 -1
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/RECORD +105 -64
- scitex/gen/_ci.py +0 -12
- scitex/gen/_title_case.py +0 -89
- /scitex/{gen → context}/_detect_environment.py +0 -0
- /scitex/{gen → context}/_get_notebook_path.py +0 -0
- /scitex/{gen/_shell.py → sh/_shell_legacy.py} +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/WHEEL +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/entry_points.txt +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Standard Python module template."""
|
|
3
|
+
|
|
4
|
+
TEMPLATE = {
|
|
5
|
+
"name": "Python Module",
|
|
6
|
+
"description": "Standard Python module with docstring, type hints, and exports",
|
|
7
|
+
"filename": "module.py",
|
|
8
|
+
"usage": """
|
|
9
|
+
Usage:
|
|
10
|
+
from module import function_name
|
|
11
|
+
""",
|
|
12
|
+
"content": '''#!/usr/bin/env python3
|
|
13
|
+
# -*- coding: utf-8 -*-
|
|
14
|
+
# Timestamp: "{timestamp}"
|
|
15
|
+
# File: {filepath}
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
{docstring}
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from typing import Optional
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def function_name(arg1, kwarg1: Optional[str] = None):
|
|
25
|
+
"""
|
|
26
|
+
Function description.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
arg1 : type
|
|
31
|
+
Description of arg1.
|
|
32
|
+
kwarg1 : str, optional
|
|
33
|
+
Description of kwarg1.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
type
|
|
38
|
+
Description of return value.
|
|
39
|
+
|
|
40
|
+
Examples
|
|
41
|
+
--------
|
|
42
|
+
>>> result = function_name(value)
|
|
43
|
+
"""
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = ["function_name"]
|
|
48
|
+
|
|
49
|
+
# EOF
|
|
50
|
+
''',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# EOF
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Timestamp: 2026-01-25
|
|
3
|
+
# File: src/scitex/template/_templates/plt.py
|
|
4
|
+
# ----------------------------------------
|
|
5
|
+
|
|
6
|
+
"""Template for stx.plt plotting module usage."""
|
|
7
|
+
|
|
8
|
+
TEMPLATE = {
|
|
9
|
+
"name": "Plotting Module",
|
|
10
|
+
"description": "stx.plt usage for publication-ready figures with automatic CSV export",
|
|
11
|
+
"filename": "plot_script.py",
|
|
12
|
+
"priority": 2,
|
|
13
|
+
"content": '''#!/usr/bin/env python3
|
|
14
|
+
# -*- coding: utf-8 -*-
|
|
15
|
+
# Timestamp: {timestamp}
|
|
16
|
+
# File: {filepath}
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
stx.plt - Publication-Ready Plotting
|
|
20
|
+
====================================
|
|
21
|
+
|
|
22
|
+
stx.plt wraps matplotlib with:
|
|
23
|
+
- Automatic CSV export when saving figures (reproducibility)
|
|
24
|
+
- Pre-configured paper-quality styles
|
|
25
|
+
- Enhanced axis methods (set_xyt, plot_line, etc.)
|
|
26
|
+
- Color palettes (COLORS injection in @stx.session)
|
|
27
|
+
|
|
28
|
+
Usage Patterns
|
|
29
|
+
--------------
|
|
30
|
+
1. Direct API: import scitex as stx; stx.plt.subplots()
|
|
31
|
+
2. With @stx.session: plt is auto-injected with proper style
|
|
32
|
+
3. CLI: scitex plt <recipe.yaml> (for FigRecipe specs)
|
|
33
|
+
4. MCP: plt_plot, plt_compose, plt_reproduce tools
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
import scitex as stx
|
|
37
|
+
|
|
38
|
+
# ============================================================
|
|
39
|
+
# Pattern 1: Direct API Usage
|
|
40
|
+
# ============================================================
|
|
41
|
+
|
|
42
|
+
# Basic figure creation
|
|
43
|
+
fig, ax = stx.plt.subplots()
|
|
44
|
+
x = [1, 2, 3, 4, 5]
|
|
45
|
+
y = [2, 4, 1, 5, 3]
|
|
46
|
+
ax.plot(x, y, label="Data")
|
|
47
|
+
ax.set_xyt("X Axis", "Y Axis", "My Plot") # Enhanced: xlabel, ylabel, title
|
|
48
|
+
ax.legend()
|
|
49
|
+
|
|
50
|
+
# Save with auto CSV export (creates plot.png + plot.csv)
|
|
51
|
+
stx.io.save(fig, "plot.png")
|
|
52
|
+
|
|
53
|
+
# ============================================================
|
|
54
|
+
# Pattern 2: Multiple Subplots
|
|
55
|
+
# ============================================================
|
|
56
|
+
|
|
57
|
+
fig, axes = stx.plt.subplots(2, 2, figsize=(10, 8))
|
|
58
|
+
|
|
59
|
+
# Flatten for easier iteration
|
|
60
|
+
for idx, ax in enumerate(axes.flat):
|
|
61
|
+
ax.plot([1, 2, 3], [idx, idx*2, idx*3])
|
|
62
|
+
ax.set_xyt(f"X{{idx}}", f"Y{{idx}}", f"Panel {{idx}}")
|
|
63
|
+
|
|
64
|
+
fig.tight_layout()
|
|
65
|
+
stx.io.save(fig, "multipanel.png")
|
|
66
|
+
|
|
67
|
+
# ============================================================
|
|
68
|
+
# Pattern 3: With @stx.session (Recommended)
|
|
69
|
+
# ============================================================
|
|
70
|
+
|
|
71
|
+
@stx.session
|
|
72
|
+
def main(
|
|
73
|
+
n_points=100,
|
|
74
|
+
CONFIG=stx.INJECTED, # Session config
|
|
75
|
+
plt=stx.INJECTED, # Pre-configured matplotlib
|
|
76
|
+
COLORS=stx.INJECTED, # Color palette
|
|
77
|
+
rng=stx.INJECTED, # Random generator
|
|
78
|
+
logger=stx.INJECTED, # Logger
|
|
79
|
+
):
|
|
80
|
+
"""Example plotting with session management."""
|
|
81
|
+
import numpy as np
|
|
82
|
+
|
|
83
|
+
# Generate data
|
|
84
|
+
x = np.linspace(0, 10, n_points)
|
|
85
|
+
y1 = np.sin(x) + rng.normal(0, 0.1, n_points)
|
|
86
|
+
y2 = np.cos(x) + rng.normal(0, 0.1, n_points)
|
|
87
|
+
|
|
88
|
+
# Create figure using injected plt
|
|
89
|
+
fig, ax = plt.subplots()
|
|
90
|
+
|
|
91
|
+
# Use injected COLORS for consistent styling
|
|
92
|
+
ax.plot(x, y1, color=COLORS[0], label="sin(x)")
|
|
93
|
+
ax.plot(x, y2, color=COLORS[1], label="cos(x)")
|
|
94
|
+
|
|
95
|
+
# Enhanced axis methods
|
|
96
|
+
ax.set_xyt("Time (s)", "Amplitude", "Waveform Comparison")
|
|
97
|
+
ax.legend()
|
|
98
|
+
|
|
99
|
+
# Save to CONFIG.SDIR_OUT (auto CSV export)
|
|
100
|
+
stx.io.save(fig, CONFIG.SDIR_OUT / "waveforms.png")
|
|
101
|
+
logger.info(f"Saved figure to {{CONFIG.SDIR_OUT}}")
|
|
102
|
+
|
|
103
|
+
return 0
|
|
104
|
+
|
|
105
|
+
# ============================================================
|
|
106
|
+
# Pattern 4: Statistical Plots
|
|
107
|
+
# ============================================================
|
|
108
|
+
|
|
109
|
+
def statistical_plots():
|
|
110
|
+
"""Common statistical visualization patterns."""
|
|
111
|
+
import numpy as np
|
|
112
|
+
|
|
113
|
+
fig, axes = stx.plt.subplots(1, 3, figsize=(12, 4))
|
|
114
|
+
|
|
115
|
+
# Box plot
|
|
116
|
+
data = [np.random.randn(100) + i for i in range(3)]
|
|
117
|
+
axes[0].boxplot(data)
|
|
118
|
+
axes[0].set_xyt("Group", "Value", "Box Plot")
|
|
119
|
+
|
|
120
|
+
# Histogram
|
|
121
|
+
axes[1].hist(np.random.randn(1000), bins=30, edgecolor='black')
|
|
122
|
+
axes[1].set_xyt("Value", "Count", "Histogram")
|
|
123
|
+
|
|
124
|
+
# Scatter with regression
|
|
125
|
+
x = np.random.randn(50)
|
|
126
|
+
y = 2*x + np.random.randn(50)*0.5
|
|
127
|
+
axes[2].scatter(x, y, alpha=0.6)
|
|
128
|
+
axes[2].set_xyt("X", "Y", "Scatter Plot")
|
|
129
|
+
|
|
130
|
+
fig.tight_layout()
|
|
131
|
+
stx.io.save(fig, "stats_plots.png")
|
|
132
|
+
|
|
133
|
+
# ============================================================
|
|
134
|
+
# Pattern 5: Heatmaps and Images
|
|
135
|
+
# ============================================================
|
|
136
|
+
|
|
137
|
+
def heatmap_example():
|
|
138
|
+
"""Heatmap visualization pattern."""
|
|
139
|
+
import numpy as np
|
|
140
|
+
|
|
141
|
+
fig, ax = stx.plt.subplots()
|
|
142
|
+
|
|
143
|
+
# Create correlation matrix
|
|
144
|
+
data = np.random.randn(10, 10)
|
|
145
|
+
corr = np.corrcoef(data)
|
|
146
|
+
|
|
147
|
+
im = ax.imshow(corr, cmap='RdBu_r', vmin=-1, vmax=1)
|
|
148
|
+
ax.set_xyt("Feature", "Feature", "Correlation Matrix")
|
|
149
|
+
fig.colorbar(im, ax=ax, label="Correlation")
|
|
150
|
+
|
|
151
|
+
stx.io.save(fig, "heatmap.png")
|
|
152
|
+
|
|
153
|
+
# ============================================================
|
|
154
|
+
# Key Features Summary
|
|
155
|
+
# ============================================================
|
|
156
|
+
|
|
157
|
+
"""
|
|
158
|
+
stx.plt Key Features:
|
|
159
|
+
---------------------
|
|
160
|
+
1. Enhanced Axis Methods:
|
|
161
|
+
- ax.set_xyt(xlabel, ylabel, title) # All in one call
|
|
162
|
+
- ax.plot_line(x, y, **kwargs) # With auto data tracking
|
|
163
|
+
|
|
164
|
+
2. Auto CSV Export:
|
|
165
|
+
- stx.io.save(fig, "plot.png") # Creates plot.png + plot.csv
|
|
166
|
+
- CSV contains all plotted data for reproducibility
|
|
167
|
+
|
|
168
|
+
3. Pre-configured Styles:
|
|
169
|
+
- Publication-quality fonts and sizes
|
|
170
|
+
- Consistent color palettes
|
|
171
|
+
- Grid and tick configurations
|
|
172
|
+
|
|
173
|
+
4. Color Palettes (via COLORS injection):
|
|
174
|
+
- COLORS[0], COLORS[1], ... for consistent styling
|
|
175
|
+
- Colorblind-friendly by default
|
|
176
|
+
|
|
177
|
+
5. Figure Recipes (advanced):
|
|
178
|
+
- YAML specifications for reproducible figures
|
|
179
|
+
- CLI: scitex plt recipe.yaml -o output.png
|
|
180
|
+
- MCP: plt_plot, plt_compose, plt_reproduce
|
|
181
|
+
|
|
182
|
+
CLI Commands:
|
|
183
|
+
-------------
|
|
184
|
+
scitex plt <recipe.yaml> # Render from recipe
|
|
185
|
+
scitex plt --help # Show all options
|
|
186
|
+
|
|
187
|
+
MCP Tools:
|
|
188
|
+
----------
|
|
189
|
+
plt_plot # Create figure from specification
|
|
190
|
+
plt_compose # Combine multiple figures
|
|
191
|
+
plt_reproduce # Reproduce from saved recipe
|
|
192
|
+
plt_crop # Crop whitespace
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
if __name__ == "__main__":
|
|
196
|
+
main()
|
|
197
|
+
''',
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
__all__ = ["TEMPLATE"]
|
|
201
|
+
|
|
202
|
+
# EOF
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Timestamp: 2026-01-25
|
|
3
|
+
# File: src/scitex/template/_templates/scholar.py
|
|
4
|
+
# ----------------------------------------
|
|
5
|
+
|
|
6
|
+
"""Template for stx.scholar literature management module usage."""
|
|
7
|
+
|
|
8
|
+
TEMPLATE = {
|
|
9
|
+
"name": "Scholar Module",
|
|
10
|
+
"description": "stx.scholar usage for literature management, BibTeX enrichment, and PDF downloads",
|
|
11
|
+
"filename": "scholar_script.py",
|
|
12
|
+
"priority": 4,
|
|
13
|
+
"content": '''#!/usr/bin/env python3
|
|
14
|
+
# -*- coding: utf-8 -*-
|
|
15
|
+
# Timestamp: {timestamp}
|
|
16
|
+
# File: {filepath}
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
stx.scholar - Literature Management
|
|
20
|
+
===================================
|
|
21
|
+
|
|
22
|
+
stx.scholar provides:
|
|
23
|
+
- BibTeX enrichment (DOIs, abstracts, citations, impact factors)
|
|
24
|
+
- PDF downloading with institutional access support
|
|
25
|
+
- Paper search across multiple databases
|
|
26
|
+
- Project-based paper organization
|
|
27
|
+
- CrossRef local database (167M+ papers)
|
|
28
|
+
|
|
29
|
+
Usage Patterns
|
|
30
|
+
--------------
|
|
31
|
+
1. CLI: scitex scholar <command> [options]
|
|
32
|
+
2. MCP: scholar_* tools for Claude Code integration
|
|
33
|
+
3. Python API: stx.scholar.* functions
|
|
34
|
+
|
|
35
|
+
Typical Workflow
|
|
36
|
+
----------------
|
|
37
|
+
1. Create project: scitex scholar project create myresearch
|
|
38
|
+
2. Add papers from BibTeX: scitex scholar add --bibtex refs.bib --project myresearch
|
|
39
|
+
3. Enrich metadata: scitex scholar enrich --project myresearch
|
|
40
|
+
4. Download PDFs: scitex scholar fetch --project myresearch
|
|
41
|
+
5. Search for more: scitex scholar search "machine learning EEG"
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
import scitex as stx
|
|
45
|
+
|
|
46
|
+
# ============================================================
|
|
47
|
+
# Pattern 1: CLI Usage (Recommended)
|
|
48
|
+
# ============================================================
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
CLI Commands:
|
|
52
|
+
-------------
|
|
53
|
+
|
|
54
|
+
# Project Management
|
|
55
|
+
scitex scholar project create myresearch # Create new project
|
|
56
|
+
scitex scholar project list # List all projects
|
|
57
|
+
|
|
58
|
+
# Add Papers
|
|
59
|
+
scitex scholar add --bibtex refs.bib --project myresearch
|
|
60
|
+
scitex scholar add --doi "10.1038/nature12373" --project myresearch
|
|
61
|
+
|
|
62
|
+
# Enrich BibTeX (add DOIs, abstracts, citations)
|
|
63
|
+
scitex scholar enrich --bibtex refs.bib --output enriched.bib
|
|
64
|
+
scitex scholar enrich --project myresearch
|
|
65
|
+
|
|
66
|
+
# Download PDFs
|
|
67
|
+
scitex scholar fetch --project myresearch
|
|
68
|
+
scitex scholar fetch --doi "10.1038/nature12373" --output ./pdfs/
|
|
69
|
+
|
|
70
|
+
# Search Databases
|
|
71
|
+
scitex scholar search "machine learning EEG" --limit 50
|
|
72
|
+
scitex scholar search "CRISPR" --source crossref --year-min 2020
|
|
73
|
+
|
|
74
|
+
# Check Library Status
|
|
75
|
+
scitex scholar status --project myresearch
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
# ============================================================
|
|
79
|
+
# Pattern 2: CrossRef Local Search (167M+ papers)
|
|
80
|
+
# ============================================================
|
|
81
|
+
|
|
82
|
+
"""
|
|
83
|
+
CrossRef Local Database:
|
|
84
|
+
------------------------
|
|
85
|
+
Fast full-text search across 167M+ academic papers.
|
|
86
|
+
Supports FTS5 query syntax: AND, OR, NOT, "exact phrases"
|
|
87
|
+
|
|
88
|
+
CLI:
|
|
89
|
+
----
|
|
90
|
+
scitex scholar crossref search "neural network AND hippocampus"
|
|
91
|
+
scitex scholar crossref get 10.1038/nature12373
|
|
92
|
+
scitex scholar crossref citations 10.1038/nature12373
|
|
93
|
+
|
|
94
|
+
MCP Tools:
|
|
95
|
+
----------
|
|
96
|
+
crossref_search(query, limit) # Search papers
|
|
97
|
+
crossref_get(doi) # Get metadata by DOI
|
|
98
|
+
crossref_citations(doi, direction) # Get citing/cited papers
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
# ============================================================
|
|
102
|
+
# Pattern 3: Paper Caching for Research Topics
|
|
103
|
+
# ============================================================
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
Paper Cache Workflow:
|
|
107
|
+
---------------------
|
|
108
|
+
Build reusable collections for specific research topics.
|
|
109
|
+
|
|
110
|
+
# Create cache from search query
|
|
111
|
+
scitex scholar cache create epilepsy "epilepsy seizure prediction" --limit 1000
|
|
112
|
+
|
|
113
|
+
# Query cached papers
|
|
114
|
+
scitex scholar cache query epilepsy --year-min 2020 --limit 50
|
|
115
|
+
|
|
116
|
+
# Get top cited papers
|
|
117
|
+
scitex scholar cache top-cited epilepsy --n 20
|
|
118
|
+
|
|
119
|
+
# Export to formats
|
|
120
|
+
scitex scholar cache export epilepsy --format bibtex --output refs.bib
|
|
121
|
+
scitex scholar cache export epilepsy --format csv --output papers.csv
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
# ============================================================
|
|
125
|
+
# Pattern 4: Institutional Authentication
|
|
126
|
+
# ============================================================
|
|
127
|
+
|
|
128
|
+
"""
|
|
129
|
+
Institutional Access (OpenAthens/Shibboleth):
|
|
130
|
+
---------------------------------------------
|
|
131
|
+
For downloading papers requiring institutional credentials.
|
|
132
|
+
|
|
133
|
+
# Check authentication status
|
|
134
|
+
scitex scholar auth status
|
|
135
|
+
|
|
136
|
+
# Login via OpenAthens
|
|
137
|
+
scitex scholar auth login --method openathens
|
|
138
|
+
|
|
139
|
+
# Logout and clear session
|
|
140
|
+
scitex scholar auth logout
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
# ============================================================
|
|
144
|
+
# Pattern 5: Python API Usage
|
|
145
|
+
# ============================================================
|
|
146
|
+
|
|
147
|
+
def python_api_example():
|
|
148
|
+
"""Direct Python API usage."""
|
|
149
|
+
from scitex.scholar import (
|
|
150
|
+
search_papers,
|
|
151
|
+
enrich_bibtex,
|
|
152
|
+
download_pdf,
|
|
153
|
+
parse_bibtex,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Search for papers
|
|
157
|
+
results = search_papers(
|
|
158
|
+
query="machine learning EEG",
|
|
159
|
+
search_mode="crossref",
|
|
160
|
+
limit=20
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# Parse BibTeX file
|
|
164
|
+
papers = parse_bibtex("references.bib")
|
|
165
|
+
|
|
166
|
+
# Enrich with metadata
|
|
167
|
+
enrich_bibtex(
|
|
168
|
+
bibtex_path="references.bib",
|
|
169
|
+
output_path="enriched.bib",
|
|
170
|
+
add_abstracts=True,
|
|
171
|
+
add_citations=True,
|
|
172
|
+
add_impact_factors=True
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# Download a specific PDF
|
|
176
|
+
download_pdf(
|
|
177
|
+
doi="10.1038/nature12373",
|
|
178
|
+
output_dir="./pdfs/"
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# ============================================================
|
|
182
|
+
# Pattern 6: With @stx.session (Research Workflow)
|
|
183
|
+
# ============================================================
|
|
184
|
+
|
|
185
|
+
@stx.session
|
|
186
|
+
def main(
|
|
187
|
+
topic="neural networks",
|
|
188
|
+
n_papers=50,
|
|
189
|
+
CONFIG=stx.INJECTED,
|
|
190
|
+
logger=stx.INJECTED,
|
|
191
|
+
):
|
|
192
|
+
"""Research literature workflow."""
|
|
193
|
+
from scitex.scholar import search_papers, enrich_bibtex
|
|
194
|
+
|
|
195
|
+
# 1. Search for papers
|
|
196
|
+
logger.info(f"Searching for papers on: {{topic}}")
|
|
197
|
+
results = search_papers(
|
|
198
|
+
query=topic,
|
|
199
|
+
search_mode="crossref",
|
|
200
|
+
limit=n_papers
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# 2. Save search results
|
|
204
|
+
stx.io.save(results, CONFIG.SDIR_OUT / "search_results.json")
|
|
205
|
+
|
|
206
|
+
# 3. If BibTeX exists, enrich it
|
|
207
|
+
bibtex_path = CONFIG.SDIR_OUT / "references.bib"
|
|
208
|
+
if bibtex_path.exists():
|
|
209
|
+
enrich_bibtex(
|
|
210
|
+
bibtex_path=str(bibtex_path),
|
|
211
|
+
output_path=str(CONFIG.SDIR_OUT / "enriched.bib")
|
|
212
|
+
)
|
|
213
|
+
logger.info("BibTeX enriched with metadata")
|
|
214
|
+
|
|
215
|
+
logger.info(f"Found {{len(results)}} papers")
|
|
216
|
+
return 0
|
|
217
|
+
|
|
218
|
+
# ============================================================
|
|
219
|
+
# MCP Tools Reference
|
|
220
|
+
# ============================================================
|
|
221
|
+
|
|
222
|
+
"""
|
|
223
|
+
MCP Tools for Claude Code:
|
|
224
|
+
--------------------------
|
|
225
|
+
|
|
226
|
+
Search & Discovery:
|
|
227
|
+
- scholar_search_papers(query, limit, search_mode)
|
|
228
|
+
- scholar_crossref_search(query, limit, year_min, year_max)
|
|
229
|
+
- scholar_crossref_get(doi)
|
|
230
|
+
- scholar_crossref_citations(doi, direction)
|
|
231
|
+
|
|
232
|
+
Library Management:
|
|
233
|
+
- scholar_create_project(project_name, description)
|
|
234
|
+
- scholar_list_projects()
|
|
235
|
+
- scholar_add_papers_to_project(project, dois, bibtex_path)
|
|
236
|
+
- scholar_get_library_status(project)
|
|
237
|
+
|
|
238
|
+
Enrichment & Download:
|
|
239
|
+
- scholar_enrich_bibtex(bibtex_path, add_abstracts, add_citations)
|
|
240
|
+
- scholar_fetch_papers(project, papers, async_mode)
|
|
241
|
+
- scholar_download_pdf(doi, output_dir)
|
|
242
|
+
|
|
243
|
+
BibTeX Operations:
|
|
244
|
+
- scholar_parse_bibtex(bibtex_path)
|
|
245
|
+
- scholar_resolve_dois(titles, bibtex_path)
|
|
246
|
+
- scholar_export_papers(output_path, format)
|
|
247
|
+
|
|
248
|
+
Authentication:
|
|
249
|
+
- scholar_authenticate(method, institution)
|
|
250
|
+
- scholar_check_auth_status(method)
|
|
251
|
+
- scholar_logout(method)
|
|
252
|
+
|
|
253
|
+
Cache Operations:
|
|
254
|
+
- cache_create(name, query, limit)
|
|
255
|
+
- cache_query(name, fields, year_min, year_max)
|
|
256
|
+
- cache_top_cited(name, n)
|
|
257
|
+
- cache_export(name, output_path, format)
|
|
258
|
+
"""
|
|
259
|
+
|
|
260
|
+
if __name__ == "__main__":
|
|
261
|
+
main()
|
|
262
|
+
''',
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
__all__ = ["TEMPLATE"]
|
|
266
|
+
|
|
267
|
+
# EOF
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Session script template - full @stx.session with all injections."""
|
|
3
|
+
|
|
4
|
+
TEMPLATE = {
|
|
5
|
+
"name": "Session Script",
|
|
6
|
+
"description": "@stx.session decorated script with auto CLI, config injection, and output tracking",
|
|
7
|
+
"filename": "script.py",
|
|
8
|
+
"usage": """
|
|
9
|
+
Usage:
|
|
10
|
+
python script.py # Run with defaults
|
|
11
|
+
python script.py --kwarg1 value # Override parameter
|
|
12
|
+
python script.py --help # Show auto-generated help
|
|
13
|
+
|
|
14
|
+
Output Structure:
|
|
15
|
+
script_out/
|
|
16
|
+
├── output.csv # stx.io.save() files go here (ROOT)
|
|
17
|
+
├── figure.png
|
|
18
|
+
└── FINISHED_SUCCESS/<session_id>/ # Session metadata only
|
|
19
|
+
""",
|
|
20
|
+
"content": '''#!/usr/bin/env python3
|
|
21
|
+
# -*- coding: utf-8 -*-
|
|
22
|
+
# Timestamp: "{timestamp}"
|
|
23
|
+
# File: {filepath}
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
{docstring}
|
|
27
|
+
|
|
28
|
+
Usage
|
|
29
|
+
-----
|
|
30
|
+
$ python {filename} --help # Show auto-generated CLI help
|
|
31
|
+
$ python {filename} # Run with default parameters
|
|
32
|
+
$ python {filename} --kwarg1 value # Override parameters
|
|
33
|
+
|
|
34
|
+
Injected Global Variables
|
|
35
|
+
-------------------------
|
|
36
|
+
CONFIG : DotDict (access: CONFIG.key or CONFIG['key'])
|
|
37
|
+
Session configuration with paths and metadata.
|
|
38
|
+
|
|
39
|
+
Key Paths:
|
|
40
|
+
- CONFIG.ID : Session ID (e.g., '2025Y-01M-20D-10h30m00s_XyZ1')
|
|
41
|
+
- CONFIG.FILE : This script's absolute path
|
|
42
|
+
- CONFIG.SDIR_OUT : Output ROOT directory ({filename_stem}_out/)
|
|
43
|
+
USE THIS for stx.io.save() - files go here!
|
|
44
|
+
- CONFIG.SDIR_RUN : Session run directory (inside RUNNING/ or FINISHED_*)
|
|
45
|
+
Contains logs and CONFIG snapshots only
|
|
46
|
+
- CONFIG.PID : Process ID
|
|
47
|
+
- CONFIG.ARGS : Parsed CLI arguments as dict
|
|
48
|
+
|
|
49
|
+
YAML Config (from ./config/*.yaml):
|
|
50
|
+
- CONFIG.<FILENAME>.<key> : Values from config files
|
|
51
|
+
|
|
52
|
+
plt : module
|
|
53
|
+
matplotlib.pyplot configured for session
|
|
54
|
+
|
|
55
|
+
COLORS : DotDict
|
|
56
|
+
Color palette: COLORS.blue, COLORS.red, COLORS.green, etc.
|
|
57
|
+
|
|
58
|
+
rng : RandomStateManager
|
|
59
|
+
Reproducible random number generator (seeded)
|
|
60
|
+
|
|
61
|
+
logger : SciTeXLogger
|
|
62
|
+
Configured logger: logger.info(), logger.warning(), logger.error()
|
|
63
|
+
|
|
64
|
+
Output Directory Structure
|
|
65
|
+
--------------------------
|
|
66
|
+
{filename_stem}_out/ <- CONFIG.SDIR_OUT (save files here!)
|
|
67
|
+
├── output.csv <- stx.io.save(df, "output.csv")
|
|
68
|
+
├── figure.png <- stx.io.save(fig, "figure.png")
|
|
69
|
+
├── figure.csv <- Auto-exported plot data
|
|
70
|
+
└── FINISHED_SUCCESS/
|
|
71
|
+
└── <session_id>/ <- CONFIG.SDIR_RUN (logs/configs)
|
|
72
|
+
├── CONFIGS/
|
|
73
|
+
│ ├── CONFIG.pkl
|
|
74
|
+
│ └── CONFIG.yaml
|
|
75
|
+
└── logs/
|
|
76
|
+
├── stdout.log
|
|
77
|
+
└── stderr.log
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
import numpy as np
|
|
81
|
+
import scitex as stx
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@stx.session
|
|
85
|
+
def main(
|
|
86
|
+
# Uncomment and modify as needed:
|
|
87
|
+
# input_file, # Required argument -> CLI positional
|
|
88
|
+
# n_samples=100, # Optional argument -> CLI --n-samples
|
|
89
|
+
# threshold=0.05, # Optional argument -> CLI --threshold
|
|
90
|
+
# verbose=True, # Optional argument -> CLI --verbose
|
|
91
|
+
CONFIG=stx.INJECTED, # Auto-injected from ./config/*.yaml
|
|
92
|
+
plt=stx.INJECTED, # Pre-configured matplotlib
|
|
93
|
+
COLORS=stx.INJECTED, # Color palette
|
|
94
|
+
rng=stx.INJECTED, # Random number generator
|
|
95
|
+
logger=stx.INJECTED, # Session logger
|
|
96
|
+
):
|
|
97
|
+
"""
|
|
98
|
+
Script description shown in --help output.
|
|
99
|
+
|
|
100
|
+
This docstring becomes the CLI help message.
|
|
101
|
+
"""
|
|
102
|
+
# Log session info
|
|
103
|
+
logger.info(f"Session ID: {{CONFIG.ID}}")
|
|
104
|
+
logger.info(f"Output dir: {{CONFIG.SDIR_OUT}}") # Where files are saved
|
|
105
|
+
|
|
106
|
+
# Generate example data
|
|
107
|
+
x = np.linspace(0, 10, 100)
|
|
108
|
+
y = np.sin(x)
|
|
109
|
+
|
|
110
|
+
# Create figure
|
|
111
|
+
fig, ax = plt.subplots()
|
|
112
|
+
ax.plot_line(x, y, color=COLORS.blue, label="sin(x)")
|
|
113
|
+
ax.set_xyt("X", "Y", "Example Figure")
|
|
114
|
+
ax.legend_()
|
|
115
|
+
|
|
116
|
+
# Save outputs to CONFIG.SDIR_OUT (automatic)
|
|
117
|
+
stx.io.save(fig, "figure.png") # -> {filename_stem}_out/figure.png
|
|
118
|
+
# stx.io.save(df, "results.csv") # -> {filename_stem}_out/results.csv
|
|
119
|
+
|
|
120
|
+
return 0 # Return 0 for success
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|
|
125
|
+
|
|
126
|
+
# EOF
|
|
127
|
+
''',
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# EOF
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Minimal session script template."""
|
|
3
|
+
|
|
4
|
+
TEMPLATE = {
|
|
5
|
+
"name": "Minimal Session Script",
|
|
6
|
+
"description": "Minimal @stx.session script with essential injections only",
|
|
7
|
+
"filename": "script.py",
|
|
8
|
+
"usage": """
|
|
9
|
+
Usage:
|
|
10
|
+
python script.py
|
|
11
|
+
python script.py --help
|
|
12
|
+
""",
|
|
13
|
+
"content": '''#!/usr/bin/env python3
|
|
14
|
+
# -*- coding: utf-8 -*-
|
|
15
|
+
# Timestamp: "{timestamp}"
|
|
16
|
+
# File: {filepath}
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
{docstring}
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import scitex as stx
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@stx.session
|
|
26
|
+
def main(
|
|
27
|
+
CONFIG=stx.INJECTED,
|
|
28
|
+
logger=stx.INJECTED,
|
|
29
|
+
):
|
|
30
|
+
"""Script description for --help."""
|
|
31
|
+
logger.info(f"Session: {{CONFIG.ID}}")
|
|
32
|
+
logger.info(f"Output: {{CONFIG.SDIR_OUT}}")
|
|
33
|
+
return 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
main()
|
|
38
|
+
|
|
39
|
+
# EOF
|
|
40
|
+
''',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# EOF
|