public RunningJob run(String inputPath, String outputPath) throws Exception { sLogger.info("Tool name: BuildGraph"); sLogger.info(" - input: " + inputPath); sLogger.info(" - output: " + outputPath); JobConf conf = new JobConf(BuildGraph.class); conf.setJobName("BuildGraph " + inputPath + " " + ContrailConfig.K); ContrailConfig.initializeConfiguration(conf); FileInputFormat.addInputPath(conf, new Path(inputPath)); FileOutputFormat.setOutputPath(conf, new Path(outputPath)); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(TextOutputFormat.class); conf.setMapOutputKeyClass(Text.class); conf.setMapOutputValueClass(Text.class); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(BuildGraphMapper.class); conf.setReducerClass(BuildGraphReducer.class); // delete the output directory if it exists already FileSystem.get(conf).delete(new Path(outputPath), true); return JobClient.runJob(conf); }
public int run(String[] args) throws Exception { // TODO (jlewi): Currently the options specified here need to appear first on // the command line otherwise we get an exeption when calling CommandLineParser.parse // What we'd like to have happen is that any options not defined here // get stored in CommandLine.args which get passed onto ContrailConfig.parseOptions. Option kmer = new Option("k", "k", true, "k. The length of each kmer to use."); Option input = new Option( "input", "input", true, "The directory containing the input (i.e the output of BuildGraph.)"); Option output = new Option( "output", "output", true, "The directory where the output should be written to."); Options options = new Options(); options.addOption(kmer); options.addOption(input); options.addOption(output); CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args, true); if (!line.hasOption("input") || !line.hasOption("output") || !line.hasOption("k")) { System.out.println("ERROR: Missing required arguments"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("QuickMerge", options); } String inputPath = line.getOptionValue("input"); String outputPath = line.getOptionValue("output"); ContrailConfig.K = Integer.parseInt(line.getOptionValue("k")); ContrailConfig.parseOptions(line.getArgs()); long starttime = System.currentTimeMillis(); run(inputPath, outputPath); long endtime = System.currentTimeMillis(); float diff = (float) (((float) (endtime - starttime)) / 1000.0); System.out.println("Runtime: " + diff + " s"); return 0; }