Пример #1
0
        public static void Main(string[] args)
        {
            SplashRunner app = new SplashRunner();

            bool show_help = false;
            string filename = string.Empty;
            int spec_col = 0;
            int id_col = 1;

            var p = new OptionSet() {
                "Usage: SplashRunner [OPTIONS]+",
                "Calculates splash codes for the specified file.",
                "",
                "Options:",
                { "f|file=", "the {NAME} of the file containing the spectra to calculate splashes for.",
                    v => filename = v },
                { "s|spectrum=",
                    "the zero-based column number of the spectrum.\n" +
                    "this must be an integer. Default = 0",
                    (int v) => spec_col = v },
                { "i|id=",
                    "the zero-based column number of the origin id.\n" +
                    "this must be an string. Default = 1",
                    (int v) => id_col = v },
                { "h|help",  "show this message and exit",
                    v => show_help = v != null },
            };

            List<string> extra;
            try {
                extra = p.Parse (args);
            } catch (OptionException e) {
                Console.Write ("SplashRunner: ");
                Console.WriteLine (e.Message);
                Console.WriteLine ("Try `SplashRunner --help' for more information.");
                return;
            }

            if (show_help) {
                p.WriteOptionDescriptions (Console.Out);
                return;
            }

            string error = "\nPlease provide a filename (<name>.csv) with spectra to hash.\nFile should contain a list of coma separated values in the form 'identifier,spectrum' each on a separate line.\n";

            if(string.IsNullOrEmpty(filename)) {
                Console.WriteLine("Error: {0}\n", error);
                p.WriteOptionDescriptions(Console.Out);
                return;
            } else if(!new FileInfo(filename).Exists) {
                Console.WriteLine("File '{0}' doesn't exists.\n");
                p.WriteOptionDescriptions(Console.Out);
                return;
            }

            app.hashFile(filename, spec_col, id_col);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            SplashRunner app = new SplashRunner();

            bool   show_help = false;
            string filename  = string.Empty;
            int    spec_col  = 0;
            int    id_col    = 1;

            var p = new OptionSet()
            {
                "Usage: SplashRunner [OPTIONS]+",
                "Calculates splash codes for the specified file.",
                "",
                "Options:",
                { "f|file=", "the {NAME} of the file containing the spectra to calculate splashes for.",
                  v => filename = v },
                { "s|spectrum=",
                  "the zero-based column number of the spectrum.\n" +
                  "this must be an integer. Default = 0",
                  (int v) => spec_col = v },
                { "i|id=",
                  "the zero-based column number of the origin id.\n" +
                  "this must be an string. Default = 1",
                  (int v) => id_col = v },
                { "h|help", "show this message and exit",
                  v => show_help = v != null },
            };

            List <string> extra;

            try {
                extra = p.Parse(args);
            } catch (OptionException e) {
                Console.Write("SplashRunner: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `SplashRunner --help' for more information.");
                return;
            }

            if (show_help)
            {
                p.WriteOptionDescriptions(Console.Out);
                return;
            }

            string error = "\nPlease provide a filename (<name>.csv) with spectra to hash.\nFile should contain a list of coma separated values in the form 'identifier,spectrum' each on a separate line.\n";

            if (string.IsNullOrEmpty(filename))
            {
                Console.WriteLine("Error: {0}\n", error);
                p.WriteOptionDescriptions(Console.Out);
                return;
            }
            else if (!new FileInfo(filename).Exists)
            {
                Console.WriteLine("File '{0}' doesn't exists.\n");
                p.WriteOptionDescriptions(Console.Out);
                return;
            }

            app.hashFile(filename, spec_col, id_col);
        }