()
| 12 | -no_progress : flag to disable output to command line |
| 13 | ''' |
| 14 | def main(): |
| 15 | parser = argparse.ArgumentParser(description="Test tool for prototyping TOPPView-plugins") |
| 16 | parser.add_argument("-write_ini", help="Writes ini to specified path and exits.") |
| 17 | parser.add_argument("-ini", help="The ini file to load") |
| 18 | parser.add_argument("-in", help="The input file") |
| 19 | parser.add_argument("-out", help="The output file") |
| 20 | parser.add_argument("-no_progress", action="store_false", help="Turn of output to the command line") |
| 21 | |
| 22 | args = vars(parser.parse_args()) |
| 23 | |
| 24 | ini_path = args["write_ini"] |
| 25 | |
| 26 | # create ini at path |
| 27 | if ini_path is not None: |
| 28 | # create the default parameters |
| 29 | param = Param() |
| 30 | # this will create the param structure that is mandatory for all plugins |
| 31 | param.initPluginParam("ExamplePlugin", "0.0.1") |
| 32 | # the valid input fileformats have to be added like this |
| 33 | param.setValidStrings("ExamplePlugin:1:in", [b"*.mzML"]) |
| 34 | |
| 35 | # additional parameters can be added like this |
| 36 | param.setValue("ExamplePlugin:1:Number", 0, "This is an additional numeric parameter") |
| 37 | param.setValue("ExamplePlugin:1:Text", "example 1", "This is an additional text parameter") |
| 38 | param.setValidStrings("ExamplePlugin:1:Text", [b"option 1", b"option 2", b"option 3"]) |
| 39 | param.setValue("ExamplePlugin:1:Required", "", "This is an additional required parameter", [b"required"]) |
| 40 | |
| 41 | # write them to the given filepath |
| 42 | file = ParamXMLFile() |
| 43 | file.store(ini_path, param) |
| 44 | |
| 45 | exit() |
| 46 | |
| 47 | # this is an example for loading and saving an experiment from a mzML file |
| 48 | MzML = MzMLFile() |
| 49 | exp = MSExperiment() |
| 50 | |
| 51 | input_file = args["in"] |
| 52 | output_file = args["out"] |
| 53 | MzML.load(input_file, exp) |
| 54 | # we save it here without doing anything |
| 55 | MzML.store(output_file, exp) |
| 56 | |
| 57 | |
| 58 | if __name__ == "__main__": |
no test coverage detected