prismWriter 1.0.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 smestern
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include requirements.txt
4
+ recursive-include prismWriter *.pzfx
5
+ recursive-include prismWriter/schema *.xml
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.1
2
+ Name: prismWriter
3
+ Version: 1.0.0
4
+ Summary: Python library for programmatically creating and manipulating GraphPad Prism (.pzfx) files
5
+ Author: smestern
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 smestern
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/smestern/prismWriter
29
+ Project-URL: Repository, https://github.com/smestern/prismWriter
30
+ Project-URL: Documentation, https://github.com/smestern/prismWriter#readme
31
+ Project-URL: Bug Tracker, https://github.com/smestern/prismWriter/issues
32
+ Keywords: graphpad,prism,pzfx,data visualization,scientific,pandas
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Science/Research
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.8
40
+ Classifier: Programming Language :: Python :: 3.9
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Topic :: Scientific/Engineering
45
+ Classifier: Topic :: Scientific/Engineering :: Visualization
46
+ Requires-Python: >=3.8
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+ Requires-Dist: numpy>=1.20
50
+ Requires-Dist: pandas>=1.3
51
+ Requires-Dist: openpyxl>=3.0
52
+ Provides-Extra: gui
53
+ Requires-Dist: PySide2>=5.15; extra == "gui"
54
+ Provides-Extra: web
55
+ Requires-Dist: streamlit>=1.20; extra == "web"
56
+ Provides-Extra: all
57
+ Requires-Dist: PySide2>=5.15; extra == "all"
58
+ Requires-Dist: streamlit>=1.20; extra == "all"
59
+ Provides-Extra: dev
60
+ Requires-Dist: pytest>=7.0; extra == "dev"
61
+ Requires-Dist: pytest-cov; extra == "dev"
62
+ Requires-Dist: black; extra == "dev"
63
+ Requires-Dist: flake8; extra == "dev"
64
+ Requires-Dist: build; extra == "dev"
65
+ Requires-Dist: twine; extra == "dev"
66
+
67
+ # prismWriter
68
+
69
+ Python library and GUI for programmatically creating and manipulating GraphPad Prism (`.pzfx`) files. Convert pandas DataFrames into Prism's XML-based table format with complex grouping structures.
70
+
71
+ **Version:** 1.0.0
72
+
73
+ ## Features
74
+
75
+ - Convert pandas DataFrames to GraphPad Prism format
76
+ - Flexible grouping: main groups, sub-columns, row labels
77
+ - Multiple interfaces: Python API, Qt GUI, and Streamlit Web interface
78
+ - Load and modify existing `.pzfx` files
79
+ - Validate table structure with preview functionality
80
+ - Automatic backup creation when loading existing files
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ pip install -e .
86
+ ```
87
+
88
+ ### Requirements
89
+
90
+ - Python >= 3.7
91
+ - numpy
92
+ - pandas
93
+ - PySide2 (for Qt GUI)
94
+ - streamlit >= 1.28.0 (for web interface)
95
+ - openpyxl (for Excel file support)
96
+
97
+ ## Quick Start
98
+
99
+ ### Python API
100
+
101
+ ```python
102
+ from prismWriter.prism_writer import PrismFile
103
+ import pandas as pd
104
+
105
+ # Create a new PrismFile
106
+ pf = PrismFile()
107
+
108
+ # Load your data
109
+ df = pd.read_csv('data.csv')
110
+
111
+ # Create a grouped table
112
+ pf.make_group_table(
113
+ group_name="MyTable",
114
+ group_values=df,
115
+ groupby="condition", # Main grouping column
116
+ cols=["value1", "value2"], # Data columns
117
+ subgroupby="replicate" # Sub-grouping
118
+ )
119
+
120
+ # Save to Prism file
121
+ pf.save("output.pzfx")
122
+ ```
123
+
124
+ ### Web Interface (Streamlit)
125
+
126
+ The easiest way to use prismWriter:
127
+
128
+ ```bash
129
+ streamlit run prismWriter/streamlit_app.py
130
+ ```
131
+
132
+ Or use the provided launch script:
133
+ - **Windows**: `run_web.bat`
134
+
135
+ Or after installation:
136
+ ```bash
137
+ prismwriter-web
138
+ ```
139
+
140
+ Features:
141
+ - Upload CSV/Excel files (with multi-sheet Excel support)
142
+ - Live data preview with automatic column type detection
143
+ - Interactive grouping configuration
144
+ - Preview table structure before generating
145
+ - Direct download of generated `.pzfx` files
146
+ - Load and view existing Prism files
147
+
148
+ ### Qt GUI
149
+
150
+ ```bash
151
+ python prismWriter/gui.py
152
+ ```
153
+
154
+ Or after installation:
155
+ ```bash
156
+ prismwriter-gui
157
+ ```
158
+
159
+ ## API Reference
160
+
161
+ ### PrismFile Class
162
+
163
+ ```python
164
+ pf = PrismFile(file=None) # Create new or load existing file
165
+ ```
166
+
167
+ **Methods:**
168
+ - `load(file_path, backup=True)` - Load an existing Prism file
169
+ - `smake_group_table(group_name, group_values, groupby=None, cols=None, subgroupby=None, rowgroupby=None, append=True)` - Create a grouped table
170
+ - `get_table_names()` - Get list of all table names
171
+ - `to_dataframe(table_name)` - Convert a table to pandas DataFrame
172
+ - `save(file_path)` - Save to file
173
+ - `write(file_path, xml_declaration=True, encoding='utf-8', pretty_print=True)` - Write with options
174
+ - `remove_table(table_name)` - Remove a table from the file
175
+
176
+ ### Grouping Parameters
177
+
178
+ - **`groupby`**: Main column grouping - creates separate Y-columns for each category
179
+ - **`subgroupby`**: Sub-columns within each Y-column (string for column name, or list for data columns)
180
+ - **`rowgroupby`**: Row labels on the vertical axis (string for column name, or list for data columns)
181
+ - **`cols`**: Data columns to include
182
+
183
+ **Note**: Use either column name (`subgroupby='condition'`) OR list of data columns (`subgroupby=['col1', 'col2']`) - not both.
184
+
185
+ ### Example Data Structure
186
+
187
+ ```python
188
+ import pandas as pd
189
+ from prismWriter.prism_writer import PrismFile
190
+
191
+ # Sample data
192
+ data = {
193
+ 'treatment': ['Control', 'Control', 'Drug A', 'Drug A'],
194
+ 'time': [0, 24, 0, 24],
195
+ 'replicate': [1, 1, 1, 1],
196
+ 'value': [10.5, 15.2, 12.1, 25.8]
197
+ }
198
+ df = pd.DataFrame(data)
199
+
200
+ # Create Prism file
201
+ pf = PrismFile()
202
+ pf.make_group_table(
203
+ group_name="Treatment_Data",
204
+ group_values=df,
205
+ groupby="treatment", # Separate columns for Control vs Drug A
206
+ rowgroupby="time", # Rows labeled by timepoint
207
+ cols=["value"] # Data column
208
+ )
209
+ pf.save("treatment_data.pzfx")
210
+ ```
211
+
212
+ ## Loading Existing Files
213
+
214
+ ```python
215
+ from prismWriter.prism_writer import PrismFile
216
+
217
+ # Load existing Prism file (creates automatic backup)
218
+ pf = PrismFile()
219
+ pf.load("existing.pzfx")
220
+
221
+ # Or load directly in constructor
222
+ pf = PrismFile(file="existing.pzfx")
223
+
224
+ # Get table names
225
+ tables = pf.get_table_names()
226
+ print(f"Found tables: {tables}")
227
+
228
+ # Convert table to DataFrame
229
+ df = pf.to_dataframe("TableName")
230
+
231
+ # Add new table
232
+ pf.make_group_table(
233
+ group_name="NewTable",
234
+ group_values=df,
235
+ groupby="category",
236
+ cols=["value"]
237
+ )
238
+
239
+ # Save (use write() for more options)
240
+ pf.save("modified.pzfx")
241
+ ```
242
+
243
+ ## Dependencies
244
+
245
+ - **Core**: pandas, numpy
246
+ - **GUI**: PySide2 (Qt bindings)
247
+ - **Web**: streamlit >= 1.28.0
248
+ - **Files**: openpyxl for Excel support
249
+
250
+ ## Project Structure
251
+
252
+ ```
253
+ prismWriter/
254
+ ├── prismWriter/
255
+ │ ├── __init__.py # Package exports
256
+ │ ├── prism_writer.py # Core XML generation engine
257
+ │ ├── gui.py # PySide2 Qt GUI wrapper
258
+ │ ├── streamlit_app.py # Streamlit web interface
259
+ │ ├── prism_template2.pzfx # XML structure template
260
+ │ └── schema/ # Prism XML schemas
261
+ ├── tests/
262
+ │ ├── test_prism_writer.py
263
+ │ ├── test_gui.py
264
+ │ └── test_data.csv
265
+ ├── pyproject.toml
266
+ └── README.md
267
+ ```
268
+
269
+ ## Development
270
+
271
+ ### Running Tests
272
+
273
+ ```bash
274
+ pytest tests/
275
+ ```
276
+
277
+ ### Key Implementation Details
278
+
279
+ - Uses `prism_template2.pzfx` as XML structure blueprint
280
+ - XML Namespace: `{http://graphpad.com/prism/Prism.htm}`
281
+ - "Raveling" strategy: transforms DataFrames into flat structure via `melt()`, then rebuilds into nested XML hierarchy
282
+ - Automatic backup files created as `{filename}.backup{timestamp}` when loading existing files
283
+ - Logging enabled at INFO level for debugging table creation
284
+
285
+ ## Known Limitations
286
+
287
+ - No validation for duplicate table names
288
+ - Row mismatch warnings can occur with sparse data
289
+ - Template system hardcoded to specific Prism XML schema version
290
+ - No undo functionality - backup files are the safety net
291
+
292
+ ## License
293
+
294
+ MIT License
295
+
296
+ ## Contributing
297
+
298
+ Contributions welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,232 @@
1
+ # prismWriter
2
+
3
+ Python library and GUI for programmatically creating and manipulating GraphPad Prism (`.pzfx`) files. Convert pandas DataFrames into Prism's XML-based table format with complex grouping structures.
4
+
5
+ **Version:** 1.0.0
6
+
7
+ ## Features
8
+
9
+ - Convert pandas DataFrames to GraphPad Prism format
10
+ - Flexible grouping: main groups, sub-columns, row labels
11
+ - Multiple interfaces: Python API, Qt GUI, and Streamlit Web interface
12
+ - Load and modify existing `.pzfx` files
13
+ - Validate table structure with preview functionality
14
+ - Automatic backup creation when loading existing files
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install -e .
20
+ ```
21
+
22
+ ### Requirements
23
+
24
+ - Python >= 3.7
25
+ - numpy
26
+ - pandas
27
+ - PySide2 (for Qt GUI)
28
+ - streamlit >= 1.28.0 (for web interface)
29
+ - openpyxl (for Excel file support)
30
+
31
+ ## Quick Start
32
+
33
+ ### Python API
34
+
35
+ ```python
36
+ from prismWriter.prism_writer import PrismFile
37
+ import pandas as pd
38
+
39
+ # Create a new PrismFile
40
+ pf = PrismFile()
41
+
42
+ # Load your data
43
+ df = pd.read_csv('data.csv')
44
+
45
+ # Create a grouped table
46
+ pf.make_group_table(
47
+ group_name="MyTable",
48
+ group_values=df,
49
+ groupby="condition", # Main grouping column
50
+ cols=["value1", "value2"], # Data columns
51
+ subgroupby="replicate" # Sub-grouping
52
+ )
53
+
54
+ # Save to Prism file
55
+ pf.save("output.pzfx")
56
+ ```
57
+
58
+ ### Web Interface (Streamlit)
59
+
60
+ The easiest way to use prismWriter:
61
+
62
+ ```bash
63
+ streamlit run prismWriter/streamlit_app.py
64
+ ```
65
+
66
+ Or use the provided launch script:
67
+ - **Windows**: `run_web.bat`
68
+
69
+ Or after installation:
70
+ ```bash
71
+ prismwriter-web
72
+ ```
73
+
74
+ Features:
75
+ - Upload CSV/Excel files (with multi-sheet Excel support)
76
+ - Live data preview with automatic column type detection
77
+ - Interactive grouping configuration
78
+ - Preview table structure before generating
79
+ - Direct download of generated `.pzfx` files
80
+ - Load and view existing Prism files
81
+
82
+ ### Qt GUI
83
+
84
+ ```bash
85
+ python prismWriter/gui.py
86
+ ```
87
+
88
+ Or after installation:
89
+ ```bash
90
+ prismwriter-gui
91
+ ```
92
+
93
+ ## API Reference
94
+
95
+ ### PrismFile Class
96
+
97
+ ```python
98
+ pf = PrismFile(file=None) # Create new or load existing file
99
+ ```
100
+
101
+ **Methods:**
102
+ - `load(file_path, backup=True)` - Load an existing Prism file
103
+ - `smake_group_table(group_name, group_values, groupby=None, cols=None, subgroupby=None, rowgroupby=None, append=True)` - Create a grouped table
104
+ - `get_table_names()` - Get list of all table names
105
+ - `to_dataframe(table_name)` - Convert a table to pandas DataFrame
106
+ - `save(file_path)` - Save to file
107
+ - `write(file_path, xml_declaration=True, encoding='utf-8', pretty_print=True)` - Write with options
108
+ - `remove_table(table_name)` - Remove a table from the file
109
+
110
+ ### Grouping Parameters
111
+
112
+ - **`groupby`**: Main column grouping - creates separate Y-columns for each category
113
+ - **`subgroupby`**: Sub-columns within each Y-column (string for column name, or list for data columns)
114
+ - **`rowgroupby`**: Row labels on the vertical axis (string for column name, or list for data columns)
115
+ - **`cols`**: Data columns to include
116
+
117
+ **Note**: Use either column name (`subgroupby='condition'`) OR list of data columns (`subgroupby=['col1', 'col2']`) - not both.
118
+
119
+ ### Example Data Structure
120
+
121
+ ```python
122
+ import pandas as pd
123
+ from prismWriter.prism_writer import PrismFile
124
+
125
+ # Sample data
126
+ data = {
127
+ 'treatment': ['Control', 'Control', 'Drug A', 'Drug A'],
128
+ 'time': [0, 24, 0, 24],
129
+ 'replicate': [1, 1, 1, 1],
130
+ 'value': [10.5, 15.2, 12.1, 25.8]
131
+ }
132
+ df = pd.DataFrame(data)
133
+
134
+ # Create Prism file
135
+ pf = PrismFile()
136
+ pf.make_group_table(
137
+ group_name="Treatment_Data",
138
+ group_values=df,
139
+ groupby="treatment", # Separate columns for Control vs Drug A
140
+ rowgroupby="time", # Rows labeled by timepoint
141
+ cols=["value"] # Data column
142
+ )
143
+ pf.save("treatment_data.pzfx")
144
+ ```
145
+
146
+ ## Loading Existing Files
147
+
148
+ ```python
149
+ from prismWriter.prism_writer import PrismFile
150
+
151
+ # Load existing Prism file (creates automatic backup)
152
+ pf = PrismFile()
153
+ pf.load("existing.pzfx")
154
+
155
+ # Or load directly in constructor
156
+ pf = PrismFile(file="existing.pzfx")
157
+
158
+ # Get table names
159
+ tables = pf.get_table_names()
160
+ print(f"Found tables: {tables}")
161
+
162
+ # Convert table to DataFrame
163
+ df = pf.to_dataframe("TableName")
164
+
165
+ # Add new table
166
+ pf.make_group_table(
167
+ group_name="NewTable",
168
+ group_values=df,
169
+ groupby="category",
170
+ cols=["value"]
171
+ )
172
+
173
+ # Save (use write() for more options)
174
+ pf.save("modified.pzfx")
175
+ ```
176
+
177
+ ## Dependencies
178
+
179
+ - **Core**: pandas, numpy
180
+ - **GUI**: PySide2 (Qt bindings)
181
+ - **Web**: streamlit >= 1.28.0
182
+ - **Files**: openpyxl for Excel support
183
+
184
+ ## Project Structure
185
+
186
+ ```
187
+ prismWriter/
188
+ ├── prismWriter/
189
+ │ ├── __init__.py # Package exports
190
+ │ ├── prism_writer.py # Core XML generation engine
191
+ │ ├── gui.py # PySide2 Qt GUI wrapper
192
+ │ ├── streamlit_app.py # Streamlit web interface
193
+ │ ├── prism_template2.pzfx # XML structure template
194
+ │ └── schema/ # Prism XML schemas
195
+ ├── tests/
196
+ │ ├── test_prism_writer.py
197
+ │ ├── test_gui.py
198
+ │ └── test_data.csv
199
+ ├── pyproject.toml
200
+ └── README.md
201
+ ```
202
+
203
+ ## Development
204
+
205
+ ### Running Tests
206
+
207
+ ```bash
208
+ pytest tests/
209
+ ```
210
+
211
+ ### Key Implementation Details
212
+
213
+ - Uses `prism_template2.pzfx` as XML structure blueprint
214
+ - XML Namespace: `{http://graphpad.com/prism/Prism.htm}`
215
+ - "Raveling" strategy: transforms DataFrames into flat structure via `melt()`, then rebuilds into nested XML hierarchy
216
+ - Automatic backup files created as `{filename}.backup{timestamp}` when loading existing files
217
+ - Logging enabled at INFO level for debugging table creation
218
+
219
+ ## Known Limitations
220
+
221
+ - No validation for duplicate table names
222
+ - Row mismatch warnings can occur with sparse data
223
+ - Template system hardcoded to specific Prism XML schema version
224
+ - No undo functionality - backup files are the safety net
225
+
226
+ ## License
227
+
228
+ MIT License
229
+
230
+ ## Contributing
231
+
232
+ Contributions welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,13 @@
1
+ """
2
+ prismWriter - Python library for creating GraphPad Prism files
3
+
4
+ This library allows you to programmatically create and manipulate
5
+ GraphPad Prism (.pzfx) files from pandas DataFrames.
6
+ """
7
+
8
+ __version__ = "1.0.0"
9
+ __author__ = "smestern"
10
+
11
+ from .prism_writer import PrismFile
12
+
13
+ __all__ = ["PrismFile", "__version__"]