atomict 1.2.17__py3-none-any.whl → 1.2.19__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.
atomict/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.17"
1
+ __version__ = "1.2.19"
atomict/cli/main.py CHANGED
@@ -61,8 +61,7 @@ def cli(ctx, verbose: bool):
61
61
  @cli.command(default_command=True)
62
62
  @click.argument("input_file", required=True)
63
63
  @click.argument("output_file", required=True)
64
- @click.option("--strict-map-keys", is_flag=True, default=False, help="Enable strict map keys in msgpack files (sets strict_map_key=True)")
65
- def convert(input_file, output_file, strict_map_keys):
64
+ def convert(input_file, output_file):
66
65
  """Convert between atomic structure file formats using ASE
67
66
 
68
67
  Supports all formats that ASE can read/write, with special handling for .atm and .atraj files.
@@ -71,14 +70,13 @@ def convert(input_file, output_file, strict_map_keys):
71
70
  tess input.xyz output.atm
72
71
  tess input.traj output.atraj
73
72
 
74
- Options:
75
- --strict-map-keys Enable strict map keys in msgpack files (default: False)
76
73
  """
77
74
  try:
78
75
  import os.path
79
76
  from ase.io import read, write
80
77
  from ase.io.formats import UnknownFileTypeError
81
- from atomict.io.msgpack import save_msgpack, save_msgpack_trajectory, load_msgpack, load_msgpack_trajectory
78
+ from atomict.io.formats.atraj import read_atraj, write_atraj
79
+ from atomict.io.formats.tess import read_tess, write_tess
82
80
  except ImportError:
83
81
  console.print("[red]Error: ASE (Atomic Simulation Environment) is required for file conversion.[/red]")
84
82
  console.print("[yellow]Install it with: pip install ase[/yellow]")
@@ -103,30 +101,34 @@ def convert(input_file, output_file, strict_map_keys):
103
101
  console.print(f"[red]Error: Input file '{input_file}' not found.[/red]")
104
102
  return
105
103
 
106
- msgpack_formats = ["atm"]
107
- traj_msgpack_formats = ["atraj"]
104
+ traj_msgpack_formats = ["atraj", "tess"]
108
105
 
109
- if input_ext not in RW_FORMATS and input_ext not in msgpack_formats and input_ext not in traj_msgpack_formats:
110
- console.print(f"[red]Error: Format '{input_ext}' is not supported for reading.[/red]")
106
+ def _is_supported(ext: str) -> bool:
107
+ return (
108
+ ext in RW_FORMATS
109
+ or ext in traj_msgpack_formats
110
+ )
111
+
112
+ def _print_supported_error(ext: str, action: str) -> None:
113
+ console.print(f"[red]Error: Format '{ext}' is not supported for {action}.[/red]")
111
114
  console.print("[yellow]Supported read/write formats include:[/yellow]")
112
115
  for i in range(0, len(RW_FORMATS), 5):
113
116
  console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
114
- console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
117
+ console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory), tess (msgpack trajectory)[/yellow]")
118
+
119
+ if not _is_supported(input_ext):
120
+ _print_supported_error(input_ext, "reading")
115
121
  return
116
-
117
- if output_ext not in RW_FORMATS and output_ext not in msgpack_formats and output_ext not in traj_msgpack_formats:
118
- console.print(f"[red]Error: Format '{output_ext}' is not supported for writing.[/red]")
119
- console.print("[yellow]Supported read/write formats include:[/yellow]")
120
- for i in range(0, len(RW_FORMATS), 5):
121
- console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
122
- console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
122
+
123
+ if not _is_supported(output_ext):
124
+ _print_supported_error(output_ext, "writing")
123
125
  return
124
126
 
125
127
  try:
126
- if input_ext in msgpack_formats:
127
- atoms = load_msgpack(input_file, strict_map_key=strict_map_keys)
128
- elif input_ext in traj_msgpack_formats:
129
- atoms, _ = load_msgpack_trajectory(input_file, strict_map_key=strict_map_keys)
128
+ if input_ext == "atraj":
129
+ atoms, _ = read_atraj(input_file)
130
+ elif input_ext == "tess":
131
+ atoms, _ = read_tess(input_file)
130
132
  else:
131
133
  atoms = read(input_file, index=":")
132
134
  except UnknownFileTypeError:
@@ -140,15 +142,14 @@ def convert(input_file, output_file, strict_map_keys):
140
142
  return
141
143
 
142
144
  try:
143
- if output_ext in msgpack_formats:
144
- save_msgpack(atoms, output_file)
145
- console.print(f"[green]Successfully converted {input_file} to {output_file} (MSGPACK format)[/green]")
146
- elif output_ext in traj_msgpack_formats:
147
- save_msgpack_trajectory(atoms, output_file)
148
- console.print(f"[green]Successfully converted {input_file} to {output_file} (MSGPACK trajectory format)[/green]")
145
+ if output_ext == "atraj":
146
+ write_atraj(atoms, output_file)
147
+ elif output_ext == "tess":
148
+ write_tess(atoms, output_file)
149
149
  else:
150
150
  write(output_file, atoms)
151
- console.print(f"[green]Successfully converted {input_file} to {output_file}[/green]")
151
+
152
+ console.print(f"[green]Successfully converted {input_file} to {output_file}[/green]")
152
153
 
153
154
  except UnknownFileTypeError:
154
155
  console.print(f"[red]Error: Unknown file type for output file '{output_file}'[/red]")
@@ -199,7 +200,7 @@ if type -q tess
199
200
  end
200
201
  """
201
202
  click.echo(f"# Shell completion for {shell}")
202
- click.echo(completion_script.strip())
203
+ click.echo((completion_script or "").strip())
203
204
  click.echo(
204
205
  "# Don't forget to source your rc file! `source ~/.bashrc` or `source ~/.zshrc` ..."
205
206
  )
@@ -1,4 +1,7 @@
1
- from typing import Union, List, Dict, Any, Tuple
1
+ import numpy as np
2
+ from ase import Atoms
3
+ from ase.constraints import dict2constraint
4
+ from ase.calculators.singlepoint import SinglePointCalculator
2
5
 
3
6
 
4
7
  def atoms_to_dict(atoms_list, selective=False):
@@ -16,7 +19,6 @@ def atoms_to_dict(atoms_list, selective=False):
16
19
  Dict
17
20
  Dictionary with all extracted properties
18
21
  """
19
- import numpy as np
20
22
 
21
23
  # Create data structure with common properties
22
24
  data = {
@@ -205,91 +207,113 @@ def dict_to_atoms(data):
205
207
  List[Atoms]
206
208
  List of ASE Atoms objects
207
209
  """
208
- try:
209
- import numpy as np
210
- from ase import Atoms
211
- from ase.constraints import dict2constraint
212
- from ase.calculators.singlepoint import SinglePointCalculator
213
- except ImportError:
214
- raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
215
210
 
216
211
  n_frames = data['n_frames']
217
- atoms_list = []
218
-
219
- # Get unique symbols
212
+ atoms_list = [None] * n_frames # type: ignore[assignment]
213
+
214
+ # Cache lookups outside loop for speed
220
215
  unique_symbols = data['unique_symbols']
216
+ unique_symbols_array = np.asarray(unique_symbols, dtype=object)
221
217
  symbols_map = data['symbols']
222
-
223
- # Loop through frames
218
+ positions = data['positions']
219
+ cells = data['cell']
220
+ pbc = data['pbc']
221
+ n_atoms_seq = data['n_atoms']
222
+
223
+ numbers_data = data.get('numbers')
224
+ has_numbers = numbers_data is not None
225
+
226
+ tags = data.get('tags')
227
+ masses = data.get('masses')
228
+ momenta = data.get('momenta')
229
+ initial_charges = data.get('initial_charges')
230
+ initial_magmoms = data.get('initial_magmoms')
231
+ top_mask = data.get('top_mask')
232
+ constraints = data.get('constraints')
233
+ ase_objtype = data.get('ase_objtype')
234
+ forces = data.get('forces')
235
+ stress = data.get('stress')
236
+ atom_infos = data.get('atom_infos')
237
+ custom_arrays = data.get('custom_arrays')
238
+ calc_results = data.get('calc_results')
239
+
224
240
  for i in range(n_frames):
225
- # Get symbols for this frame - handle both old and new format
226
- if isinstance(symbols_map[i], np.ndarray):
227
- frame_symbols = [unique_symbols[idx] for idx in symbols_map[i]]
241
+ symbols_entry = symbols_map[i]
242
+ if isinstance(symbols_entry, np.ndarray):
243
+ symbols_idx = symbols_entry
228
244
  else:
229
- # Legacy format - symbols were stored as a 2D array
230
- idx = i * data['n_atoms'][i]
231
- frame_symbols = [unique_symbols[symbols_map[idx + j]] for j in range(data['n_atoms'][i])]
232
-
233
- # Create atoms object with basic properties
234
- atoms = Atoms(
235
- symbols=frame_symbols,
236
- positions=data['positions'][i],
237
- cell=data['cell'][i],
238
- pbc=data['pbc'][i],
239
- )
245
+ start_idx = i * n_atoms_seq[i]
246
+ symbols_idx = symbols_map[start_idx:start_idx + n_atoms_seq[i]]
247
+
248
+ if has_numbers:
249
+ atoms = Atoms(
250
+ numbers=numbers_data[i],
251
+ positions=positions[i],
252
+ cell=cells[i],
253
+ pbc=pbc[i],
254
+ )
255
+ else:
256
+ # Avoid numpy conversion and tolist() for small arrays
257
+ if isinstance(symbols_idx, np.ndarray):
258
+ frame_symbols = [unique_symbols[idx] for idx in symbols_idx]
259
+ else:
260
+ frame_symbols = [unique_symbols[idx] for idx in symbols_idx]
261
+ atoms = Atoms(
262
+ symbols=frame_symbols,
263
+ positions=positions[i],
264
+ cell=cells[i],
265
+ pbc=pbc[i],
266
+ )
240
267
 
241
268
  # Set optional properties if they exist
242
- if 'tags' in data:
243
- atoms.set_tags(data['tags'][i])
244
-
245
- if 'masses' in data:
246
- atoms.set_masses(data['masses'][i])
247
-
248
- if 'momenta' in data:
249
- atoms.set_momenta(data['momenta'][i])
250
-
251
- if 'initial_charges' in data:
252
- atoms.set_initial_charges(data['initial_charges'][i])
253
-
254
- if 'initial_magmoms' in data:
255
- atoms.set_initial_magnetic_moments(data['initial_magmoms'][i])
256
-
257
- if 'top_mask' in data and i < len(data['top_mask']) and data['top_mask'][i] is not None:
258
- atoms.top_mask = np.array(data['top_mask'][i], dtype=bool)
269
+ if tags is not None:
270
+ atoms.set_tags(tags[i])
271
+
272
+ if masses is not None:
273
+ atoms.set_masses(masses[i])
274
+
275
+ if momenta is not None:
276
+ atoms.set_momenta(momenta[i])
277
+
278
+ if initial_charges is not None:
279
+ atoms.set_initial_charges(initial_charges[i])
280
+
281
+ if initial_magmoms is not None:
282
+ atoms.set_initial_magnetic_moments(initial_magmoms[i])
259
283
 
260
- if 'numbers' in data:
261
- atoms.set_atomic_numbers(data['numbers'][i])
284
+ if top_mask is not None and i < len(top_mask) and top_mask[i] is not None:
285
+ atoms.top_mask = np.asarray(top_mask[i], dtype=bool)
262
286
 
263
- if 'constraints' in data and i < len(data['constraints']):
264
- for c in data['constraints'][i]:
287
+ if constraints is not None and i < len(constraints):
288
+ for c in constraints[i]:
265
289
  atoms.constraints.append(dict2constraint(c))
266
290
 
267
- if 'ase_objtype' in data and i < len(data['ase_objtype']) and data['ase_objtype'][i] is not None:
268
- atoms.ase_objtype = data['ase_objtype'][i]
291
+ if ase_objtype is not None and i < len(ase_objtype) and ase_objtype[i] is not None:
292
+ atoms.ase_objtype = ase_objtype[i]
269
293
 
270
- if 'forces' in data and i < len(data['forces']):
271
- atoms.arrays['forces'] = data['forces'][i]
294
+ if forces is not None and i < len(forces):
295
+ atoms.arrays['forces'] = forces[i]
272
296
 
273
- if 'stress' in data and i < len(data['stress']):
274
- atoms.stress = np.array(data['stress'][i], dtype=np.float64).copy()
297
+ if stress is not None and i < len(stress):
298
+ atoms.stress = np.array(stress[i], dtype=np.float64).copy()
275
299
 
276
300
  # Restore atom info
277
- if 'atom_infos' in data and i < len(data['atom_infos']):
278
- atoms.info.update(data['atom_infos'][i])
301
+ if atom_infos is not None and i < len(atom_infos):
302
+ atoms.info.update(atom_infos[i])
279
303
 
280
304
  # Restore custom arrays
281
- if 'custom_arrays' in data:
282
- for key, values in data['custom_arrays'].items():
305
+ if custom_arrays is not None:
306
+ for key, values in custom_arrays.items():
283
307
  if i < len(values) and values[i] is not None:
284
308
  atoms.arrays[key] = values[i]
285
309
 
286
310
  # Restore calculator if present
287
311
  calc_created = False
288
312
  calc_data = {}
289
-
313
+
290
314
  # First try from calc_results (new format)
291
- if 'calc_results' in data and i < len(data['calc_results']):
292
- calc_data = data['calc_results'][i]
315
+ if calc_results is not None and i < len(calc_results):
316
+ calc_data = calc_results[i]
293
317
 
294
318
  if calc_data and len(calc_data) > 1: # Only create calculator if there's data beyond just the name
295
319
  # Initialize a SinglePointCalculator
@@ -320,180 +344,6 @@ def dict_to_atoms(data):
320
344
  calc.results[key] = value
321
345
  atoms.calc = calc
322
346
 
323
- atoms_list.append(atoms)
347
+ atoms_list[i] = atoms
324
348
 
325
349
  return atoms_list
326
-
327
-
328
- def load_msgpack(filename: str, strict_map_key: bool = True) -> Union['ase.Atoms', List['ase.Atoms']]:
329
- """Load atoms from a msgpack file with high efficiency and speed.
330
-
331
- Parameters:
332
- -----------
333
- filename : str
334
- The input filename
335
- strict_map_key : bool, default=False
336
- If True, only allow string keys in msgpack dictionaries
337
- If False, allow integer and other keys in msgpack dictionaries
338
- """
339
-
340
- try:
341
- import msgpack
342
- import msgpack_numpy as m
343
- except ImportError:
344
- raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
345
-
346
- # Enable numpy array deserialization
347
- m.patch()
348
-
349
- # Load data
350
- with open(filename, 'rb') as f:
351
- data = msgpack.unpack(f, raw=False, strict_map_key=strict_map_key)
352
-
353
- # Convert to atoms objects
354
- atoms_list = dict_to_atoms(data)
355
-
356
- # Return single atom or list based on input
357
- return atoms_list[0] if data['n_frames'] == 1 else atoms_list
358
-
359
-
360
- def save_msgpack(atoms: Union['ase.Atoms', List['ase.Atoms']], filename: str):
361
- """Save atoms to a msgpack file with high efficiency and speed."""
362
-
363
- try:
364
- import msgpack
365
- import msgpack_numpy as m
366
- from ase import Atoms
367
- except ImportError:
368
- raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
369
-
370
- # Enable numpy array serialization
371
- m.patch()
372
-
373
- # Single atoms case - convert to list
374
- if isinstance(atoms, Atoms):
375
- atoms_list = [atoms]
376
- else:
377
- atoms_list = atoms
378
-
379
- # Extract properties to dictionary - use selective mode for single atoms
380
- # to avoid storing default properties
381
- selective = len(atoms_list) == 1
382
- data = atoms_to_dict(atoms_list, selective=selective)
383
-
384
- # Pack and save
385
- with open(filename, 'wb') as f:
386
- msgpack.pack(data, f, use_bin_type=True)
387
-
388
-
389
- def save_msgpack_trajectory(atoms: Union['ase.Atoms', List['ase.Atoms']], filename: str, metadata: Dict = None):
390
- """Save atoms to a msgpack trajectory file with metadata.
391
-
392
- Parameters:
393
- -----------
394
- atoms : Atoms or list of Atoms
395
- The atoms to save
396
- filename : str
397
- The output filename
398
- metadata : dict, optional
399
- Additional metadata to store with the trajectory
400
- """
401
- try:
402
- import msgpack
403
- import msgpack_numpy as m
404
- from ase import Atoms
405
- except ImportError:
406
- raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
407
-
408
- # Enable numpy array serialization
409
- m.patch()
410
-
411
- # Single atoms case - convert to list
412
- if isinstance(atoms, Atoms):
413
- atoms_list = [atoms]
414
- else:
415
- atoms_list = atoms
416
-
417
- # Create container for the trajectory data
418
- traj_data = {
419
- 'format_version': 1, # Version for future compatibility
420
- 'metadata': metadata or {},
421
- }
422
-
423
- # Extract properties to dictionary - no selective mode for trajectories
424
- atoms_data = atoms_to_dict(atoms_list, selective=False)
425
-
426
- # Add atoms data to the trajectory container
427
- traj_data['atoms_data'] = atoms_data
428
-
429
- # Pack and save
430
- with open(filename, 'wb') as f:
431
- msgpack.pack(traj_data, f, use_bin_type=True)
432
-
433
-
434
- def load_msgpack_trajectory(filename: str, strict_map_key: bool = True) -> Tuple[List['ase.Atoms'], Dict]:
435
- """Load atoms from a msgpack trajectory file with metadata.
436
-
437
- Parameters:
438
- -----------
439
- filename : str
440
- The input filename
441
- strict_map_key : bool, default=False
442
- If True, only allow string keys in msgpack dictionaries
443
- If False, allow integer and other keys in msgpack dictionaries
444
-
445
- Returns:
446
- --------
447
- atoms_list : list of Atoms
448
- The loaded atoms
449
- metadata : dict
450
- The metadata stored with the trajectory
451
- """
452
- try:
453
- import msgpack
454
- import msgpack_numpy as m
455
- except ImportError:
456
- raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
457
-
458
- # Enable numpy array deserialization
459
- m.patch()
460
-
461
- # Load data
462
- with open(filename, 'rb') as f:
463
- traj_data = msgpack.unpack(f, raw=False, strict_map_key=strict_map_key)
464
-
465
- # Check if this is a new-style trajectory with format_version
466
- if isinstance(traj_data, dict) and 'format_version' in traj_data:
467
- metadata = traj_data.get('metadata', {})
468
- atoms_data = traj_data.get('atoms_data', {})
469
- else:
470
- # Legacy format - just raw atoms data
471
- metadata = {}
472
- atoms_data = traj_data
473
-
474
- # Ensure that calculated properties are transferred to the calculator in dict_to_atoms
475
- if 'calc_results' not in atoms_data and hasattr(atoms_data, 'get') and atoms_data.get('forces') is not None:
476
- # If we have forces in the data but no calc_results, create calc_results entries
477
- calc_data_list = []
478
- n_frames = atoms_data.get('n_frames', 0)
479
-
480
- for i in range(n_frames):
481
- calc_data = {'name': 'SinglePointCalculator'}
482
- if 'forces' in atoms_data and i < len(atoms_data['forces']):
483
- calc_data['forces'] = atoms_data['forces'][i]
484
- if 'stress' in atoms_data and i < len(atoms_data['stress']):
485
- calc_data['stress'] = atoms_data['stress'][i]
486
- if 'energy' in atoms_data and i < len(atoms_data['energy']):
487
- calc_data['energy'] = atoms_data['energy'][i]
488
- calc_data_list.append(calc_data)
489
-
490
- atoms_data['calc_results'] = calc_data_list
491
-
492
- # Convert to atoms objects
493
- atoms_list = dict_to_atoms(atoms_data)
494
-
495
- # Make sure atoms_list is always a list
496
- if not isinstance(atoms_list, list):
497
- atoms_list = [atoms_list]
498
-
499
- return atoms_list, metadata
@@ -0,0 +1,99 @@
1
+ from typing import Union, List, Dict, TYPE_CHECKING
2
+
3
+
4
+ if TYPE_CHECKING:
5
+ import ase
6
+
7
+
8
+ def write_atraj(atoms: Union['ase.Atoms', List['ase.Atoms']], filename: str, metadata: Dict = None):
9
+ """Save atoms to a mpv1 file."""
10
+
11
+ from atomict.io.msgpack import atoms_to_dict
12
+
13
+ try:
14
+ import msgpack
15
+ import msgpack_numpy as m
16
+ from ase import Atoms
17
+ except ImportError:
18
+ raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
19
+
20
+ # Enable numpy array serialization
21
+ m.patch()
22
+
23
+ # Single atoms case - convert to list
24
+ if isinstance(atoms, Atoms):
25
+ atoms_list = [atoms]
26
+ else:
27
+ atoms_list = atoms
28
+
29
+ # Create container for the trajectory data
30
+ traj_data = {
31
+ 'format_version': 1, # Version for future compatibility
32
+ 'metadata': metadata or {},
33
+ }
34
+
35
+ # Extract properties to dictionary - no selective mode for trajectories
36
+ atoms_data = atoms_to_dict(atoms_list, selective=False)
37
+
38
+ # Add atoms data to the trajectory container
39
+ traj_data['atoms_data'] = atoms_data
40
+
41
+ # Pack and save
42
+ with open(filename, 'wb') as f:
43
+ msgpack.pack(traj_data, f, use_bin_type=True)
44
+
45
+
46
+ def read_atraj(filename: str) -> Union['ase.Atoms', List['ase.Atoms']]:
47
+
48
+ """Load atoms from a mpv1 file."""
49
+ from atomict.io.msgpack import dict_to_atoms
50
+
51
+ try:
52
+ import msgpack
53
+ import msgpack_numpy as m
54
+ except ImportError:
55
+ raise ImportError("You need to install with `pip install atomict[utils]` to use msgpack I/O")
56
+
57
+ # Enable numpy array deserialization
58
+ m.patch()
59
+
60
+ # Load data
61
+ with open(filename, 'rb') as f:
62
+ traj_data = msgpack.unpack(f, raw=False, strict_map_key=True)
63
+
64
+ # Check if this is a new-style trajectory with format_version
65
+ if isinstance(traj_data, dict) and 'format_version' in traj_data:
66
+ metadata = traj_data.get('metadata', {})
67
+ atoms_data = traj_data.get('atoms_data', {})
68
+ else:
69
+ # Legacy format - just raw atoms data
70
+ metadata = {}
71
+ atoms_data = traj_data
72
+
73
+ # Ensure that calculated properties are transferred to the calculator in dict_to_atoms
74
+ if 'calc_results' not in atoms_data and hasattr(atoms_data, 'get') and atoms_data.get('forces') is not None:
75
+ # If we have forces in the data but no calc_results, create calc_results entries
76
+ calc_data_list = []
77
+ n_frames = atoms_data.get('n_frames', 0)
78
+
79
+ for i in range(n_frames):
80
+ calc_data = {'name': 'SinglePointCalculator'}
81
+ if 'forces' in atoms_data and i < len(atoms_data['forces']):
82
+ calc_data['forces'] = atoms_data['forces'][i]
83
+ if 'stress' in atoms_data and i < len(atoms_data['stress']):
84
+ calc_data['stress'] = atoms_data['stress'][i]
85
+ if 'energy' in atoms_data and i < len(atoms_data['energy']):
86
+ calc_data['energy'] = atoms_data['energy'][i]
87
+ calc_data_list.append(calc_data)
88
+
89
+ atoms_data['calc_results'] = calc_data_list
90
+
91
+ # Convert to atoms objects
92
+ atoms_list = dict_to_atoms(atoms_data)
93
+
94
+ # Make sure atoms_list is always a list
95
+ if not isinstance(atoms_list, list):
96
+ atoms_list = [atoms_list]
97
+
98
+ return atoms_list, metadata
99
+