Streamlining the RosettaScripts Interface: RosettaScripts Type-hinting in VS Code
~ contributed by Dr. Vikram Mulligan
RosettaScripts Type-hinting in VS Code
By Dr. Vikram Mulligan, Research Scientist, Flatiron Institute
The RosettaScripts scripting language began as a loose XML-like language with informal syntax, with each Rosetta module defining its own XML interface. This made it difficult to ensure that Rosetta could handle bad inputs correctly: often, typos or nonsensical inputs were simply ignored, and users were not alerted about problems in their scripts. This was solved by formalizing the XML interface with an XML Schema Definition (XSD), a project led by Dr. Andrew Leaver-Fay a few years back. We now require any Rosetta module with an XML interface to provide a machine-readable description of the XML interface, permitting automated checking of syntax, unused inputs, etc., and allowing informative error messages.
Rosetta now automatically interrogates all of its own modules on startup and constructs a unified XSD for the entire RosettaScripts language. This turns out to be useful for other things as well. One is easier interfaces with script editors and interactive development environments (IDEs), which can read XML schemas and use them to provide type-hinting and autocompletion. We’ve recently added instructions on the Rosetta help wiki (https://new.rosettacommons.org/docs/latest/scripting_documentation/RosettaScripts/Using-RosettaScripts-with-VSCode) for exporting the RosettaScripts XSD from Rosetta and setting up type-hinting and autocorrect in VSCode, making it much easier to write RosettaScripts XML files. In addition, the same XSD infrastructure has enabled the rosetta_scripts application’s “-info” command-line flag, which can be used to write a human-readable summary of the interface of any Rosetta mover, filter, task operation, simple metric, residue selector, etc. If you would like to take it for a test drive, try running the rosetta_scripts application with the flag “-info PackRotamersMover”.