Resname
Command-line interface for renaming residues within a Protein Data Bank (PDB) file.
add_pdb_resname_subparser(subparsers)
¶
Adds the 'resname' subcommand to the Simlify CLI for renaming residues.
This function configures an argparse
subparser named 'resname' which allows
users to specify a PDB file, the current residue name to be replaced, the new
residue name, and options for specifying an output file and filtering residues
based on their indices.
PARAMETER | DESCRIPTION |
---|---|
subparsers
|
An
|
RETURNS | DESCRIPTION |
---|---|
The configured |
The 'resname' subcommand accepts the following arguments:
pdb_path
: Path to the input PDB file where residue names will be replaced. This argument is optional. If not provided, the program might expect the path through other configuration mechanisms.current_resname
: The current three-letter code of the residue name that should be replaced (e.g., "ALA").new_resname
: The new three-letter code to which the residue should be renamed (e.g., "GLY").--output
: Path to the new PDB file where the modified structure will be saved. If not provided, the output might overwrite the input file or be handled in another way by the underlying function.--include
: One or more residue indices to only include for renaming. Residues with indices not in this list will not be renamed. Indices should match the residue number in the PDB file.--exclude
: One or more residue indices to exclude from renaming. All residues except those with indices in this list will be renamed. Indices should match the residue number in the PDB file.
The function sets the default action for this subparser to be the
cli_replace_resnames
function, which will be called when the user invokes
the 'resname' subcommand.
cli_replace_resnames(args, parser)
¶
Command-line interface function to rename residues in a PDB file.
This function serves as the entry point when the user executes the 'resname'
subcommand of the Simlify CLI. It receives the parsed command-line arguments
and the argument parser object. It constructs a dictionary mapping the current
residue name to the new residue name. It then determines whether to use a filter
function based on the presence of the --include
or --exclude
arguments. If
either of these arguments is provided, the parse_resid
function is used as a
filter. Finally, it calls the run_replace_resnames
function from the
simlify.structure.pdb.names
module to perform the residue renaming operation.
PARAMETER | DESCRIPTION |
---|---|
args
|
An
TYPE:
|
parser
|
The argument parser object for the 'resname' subcommand, used to display help messages if necessary (though not explicitly used in this function).
TYPE:
|
The function retrieves the following arguments from the args
object:
pdb_path
: Path to the input PDB file.current_resname
: The residue name to be replaced.new_resname
: The new residue name.output
: Path to the output PDB file.include
: A list of residue indices to include for renaming.exclude
: A list of residue indices to exclude from renaming.
It creates a resname_map
dictionary with the provided current and new
residue names. It also sets the fn_filter
to parse_resid
if either
args.include
or args.exclude
is provided, otherwise it remains None
.
Finally, it calls run_replace_resnames
with these parameters to perform the residue renaming.