orto 1.0.5__tar.gz → 1.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orto
3
- Version: 1.0.5
3
+ Version: 1.1.0
4
4
  Summary: A package to make life easier when performing Orca calculations.
5
5
  Home-page: https://orto.kragskow.group
6
6
  Author: Jon Kragskow
@@ -15,7 +15,7 @@ Description-Content-Type: text/markdown
15
15
  Requires-Dist: numpy>=2.1.2
16
16
  Requires-Dist: xyz_py>=5.13.1
17
17
  Requires-Dist: matplotlib>=3.9.2
18
- Requires-Dist: extto>=0.5.0
18
+ Requires-Dist: extto>=1.0.0
19
19
  Requires-Dist: pandas>=2.2.3
20
20
  Requires-Dist: subto>=0.1.1
21
21
  Requires-Dist: python-docx>=1.1.2
@@ -0,0 +1 @@
1
+ __version__ = '1.1.0'
@@ -464,7 +464,7 @@ def gen_job_func(uargs):
464
464
 
465
465
  # Check xyz file is present
466
466
  try:
467
- inp.check_xyz(oj.input_file, uargs.skip_xyz)
467
+ inp.check_coord(oj.input_file, uargs.skip_xyz)
468
468
  except (DataNotFoundError, DataFormattingError) as e:
469
469
  ut.red_exit(str(e))
470
470
 
@@ -504,6 +504,28 @@ def gen_job_func(uargs):
504
504
  # Use orca file value
505
505
  config['mem_per_cpu'] = maxcore
506
506
 
507
+ # Check if NBO is requested
508
+ if inp.get_nbo(oj.input_file):
509
+ # Check if NBO module has been provided to orto
510
+ try:
511
+ if os.getenv('orto_nbo_load') is not None:
512
+ nbo_module = os.getenv('orto_nbo_load')
513
+ else:
514
+ ut.red_exit(
515
+ 'Missing orto_nbo_load environment variable'
516
+ )
517
+ except ValueError:
518
+ ut.red_exit(
519
+ (
520
+ 'Missing or malformed orto_nbo_load'
521
+ 'environment variable'
522
+ )
523
+ )
524
+ oj.pre_orca += f'module load {nbo_module}\n'
525
+ oj.pre_orca += f'export NBOFIL={oj.input_file.stem}\n'
526
+ else:
527
+ nbo_module = None
528
+
507
529
  # Set SLURM error and output file names
508
530
  config['error'] = 'slurm.%j.e'
509
531
  config['output'] = 'slurm.%j.o'
@@ -1880,7 +1880,7 @@ class MOInpExtractor(extto.LineExtractor):
1880
1880
 
1881
1881
  class XYZInputExtractor(extto.LineExtractor):
1882
1882
  '''
1883
- Extracts .xyz line of an input file
1883
+ Extracts *xyz line of an input file
1884
1884
 
1885
1885
  *xyz charge multiplicity
1886
1886
  '''
@@ -1936,6 +1936,26 @@ class XYZInputExtractor(extto.LineExtractor):
1936
1936
  return _ext.data
1937
1937
 
1938
1938
 
1939
+ class IntInputExtractor(XYZInputExtractor):
1940
+ '''
1941
+ Extracts *int line of an input file
1942
+
1943
+ *int charge multiplicity
1944
+ '''
1945
+
1946
+ # Regex pattern for line
1947
+ PATTERN = rb'\* *int *-?\d+ *\d'
1948
+
1949
+ MODIFIERS = [re.IGNORECASE]
1950
+
1951
+ @property
1952
+ def data(self) -> list[str]:
1953
+ '''
1954
+ *int line, one entry per match
1955
+ '''
1956
+ return self._data
1957
+
1958
+
1939
1959
  class MaxCoreInputExtractor(extto.LineExtractor):
1940
1960
  '''
1941
1961
  Extracts maxcore from input file\n
@@ -2006,7 +2026,7 @@ class SimpleInputExtractor(extto.LineExtractor):
2006
2026
  # Regex pattern for line
2007
2027
  PATTERN = rb'^ *!.*'
2008
2028
 
2009
- MODIFIERS = [re.IGNORECASE]
2029
+ MODIFIERS = [re.IGNORECASE, re.MULTILINE]
2010
2030
 
2011
2031
  @property
2012
2032
  def data(self) -> list[str]:
@@ -9,6 +9,45 @@ from . import extractor as oe
9
9
  from . import utils as ut
10
10
 
11
11
 
12
+ def get_nbo(file_name: str | Path) -> bool:
13
+ '''
14
+ Check if NBO is present in the simple input line.\n
15
+
16
+ Parameters
17
+ ----------
18
+ file_name: str | Path
19
+ Orca input file as either name or Path object
20
+
21
+ Returns
22
+ -------
23
+ bool
24
+ True if NBO is present, False otherwise
25
+ '''
26
+ # Check for simple input line beginning with !
27
+ try:
28
+ simple = oe.SimpleInputExtractor.extract(file_name)
29
+ except DataNotFoundError:
30
+ ut.red_exit(
31
+ 'Error: Missing simple input line (or !) in input file'
32
+ )
33
+ # Check for NBO in simple input
34
+ nbo_simple = re.findall(
35
+ r'NBO',
36
+ simple[0],
37
+ flags=re.IGNORECASE
38
+ )
39
+ if len(nbo_simple):
40
+ # Set to True if found
41
+ if nbo_simple is None:
42
+ _nbo = True
43
+ else:
44
+ _nbo = True
45
+ else:
46
+ _nbo = False
47
+
48
+ return _nbo
49
+
50
+
12
51
  def get_nprocs(file_name: str | Path) -> int:
13
52
  '''
14
53
  Get the number of processors from the input file.\n
@@ -45,17 +84,17 @@ def get_nprocs(file_name: str | Path) -> int:
45
84
  )
46
85
 
47
86
  # Check for PALX in simple input
48
- if 'pal' in simple[0].lower():
49
- # and extract nprocs if found
50
- _palprocs = re.findall(
51
- r'PAL(\d+)',
52
- simple[0],
53
- flags=re.IGNORECASE)
87
+ pal_simple = re.findall(
88
+ r'PAL(\d+)',
89
+ simple[0],
90
+ flags=re.IGNORECASE
91
+ )
92
+ if len(pal_simple):
54
93
  # Set to zero if not found
55
- if _palprocs is None:
94
+ if pal_simple is None:
56
95
  _palprocs = 0
57
96
  else:
58
- _palprocs = int(_palprocs[0])
97
+ _palprocs = int(pal_simple[0])
59
98
  # check if power of 2
60
99
  if not np.log2(_palprocs).is_integer():
61
100
  ut.red_exit(
@@ -124,6 +163,81 @@ def get_maxcore(file_name: str | Path) -> int:
124
163
  return maxcore
125
164
 
126
165
 
166
+ def check_coord(file_name: str | Path, skip_check) -> None:
167
+ '''
168
+ Check *xyz, *xyzfile, or *int line is present in input file.\n
169
+ If xyzfile is given, then also checks if this exists and is formatted \n
170
+ correctly.\n
171
+
172
+ Parameters
173
+ ----------
174
+ file_name: str | Path
175
+ Orca input file as either name or Path object
176
+ skip_check: bool
177
+ If True, skip the xyz file check
178
+
179
+ Returns
180
+ -------
181
+ None
182
+
183
+ Raises
184
+ ------
185
+ DataNotFoundError
186
+ If neither *xyzfile, *xyz, nor *int are present in the input file
187
+ DataFormattingError
188
+ If xyz file is not formatted correctly
189
+ '''
190
+
191
+ # Get xyz file name and check it exists and is formatted correctly
192
+ try:
193
+ xyz_file = oe.XYZFileInputExtractor.extract(file_name)
194
+ except DataNotFoundError:
195
+ xyz_file = []
196
+
197
+ try:
198
+ xyzline = oe.XYZInputExtractor.extract(file_name)
199
+ except DataNotFoundError:
200
+ xyzline = []
201
+
202
+ try:
203
+ intline = oe.IntInputExtractor.extract(file_name)
204
+ except DataNotFoundError:
205
+ intline = []
206
+
207
+ lens = [len(xyz_file), len(xyzline), len(intline)]
208
+
209
+ if not sum(lens):
210
+ ut.red_exit(
211
+ 'Error: missing or incorrect *xyzfile or *xyz line in input'
212
+ )
213
+ elif sum(lens) > 1:
214
+ ut.red_exit(
215
+ (
216
+ 'Error: multiple *xyzfile or *xyz lines in input.\n'
217
+ 'Only one can be present'
218
+ )
219
+ )
220
+
221
+ if len(xyz_file):
222
+ xyz_file = Path(xyz_file[0])
223
+ if not xyz_file.is_file():
224
+ ut.red_exit(
225
+ 'Error: xyz file specified in input cannot be found'
226
+ )
227
+
228
+ if not skip_check:
229
+ try:
230
+ xyzp.check_xyz(
231
+ xyz_file.absolute(),
232
+ allow_indices=False
233
+ )
234
+ except xyzp.XYZError as e:
235
+ raise DataFormattingError(
236
+ f'{e}\n Use -sx to skip this check at your peril'
237
+ )
238
+ return
239
+
240
+
127
241
  def check_xyz(file_name: str | Path, skip_check) -> None:
128
242
  '''
129
243
  Check *xyz or *xyzfile line is present in input file.\n
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orto
3
- Version: 1.0.5
3
+ Version: 1.1.0
4
4
  Summary: A package to make life easier when performing Orca calculations.
5
5
  Home-page: https://orto.kragskow.group
6
6
  Author: Jon Kragskow
@@ -15,7 +15,7 @@ Description-Content-Type: text/markdown
15
15
  Requires-Dist: numpy>=2.1.2
16
16
  Requires-Dist: xyz_py>=5.13.1
17
17
  Requires-Dist: matplotlib>=3.9.2
18
- Requires-Dist: extto>=0.5.0
18
+ Requires-Dist: extto>=1.0.0
19
19
  Requires-Dist: pandas>=2.2.3
20
20
  Requires-Dist: subto>=0.1.1
21
21
  Requires-Dist: python-docx>=1.1.2
@@ -1,7 +1,7 @@
1
1
  numpy>=2.1.2
2
2
  xyz_py>=5.13.1
3
3
  matplotlib>=3.9.2
4
- extto>=0.5.0
4
+ extto>=1.0.0
5
5
  pandas>=2.2.3
6
6
  subto>=0.1.1
7
7
  python-docx>=1.1.2
@@ -8,7 +8,7 @@ Please see the `orto` documentation for more details.
8
8
 
9
9
  # DO NOT EDIT THIS NUMBER!
10
10
  # IT IS AUTOMATICALLY CHANGED BY python-semantic-release
11
- __version__ = '1.0.5'
11
+ __version__ = '1.1.0'
12
12
 
13
13
  setuptools.setup(
14
14
  name='orto',
@@ -35,7 +35,7 @@ setuptools.setup(
35
35
  'numpy>=2.1.2',
36
36
  'xyz_py>=5.13.1',
37
37
  'matplotlib>=3.9.2',
38
- 'extto>=0.5.0',
38
+ 'extto>=1.0.0',
39
39
  'pandas>=2.2.3',
40
40
  'subto>=0.1.1',
41
41
  'python-docx>=1.1.2'
@@ -1 +0,0 @@
1
- __version__ = '1.0.5'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes