digichem-core 6.10.3__py3-none-any.whl → 7.0.1__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.
- digichem/__init__.py +2 -2
- digichem/config/base.py +11 -2
- digichem/config/util.py +3 -2
- digichem/file/prattle.py +9 -7
- digichem/image/spectroscopy.py +17 -4
- digichem/input/__init__.py +1 -1
- digichem/input/digichem_input.py +39 -34
- digichem/parse/base.py +8 -6
- digichem/parse/cclib.py +10 -6
- digichem/parse/dump.py +31 -35
- digichem/parse/gaussian.py +2 -2
- digichem/parse/turbomole.py +2 -3
- digichem/parse/util.py +6 -5
- digichem/result/alignment/base.py +2 -2
- digichem/result/atom.py +4 -4
- digichem/result/base.py +53 -5
- digichem/result/dipole_moment.py +1 -1
- digichem/result/emission.py +5 -5
- digichem/result/energy.py +8 -8
- digichem/result/excited_state.py +20 -13
- digichem/result/ground_state.py +2 -2
- digichem/result/metadata.py +12 -21
- digichem/result/nmr.py +37 -28
- digichem/result/orbital.py +3 -3
- digichem/result/result.py +14 -14
- digichem/result/soc.py +3 -3
- digichem/result/spectroscopy.py +5 -4
- digichem/result/tdm.py +5 -5
- digichem/result/vibration.py +15 -6
- digichem/test/test_input.py +17 -3
- digichem/test/test_parsing.py +9 -0
- digichem/test/test_prattle.py +31 -2
- {digichem_core-6.10.3.dist-info → digichem_core-7.0.1.dist-info}/METADATA +1 -1
- {digichem_core-6.10.3.dist-info → digichem_core-7.0.1.dist-info}/RECORD +37 -37
- {digichem_core-6.10.3.dist-info → digichem_core-7.0.1.dist-info}/WHEEL +0 -0
- {digichem_core-6.10.3.dist-info → digichem_core-7.0.1.dist-info}/licenses/COPYING.md +0 -0
- {digichem_core-6.10.3.dist-info → digichem_core-7.0.1.dist-info}/licenses/LICENSE +0 -0
digichem/result/nmr.py
CHANGED
|
@@ -22,7 +22,7 @@ class NMR_spectrometer(Result_object):
|
|
|
22
22
|
A class for generating NMR spectra on-demand.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
|
-
def __init__(self, nmr_results, frequency = 300, fwhm = 0.001, resolution = 0.001, cutoff = 0.01, coupling_filter = 0.1, pre_merge = 0.01, post_merge = None, isotope_options = None):
|
|
25
|
+
def __init__(self, nmr_results, frequency = 300, fwhm = 0.001, resolution = 0.001, cutoff = 0.01, y_filter = 1e-6, coupling_filter = 0.1, pre_merge = 0.01, post_merge = None, isotope_options = None):
|
|
26
26
|
"""
|
|
27
27
|
Constructor for NMR_spectrometer.
|
|
28
28
|
|
|
@@ -39,6 +39,7 @@ class NMR_spectrometer(Result_object):
|
|
|
39
39
|
self.fwhm = fwhm
|
|
40
40
|
self.gaussian_resolution = resolution
|
|
41
41
|
self.gaussian_cutoff = cutoff
|
|
42
|
+
self.y_filter = y_filter
|
|
42
43
|
self.coupling_filter = coupling_filter
|
|
43
44
|
self._isotope_options = isotope_options if isotope_options is not None else {}
|
|
44
45
|
|
|
@@ -48,6 +49,7 @@ class NMR_spectrometer(Result_object):
|
|
|
48
49
|
"pre_merge": self.pre_merge,
|
|
49
50
|
"post_merge": self.post_merge,
|
|
50
51
|
"fwhm": self.fwhm,
|
|
52
|
+
"y_filter": self.y_filter,
|
|
51
53
|
"gaussian_resolution": self.gaussian_resolution,
|
|
52
54
|
"coupling_filter": self.coupling_filter,
|
|
53
55
|
"gaussian_cutoff": self.gaussian_cutoff,
|
|
@@ -66,6 +68,7 @@ class NMR_spectrometer(Result_object):
|
|
|
66
68
|
fwhm = options['nmr']['fwhm'],
|
|
67
69
|
resolution = options['nmr']['gaussian_resolution'],
|
|
68
70
|
cutoff = options['nmr']['gaussian_cutoff'],
|
|
71
|
+
y_filter = options['nmr']['y_filter'],
|
|
69
72
|
coupling_filter = options['nmr']['coupling_filter'],
|
|
70
73
|
pre_merge = options['nmr']['pre_merge'],
|
|
71
74
|
post_merge = options['nmr']['post_merge'],
|
|
@@ -160,6 +163,9 @@ class NMR_spectrometer(Result_object):
|
|
|
160
163
|
|
|
161
164
|
return False
|
|
162
165
|
|
|
166
|
+
def __iter__(self):
|
|
167
|
+
return iter(self.available.keys())
|
|
168
|
+
|
|
163
169
|
def __getitem__(self, item):
|
|
164
170
|
"""
|
|
165
171
|
Generate a spectrum for a given shortcode.
|
|
@@ -170,7 +176,7 @@ class NMR_spectrometer(Result_object):
|
|
|
170
176
|
# match the interface.
|
|
171
177
|
return lambda digichem_options: self.spectrum(*self.parse_shortcode(item))
|
|
172
178
|
|
|
173
|
-
def
|
|
179
|
+
def _get_dump_(self):
|
|
174
180
|
"""
|
|
175
181
|
Method used to get a dictionary used to generate on-demand values for dumping.
|
|
176
182
|
|
|
@@ -180,7 +186,7 @@ class NMR_spectrometer(Result_object):
|
|
|
180
186
|
"""
|
|
181
187
|
return self
|
|
182
188
|
|
|
183
|
-
def
|
|
189
|
+
def _dump_(self, digichem_options, all):
|
|
184
190
|
# Return a list of possible spectra we can generate.
|
|
185
191
|
return {
|
|
186
192
|
"codes": list(self.available.keys()),
|
|
@@ -208,7 +214,7 @@ class NMR_spectrometer(Result_object):
|
|
|
208
214
|
|
|
209
215
|
# The total spectrum takes all simulated peaks.
|
|
210
216
|
# These are grouped by atom_group, flatten this list before passing to spectroscopy.
|
|
211
|
-
graph = Combined_graph.from_nmr(grouped_peaks, isotope_options['fwhm'], isotope_options['gaussian_resolution'], isotope_options['gaussian_cutoff'])
|
|
217
|
+
graph = Combined_graph.from_nmr(grouped_peaks, isotope_options['fwhm'], isotope_options['gaussian_resolution'], isotope_options['gaussian_cutoff'], filter = isotope_options['y_filter'])
|
|
212
218
|
|
|
213
219
|
return graph
|
|
214
220
|
|
|
@@ -489,6 +495,8 @@ class NMR_list(Result_container):
|
|
|
489
495
|
self.options = options
|
|
490
496
|
self.groups = self.group()
|
|
491
497
|
self.spectrometer = NMR_spectrometer.from_options(self.groups, options = options)
|
|
498
|
+
# This is used as part of the dump mechanic.
|
|
499
|
+
self.spectrum = self.spectrometer
|
|
492
500
|
|
|
493
501
|
@classmethod
|
|
494
502
|
def from_parser(self, parser):
|
|
@@ -599,14 +607,15 @@ class NMR_list(Result_container):
|
|
|
599
607
|
|
|
600
608
|
return nmr_object_groups
|
|
601
609
|
|
|
602
|
-
def
|
|
610
|
+
def _dump_(self, digichem_options, all):
|
|
603
611
|
"""
|
|
604
612
|
Dump this list of NMR results to a list of primitive types.
|
|
605
613
|
"""
|
|
606
614
|
grouping = self.groups
|
|
607
615
|
dump_dict = {
|
|
608
|
-
"values": super().
|
|
609
|
-
"groups": {group_id.label: group.dump(digichem_options) for group_id, group in grouping.items()},
|
|
616
|
+
"values": super()._dump_(digichem_options, all),
|
|
617
|
+
"groups": {group_id.label: group.dump(digichem_options, all) for group_id, group in grouping.items()},
|
|
618
|
+
"spectrum": self.spectrometer.dump(digichem_options, all)
|
|
610
619
|
}
|
|
611
620
|
return dump_dict
|
|
612
621
|
|
|
@@ -620,17 +629,17 @@ class NMR_list(Result_container):
|
|
|
620
629
|
"""
|
|
621
630
|
return self(NMR.list_from_dump(data['values'], result_set, options), atoms = result_set.atoms, options = options)
|
|
622
631
|
|
|
623
|
-
def
|
|
624
|
-
|
|
625
|
-
|
|
632
|
+
# def _get_dump_(self):
|
|
633
|
+
# """
|
|
634
|
+
# Method used to get a dictionary used to generate on-demand values for dumping.
|
|
626
635
|
|
|
627
|
-
|
|
636
|
+
# This functionality is useful for hiding expense properties from the normal dump process, while still exposing them when specifically requested.
|
|
628
637
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
638
|
+
# Each key in the returned dict is the name of a dumpable item, each value is a function to call with digichem_options as its only param.
|
|
639
|
+
# """
|
|
640
|
+
# return {
|
|
641
|
+
# "spectrum": lambda digichem_options: self.spectrometer
|
|
642
|
+
# }
|
|
634
643
|
|
|
635
644
|
|
|
636
645
|
class NMR_group(Result_object, Floatable_mixin):
|
|
@@ -649,7 +658,7 @@ class NMR_group(Result_object, Floatable_mixin):
|
|
|
649
658
|
def __float__(self):
|
|
650
659
|
return float(self.shielding)
|
|
651
660
|
|
|
652
|
-
def
|
|
661
|
+
def _dump_(self, digichem_options, all):
|
|
653
662
|
"""
|
|
654
663
|
Get a representation of this result object in primitive format.
|
|
655
664
|
"""
|
|
@@ -661,7 +670,7 @@ class NMR_group(Result_object, Floatable_mixin):
|
|
|
661
670
|
"value": self.shielding
|
|
662
671
|
},
|
|
663
672
|
#"couplings": [{"groups": [group.label for group in coupling['groups']], "isotopes": list(coupling["isotopes"]), "total": coupling["total"]} for coupling in self.couplings],
|
|
664
|
-
"couplings": [coupling.dump(digichem_options) for coupling in self.couplings]
|
|
673
|
+
"couplings": [coupling.dump(digichem_options, all) for coupling in self.couplings]
|
|
665
674
|
}
|
|
666
675
|
|
|
667
676
|
class NMR_group_spin_coupling(Result_object):
|
|
@@ -686,7 +695,7 @@ class NMR_group_spin_coupling(Result_object):
|
|
|
686
695
|
"""
|
|
687
696
|
return sum([coupling.isotropic('total') for coupling in self.couplings]) / len(self.couplings)
|
|
688
697
|
|
|
689
|
-
def
|
|
698
|
+
def _dump_(self, digichem_options, all):
|
|
690
699
|
"""
|
|
691
700
|
Get a representation of this result object in primitive format.
|
|
692
701
|
"""
|
|
@@ -697,7 +706,7 @@ class NMR_group_spin_coupling(Result_object):
|
|
|
697
706
|
"units": "Hz",
|
|
698
707
|
"value": float(self.total),
|
|
699
708
|
}
|
|
700
|
-
#"couplings": [coupling.dump(digichem_options) for coupling in self.couplings]
|
|
709
|
+
#"couplings": [coupling.dump(digichem_options, all) for coupling in self.couplings]
|
|
701
710
|
}
|
|
702
711
|
|
|
703
712
|
def other(self, atom_group):
|
|
@@ -819,14 +828,14 @@ class NMR(Result_object, Floatable_mixin):
|
|
|
819
828
|
]
|
|
820
829
|
|
|
821
830
|
|
|
822
|
-
def
|
|
831
|
+
def _dump_(self, digichem_options, all):
|
|
823
832
|
"""
|
|
824
833
|
Get a representation of this result object in primitive format.
|
|
825
834
|
"""
|
|
826
835
|
return {
|
|
827
836
|
"atom": self.atom.label,
|
|
828
|
-
"shielding": self.shielding.dump(digichem_options),
|
|
829
|
-
"couplings": self.couplings.dump(digichem_options)
|
|
837
|
+
"shielding": self.shielding.dump(digichem_options, all),
|
|
838
|
+
"couplings": self.couplings.dump(digichem_options, all)
|
|
830
839
|
}
|
|
831
840
|
|
|
832
841
|
|
|
@@ -867,7 +876,7 @@ class NMR_tensor_ABC(Result_object):
|
|
|
867
876
|
eigenvalues = self.eigenvalues(tensor)
|
|
868
877
|
return sum(eigenvalues) / len(eigenvalues)
|
|
869
878
|
|
|
870
|
-
def
|
|
879
|
+
def _dump_(self, digichem_options, all):
|
|
871
880
|
"""
|
|
872
881
|
Get a representation of this result object in primitive format.
|
|
873
882
|
"""
|
|
@@ -931,7 +940,7 @@ class NMR_shielding(NMR_tensor_ABC):
|
|
|
931
940
|
|
|
932
941
|
return shieldings
|
|
933
942
|
|
|
934
|
-
def
|
|
943
|
+
def _dump_(self, digichem_options, all):
|
|
935
944
|
"""
|
|
936
945
|
Get a representation of this result object in primitive format.
|
|
937
946
|
"""
|
|
@@ -939,7 +948,7 @@ class NMR_shielding(NMR_tensor_ABC):
|
|
|
939
948
|
"reference": self.reference,
|
|
940
949
|
}
|
|
941
950
|
|
|
942
|
-
dump_dic.update(super().
|
|
951
|
+
dump_dic.update(super()._dump_(digichem_options, all))
|
|
943
952
|
return dump_dic
|
|
944
953
|
|
|
945
954
|
@classmethod
|
|
@@ -1073,7 +1082,7 @@ class NMR_spin_coupling(NMR_tensor_ABC):
|
|
|
1073
1082
|
in data
|
|
1074
1083
|
]
|
|
1075
1084
|
|
|
1076
|
-
def
|
|
1085
|
+
def _dump_(self, digichem_options, all):
|
|
1077
1086
|
"""
|
|
1078
1087
|
Get a representation of this result object in primitive format.
|
|
1079
1088
|
"""
|
|
@@ -1082,5 +1091,5 @@ class NMR_spin_coupling(NMR_tensor_ABC):
|
|
|
1082
1091
|
"isotopes": (self.isotopes[0], self.isotopes[1]),
|
|
1083
1092
|
}
|
|
1084
1093
|
|
|
1085
|
-
dump_dic.update(super().
|
|
1094
|
+
dump_dic.update(super()._dump_(digichem_options, all))
|
|
1086
1095
|
return dump_dic
|
digichem/result/orbital.py
CHANGED
|
@@ -238,7 +238,7 @@ class Molecular_orbital_list(Result_container):
|
|
|
238
238
|
|
|
239
239
|
return self(cls.list_from_dump(data['values'], result_set, options))
|
|
240
240
|
|
|
241
|
-
def
|
|
241
|
+
def _dump_(self, digichem_options, all):
|
|
242
242
|
"""
|
|
243
243
|
Get a representation of this result object in primitive format.
|
|
244
244
|
"""
|
|
@@ -249,7 +249,7 @@ class Molecular_orbital_list(Result_container):
|
|
|
249
249
|
},
|
|
250
250
|
"num_occupied": len(self.occupied),
|
|
251
251
|
"num_virtual": len(self.virtual),
|
|
252
|
-
"values": super().
|
|
252
|
+
"values": super()._dump_(digichem_options, all),
|
|
253
253
|
"spin_type": self.safe_get("spin_type")
|
|
254
254
|
}
|
|
255
255
|
# # Add HOMO and LUMO
|
|
@@ -498,7 +498,7 @@ class Molecular_orbital(Result_object, Floatable_mixin):
|
|
|
498
498
|
# The index used to access data from cclib (which always has two lists, one for alpha one for beta).
|
|
499
499
|
ccdata_index = 0
|
|
500
500
|
|
|
501
|
-
def
|
|
501
|
+
def _dump_(self, digichem_options, all):
|
|
502
502
|
"""
|
|
503
503
|
Get a representation of this result object in primitive format.
|
|
504
504
|
"""
|
digichem/result/result.py
CHANGED
|
@@ -221,7 +221,7 @@ class Result_set(Result_object):
|
|
|
221
221
|
# No S1 available.
|
|
222
222
|
return None
|
|
223
223
|
|
|
224
|
-
def
|
|
224
|
+
def _dump_(self, digichem_options, all):
|
|
225
225
|
"Dump the data contained in this result set, serialising it to a hierarchy of dicts that can be saved in various formats."
|
|
226
226
|
# Start with our DB ID if we have one.
|
|
227
227
|
dump_dic = {}
|
|
@@ -229,19 +229,19 @@ class Result_set(Result_object):
|
|
|
229
229
|
dump_dic['_id'] = self._id
|
|
230
230
|
|
|
231
231
|
dump_dic.update({
|
|
232
|
-
"metadata": self.metadata.dump(digichem_options),
|
|
233
|
-
"ground_state": self.ground_state.dump(digichem_options) if self.ground_state is not None else None,
|
|
234
|
-
"energies": self.energies.dump(digichem_options),
|
|
235
|
-
"atoms": self.atoms.dump(digichem_options),
|
|
236
|
-
"raw_atoms": self.raw_atoms.dump(digichem_options),
|
|
237
|
-
"orbitals": self.orbitals.dump(digichem_options),
|
|
238
|
-
"beta_orbitals": self.beta_orbitals.dump(digichem_options),
|
|
239
|
-
"pdm": self.pdm.dump(digichem_options) if self.pdm is not None else None,
|
|
240
|
-
"excited_states": self.excited_states.dump(digichem_options),
|
|
241
|
-
"soc": self.soc.dump(digichem_options),
|
|
242
|
-
"vibrations": self.vibrations.dump(digichem_options),
|
|
243
|
-
"nmr": self.nmr.dump(digichem_options),
|
|
244
|
-
"emission": self.emission.dump(digichem_options)
|
|
232
|
+
"metadata": self.metadata.dump(digichem_options, all),
|
|
233
|
+
"ground_state": self.ground_state.dump(digichem_options, all) if self.ground_state is not None else None,
|
|
234
|
+
"energies": self.energies.dump(digichem_options, all),
|
|
235
|
+
"atoms": self.atoms.dump(digichem_options, all),
|
|
236
|
+
"raw_atoms": self.raw_atoms.dump(digichem_options, all),
|
|
237
|
+
"orbitals": self.orbitals.dump(digichem_options, all),
|
|
238
|
+
"beta_orbitals": self.beta_orbitals.dump(digichem_options, all),
|
|
239
|
+
"pdm": self.pdm.dump(digichem_options, all) if self.pdm is not None else None,
|
|
240
|
+
"excited_states": self.excited_states.dump(digichem_options, all),
|
|
241
|
+
"soc": self.soc.dump(digichem_options, all),
|
|
242
|
+
"vibrations": self.vibrations.dump(digichem_options, all),
|
|
243
|
+
"nmr": self.nmr.dump(digichem_options, all),
|
|
244
|
+
"emission": self.emission.dump(digichem_options, all)
|
|
245
245
|
})
|
|
246
246
|
|
|
247
247
|
return dump_dic
|
digichem/result/soc.py
CHANGED
|
@@ -104,7 +104,7 @@ class Spin_orbit_coupling(Result_object, Floatable_mixin):
|
|
|
104
104
|
self.zero = zero
|
|
105
105
|
self.negative_one = negative_one
|
|
106
106
|
|
|
107
|
-
def
|
|
107
|
+
def _dump_(self, digichem_options, all):
|
|
108
108
|
"""
|
|
109
109
|
Get a representation of this result object in primitive format.
|
|
110
110
|
"""
|
|
@@ -235,11 +235,11 @@ class Total_spin_orbit_coupling(Spin_orbit_coupling):
|
|
|
235
235
|
"""
|
|
236
236
|
return "<{}|Hso|{}> (cm-1): {:10.5f}".format(self.singlet_state.state_symbol, self.triplet_state.state_symbol, self.root_sum_square)
|
|
237
237
|
|
|
238
|
-
def
|
|
238
|
+
def _dump_(self, digichem_options, all):
|
|
239
239
|
"""
|
|
240
240
|
Get a representation of this result object in primitive format.
|
|
241
241
|
"""
|
|
242
|
-
dump_dic = super().
|
|
242
|
+
dump_dic = super()._dump_(digichem_options, all)
|
|
243
243
|
# Remove elements.
|
|
244
244
|
del(dump_dic['soc'])
|
|
245
245
|
return dump_dic
|
digichem/result/spectroscopy.py
CHANGED
|
@@ -112,7 +112,7 @@ class Spectroscopy_graph(Spectroscopy_graph_abc):
|
|
|
112
112
|
For generating pictures of these graphs, see digichem.image.spectroscopy
|
|
113
113
|
"""
|
|
114
114
|
|
|
115
|
-
def __init__(self, coordinates, fwhm, resolution = 1, cutoff = 0.01, adjust_zero = False):
|
|
115
|
+
def __init__(self, coordinates, fwhm, resolution = 1, cutoff = 0.01, filter = 1e-6, adjust_zero = False):
|
|
116
116
|
"""
|
|
117
117
|
Constructor for Spectroscopy_graph objects
|
|
118
118
|
|
|
@@ -137,6 +137,7 @@ class Spectroscopy_graph(Spectroscopy_graph_abc):
|
|
|
137
137
|
self.fwhm = fwhm
|
|
138
138
|
self.resolution = resolution
|
|
139
139
|
self.cutoff = cutoff
|
|
140
|
+
self.filter = filter
|
|
140
141
|
|
|
141
142
|
# Caches
|
|
142
143
|
self._gaussians = []
|
|
@@ -187,7 +188,7 @@ class Spectroscopy_graph(Spectroscopy_graph_abc):
|
|
|
187
188
|
# Next, determine the limits in which we'll plot.
|
|
188
189
|
limits = self.gaussian_limits()
|
|
189
190
|
|
|
190
|
-
# Apply rounding to nearest resolution step cover up floating-point errors.
|
|
191
|
+
# Apply rounding to nearest resolution step to cover up floating-point errors.
|
|
191
192
|
points = [self.resolution *round(point / self.resolution) for point in numpy.linspace(*limits)]
|
|
192
193
|
|
|
193
194
|
# Plot and return.
|
|
@@ -202,7 +203,7 @@ class Spectroscopy_graph(Spectroscopy_graph_abc):
|
|
|
202
203
|
)
|
|
203
204
|
)
|
|
204
205
|
gaussians = [
|
|
205
|
-
[(x, self.gaussian(a, b, c, x))
|
|
206
|
+
[(x, y) for x in points if (y := self.gaussian(a, b, c, x)) >= self.filter]
|
|
206
207
|
for b, a in self.base_coordinates
|
|
207
208
|
]
|
|
208
209
|
|
|
@@ -232,7 +233,7 @@ class Spectroscopy_graph(Spectroscopy_graph_abc):
|
|
|
232
233
|
# Plot and return.
|
|
233
234
|
digichem.log.get_logger().debug("Plotting cumulative gaussian peaks from {:0.2f} to {:0.2f} with a step size of {} ({} total points) for {} peaks ({} total iterations)".format(limits[0], limits[1], self.resolution, limits[2], len(self.base_coordinates), len(self.base_coordinates) * limits[2]))
|
|
234
235
|
gaussian = [
|
|
235
|
-
(x, sum((self.gaussian(a, b, c, x) for b, a in self.base_coordinates)))
|
|
236
|
+
(x, y) for x in points if ( y := sum((self.gaussian(a, b, c, x) for b, a in self.base_coordinates))) > self.filter
|
|
236
237
|
]
|
|
237
238
|
|
|
238
239
|
return gaussian
|
digichem/result/tdm.py
CHANGED
|
@@ -42,12 +42,12 @@ class Transition_dipole_moment_ABC(Dipole_moment_ABC):
|
|
|
42
42
|
atoms = result_set.atoms
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
-
def
|
|
45
|
+
def _dump_(self, digichem_options, all):
|
|
46
46
|
"""
|
|
47
47
|
Get a representation of this result object in primitive format.
|
|
48
48
|
"""
|
|
49
49
|
data = {'state_level': self.state_level}
|
|
50
|
-
data.update(super().
|
|
50
|
+
data.update(super()._dump_(digichem_options, all))
|
|
51
51
|
return data
|
|
52
52
|
|
|
53
53
|
@property
|
|
@@ -221,13 +221,13 @@ class Transition_dipole_moment(Result_object):
|
|
|
221
221
|
|
|
222
222
|
return self(electric = electric, magnetic = magnetic)
|
|
223
223
|
|
|
224
|
-
def
|
|
224
|
+
def _dump_(self, digichem_options, all):
|
|
225
225
|
"""
|
|
226
226
|
Get a representation of this result object in primitive format.
|
|
227
227
|
"""
|
|
228
228
|
return {
|
|
229
|
-
"electric": self.electric.dump(digichem_options) if self.electric is not None else None,
|
|
230
|
-
"magnetic": self.magnetic.dump(digichem_options) if self.magnetic is not None else None,
|
|
229
|
+
"electric": self.electric.dump(digichem_options, all) if self.electric is not None else None,
|
|
230
|
+
"magnetic": self.magnetic.dump(digichem_options, all) if self.magnetic is not None else None,
|
|
231
231
|
"angle": {
|
|
232
232
|
"value": float(self.angle().angle) if self.electric is not None and self.magnetic is not None else None,
|
|
233
233
|
"units": self.angle().units if self.electric is not None and self.magnetic is not None else None,
|
digichem/result/vibration.py
CHANGED
|
@@ -43,7 +43,7 @@ class Vibrations_list(Result_container, Unmergeable_container_mixin):
|
|
|
43
43
|
"""
|
|
44
44
|
return self(Vibration.list_from_parser(parser))
|
|
45
45
|
|
|
46
|
-
def
|
|
46
|
+
def _get_dump_(self):
|
|
47
47
|
"""
|
|
48
48
|
Method used to get a dictionary used to generate on-demand values for dumping.
|
|
49
49
|
|
|
@@ -51,7 +51,9 @@ class Vibrations_list(Result_container, Unmergeable_container_mixin):
|
|
|
51
51
|
|
|
52
52
|
Each key in the returned dict is the name of a dumpable item, each value is a function to call with digichem_options as its only param.
|
|
53
53
|
"""
|
|
54
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
"spectrum": self.generate_spectrum,
|
|
56
|
+
}
|
|
55
57
|
|
|
56
58
|
def generate_spectrum(self, digichem_options):
|
|
57
59
|
"""
|
|
@@ -65,7 +67,14 @@ class Vibrations_list(Result_container, Unmergeable_container_mixin):
|
|
|
65
67
|
from digichem.result.spectroscopy import Spectroscopy_graph
|
|
66
68
|
|
|
67
69
|
|
|
68
|
-
spectrum = Spectroscopy_graph.from_vibrations(
|
|
70
|
+
spectrum = Spectroscopy_graph.from_vibrations(
|
|
71
|
+
self,
|
|
72
|
+
fwhm = digichem_options['IR_spectrum']['fwhm'],
|
|
73
|
+
resolution = digichem_options['IR_spectrum']['gaussian_resolution'],
|
|
74
|
+
cutoff = digichem_options['IR_spectrum']['gaussian_cutoff'],
|
|
75
|
+
filter = digichem_options['IR_spectrum']['y_filter'],
|
|
76
|
+
)
|
|
77
|
+
|
|
69
78
|
|
|
70
79
|
try:
|
|
71
80
|
spectrum_data = spectrum.plot_cumulative_gaussian()
|
|
@@ -82,11 +91,11 @@ class Vibrations_list(Result_container, Unmergeable_container_mixin):
|
|
|
82
91
|
"peaks": spectrum_peaks
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
def
|
|
94
|
+
def _dump_(self, digichem_options, all):
|
|
86
95
|
dump_dict = {
|
|
87
96
|
"num_vibrations": len(self),
|
|
88
97
|
"num_negative": len(self.negative),
|
|
89
|
-
"values": super().
|
|
98
|
+
"values": super()._dump_(digichem_options, all),
|
|
90
99
|
}
|
|
91
100
|
return dump_dict
|
|
92
101
|
|
|
@@ -126,7 +135,7 @@ class Vibration(Result_object, Floatable_mixin):
|
|
|
126
135
|
"""
|
|
127
136
|
return float(self.frequency)
|
|
128
137
|
|
|
129
|
-
def
|
|
138
|
+
def _dump_(self, digichem_options, all):
|
|
130
139
|
"""
|
|
131
140
|
Get a representation of this result object in primitive format.
|
|
132
141
|
"""
|
digichem/test/test_input.py
CHANGED
|
@@ -4,14 +4,14 @@ import pytest
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
from digichem.test.util import pyridine_si_v2, pyridine_si_v1, pyridine_cml,\
|
|
7
|
-
result_files
|
|
7
|
+
result_files, ethane_xyz, benzene_cdx, cyclopentane_com
|
|
8
8
|
from digichem.input.digichem_input import si_from_file
|
|
9
9
|
|
|
10
10
|
@pytest.mark.parametrize("file_path", [
|
|
11
11
|
pyridine_si_v2,
|
|
12
12
|
pyridine_si_v1
|
|
13
13
|
])
|
|
14
|
-
def
|
|
14
|
+
def test_si_reading(file_path):
|
|
15
15
|
"""
|
|
16
16
|
Test whether we can correctly read from an existing si file.
|
|
17
17
|
"""
|
|
@@ -51,7 +51,7 @@ def test_si_writing(tmp_path):
|
|
|
51
51
|
[result_files['turbomole'][0], "60a8ebd9e701b849cfccd9cbb41684519a7fdf0b"],
|
|
52
52
|
[result_files['orca'][0], "e48e7f653f4e67c1bd4c5c4bb76405fad2d441d0"],
|
|
53
53
|
])
|
|
54
|
-
def
|
|
54
|
+
def test_si_history(file_path, sha):
|
|
55
55
|
"""
|
|
56
56
|
Test whether the history attribute is set properly.
|
|
57
57
|
"""
|
|
@@ -62,3 +62,17 @@ def test_input_history(file_path, sha):
|
|
|
62
62
|
dump = si_file.dict
|
|
63
63
|
|
|
64
64
|
assert dump['history'] == sha
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.parametrize("file_path, format", [
|
|
68
|
+
(cyclopentane_com, "mol"),
|
|
69
|
+
(ethane_xyz, "cml"),
|
|
70
|
+
(benzene_cdx, "xyz"),
|
|
71
|
+
(result_files['gaussian'][0], "com")
|
|
72
|
+
])
|
|
73
|
+
def test_si_file_convert(file_path, format, tmp_path):
|
|
74
|
+
"""
|
|
75
|
+
Test whether we can convert from arbitrary formats to another format.
|
|
76
|
+
"""
|
|
77
|
+
si_file = si_from_file(file_path)
|
|
78
|
+
si_file.to_format(format, (tmp_path / "file").with_suffix("." + format))
|
digichem/test/test_parsing.py
CHANGED
|
@@ -144,3 +144,12 @@ def test_turbomole_archives(result_files, num_archives, digichem_options):
|
|
|
144
144
|
|
|
145
145
|
finally:
|
|
146
146
|
archive.cleanup()
|
|
147
|
+
|
|
148
|
+
def test_profile_parsing(digichem_options):
|
|
149
|
+
"""Can we parse profile data from profile.csv?"""
|
|
150
|
+
src = Path(data_directory(), 'Pyridine/Gaussian 16 Excited States TDA Optimised S(1) PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz')
|
|
151
|
+
|
|
152
|
+
res = parse_calculation(src, options = digichem_options)
|
|
153
|
+
|
|
154
|
+
assert res.metadata.performance is not None
|
|
155
|
+
|
digichem/test/test_prattle.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""Tests for functioning of oprattle"""
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
|
|
3
4
|
import pytest
|
|
4
5
|
|
|
5
6
|
from digichem.file.prattle import Oprattle_formats, Openprattle_converter
|
|
6
|
-
|
|
7
7
|
from digichem.test.util import ethane_xyz, benzene_cdx
|
|
8
8
|
|
|
9
9
|
@pytest.mark.parametrize("readwrite", ["read", "write"])
|
|
@@ -14,14 +14,43 @@ def test_formats(readwrite):
|
|
|
14
14
|
else:
|
|
15
15
|
assert len(Oprattle_formats().write()) > 0
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
@pytest.mark.parametrize("file_path", [
|
|
18
19
|
ethane_xyz,
|
|
19
20
|
benzene_cdx
|
|
20
21
|
])
|
|
21
|
-
def
|
|
22
|
+
def test_from_path(file_path):
|
|
23
|
+
"""
|
|
24
|
+
Can we convert a file found on the filesystem?
|
|
25
|
+
"""
|
|
22
26
|
Openprattle_converter(input_file_path = file_path).convert("com")
|
|
23
27
|
|
|
24
28
|
|
|
29
|
+
@pytest.mark.parametrize("file_path, mode", [
|
|
30
|
+
(ethane_xyz, "r"),
|
|
31
|
+
(benzene_cdx, "rb")
|
|
32
|
+
])
|
|
33
|
+
def test_from_file(file_path, mode):
|
|
34
|
+
"""
|
|
35
|
+
Can we convert from an open file?
|
|
36
|
+
"""
|
|
37
|
+
with open(file_path, mode) as input_file:
|
|
38
|
+
Openprattle_converter(input_file = input_file, input_file_type = Path(file_path).suffix[1:]).convert("com")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize("file_path, mode", [
|
|
42
|
+
(ethane_xyz, "r"),
|
|
43
|
+
(benzene_cdx, "rb")
|
|
44
|
+
])
|
|
45
|
+
def test_from_buffer(file_path, mode):
|
|
46
|
+
"""
|
|
47
|
+
Can we convert from an open file?
|
|
48
|
+
"""
|
|
49
|
+
with open(file_path, mode) as input_file:
|
|
50
|
+
data = input_file.read()
|
|
51
|
+
Openprattle_converter(input_file_buffer = data, input_file_type = Path(file_path).suffix[1:]).convert("com")
|
|
52
|
+
|
|
53
|
+
|
|
25
54
|
@pytest.mark.parametrize("file_path", [
|
|
26
55
|
ethane_xyz,
|
|
27
56
|
benzene_cdx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: digichem-core
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.1
|
|
4
4
|
Summary: Open-source library for Digichem core components
|
|
5
5
|
Project-URL: Homepage, https://github.com/Digichem-Project/digichem-core
|
|
6
6
|
Project-URL: Documentation, https://doc.digi-chem.co.uk
|