This module provides a command-line tool for displaying and modifying metadata in ABIF files.
The abimetadata tool allows users to:
- List all human-readable metadata fields in an ABIF file
- View the full content of a specific tag
- Edit the value of a tag (currently limited to string-type tags)
Command-line usage:
abimetadata <input.ab1> [options]
Options:
Examples:
# List all tags abimetadata input.ab1 # View a specific tag's full content abimetadata input.ab1 -t SMPL1 # Edit a tag abimetadata input.ab1 -t SMPL1 -v "New Sample Name" -o modified.ab1
Types
Config = object inputFile*: string ## Path to the input ABIF file outputFile*: string ## Path to the output file (when editing) tag*: string ## Tag name to view or edit value*: string ## New value for tag (when editing) listTags*: bool ## Whether to list all tags (default behavior) debug*: bool ## Whether to show debug information limit*: int ## Maximum number of tags to display (0 = no limit) showVersion*: bool ## Whether to show version information
- Configuration for the abimetadata tool. Contains command-line options and settings. Source Edit
Procs
proc canDisplayTag(tagName: string; entry: DirectoryEntry): bool {....raises: [], tags: [], forbids: [].}
-
Determines if a tag can be displayed based on its name and properties.
Parameters: tagName: The name of the tag entry: The DirectoryEntry for the tag
Returns: true if the tag can be displayed, false otherwise
Source Edit proc displaySingleTag(trace: ABIFTrace; tagName: string; debug: bool) {. ...raises: [KeyError], tags: [ReadIOEffect], forbids: [].}
-
Displays the full content of a single tag.
Parameters: trace: The ABIFTrace containing the tag tagName: The name of the tag to display debug: Whether to show debug information
Source Edit proc formatTagValue(tagName: string; entry: DirectoryEntry; trace: ABIFTrace): string {. ...raises: [], tags: [ReadIOEffect], forbids: [].}
-
Formats a tag's value for display, with possible truncation for long values.
Parameters: tagName: The name of the tag entry: The DirectoryEntry for the tag trace: The ABIFTrace containing the tag
Returns: The tag's value as a string, possibly truncated for display
Source Edit proc getFullTagValue(tagName: string; entry: DirectoryEntry; trace: ABIFTrace): string {. ...raises: [], tags: [ReadIOEffect], forbids: [].}
-
Gets the full, untruncated value of a tag.
Parameters: tagName: The name of the tag entry: The DirectoryEntry for the tag trace: The ABIFTrace containing the tag
Returns: The tag's value as a string, formatted according to its data type
Source Edit proc isHumanReadableType(tagType: ElementType): bool {....raises: [], tags: [], forbids: [].}
-
Determines if a tag type can be displayed in a human-readable format.
Parameters: tagType: The ElementType to check
Returns: true if the type is human-readable, false otherwise
Source Edit proc listMetadata(trace: ABIFTrace; debug: bool; limit: int = 0) {. ...raises: [IOError, KeyError], tags: [WriteIOEffect, ReadIOEffect], forbids: [].}
-
Lists all human-readable metadata fields in the ABIF file.
Parameters: trace: The ABIFTrace to list metadata from debug: Whether to show debug information limit: Maximum number of tags to display (0 = no limit)
Source Edit proc main() {....raises: [ValueError, OSError], tags: [ReadIOEffect, ReadDirEffect, WriteIOEffect, ExecIOEffect], forbids: [].}
-
Main entry point for the abimetadata program.
Handles command-line parsing and executes the appropriate action based on the provided options (list, view, or edit tags).
Source Edit proc parseCommandLine(): Config {....raises: [ValueError, OSError], tags: [ReadIOEffect], forbids: [].}
-
Parses command line arguments and returns a Config object.
This procedure:
- Initializes Config with default values
- Processes command-line arguments
- Handles special flags like --version and --help
- Validates required parameters based on operating mode
Returns: A Config object with settings based on command-line arguments
Source Edit proc verifyTagUpdate(inputFile, outputFile, tagName: string): bool {....raises: [], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}
-
Verifies that a tag was properly updated by comparing original and modified files.
Parameters: inputFile: Path to the original ABIF file outputFile: Path to the modified ABIF file tagName: The name of the tag that was modified
Returns: true if the tag was successfully updated, false otherwise
Source Edit proc verifyTagUpdateBasic(inputFile, outputFile, tagName: string; newValue: string; offset: int): bool {.discardable, ...raises: [], tags: [ReadIOEffect], forbids: [].}
- Verifies tag update by directly checking the binary content at the specified offset This simpler method just checks if we can find the expected value at the offset Source Edit