chromaquant 0.4.0__py3-none-any.whl → 0.5.0__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.
Files changed (63) hide show
  1. chromaquant/__init__.py +9 -2
  2. chromaquant/data/__init__.py +14 -0
  3. chromaquant/data/breakdown.py +430 -0
  4. chromaquant/data/dataset.py +195 -0
  5. chromaquant/data/table.py +412 -0
  6. chromaquant/data/value.py +215 -0
  7. chromaquant/formula/__init__.py +13 -0
  8. chromaquant/formula/base_formulas.py +168 -0
  9. chromaquant/formula/formula.py +507 -0
  10. chromaquant/import_local_packages.py +55 -0
  11. chromaquant/logging_and_handling.py +76 -0
  12. chromaquant/match/__init__.py +13 -0
  13. chromaquant/match/match.py +184 -0
  14. chromaquant/match/match_config.py +296 -0
  15. chromaquant/match/match_tools.py +154 -0
  16. chromaquant/{Quant → results}/__init__.py +2 -2
  17. chromaquant/results/reporting_tools.py +190 -0
  18. chromaquant/results/results.py +250 -0
  19. chromaquant/utils/__init__.py +14 -0
  20. chromaquant/utils/categories.py +127 -0
  21. chromaquant/utils/chemical_formulas.py +104 -0
  22. chromaquant/utils/dataframe_processing.py +222 -0
  23. chromaquant/utils/file_tools.py +100 -0
  24. chromaquant/utils/formula_tools.py +119 -0
  25. chromaquant-0.5.0.dist-info/METADATA +61 -0
  26. chromaquant-0.5.0.dist-info/RECORD +29 -0
  27. {chromaquant-0.4.0.dist-info → chromaquant-0.5.0.dist-info}/WHEEL +1 -1
  28. {chromaquant-0.4.0.dist-info → chromaquant-0.5.0.dist-info}/licenses/LICENSE.txt +1 -1
  29. chromaquant-0.5.0.dist-info/licenses/LICENSES_bundled.txt +251 -0
  30. chromaquant/Handle/__init__.py +0 -13
  31. chromaquant/Handle/fileChecks.py +0 -172
  32. chromaquant/Handle/handleDirectories.py +0 -89
  33. chromaquant/Hydro/__init__.py +0 -12
  34. chromaquant/Hydro/hydroMain.py +0 -496
  35. chromaquant/Manual/HydroUI.py +0 -418
  36. chromaquant/Manual/QuantUPP.py +0 -373
  37. chromaquant/Manual/Quantification.py +0 -1305
  38. chromaquant/Manual/__init__.py +0 -10
  39. chromaquant/Manual/duplicateMatch.py +0 -211
  40. chromaquant/Manual/fpm_match.py +0 -798
  41. chromaquant/Manual/label-type.py +0 -179
  42. chromaquant/Match/AutoFpmMatch.py +0 -1133
  43. chromaquant/Match/MatchSub/__init__.py +0 -13
  44. chromaquant/Match/MatchSub/matchTools.py +0 -282
  45. chromaquant/Match/MatchSub/peakTools.py +0 -259
  46. chromaquant/Match/__init__.py +0 -13
  47. chromaquant/Match/matchMain.py +0 -233
  48. chromaquant/Quant/AutoQuantification.py +0 -1329
  49. chromaquant/Quant/QuantSub/__init__.py +0 -15
  50. chromaquant/Quant/QuantSub/gasFID.py +0 -241
  51. chromaquant/Quant/QuantSub/gasTCD.py +0 -425
  52. chromaquant/Quant/QuantSub/liquidFID.py +0 -310
  53. chromaquant/Quant/QuantSub/parseTools.py +0 -162
  54. chromaquant/Quant/quantMain.py +0 -417
  55. chromaquant/UAPP/__init__.py +0 -12
  56. chromaquant/UAPP/uappMain.py +0 -427
  57. chromaquant/__main__.py +0 -526
  58. chromaquant/oldui.py +0 -492
  59. chromaquant/properties.json +0 -4
  60. chromaquant-0.4.0.dist-info/METADATA +0 -189
  61. chromaquant-0.4.0.dist-info/RECORD +0 -38
  62. chromaquant-0.4.0.dist-info/entry_points.txt +0 -2
  63. chromaquant-0.4.0.dist-info/licenses/LICENSES_bundled.txt +0 -1035
@@ -1,233 +0,0 @@
1
- """
2
-
3
- COPYRIGHT STATEMENT:
4
-
5
- ChromaQuant – A quantification software for complex gas chromatographic data
6
-
7
- Copyright (c) 2024, by Julia Hancock
8
- Affiliation: Dr. Julie Elaine Rorrer
9
- URL: https://www.rorrerlab.com/
10
-
11
- License: BSD 3-Clause License
12
-
13
- ---
14
-
15
- SCRIPT THAT MATCHES FID AND MS PEAKS
16
-
17
- Julia Hancock
18
- Started 12/10/2023
19
-
20
- """
21
- """ PACKAGES """
22
- import sys
23
- import pandas as pd
24
- import os
25
- from molmass import Formula
26
- import math
27
- import numpy as np
28
- from chemformula import ChemFormula
29
- import json
30
- from datetime import datetime
31
- import logging
32
- import scipy
33
- import importlib.util
34
-
35
- """ DIRECTORIES (MANUAL) """
36
- """
37
- testPath = "/Users/connards/Desktop/University/Rorrer Lab/Scripts/chromaquant/src/chromaquant/"
38
- #Define file directory
39
- D_files = "/Users/connards/Documents/ChromaQuant"
40
-
41
- #Define app directory
42
- D_app = "/Users/connards/Desktop/University/Rorrer Lab/Scripts/chromaquant/src/chromaquant"
43
-
44
- #Define resources directory
45
- D_rsc = os.path.join(D_files,'resources')
46
-
47
- #Define theme directory
48
- D_theme = os.path.join(D_rsc,'forest','forest-light.tcl')
49
-
50
- #Define response factors directory
51
- D_rf = os.path.join(D_files,'response-factors')
52
-
53
- #Define data directory
54
- D_data = os.path.join(D_files,'data')
55
-
56
- #Define images directory
57
- D_img = os.path.join(D_files,'images')
58
-
59
- directories = {'files':D_files,'resources':D_rsc,'theme':D_theme,'rf':D_rf,'data':D_data,'images':D_img}
60
- """
61
-
62
- """ VARIABLES FOR TESTING"""
63
-
64
- #sname = 'example2'
65
- #sphase = 'L'
66
-
67
- """ LOCAL PACKAGES """
68
-
69
- #Get package directory
70
- app_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
71
-
72
- #Get absolute directories for subpackages
73
- subpack_dir = {'Handle':os.path.join(app_dir,'Handle','__init__.py'),
74
- 'Manual':os.path.join(app_dir,'Manual','__init__.py'),
75
- 'MatchSub':os.path.join(app_dir,'Match','MatchSub','__init__.py')}
76
-
77
- #Define function to import from path
78
- def import_from_path(module_name,path):
79
- #Define spec
80
- spec = importlib.util.spec_from_file_location(module_name,path)
81
- #Define modules
82
- module = importlib.util.module_from_spec(spec)
83
- #Expand sys.modules dict
84
- sys.modules[module_name] = module
85
- #Load module
86
- spec.loader.exec_module(module)
87
- return module
88
-
89
- #Import all local packages
90
- hd = import_from_path("hd",subpack_dir['Handle'])
91
- mn = import_from_path("mn",subpack_dir['Manual'])
92
- mtsb = import_from_path("mtsb",subpack_dir['MatchSub'])
93
-
94
- """ FIT DEFINITION FUNCTION """
95
-
96
- #Function that defines fit lambda based on parameters in analysis-config
97
- def getFitLambda(fit_param):
98
- """ This function requires a dictionary of polynomial parameters, with keys "a", "b", etc. """
99
-
100
- if fit_param['fit-type'] == "First Order":
101
-
102
- fit = lambda FID_RT: fit_param['a']*FID_RT + fit_param['b']
103
-
104
- elif fit_param['fit-type'] == "Third Order":
105
-
106
- fit = lambda FID_RT: fit_param['a']*FID_RT**3 + fit_param['b']*FID_RT**2 + fit_param['c']*FID_RT + fit_param['d']
107
-
108
- else:
109
-
110
- fit = None
111
-
112
- return fit
113
-
114
- """ MATCH FUNCTION """
115
- def mainMatch(sname,sphase,model):
116
-
117
- print("[matchMain] Beginning match...")
118
-
119
- #Get current time
120
- print("[matchMain] Getting current time...")
121
- now = datetime.now()
122
-
123
- """ DIRECTORIES """
124
- print("[matchMain] Getting directories...")
125
- #Get directories from handling script
126
- directories = hd.handle(app_dir)
127
-
128
- #Data file log directory
129
- directories['log'] = os.path.join(directories['data'],sname,'log')
130
-
131
- #Data file breakdowns directory
132
- directories['break'] = os.path.join(directories['data'],sname,'breakdowns')
133
-
134
- #Raw data file directory
135
- directories['raw'] = os.path.join(directories['data'],sname,'raw data')
136
-
137
- """ ANALYSIS CONFIGURATION """
138
- print("[matchMain] Interpreting analysis configuration...")
139
- #Read analysis configuration file
140
- with open(os.path.join(directories['resources'],'analysis-config.json')) as f:
141
- analysis_config = json.load(f)
142
-
143
- #Extract analysis configuration info
144
- #This dictionary contain lists of substrings to be checked against compound name strings to
145
- #assign a compound type
146
-
147
- #Six compound types exist: linear alkanes (L), branched alkanes (B), aromatics (A), cycloalkanes (C),
148
- #alkenes/alkynes (E), and other (O)
149
-
150
- #Each compound type abbreviation will have an entry in the dictionary corresponding to a list of
151
- #substrings to be checked against a compound name string
152
-
153
- contains = analysis_config["CT-assign-contains"]
154
-
155
- #Tuple of contains keys in order of priority
156
- keyloop = analysis_config["CT-assign-keyloop"]
157
-
158
- #Tuple of elements to be excluded and automatically labelled as 'O'
159
- element_exclude = analysis_config["CT-assign-element-exclude"]
160
-
161
- #File suffixes to add to form data filenames
162
- file_suffix = analysis_config["file-suffix"]
163
-
164
- #Fit parameters for matching FID and MS accortding to polynomial fit
165
- match_fit_parameters = analysis_config["match-fit-parameters"]
166
-
167
- #Acceptable peak errors for matching
168
- peak_errors = analysis_config["peak-errors"]
169
-
170
- """ RUN FUNCTIONS """
171
- print("[matchMain] Running match functions...")
172
-
173
- #Run the file naming function – this function will create paths to all relevant files for matching FID and MS peaks according to sample name and phase
174
- print("[matchMain] Getting data pths...")
175
- paths = hd.fileNamer(sname,sphase,file_suffix,directories['raw'])
176
-
177
- # Run the file checking function – this function will search for an existing FIDpMS file, creating one if it does not exist.
178
- # It will then read the file as a pandas DataFrame. The tf Boolean describes whether or not there exist manually-matched peaks.
179
- print("[matchMain] Checking for FIDpMS file...")
180
- fpmDF, tf = hd.checkFile(paths[2],paths[0])
181
-
182
- # Import MS UPP data
183
- print("[matchMain] Importing mass spectrometry data...")
184
- mDF = pd.read_csv(paths[1])
185
-
186
- # Get only relevant columns of MS UPP data
187
- print("[matchMain] Cleaning mass spectrometry data...")
188
- mDF = mDF.loc[:,['Component RT','Compound Name','Formula','Match Factor']]
189
-
190
- # Third order function for testing
191
- #fit = lambda FID_RT: 0.0252*FID_RT**3 - 0.5274*FID_RT**2 + 4.8067*FID_RT - 3.0243
192
-
193
- # Get fit function using analysis-config
194
- print("[matchMain] Extracting match fit parameters...")
195
- fit = getFitLambda(match_fit_parameters)
196
-
197
- #If model is polynomial...
198
- if model == 'P':
199
- # Run the matching function – this function takes a passed function describing an estimated relationship between MS RT's and FID RT's and matches peaks.
200
- # Function can be of any form as long as it returns a floating point value for the estimated MS RT
201
- print("[matchMain] Matching peaks according to polynomial fit...")
202
- fpmDF = mtsb.matchPeaks(fpmDF,mDF,fit,peak_errors['peak-error-third'])
203
-
204
- #If model is retention time...
205
- if model == 'R':
206
- # Run the matching function – this function takes a passed function describing an estimated relationship between MS RT's and FID RT's and matches peaks.
207
- # Function can be of any form as long as it returns a floating point value for the estimated MS RT
208
- print("[matchMain] Matching peaks by retention time...")
209
- fpmDF = mtsb.matchRT(fpmDF,mDF,peakError=peak_errors['peak-error-RT'])
210
- fpmDF = mtsb.matchPeaks(fpmDF,mDF,fit,peak_errors['peak-error-third'])
211
-
212
- # Run the compound type abbreviation assignment function – this function takes a passed matched FID and MS list and assigns
213
- # compound type abbreviations to each matched entry
214
- print("[matchMain] Assigning compound types...")
215
- fpmDF = mtsb.ctaAssign(fpmDF, contains, keyloop, element_exclude)
216
-
217
- print("[matchMain] Handling duplicates...")
218
- #Run the duplicate handling function
219
- fpmDF = mtsb.duplicateHandle(fpmDF)
220
-
221
- print("[AutoFpmMatch] Saving results...")
222
- #Save the FIDpMS data
223
- fpmDF.to_csv(paths[2],index=False)
224
-
225
- #Print computation time
226
- compTime = datetime.now().timestamp()*1000 - now.timestamp()*1000
227
- print("[matchMain] Time taken: {:.3f} ms".format(compTime))
228
-
229
- #Close main function by returning
230
- return None
231
-
232
- #For testing
233
- #mainMatch('example2','L','R')