List of usage examples for java.io File isFile
public boolean isFile()
From source file:com.github.lgi2p.obirs.utils.JSONConverter.java
public static void main(String[] args) throws Exception { String annotdir = "/data/toxnuc/toxnuc_annots_5_11_14/annots"; String annotsIndex = "/data/toxnuc/toxnuc_annots_5_11_14.json"; File folder = new File(annotdir); File[] listOfFiles = folder.listFiles(); PrintWriter printWriter = new PrintWriter(annotsIndex); int i = 0;/*www .ja va 2 s .co m*/ for (File file : listOfFiles) { if (file.isFile()) { System.out.println(file.getPath()); String title = file.getName(); String href = file.getPath(); String json = toJSONindexFormat(i, title, Utils.readFileAsString(file), href); i++; printWriter.println(json); } } printWriter.close(); System.out.println("consult: " + annotsIndex); }
From source file:com.linkedin.pinot.integration.tests.HybridClusterIntegrationTestCommandLineRunner.java
public static void main(String[] args) throws Exception { int numArgs = args.length; if (!((numArgs == 5) || (numArgs == 6 && args[0].equals("--llc")))) { printUsage();/*from www . j a v a 2s . c o m*/ } CustomHybridClusterIntegrationTest._enabled = true; int argIdx = 0; if (args[0].equals("--llc")) { CustomHybridClusterIntegrationTest._useLlc = true; argIdx++; } CustomHybridClusterIntegrationTest._tableName = args[argIdx++]; File schemaFile = new File(args[argIdx++]); Preconditions.checkState(schemaFile.isFile()); CustomHybridClusterIntegrationTest._schemaFile = schemaFile; File dataDir = new File(args[argIdx++]); Preconditions.checkState(dataDir.isDirectory()); CustomHybridClusterIntegrationTest._dataDir = dataDir; CustomHybridClusterIntegrationTest._invertedIndexColumns = Arrays.asList(args[argIdx++].split(",")); CustomHybridClusterIntegrationTest._sortedColumn = args[argIdx]; TestListenerAdapter testListenerAdapter = new TestListenerAdapter(); TestNG testNG = new TestNG(); testNG.setTestClasses(new Class[] { CustomHybridClusterIntegrationTest.class }); testNG.addListener(testListenerAdapter); testNG.run(); System.out.println(testListenerAdapter.toString()); boolean success = true; List<ITestResult> skippedTests = testListenerAdapter.getSkippedTests(); if (!skippedTests.isEmpty()) { System.out.println("Skipped tests: " + skippedTests); for (ITestResult skippedTest : skippedTests) { System.out.println(skippedTest.getName() + ": " + skippedTest.getThrowable()); } success = false; } List<ITestResult> failedTests = testListenerAdapter.getFailedTests(); if (!failedTests.isEmpty()) { System.err.println("Failed tests: " + failedTests); for (ITestResult failedTest : failedTests) { System.out.println(failedTest.getName() + ": " + failedTest.getThrowable()); } success = false; } if (success) { System.exit(0); } else { System.exit(1); } }
From source file:net.skyebook.zerocollada.ZeroCollada.java
/** * @param args//from www. j a va 2s .c o m * @throws ParseException * @throws IOException * @throws JDOMException */ public static void main(String[] args) throws ParseException, JDOMException, IOException { // Setup Apache Commons CLI optionsSetup(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (args.length == 0 || cmd.hasOption(ZCOpts.help)) { showHelp(); } // was there a valid operation specified? if (hasValidOption(cmd)) { File fileFromCommandLine = new File(args[args.length - 1]); if (!fileFromCommandLine.exists()) { System.err.println( "The file located at " + fileFromCommandLine.toString() + " does not exist! Qutting."); return; } else if (fileFromCommandLine.isFile() && fileFromCommandLine.toString().endsWith(".dae")) { // we've been given a single file. Act on this single file doRequestedAction(fileFromCommandLine, cmd); } else if (fileFromCommandLine.isDirectory()) { // We've been given a directory of files process the ones that are .dae for (File file : fileFromCommandLine.listFiles()) { if (file.isFile() && file.toString().endsWith(".dae")) { doRequestedAction(file, cmd); } else { System.err.println(file.toString() + " does not seem to be a COLLADA file"); } } } } else { // Then why are we here? if (cmd.hasOption(ZCOpts.includeY)) { System.err.println( "You have used the " + ZCOpts.includeY + " option but have not asked for a transform (t)"); } else if (cmd.hasOption(ZCOpts.anchorCenter)) { System.err.println( "You have used the " + ZCOpts.includeY + " option but have not asked for a transform (t)"); } } }
From source file:com.trailmagic.image.util.ImagesParserImpl.java
public static final void main(String[] args) { File baseDir = new File(args[0]); if (!baseDir.isDirectory()) { printUsage();//from w ww. ja v a2 s . co m System.exit(1); } File metadataFile = new File(baseDir, METADATA_FILENAME); if (!metadataFile.isFile()) { s_logger.error("Error: Couldn't find " + baseDir + File.separator + METADATA_FILENAME); System.exit(1); } s_logger.info("Starting context..."); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] { "applicationContext-global.xml", "applicationContext-user.xml", "applicationContext-imagestore.xml", "applicationContext-imagestore-authorization.xml", "applicationContext-standalone.xml" }); ImagesParser handler = (ImagesParser) appContext.getBean("imagesParser"); s_logger.info("Beginning parse."); try { handler.parseFile(baseDir, metadataFile); s_logger.info("Parse completed."); } catch (Throwable t) { s_logger.error("Parse Failed!", t); } System.exit(0); }
From source file:ViewImageTest.java
/** * Test image(s) (default : JPEG_example_JPG_RIP_100.jpg) are parsed and * rendered to an output foler. Result can then be checked with program of * your choice./*ww w . j av a 2s.c o m*/ * * @param args * may be empty or contain parameters to override defaults : * <ul> * <li>args[0] : input image file URL or folder containing image * files URL. Default : * viewImageTest/test/JPEG_example_JPG_RIP_100.jpg</li> * <li>args[1] : output format name (for example : "jpg") for * rendered image</li> * <li>args[2] : ouput folder URL</li> * <li>args[3] : max width (in pixels) for rendered image. * Default : no value.</li> * <li>args[4] : max height (in pixels) for rendered image. * Default : no value.</li> * </ul> * @throws IOException * when a read/write error occured */ public static void main(String args[]) throws IOException { File inURL = getInputURL(args); String ext = getEncodingExt(args); File outDir = getOuputDir(args); serverObjects post = makePostParams(args); outDir.mkdirs(); File[] inFiles; if (inURL.isFile()) { inFiles = new File[1]; inFiles[0] = inURL; System.out.println("Testing ViewImage rendering with input file : " + inURL.getAbsolutePath() + " encoded To : " + ext); } else if (inURL.isDirectory()) { FileFilter filter = FileFileFilter.FILE; inFiles = inURL.listFiles(filter); System.out.println("Testing ViewImage rendering with input files in folder : " + inURL.getAbsolutePath() + " encoded To : " + ext); } else { inFiles = new File[0]; } if (inFiles.length == 0) { throw new IllegalArgumentException(inURL.getAbsolutePath() + " is not a valid file or folder url."); } System.out.println("Rendered images will be written in dir : " + outDir.getAbsolutePath()); Map<String, Exception> failures = new HashMap<String, Exception>(); try { for (File inFile : inFiles) { /* Delete eventual previous result file */ File outFile = new File(outDir, inFile.getName() + "." + ext); if (outFile.exists()) { outFile.delete(); } byte[] resourceb = getBytes(inFile); String urlString = inFile.getAbsolutePath(); EncodedImage img = null; Exception error = null; try { img = ViewImage.parseAndScale(post, true, urlString, ext, false, resourceb); } catch (Exception e) { error = e; } if (img == null) { failures.put(urlString, error); } else { FileOutputStream outFileStream = null; try { outFileStream = new FileOutputStream(outFile); img.getImage().writeTo(outFileStream); } finally { if (outFileStream != null) { outFileStream.close(); } img.getImage().close(); } } } displayResults(inFiles, failures); } finally { ConcurrentLog.shutdown(); } }
From source file:com.tamingtext.classifier.bayes.ExtractTrainingData.java
public static void main(String[] args) { log.info("Command-line arguments: " + Arrays.toString(args)); DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); ArgumentBuilder abuilder = new ArgumentBuilder(); GroupBuilder gbuilder = new GroupBuilder(); Option inputOpt = obuilder.withLongName("dir").withRequired(true) .withArgument(abuilder.withName("dir").withMinimum(1).withMaximum(1).create()) .withDescription("Lucene index directory containing input data").withShortName("d").create(); Option categoryOpt = obuilder.withLongName("categories").withRequired(true) .withArgument(abuilder.withName("file").withMinimum(1).withMaximum(1).create()) .withDescription("File containing a list of categories").withShortName("c").create(); Option outputOpt = obuilder.withLongName("output").withRequired(false) .withArgument(abuilder.withName("output").withMinimum(1).withMaximum(1).create()) .withDescription("Output directory").withShortName("o").create(); Option categoryFieldsOpt = obuilder.withLongName("category-fields").withRequired(true) .withArgument(abuilder.withName("fields").withMinimum(1).withMaximum(1).create()) .withDescription("Fields to match categories against (comma-delimited)").withShortName("cf") .create();/*from ww w . j av a 2 s .c o m*/ Option textFieldsOpt = obuilder.withLongName("text-fields").withRequired(true) .withArgument(abuilder.withName("fields").withMinimum(1).withMaximum(1).create()) .withDescription("Fields from which to extract training text (comma-delimited)").withShortName("tf") .create(); Option useTermVectorsOpt = obuilder.withLongName("use-term-vectors").withDescription( "Extract term vectors containing preprocessed data " + "instead of unprocessed, stored text values") .withShortName("tv").create(); Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h") .create(); Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(categoryOpt) .withOption(outputOpt).withOption(categoryFieldsOpt).withOption(textFieldsOpt) .withOption(useTermVectorsOpt).create(); try { Parser parser = new Parser(); parser.setGroup(group); CommandLine cmdLine = parser.parse(args); if (cmdLine.hasOption(helpOpt)) { CommandLineUtil.printHelp(group); return; } File inputDir = new File(cmdLine.getValue(inputOpt).toString()); if (!inputDir.isDirectory()) { throw new IllegalArgumentException(inputDir + " does not exist or is not a directory"); } File categoryFile = new File(cmdLine.getValue(categoryOpt).toString()); if (!categoryFile.isFile()) { throw new IllegalArgumentException(categoryFile + " does not exist or is not a directory"); } File outputDir = new File(cmdLine.getValue(outputOpt).toString()); outputDir.mkdirs(); if (!outputDir.isDirectory()) { throw new IllegalArgumentException(outputDir + " is not a directory or could not be created"); } Collection<String> categoryFields = stringToList(cmdLine.getValue(categoryFieldsOpt).toString()); if (categoryFields.size() < 1) { throw new IllegalArgumentException("At least one category field must be spcified."); } Collection<String> textFields = stringToList(cmdLine.getValue(textFieldsOpt).toString()); if (categoryFields.size() < 1) { throw new IllegalArgumentException("At least one text field must be spcified."); } boolean useTermVectors = cmdLine.hasOption(useTermVectorsOpt); extractTraininingData(inputDir, categoryFile, categoryFields, textFields, outputDir, useTermVectors); } catch (OptionException e) { log.error("Exception", e); CommandLineUtil.printHelp(group); } catch (IOException e) { log.error("IOException", e); } finally { closeWriters(); } }
From source file:DIA_Umpire_Quant.DIA_Umpire_ExtLibSearch.java
/** * @param args the command line arguments *//*from www . j a va 2 s. c o m*/ public static void main(String[] args) throws FileNotFoundException, IOException, Exception { System.out.println( "================================================================================================="); System.out.println("DIA-Umpire targeted re-extraction analysis using external library (version: " + UmpireInfo.GetInstance().Version + ")"); if (args.length != 1) { System.out.println( "command format error, the correct format should be: java -jar -Xmx10G DIA_Umpire_ExtLibSearch.jar diaumpire_module.params"); return; } try { ConsoleLogger.SetConsoleLogger(Level.INFO); ConsoleLogger.SetFileLogger(Level.DEBUG, FilenameUtils.getFullPath(args[0]) + "diaumpire_extlibsearch.log"); } catch (Exception e) { } Logger.getRootLogger().info("Version: " + UmpireInfo.GetInstance().Version); Logger.getRootLogger().info("Parameter file:" + args[0]); BufferedReader reader = new BufferedReader(new FileReader(args[0])); String line = ""; String WorkFolder = ""; int NoCPUs = 2; String ExternalLibPath = ""; String ExternalLibDecoyTag = "DECOY"; float ExtProbThreshold = 0.99f; float RTWindow_Ext = -1f; TandemParam tandemPara = new TandemParam(DBSearchParam.SearchInstrumentType.TOF5600); HashMap<String, File> AssignFiles = new HashMap<>(); //<editor-fold defaultstate="collapsed" desc="Reading parameter file"> while ((line = reader.readLine()) != null) { line = line.trim(); Logger.getRootLogger().info(line); if (!"".equals(line) && !line.startsWith("#")) { //System.out.println(line); if (line.equals("==File list begin")) { do { line = reader.readLine(); line = line.trim(); if (line.equals("==File list end")) { continue; } else if (!"".equals(line)) { File newfile = new File(line); if (newfile.exists()) { AssignFiles.put(newfile.getAbsolutePath(), newfile); } else { Logger.getRootLogger().info("File: " + newfile + " does not exist."); } } } while (!line.equals("==File list end")); } if (line.split("=").length < 2) { continue; } String type = line.split("=")[0].trim(); String value = line.split("=")[1].trim(); switch (type) { case "Path": { WorkFolder = value; break; } case "path": { WorkFolder = value; break; } case "Thread": { NoCPUs = Integer.parseInt(value); break; } case "Fasta": { tandemPara.FastaPath = value; break; } case "DecoyPrefix": { if (!"".equals(value)) { tandemPara.DecoyPrefix = value; } break; } case "ExternalLibPath": { ExternalLibPath = value; break; } case "ExtProbThreshold": { ExtProbThreshold = Float.parseFloat(value); break; } case "RTWindow_Ext": { RTWindow_Ext = Float.parseFloat(value); break; } case "ExternalLibDecoyTag": { ExternalLibDecoyTag = value; if (ExternalLibDecoyTag.endsWith("_")) { ExternalLibDecoyTag = ExternalLibDecoyTag.substring(0, ExternalLibDecoyTag.length() - 1); } break; } } } } //</editor-fold> //Initialize PTM manager using compomics library PTMManager.GetInstance(); //Check if the fasta file can be found if (!new File(tandemPara.FastaPath).exists()) { Logger.getRootLogger().info("Fasta file :" + tandemPara.FastaPath + " cannot be found, the process will be terminated, please check."); System.exit(1); } //Generate DIA file list ArrayList<DIAPack> FileList = new ArrayList<>(); File folder = new File(WorkFolder); if (!folder.exists()) { Logger.getRootLogger().info("The path : " + WorkFolder + " cannot be found."); System.exit(1); } for (final File fileEntry : folder.listFiles()) { if (fileEntry.isFile() && (fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzxml") | fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzml")) && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q1.mzxml") && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q2.mzxml") && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) { AssignFiles.put(fileEntry.getAbsolutePath(), fileEntry); } if (fileEntry.isDirectory()) { for (final File fileEntry2 : fileEntry.listFiles()) { if (fileEntry2.isFile() && (fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzxml") | fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzml")) && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q1.mzxml") && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q2.mzxml") && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) { AssignFiles.put(fileEntry2.getAbsolutePath(), fileEntry2); } } } } Logger.getRootLogger().info("No. of files assigned :" + AssignFiles.size()); for (File fileEntry : AssignFiles.values()) { Logger.getRootLogger().info(fileEntry.getAbsolutePath()); } for (File fileEntry : AssignFiles.values()) { String mzXMLFile = fileEntry.getAbsolutePath(); if (mzXMLFile.toLowerCase().endsWith(".mzxml") | mzXMLFile.toLowerCase().endsWith(".mzml")) { DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs); Logger.getRootLogger().info( "================================================================================================="); Logger.getRootLogger().info("Processing " + mzXMLFile); if (!DiaFile.LoadDIASetting()) { Logger.getRootLogger().info("Loading DIA setting failed, job is incomplete"); System.exit(1); } if (!DiaFile.LoadParams()) { Logger.getRootLogger().info("Loading parameters failed, job is incomplete"); System.exit(1); } Logger.getRootLogger().info("Loading identification results " + mzXMLFile + "...."); //If the serialization file for ID file existed if (DiaFile.ReadSerializedLCMSID()) { DiaFile.IDsummary.ReduceMemoryUsage(); DiaFile.IDsummary.FastaPath = tandemPara.FastaPath; FileList.add(DiaFile); } } } //<editor-fold defaultstate="collapsed" desc="Targeted re-extraction using external library"> //External library search Logger.getRootLogger().info("Targeted extraction using external library"); //Read exteranl library FragmentLibManager ExlibManager = FragmentLibManager.ReadFragmentLibSerialization(WorkFolder, FilenameUtils.getBaseName(ExternalLibPath)); if (ExlibManager == null) { ExlibManager = new FragmentLibManager(FilenameUtils.getBaseName(ExternalLibPath)); //Import traML file ExlibManager.ImportFragLibByTraML(ExternalLibPath, ExternalLibDecoyTag); //Check if there are decoy spectra ExlibManager.CheckDecoys(); //ExlibManager.ImportFragLibBySPTXT(ExternalLibPath); ExlibManager.WriteFragmentLibSerialization(WorkFolder); } Logger.getRootLogger() .info("No. of peptide ions in external lib:" + ExlibManager.PeptideFragmentLib.size()); for (DIAPack diafile : FileList) { if (diafile.IDsummary == null) { diafile.ReadSerializedLCMSID(); } //Generate RT mapping RTMappingExtLib RTmap = new RTMappingExtLib(diafile.IDsummary, ExlibManager, diafile.GetParameter()); RTmap.GenerateModel(); RTmap.GenerateMappedPepIon(); diafile.BuildStructure(); diafile.MS1FeatureMap.ReadPeakCluster(); diafile.GenerateMassCalibrationRTMap(); //Perform targeted re-extraction diafile.TargetedExtractionQuant(false, ExlibManager, ExtProbThreshold, RTWindow_Ext); diafile.MS1FeatureMap.ClearAllPeaks(); diafile.IDsummary.ReduceMemoryUsage(); //Remove target IDs below the defined probability threshold diafile.IDsummary.RemoveLowProbMappedIon(ExtProbThreshold); diafile.ExportID(); diafile.ClearStructure(); Logger.getRootLogger().info("Peptide ions: " + diafile.IDsummary.GetPepIonList().size() + " Mapped ions: " + diafile.IDsummary.GetMappedPepIonList().size()); } //</editor-fold> Logger.getRootLogger().info("Job done"); Logger.getRootLogger().info( "================================================================================================="); }
From source file:org.apache.s4.client.Adapter.java
@SuppressWarnings("static-access") public static void main(String args[]) throws IOException, InterruptedException { Options options = new Options(); options.addOption(OptionBuilder.withArgName("corehome").hasArg().withDescription("core home").create("c")); options.addOption(// w w w .ja v a 2 s.c o m OptionBuilder.withArgName("instanceid").hasArg().withDescription("instance id").create("i")); options.addOption( OptionBuilder.withArgName("configtype").hasArg().withDescription("configuration type").create("t")); options.addOption(OptionBuilder.withArgName("userconfig").hasArg() .withDescription("user-defined legacy data adapter configuration file").create("d")); CommandLineParser parser = new GnuParser(); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); } catch (ParseException pe) { System.err.println(pe.getLocalizedMessage()); System.exit(1); } int instanceId = -1; if (commandLine.hasOption("i")) { String instanceIdStr = commandLine.getOptionValue("i"); try { instanceId = Integer.parseInt(instanceIdStr); } catch (NumberFormatException nfe) { System.err.println("Bad instance id: %s" + instanceIdStr); System.exit(1); } } if (commandLine.hasOption("c")) { coreHome = commandLine.getOptionValue("c"); } String configType = "typical"; if (commandLine.hasOption("t")) { configType = commandLine.getOptionValue("t"); } String userConfigFilename = null; if (commandLine.hasOption("d")) { userConfigFilename = commandLine.getOptionValue("d"); } File userConfigFile = new File(userConfigFilename); if (!userConfigFile.isFile()) { System.err.println("Bad user configuration file: " + userConfigFilename); System.exit(1); } File coreHomeFile = new File(coreHome); if (!coreHomeFile.isDirectory()) { System.err.println("Bad core home: " + coreHome); System.exit(1); } if (instanceId > -1) { System.setProperty("instanceId", "" + instanceId); } else { System.setProperty("instanceId", "" + S4Util.getPID()); } String configBase = coreHome + File.separatorChar + "conf" + File.separatorChar + configType; String configPath = configBase + File.separatorChar + "client-adapter-conf.xml"; File configFile = new File(configPath); if (!configFile.exists()) { System.err.printf("adapter config file %s does not exist\n", configPath); System.exit(1); } // load adapter config xml ApplicationContext coreContext; coreContext = new FileSystemXmlApplicationContext("file:" + configPath); ApplicationContext context = coreContext; Adapter adapter = (Adapter) context.getBean("client_adapter"); ApplicationContext appContext = new FileSystemXmlApplicationContext( new String[] { "file:" + userConfigFilename }, context); Map<?, ?> inputStubBeanMap = appContext.getBeansOfType(InputStub.class); Map<?, ?> outputStubBeanMap = appContext.getBeansOfType(OutputStub.class); if (inputStubBeanMap.size() == 0 && outputStubBeanMap.size() == 0) { System.err.println("No user-defined input/output stub beans"); System.exit(1); } ArrayList<InputStub> inputStubs = new ArrayList<InputStub>(inputStubBeanMap.size()); ArrayList<OutputStub> outputStubs = new ArrayList<OutputStub>(outputStubBeanMap.size()); // add all input stubs for (Map.Entry<?, ?> e : inputStubBeanMap.entrySet()) { String beanName = (String) e.getKey(); System.out.println("Adding InputStub " + beanName); inputStubs.add((InputStub) e.getValue()); } // add all output stubs for (Map.Entry<?, ?> e : outputStubBeanMap.entrySet()) { String beanName = (String) e.getKey(); System.out.println("Adding OutputStub " + beanName); outputStubs.add((OutputStub) e.getValue()); } adapter.setInputStubs(inputStubs); adapter.setOutputStubs(outputStubs); }
From source file:com.act.lcms.db.analysis.ConfigurableAnalysis.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());//from ww w .j a v a 2s .c om } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } Double fontScale = null; if (cl.hasOption("font-scale")) { try { fontScale = Double.parseDouble(cl.getOptionValue("font-scale")); } catch (IllegalArgumentException e) { System.err.format("Argument for font-scale must be a floating point number.\n"); System.exit(1); } } File configFile = new File(cl.getOptionValue(OPTION_CONFIG_FILE)); if (!configFile.isFile()) { throw new IllegalArgumentException( String.format("Not a regular file at %s", configFile.getAbsolutePath())); } TSVParser parser = new TSVParser(); parser.parse(configFile); try (DB db = DB.openDBFromCLI(cl)) { System.out.format("Loading/updating LCMS scan files into DB\n"); ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir); List<AnalysisStep> steps = new ArrayList<>(parser.getResults().size()); int i = 0; for (Map<String, String> row : parser.getResults()) { AnalysisStep step = mapToStep(db, i, row); if (step != null) { System.out.format("%d: %s '%s' %s %s %f %s\n", step.getIndex(), step.getKind(), step.getLabel(), step.getPlateBarcode(), step.getPlateCoords(), step.getExactMass(), step.getUseFineGrainedMZTolerance()); } steps.add(step); i++; } System.out.format("Running analysis\n"); runAnalysis(db, lcmsDir, cl.getOptionValue(OPTION_OUTPUT_PREFIX), steps, cl.hasOption(OPTION_USE_HEATMAP), fontScale, cl.hasOption(OPTION_USE_SNR)); } }
From source file:kenh.xscript.ScriptUtils.java
public static void main(String[] args) { String file = null;//from ww w.ja v a2 s. c om for (String arg : args) { if (StringUtils.startsWithAny(StringUtils.lowerCase(arg), "-f:", "-file:")) { file = StringUtils.substringAfter(arg, ":"); } } Element e = null; try { if (StringUtils.isBlank(file)) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("xScript"); chooser.setAcceptAllFileFilterUsed(false); chooser.setFileFilter(new FileFilter() { public boolean accept(File f) { if (f.isDirectory()) { return true; } else if (f.isFile() && StringUtils.endsWithIgnoreCase(f.getName(), ".xml")) { return true; } return false; } public String getDescription() { return "xScript (*.xml)"; } }); int returnVal = chooser.showOpenDialog(null); chooser.requestFocus(); if (returnVal == JFileChooser.CANCEL_OPTION) return; File f = chooser.getSelectedFile(); e = getInstance(f, null); } else { e = getInstance(new File(file), null); } //debug(e); //System.out.println("----------------------"); int result = e.invoke(); if (result == Element.EXCEPTION) { Object obj = e.getEnvironment().getVariable(Constant.VARIABLE_EXCEPTION); if (obj != null && obj instanceof Throwable) { System.err.println(); ((Throwable) obj).printStackTrace(); } else { System.err.println(); System.err.println("Unknown EXCEPTION is thrown."); } } } catch (Exception ex) { ex.printStackTrace(); System.err.println(); if (ex instanceof UnsupportedScriptException) { UnsupportedScriptException ex_ = (UnsupportedScriptException) ex; if (ex_.getElement() != null) { debug(ex_.getElement(), System.err); } } } finally { if (e != null) e.getEnvironment().callback(); } }