Center
Defines the command-line interface for centering molecular structures.
add_center_subparser(subparsers)
¶
Adds the 'center' subcommand to the provided subparsers.
This function creates a subparser named 'center' under the main Simlify CLI, allowing users to move the center of mass of all frames within a molecular structure to the origin (0.0, 0.0, 0.0). It defines the necessary command-line arguments for specifying the topology, coordinate files, output path, and overwrite behavior.
PARAMETER | DESCRIPTION |
---|---|
subparsers
|
An
|
RETURNS | DESCRIPTION |
---|---|
argparse.ArgumentParser: The newly created 'center' subparser. |
The 'center' subparser accepts the following arguments:
positional arguments
topo Path to topology file. output Path to coordinate file to save the centered structure.
optional arguments
--coords Paths to one or more coordinate files. If multiple files are provided, they will be concatenated and treated as frames of the same trajectory. --overwrite Overwrite the output coordinate file if it already exists.
The function sets the default action for this subparser to be the
cli_center_atoms
function, which will be called when the user invokes
the 'center' subcommand.
cli_center_atoms(args, parser)
¶
Handles the command-line invocation of the structure centering functionality.
This function serves as the entry point when the user executes the 'center'
subcommand of the Simlify CLI. It takes the parsed command-line arguments
and the argument parser object as input. It performs a basic check to ensure
that at least a topology file is provided. If not, it prints the help message
for the 'center' subcommand and returns. Otherwise, it extracts the relevant
arguments and calls the underlying run_center_structure
function to perform
the structure centering operation.
PARAMETER | DESCRIPTION |
---|---|
args
|
An object containing the parsed command-line arguments for the 'center' subcommand.
TYPE:
|
parser
|
The argument parser object for the 'center' subcommand, used to display help messages if necessary.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
The function retrieves the following arguments from the args
object:
- topo
: Path to the topology file.
- output
: Path to the output coordinate file.
- coords
: A list of paths to coordinate files.
- overwrite
: A boolean indicating whether to overwrite the output file.
It then calls the run_center_structure
function with these arguments to
perform the actual centering of the molecular structure(s).