List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:com.revo.deployr.client.example.data.io.anon.discrete.exec.MultipleDataInMultipleDataOut.java
public static void main(String args[]) throws Exception { RClient rClient = null;// ww w .ja v a 2 s . co m try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint=" + endpoint); /* * Establish RClient connection to DeployR server. * * An RClient connection is the mandatory starting * point for any application using the client library. */ rClient = RClientFactory.createClient(endpoint); log.info("[ CONNECTION ] Established anonymous " + "connection [ RClient ]."); /* * Create the AnonymousProjectExecutionOptions object * to specify data inputs and output to the script. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions(); /* * MultipleDataInMultipleDataOut Example Note: * * The inputs sent on this example are contrived * and superfluous as the hipStar.rData binary R * object input and the hipStarUrl input perform * the exact same purpose...to load the Hip STAR * dataset into the workspace ahead of execution. * * The example is provided to simply demonstrate * the mechanism of specifying multiple inputs. */ /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData * * As this is an anonymous operation "hipStar.rData" * must have it's repository-managed access controls * set to "public". */ ProjectPreloadOptions preloadWorkspace = new ProjectPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ DATA INPUT ] Repository binary file input " + "set on execution, [ ProjectExecutionOptions.preloadWorkspace ]."); /* * Load an R object literal "hipStarUrl" into the * workspace prior to script execution. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); options.rinputs = rinputs; log.info("[ DATA INPUT ] External data source input " + "set on execution, [ ProjectPreloadOptions.rinputs ]."); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * execution. The corresponding R objects are named as * follows: * 'hip', hipDim', 'hipNames'. */ options.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ EXEC OPTION ] DeployR-encoded R object request " + "set on execution [ ProjectExecutionOptions.routputs ]."); /* * Execute a public analytics Web service as an anonymous * user based on a repository-managed R script: * /testuser/example-data-io/dataIO.R */ RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options); log.info("[ EXECUTION ] Discrete R script " + "execution completed [ RScriptExecution ]."); /* * Retrieve multiple outputs following the execution: * * 1. R console output. * 2. R console output. * 3. R console output. * 4. R console output. * 5. R console output. */ String console = exec.about().console; log.info("[ DATA OUTPUT ] Retrieved R console " + "output [ String ]."); /* * Retrieve the requested R object data encodings from * the workspace follwing the script execution. * * See the R Object Data Decoding chapter in the * Client Library Tutorial on the DeployR website for * further details. */ List<RData> objects = exec.about().workspaceObjects; for (RData rData : objects) { if (rData instanceof RDataFrame) { log.info("[ DATA OUTPUT ] Retrieved DeployR-encoded R " + "object output " + rData.getName() + " [ RDataFrame ]."); List<RData> hipSubsetVal = ((RDataFrame) rData).getValue(); } else if (rData instanceof RNumericVector) { log.info("[ DATA OUTPUT ] Retrieved DeployR-encoded R " + "object output " + rData.getName() + " [ RNumericVector ]."); List<Double> hipDimVal = ((RNumericVector) rData).getValue(); log.info("[ DATA OUTPUT ] Retrieved DeployR-encoded R " + "object " + rData.getName() + " value=" + hipDimVal); } else if (rData instanceof RStringVector) { log.info("[ DATA OUTPUT ] Retrieved DeployR-encoded R " + "object output " + rData.getName() + " [ RStringVector ]."); List<String> hipNamesVal = ((RStringVector) rData).getValue(); log.info("[ DATA OUTPUT ] Retrieved DeployR-encoded R " + "object " + rData.getName() + " value=" + hipNamesVal); } else { log.info("Unexpected DeployR-encoded R object returned, " + "object name=" + rData.getName() + ", encoding=" + rData.getClass()); } } /* * Retrieve the working directory files (artifact) * was generated by the execution. */ List<RProjectFile> wdFiles = exec.about().artifacts; for (RProjectFile wdFile : wdFiles) { log.info("[ DATA OUTPUT ] Retrieved working directory " + "file output " + wdFile.about().filename + " [ RProjectFile ]."); InputStream fis = null; try { fis = wdFile.download(); } catch (Exception ex) { log.warn("Working directory binary file " + ex); } finally { IOUtils.closeQuietly(fis); } } /* * Retrieve R graphics device plots (results) called * unnamedplot*.png that was generated by the execution. */ List<RProjectResult> results = exec.about().results; for (RProjectResult result : results) { log.info("[ DATA OUTPUT ] Retrieved graphics device " + "plot output " + result.about().filename + " [ RProjectResult ]."); InputStream fis = null; try { fis = result.download(); } catch (Exception ex) { log.warn("Graphics device plot " + ex); } finally { IOUtils.closeQuietly(fis); } } } catch (Exception ex) { log.warn("Unexpected runtime exception=" + ex); } finally { try { if (rClient != null) { /* * Release rClient connection before application exits. */ rClient.release(); } } catch (Exception fex) { } } }
From source file:mujava.cli.genmutes.java
public static void main(String[] args) throws Exception { // System.out.println("test"); genmutesCom jct = new genmutesCom(); String[] argv = { "-all", "-debug", "Flower" }; // development use, when release, // comment out this line JCommander jCommander = new JCommander(jct, args); // check session name if (jct.getParameters().size() > 1) { Util.Error("Has more parameters than needed."); return;/* w ww . ja v a 2s .c om*/ } // set session name String sessionName = jct.getParameters().get(0); muJavaHomePath = Util.loadConfig(); // check if debug mode if (jct.isDebug()) { Util.debug = true; } // get all existing session name File folder = new File(muJavaHomePath); // check if the config file has defined the correct folder if (!folder.isDirectory()) { Util.Error("ERROR: cannot locate the folder specified in mujava.config"); return; } File[] listOfFiles = folder.listFiles(); // null checking // check the specified folder has files or not if (listOfFiles == null) { Util.Error("ERROR: no files in the muJava home folder: " + muJavaHomePath); return; } List<String> fileNameList = new ArrayList<>(); for (File file : listOfFiles) { fileNameList.add(file.getName()); } // check if session is already created. if (!fileNameList.contains(sessionName)) { Util.Error("Session does not exist."); return; } // get all files in the session String[] file_list = new String[1]; // if(jct.getD()) // { File sessionFolder = new File(muJavaHomePath + "/" + sessionName + "/src"); File[] listOfFilesInSession = sessionFolder.listFiles(); file_list = new String[listOfFilesInSession.length]; for (int i = 0; i < listOfFilesInSession.length; i++) { file_list[i] = listOfFilesInSession[i].getName(); } // get all mutation operators selected HashMap<String, List<String>> ops = new HashMap<String, List<String>>(); // used // for // add // random // percentage // and // maximum String[] paras = new String[] { "1", "0" }; if (jct.getAll()) // all is selected, add all operators { // if all is selected, all mutation operators are added ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); // ops.put("SDL", jct.getAll()); } else { // if not all, add selected ops to the list if (jct.getAORB()) { ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAORS()) { ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAOIU()) { ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAOIS()) { ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAODU()) { ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getAODS()) { ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getROR()) { ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOR()) { ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOD()) { ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCOI()) { ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getSOR()) { ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOR()) { ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOI()) { ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getLOD()) { ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getASRS()) { ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getSDL()) { ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getVDL()) { ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getODL()) { ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); } if (jct.getCDL()) { ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); } } // add default option "all" if (ops.size() == 0) { ops.put("AORB", new ArrayList<String>(Arrays.asList(paras))); ops.put("AORS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODU", new ArrayList<String>(Arrays.asList(paras))); ops.put("AODS", new ArrayList<String>(Arrays.asList(paras))); ops.put("ROR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COR", new ArrayList<String>(Arrays.asList(paras))); ops.put("COD", new ArrayList<String>(Arrays.asList(paras))); ops.put("COI", new ArrayList<String>(Arrays.asList(paras))); ops.put("SOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOR", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOI", new ArrayList<String>(Arrays.asList(paras))); ops.put("LOD", new ArrayList<String>(Arrays.asList(paras))); ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras))); ops.put("SDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("ODL", new ArrayList<String>(Arrays.asList(paras))); ops.put("VDL", new ArrayList<String>(Arrays.asList(paras))); ops.put("CDL", new ArrayList<String>(Arrays.asList(paras))); } // String[] tradional_ops = ops.toArray(new String[0]); // set system setJMutationStructureAndSession(sessionName); // MutationSystem.setJMutationStructureAndSession(sessionName); MutationSystem.recordInheritanceRelation(); // generate mutants generateMutants(file_list, ops); //System.exit(0); }
From source file:net.ontopia.topicmaps.db2tm.Execute.java
public static void main(String[] argv) throws Exception { // Initialize logging CmdlineUtils.initializeLogging();// w ww . ja v a 2s. c o m // Register logging options CmdlineOptions options = new CmdlineOptions("Execute", argv); CmdlineUtils.registerLoggingOptions(options); OptionsListener ohandler = new OptionsListener(); options.addLong(ohandler, "tm", 't', true); options.addLong(ohandler, "baseuri", 'b', true); options.addLong(ohandler, "out", 'o', true); options.addLong(ohandler, "relations", 'r', true); options.addLong(ohandler, "force-rescan", 'f', true); // Parse command line options try { options.parse(); } catch (CmdlineOptions.OptionsException e) { System.err.println("Error: " + e.getMessage()); System.exit(1); } // Get command line arguments String[] args = options.getArguments(); if (args.length < 2) { usage(); System.exit(3); } // Arguments String operation = args[0]; String cfgfile = args[1]; if (!"add".equals(operation) && !"sync".equals(operation) && !"remove".equals(operation)) { usage(); System.err.println("Operation '" + operation + "' not supported."); System.exit(3); } try { // Read mapping file log.debug("Reading relation mapping file {}", cfgfile); RelationMapping mapping = RelationMapping.read(new File(cfgfile)); // open topic map String tmurl = ohandler.tm; log.debug("Opening topic map {}", tmurl); TopicMapIF topicmap; if (tmurl == null || "tm:in-memory:new".equals(tmurl)) topicmap = new InMemoryTopicMapStore().getTopicMap(); else if ("tm:rdbms:new".equals(tmurl)) topicmap = new RDBMSTopicMapStore().getTopicMap(); else { TopicMapReaderIF reader = ImportExportUtils.getReader(tmurl); topicmap = reader.read(); } TopicMapStoreIF store = topicmap.getStore(); // base locator String outfile = ohandler.out; LocatorIF baseloc = (outfile == null ? store.getBaseAddress() : new URILocator(new File(outfile))); if (baseloc == null && tmurl != null) baseloc = (ohandler.baseuri == null ? new URILocator(tmurl) : new URILocator(ohandler.baseuri)); // figure out which relations to actually process Collection<String> relations = null; if (ohandler.relations != null) { String[] relnames = StringUtils.split(ohandler.relations, ","); if (relnames.length > 0) { relations = new HashSet<String>(relnames.length); relations.addAll(Arrays.asList(relnames)); } } try { // Process data sources in mapping if ("add".equals(operation)) Processor.addRelations(mapping, relations, topicmap, baseloc); else if ("sync".equals(operation)) { boolean rescan = ohandler.forceRescan != null && Boolean.valueOf(ohandler.forceRescan).booleanValue(); Processor.synchronizeRelations(mapping, relations, topicmap, baseloc, rescan); } else if ("remove".equals(operation)) Processor.removeRelations(mapping, relations, topicmap, baseloc); else throw new UnsupportedOperationException("Unsupported operation: " + operation); // export topicmap if (outfile != null) { log.debug("Exporting topic map to {}", outfile); TopicMapWriterIF writer = ImportExportUtils.getWriter(new File(outfile)); writer.write(topicmap); } // commit transaction store.commit(); log.debug("Transaction committed."); } catch (Exception t) { log.error("Error occurred while running operation '" + operation + "'", t); // abort transaction store.abort(); log.debug("Transaction aborted."); throw t; } finally { if (store.isOpen()) store.close(); } } catch (Exception e) { Throwable cause = e.getCause(); if (cause instanceof DB2TMException) System.err.println("Error: " + e.getMessage()); else throw e; } }
From source file:cross.io.PropertyFileGenerator.java
/** * * @param args//from w ww. j av a2 s .c om */ public static void main(String[] args) { Options options = new Options(); options.addOption("f", true, "base directory for output of files"); Option provOptions = new Option("p", true, "Comma separated list of provider classes to create Properties for"); provOptions.setRequired(true); provOptions.setValueSeparator(','); options.addOption(provOptions); CommandLineParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); try { File basedir = null; List<String> providers = Collections.emptyList(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("f")) { basedir = new File(cmd.getOptionValue("f")); } else { hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options); } if (cmd.hasOption("p")) { String[] str = cmd.getOptionValues("p"); providers = Arrays.asList(str); } else { hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options); } for (String provider : providers) { createProperties(provider, basedir); } } catch (ParseException ex) { Logger.getLogger(PropertyFileGenerator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.dattack.dbtools.ping.Ping.java
/** * The <code>main</code> method. * * @param args//w w w .j a v a2 s. com * the program arguments */ public static void main(final String[] args) { final Options options = createOptions(); try { final CommandLineParser parser = new DefaultParser(); final CommandLine cmd = parser.parse(options, args); final String[] filenames = cmd.getOptionValues(FILE_OPTION); final String[] taskNames = cmd.getOptionValues(TASK_NAME_OPTION); HashSet<String> hs = null; if (taskNames != null) { hs = new HashSet<>(Arrays.asList(taskNames)); } final Ping ping = new Ping(); ping.execute(filenames, hs); } catch (@SuppressWarnings("unused") final ParseException e) { showUsage(options); } catch (final ConfigurationException | DbpingParserException e) { System.err.println(e.getMessage()); } }
From source file:com.rabbitmq.perf.PerfTest.java
public static void main(String[] args) { Options options = getOptions();/*w w w . j a v a2s .com*/ CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String testID = new SimpleDateFormat("HHmmss-SSS").format(Calendar.getInstance().getTime()); testID = strArg(cmd, 'd', "test-" + testID); String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueNames = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(testID, 1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueNames(Arrays.asList(queueNames.split(","))); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p, testID); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:edu.msu.cme.rdp.kmer.KmerSearch.java
public static void main(String[] args) throws IOException { KmerTrie kmerTrie = null;//w w w .j ava 2 s. c o m SeqReader queryReader = null; SequenceType querySeqType = SequenceType.Unknown; FastaWriter out = null; boolean exhaustive = true; boolean translQuery = false; int wordSize = -1; int translTable = 11; try { CommandLine cmdLine = new PosixParser().parse(options, args); args = cmdLine.getArgs(); if (args.length != 3) { throw new Exception("Unexpected number of arguments"); } if (cmdLine.hasOption("out")) { out = new FastaWriter(cmdLine.getOptionValue("out")); } else { out = new FastaWriter(System.out); } if (cmdLine.hasOption("correct")) { exhaustive = false; } else { exhaustive = true; } if (cmdLine.hasOption("transl-table")) { translTable = Integer.valueOf(cmdLine.getOptionValue("transl-table")); } File trainingFile = new File(args[0]); wordSize = Integer.valueOf(args[1]); File queryFile = new File(args[2]); querySeqType = SeqUtils.guessSequenceType(queryFile); queryReader = new SequenceReader(new File(args[2])); kmerTrie = KmerTrie.buildTrie(new SequenceReader(trainingFile), wordSize); if (querySeqType == SequenceType.Protein && kmerTrie.getTreeSeqType() == SequenceType.Nucleotide) { throw new Exception("Trie is made of nucleotide sequences but the query sequences are protein"); } if (querySeqType == SequenceType.Nucleotide && kmerTrie.getTreeSeqType() == SequenceType.Protein) { translQuery = true; System.err.println( "Query sequences are nucleotide but trie is in protein space, query sequences will be translated"); } if (querySeqType == SequenceType.Protein && exhaustive) { System.err.println("Cannot do an exaustive search with protein sequences, disabling"); exhaustive = false; } } catch (Exception e) { new HelpFormatter().printHelp("KmerSearch <ref_file> <word_size> <query_file>", options); System.err.println(e.getMessage()); System.exit(1); } long startTime = System.currentTimeMillis(); long seqCount = 0, passedCount = 0; Sequence querySeq; while ((querySeq = queryReader.readNextSequence()) != null) { seqCount++; List<Sequence> testSequences; if (!exhaustive) { if (translQuery) { testSequences = Arrays.asList(new Sequence(querySeq.getSeqName(), "", ProteinUtils.getInstance() .translateToProtein(querySeq.getSeqString(), true, translTable))); } else { testSequences = Arrays.asList(querySeq); } } else { if (translQuery) { testSequences = ProteinUtils.getInstance().allTranslate(querySeq); } else { testSequences = Arrays.asList(querySeq, new Sequence(querySeq.getSeqName(), "", IUBUtilities.reverseComplement(querySeq.getSeqString()))); } } boolean passed = false; for (Sequence seq : testSequences) { for (char[] kmer : KmerGenerator.getKmers(seq.getSeqString(), wordSize)) { if (kmerTrie.contains(kmer) != null) { passed = true; break; } } if (passed) { out.writeSeq(seq); passedCount++; break; } } } System.err.println("Processed: " + seqCount); System.err.println("Passed: " + passedCount); System.err.println("Failed: " + (seqCount - passedCount)); System.err.println("Time: " + (System.currentTimeMillis() - startTime) + " ms"); }
From source file:com.cws.esolutions.core.main.EmailUtility.java
public static final void main(final String[] args) { final String methodName = EmailUtility.CNAME + "#main(final String[] args)"; if (DEBUG) {/* w w w. j ava2 s . c o m*/ DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", (Object) args); } if (args.length == 0) { HelpFormatter usage = new HelpFormatter(); usage.printHelp(EmailUtility.CNAME, options, true); return; } try { CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(options, args); URL xmlURL = null; JAXBContext context = null; Unmarshaller marshaller = null; CoreConfigurationData configData = null; xmlURL = FileUtils.getFile(commandLine.getOptionValue("config")).toURI().toURL(); context = JAXBContext.newInstance(CoreConfigurationData.class); marshaller = context.createUnmarshaller(); configData = (CoreConfigurationData) marshaller.unmarshal(xmlURL); EmailMessage message = new EmailMessage(); message.setMessageTo(new ArrayList<String>(Arrays.asList(commandLine.getOptionValues("to")))); message.setMessageSubject(commandLine.getOptionValue("subject")); message.setMessageBody((String) commandLine.getArgList().get(0)); message.setEmailAddr((StringUtils.isNotEmpty(commandLine.getOptionValue("from"))) ? new ArrayList<String>(Arrays.asList(commandLine.getOptionValue("from"))) : new ArrayList<String>(Arrays.asList(configData.getMailConfig().getMailFrom()))); if (DEBUG) { DEBUGGER.debug("EmailMessage: {}", message); } try { EmailUtils.sendEmailMessage(configData.getMailConfig(), message, false); } catch (MessagingException mx) { System.err.println( "An error occurred while sending the requested message. Exception: " + mx.getMessage()); } } catch (ParseException px) { px.printStackTrace(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(EmailUtility.CNAME, options, true); } catch (MalformedURLException mx) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(EmailUtility.CNAME, options, true); } catch (JAXBException jx) { jx.printStackTrace(); System.err.println("An error occurred while loading the provided configuration file. Cannot continue."); } }