List of usage examples for java.io PrintStream print
public void print(Object obj)
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.Negater.java
@Override public void run(CommandLine commandLine) throws Exception { TypedProperties properties = TypedProperties.withProperty("direction", commandLine.getOptionValue("direction")); int[] directions = properties.getIntArray("direction", null); outer: for (String filename : commandLine.getArgs()) { List<String> lines = new ArrayList<String>(); String entry = null;/*from w w w.jav a 2s. c o m*/ BufferedReader reader = null; PrintStream writer = null; // read the entire file try { reader = new BufferedReader(new FileReader(filename)); while ((entry = reader.readLine()) != null) { lines.add(entry); } } finally { if (reader != null) { reader.close(); } } // validate the file to detect any errors prior to overwriting for (String line : lines) { try { if (!line.startsWith("#") && !line.startsWith("//")) { String[] tokens = line.split("\\s+"); if (tokens.length != directions.length) { System.err.println("unable to negate values in " + filename + ", incorrect number of values in a row"); continue outer; } for (int j = 0; j < tokens.length; j++) { if (directions[j] != 0) { Double.parseDouble(tokens[j]); } } } } catch (NumberFormatException e) { System.err.println("unable to negate values in " + filename + ", unable to parse number"); continue outer; } } // overwrite the file try { writer = new PrintStream(new File(filename)); for (String line : lines) { if (line.startsWith("#") || line.startsWith("//")) { writer.println(line); } else { String[] tokens = line.split("\\s+"); for (int j = 0; j < tokens.length; j++) { if (j > 0) { writer.print(' '); } if (directions[j] == 0) { writer.print(tokens[j]); } else { double value = Double.parseDouble(tokens[j]); writer.print(-value); } } writer.println(); } } } finally { if (writer != null) { writer.close(); } } } }
From source file:examples.ClassPropertyUsageAnalyzer.java
/** * Prints a list of related properties to the output. The list is encoded as * a single CSV value, using "@" as a separator. Miga can decode this. * Standard CSV processors do not support lists of entries as values, * however.//from w w w. j a v a2 s . c o m * * @param out * the output to write to * @param usageRecord * the data to write */ private void printRelatedProperties(PrintStream out, UsageRecord usageRecord) { List<ImmutablePair<PropertyIdValue, Double>> list = new ArrayList<ImmutablePair<PropertyIdValue, Double>>( usageRecord.propertyCoCounts.size()); for (Entry<PropertyIdValue, Integer> coCountEntry : usageRecord.propertyCoCounts.entrySet()) { double otherThisItemRate = (double) coCountEntry.getValue() / usageRecord.itemCount; double otherGlobalItemRate = (double) this.propertyRecords.get(coCountEntry.getKey()).itemCount / this.countPropertyItems; double otherThisItemRateStep = 1 / (1 + Math.exp(6 * (-2 * otherThisItemRate + 0.5))); double otherInvGlobalItemRateStep = 1 / (1 + Math.exp(6 * (-2 * (1 - otherGlobalItemRate) + 0.5))); list.add(new ImmutablePair<PropertyIdValue, Double>(coCountEntry.getKey(), otherThisItemRateStep * otherInvGlobalItemRateStep * otherThisItemRate / otherGlobalItemRate)); } Collections.sort(list, new Comparator<ImmutablePair<PropertyIdValue, Double>>() { @Override public int compare(ImmutablePair<PropertyIdValue, Double> o1, ImmutablePair<PropertyIdValue, Double> o2) { return o2.getValue().compareTo(o1.getValue()); } }); out.print(",\""); int count = 0; for (ImmutablePair<PropertyIdValue, Double> relatedProperty : list) { if (relatedProperty.right < 1.5) { break; } if (count > 0) { out.print("@"); } // makeshift escaping for Miga: out.print(getPropertyLabel(relatedProperty.left).replace("@", "")); count++; } out.print("\""); }
From source file:hu.bme.mit.sette.run.Run.java
public static void stuff(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintStream out = System.out; // print settings System.out.println("Base directory: " + BASEDIR); System.out.println("Snippet directory: " + SNIPPET_DIR); System.out.println("Snippet project name: " + SNIPPET_PROJECT); System.out.println("Output directory: " + OUTPUT_DIR); if (ToolRegister.get(CatgTool.class) != null) { System.out.println("CATG directory: " + ToolRegister.get(CatgTool.class).getToolDirectory()); }//from w ww . j a va 2s . co m if (ToolRegister.get(JPetTool.class) != null) { System.out.println("jPET executable: " + ToolRegister.get(JPetTool.class).getPetExecutable()); } if (ToolRegister.get(SpfTool.class) != null) { System.out.println("SPF JAR: " + ToolRegister.get(SpfTool.class).getToolJAR()); } System.out.println("Tools:"); for (Tool tool : ToolRegister.toArray()) { System.out.println(String.format(" %s (Version: %s, Supported Java version: %s)", tool.getName(), tool.getVersion(), tool.getSupportedJavaVersion())); } // get scenario String scenario = Run.readScenario(args, in, out); if (scenario == null) { return; } switch (scenario) { case "exit": break; case "generator": new GeneratorUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out); break; case "runner": new RunnerUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out); break; case "parser": new ParserUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out); break; case "tests-generator": new TestSuiteGenerator(Run.createSnippetProject(true), OUTPUT_DIR, Run.readTool(in, out)).generate(); break; case "tests-run": new TestSuiteRunner(Run.createSnippetProject(true), OUTPUT_DIR, Run.readTool(in, out)).analyze(); break; case "snippet-browser": EventQueue.invokeLater(new Runnable() { @Override public void run() { try { SnippetBrowser frame = new SnippetBrowser(Run.createSnippetProject(true)); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); break; case "export-csv": out.print("Target file: "); String file = in.readLine(); exportCSV(Run.createSnippetProject(true), new File(file)); break; default: throw new UnsupportedOperationException("Scenario has not been implemented yet: " + scenario); } }
From source file:com.act.lcms.plotter.WriteAndPlotMS1Results.java
public List<Pair<String, String>> writeMS1Values(Map<String, List<XZ>> ms1s, Double maxIntensity, Map<String, Double> metlinMzs, OutputStream os, boolean heatmap, boolean applyThreshold, Set<String> ionsToWrite) throws IOException { // Write data output to outfile PrintStream out = new PrintStream(os); List<Pair<String, String>> plotID = new ArrayList<>(ms1s.size()); for (Map.Entry<String, List<XZ>> ms1ForIon : ms1s.entrySet()) { String ion = ms1ForIon.getKey(); // Skip ions not in the ionsToWrite set if that set is defined. if (ionsToWrite != null && !ionsToWrite.contains(ion)) { continue; }// w w w. j a v a 2s . c o m List<XZ> ms1 = ms1ForIon.getValue(); String plotName = String.format("ion: %s, mz: %.5f", ion, metlinMzs.get(ion)); plotID.add(Pair.of(ion, plotName)); // print out the spectra to outDATA for (XZ xz : ms1) { if (heatmap) { /* * When we are building heatmaps, we use gnuplots pm3d package * along with `dgrid3d 2000,2` (which averages data into grids * that are 2000 on the time axis and 2 in the y axis), and * `view map` that flattens a 3D graphs into a 2D view. * We want time to be on the x-axis and intensity on the z-axis * (because that is the one that is mapped to heat colors) * but then we need an artificial y-axis. We create proxy y=1 * and y=2 datapoints, and then dgrid3d averaging over 2 creates * a vertical "strip". */ out.format("%.4f\t1\t%.4f\n", xz.getTime(), xz.getIntensity()); out.format("%.4f\t2\t%.4f\n", xz.getTime(), xz.getIntensity()); } else { out.format("%.4f\t%.4f\n", xz.getTime(), xz.getIntensity()); } out.flush(); } // delimit this dataset from the rest out.print("\n\n"); } return plotID; }
From source file:com.opengamma.analytics.financial.model.volatility.local.LocalVolatilityPDEGreekCalculator.java
/** * Run a forward PDE solver to get model prices (and thus implied vols) and compare these with the market data. * Also output the (model) implied volatility as a function of strike for each tenor. * @param ps The print stream//from ww w. jav a2s.com */ public void runPDESolver(final PrintStream ps) { final int n = _marketData.getNumExpiries(); final double[] expiries = _marketData.getExpiries(); final double[][] strikes = _marketData.getStrikes(); final double[][] vols = _marketData.getVolatilities(); final double maxT = expiries[n - 1]; final double maxProxyDelta = 0.4; final PDEFullResults1D pdeRes = runForwardPDESolver(_localVolatilityMoneyness, _isCall, _theta, maxT, maxProxyDelta, _timeSteps, _spaceSteps, _timeGridBunching, _spaceGridBunching, 1.0); final BlackVolatilitySurfaceMoneyness pdeVolSurface = modifiedPriceToVolSurface( _marketData.getForwardCurve(), pdeRes, 0, maxT, 0.3, 3.0, _isCall); double chiSq = 0; for (int i = 0; i < n; i++) { final int m = strikes[i].length; final double t = expiries[i]; for (int j = 0; j < m; j++) { final double k = strikes[i][j]; final double mrtVol = vols[i][j]; final double modelVol = pdeVolSurface.getVolatility(t, k); ps.println(expiries[i] + "\t" + k + "\t" + mrtVol + "\t" + modelVol); chiSq += (mrtVol - modelVol) * (mrtVol - modelVol); } } ps.println("chi^2 " + chiSq * 1e6); ps.print("\n"); ps.println("strike sensitivity"); for (int i = 0; i < n; i++) { ps.print(expiries[i] + "\t" + "" + "\t"); } ps.print("\n"); for (int i = 0; i < n; i++) { ps.print("Strike\tImplied Vol\t"); } ps.print("\n"); for (int j = 0; j < 100; j++) { for (int i = 0; i < n; i++) { final int m = strikes[i].length; final double t = expiries[i]; final double kLow = strikes[i][0]; final double kHigh = strikes[i][m - 1]; final double k = kLow + (kHigh - kLow) * j / 99.; ps.print(k + "\t" + pdeVolSurface.getVolatility(t, k) + "\t"); } ps.print("\n"); } }
From source file:org.cruxframework.crux.tools.schema.DefaultSchemaGenerator.java
/** * //ww w .j a v a 2 s .c om * @param out * @param added * @param processorClass */ private void generateEvents(PrintStream out, Set<String> added, Class<?> processorClass) { TagEvents evts = processorClass.getAnnotation(TagEvents.class); if (evts != null) { for (TagEvent evt : evts.value()) { Class<? extends EvtProcessor> evtBinder = evt.value(); try { String eventName = evtBinder.getConstructor(WidgetCreator.class) .newInstance((WidgetCreator<?>) null).getEventName(); if (!added.contains(eventName)) { out.print("<xs:attribute name=\"" + eventName + "\" "); if (evt.required()) { out.print("use=\"required\" "); } out.println(" >"); String attrDescription = evt.description(); if (attrDescription != null && attrDescription.length() > 0) { out.println("<xs:annotation>"); out.println("<xs:documentation>" + StringEscapeUtils.escapeXml(attrDescription) + "</xs:documentation>"); out.println("</xs:annotation>"); } out.println("</xs:attribute>"); added.add(eventName); } } catch (Exception e) { logger.error("Error creating XSD File: Error generating events for Processor.", e); } } } TagEventsDeclaration evtsDecl = processorClass.getAnnotation(TagEventsDeclaration.class); if (evtsDecl != null) { for (TagEventDeclaration evt : evtsDecl.value()) { out.println("<xs:attribute name=\"" + evt.value() + "\" "); if (evt.required()) { out.print("use=\"required\" "); } out.println(" >"); String attrDescription = evt.description(); if (attrDescription != null && attrDescription.length() > 0) { out.println("<xs:annotation>"); out.println("<xs:documentation>" + StringEscapeUtils.escapeXml(attrDescription) + "</xs:documentation>"); out.println("</xs:annotation>"); } out.println("</xs:attribute>"); } } }
From source file:fr.inrialpes.exmo.align.cli.GroupEval.java
public void printHTML(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far int correctVect[]; // correct so far long timeVect[]; // time so far Formatter formatter = new Formatter(writer); fsize = format.length();//from w w w . jav a 2s. com // JE: the h-means computation should be put out as well // Print the header if (embedded != true) writer.println("<html><head></head><body>"); writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<colgroup align='center' span='" + fsize + "' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<th colspan='" + fsize + "'>" + m + "</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { writer.print("Prec."); } else if (format.charAt(i) == 'f') { writer.print("FMeas."); } else if (format.charAt(i) == 'o') { writer.print("Over."); } else if (format.charAt(i) == 't') { writer.print("Time"); } else if (format.charAt(i) == 'r') { writer.print("Rec."); } writer.println("</td>"); } //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); foundVect = new int[size]; correctVect = new int[size]; timeVect = new long[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; } // </tr> // For each directory <tr> boolean colored = false; for (Vector<Object> test : result) { int nexpected = -1; if (colored == true && color != null) { colored = false; writer.println("<tr bgcolor=\"" + color + "\">"); } else { colored = true; writer.println("<tr>"); } ; // Print the directory <td>bla</td> writer.println("<td>" + (String) test.get(0) + "</td>"); // For each record print the values <td>bla</td> Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { PRecEvaluator eval = (PRecEvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { expected += eval.getExpected(); nexpected = 0; } foundVect[k] += eval.getFound(); correctVect[k] += eval.getCorrect(); timeVect[k] += eval.getTime(); for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecision()); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", eval.getFmeasure()); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", eval.getOverall()); } else if (format.charAt(i) == 't') { if (eval.getTime() == 0) { writer.print("-"); } else { formatter.format("%1.2f", eval.getTime()); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecall()); } writer.print("</td>"); } } else { for (int i = 0; i < fsize; i++) writer.print("<td>n/a</td>"); } } writer.println("</tr>"); } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); // Here we are computing a sheer average. // While in the column results we print NaN when the returned // alignment is empty, // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; // ??? for (String m : listAlgo) { double precision = (double) correctVect[k] / foundVect[k]; double recall = (double) correctVect[k] / expected; for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { formatter.format("%1.2f", precision); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", recall * (2 - (1 / precision))); } else if (format.charAt(i) == 't') { if (timeVect[k] == 0) { writer.print("-"); } else { formatter.format("%1.2f", timeVect[k]); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recall); } writer.println("</td>"); } ; k++; } writer.println("</tr>"); writer.println("</tbody></table>"); writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); writer.println("NaN: division per zero, likely due to empty alignment.</small></p>"); if (embedded != true) writer.println("</body></html>"); }
From source file:me.gloriouseggroll.quorrabot.Quorrabot.java
public Quorrabot(String username, String oauth, String apioauth, String clientid, String channelName, String owner, int baseport, InetAddress ip, String hostname, int port, double msglimit30, String datastore, String datastoreconfig, String youtubekey, String gamewispauth, String gamewisprefresh, String twitchalertstoken, String lastfmuser, String tpetoken, String twittertoken, String twittertokensecret, String streamtiptoken, String streamtipid, boolean webenable, String webauth, String webauthro, boolean musicenable, boolean usehttps, String timeZone, String mySqlHost, String mySqlPort, String mySqlConn, String mySqlPass, String mySqlUser, String mySqlName, String keystorepath, FollowersCache followersCache, ChannelHostCache hostCache, ChannelUsersCache channelUsersCache, SubscribersCache subscribersCache, String discordToken, String discordMainChannel) { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); com.gmt2001.Console.out.println(); com.gmt2001.Console.out.println(botVersion()); com.gmt2001.Console.out.println(botRevision()); com.gmt2001.Console.out.println("www.quorrabot.com"); com.gmt2001.Console.out.println(); com.gmt2001.Console.out.println("The working directory is: " + System.getProperty("user.dir")); interactive = System.getProperty("interactive") != null; this.username = username; this.oauth = oauth; this.apioauth = apioauth; this.ownerName = owner; this.channelName = channelName.toLowerCase(); this.baseport = baseport; this.ip = ip; this.datastore = datastore; this.datastoreconfig = datastoreconfig; this.hostCache = ChannelHostCache.instance(this.ownerName); this.subscribersCache = SubscribersCache.instance(this.ownerName); this.channelUsersCache = ChannelUsersCache.instance(this.ownerName); this.followersCache = FollowersCache.instance(this.ownerName); this.youtubekey = youtubekey; if (!timeZone.isEmpty()) { this.timeZone = timeZone; } else {/*from ww w.ja v a2 s. com*/ this.timeZone = "EDT"; } if (!youtubekey.isEmpty()) { YouTubeAPIv3.instance().SetAPIKey(youtubekey); } this.discordToken = discordToken; this.discordMainChannel = discordMainChannel; this.gamewispauth = gamewispauth; this.gamewisprefresh = gamewisprefresh; this.twitchalertstoken = twitchalertstoken; if (!twitchalertstoken.isEmpty()) { DonationHandlerAPI.instance().SetAccessToken(twitchalertstoken, "twitchalerts"); } this.lastfmuser = lastfmuser; if (!lastfmuser.isEmpty()) { LastFMAPI.instance().SetUsername(lastfmuser); } this.tpetoken = tpetoken; if (!tpetoken.isEmpty()) { DonationHandlerAPI.instance().SetAccessToken(tpetoken, "tpestream"); } this.streamtiptoken = streamtiptoken; if (!streamtiptoken.isEmpty()) { DonationHandlerAPI.instance().SetAccessToken(streamtiptoken, "streamtip"); } this.streamtipid = streamtipid; if (!streamtipid.isEmpty()) { DonationHandlerAPI.instance().SetClientID(streamtipid, "streamtip"); } this.twittertoken = twittertoken; this.twittertokensecret = twittertokensecret; if (!twittertoken.isEmpty() || !twittertokensecret.isEmpty()) { TwitterAPI.instance().loadAccessToken(twittertoken, twittertokensecret); } if (msglimit30 != 0) { Quorrabot.msglimit30 = msglimit30; } else { Quorrabot.msglimit30 = 18.75; } this.mySqlName = mySqlName; this.mySqlUser = mySqlUser; this.mySqlPass = mySqlPass; this.mySqlConn = mySqlConn; this.mySqlHost = mySqlHost; this.mySqlPort = mySqlPort; this.webenable = webenable; this.musicenable = musicenable; this.usehttps = usehttps; this.keystorepath = keystorepath; this.webauth = webauth; this.webauthro = webauthro; if (clientid.length() == 0) { this.clientid = "pcaalhorck7ryamyg6ijd5rtnls5pjl"; } else { this.clientid = clientid; } /** * Create a map for multiple channels. */ channels = new HashMap<>(); /** * Create a map for multiple sessions. */ sessions = new HashMap<>(); /** * Create a map for multiple oauth tokens. */ apiOAuths = new HashMap<>(); rng = new SecureRandom(); pollResults = new TreeMap<>(); voters = new TreeSet<>(); if (hostname.isEmpty()) { this.hostname = "irc.chat.twitch.tv"; this.port = 6667; } else { this.hostname = hostname; this.port = port; } if (msglimit30 > 0) { this.msglimit30 = msglimit30; } else { this.msglimit30 = 18.75; } if (datastore.equalsIgnoreCase("IniStore")) { dataStoreObj = IniStore.instance(); } else if (datastore.equalsIgnoreCase("mysqlstore")) { dataStoreObj = MySQLStore.instance(); if (this.mySqlPort.isEmpty()) { this.mySqlConn = "jdbc:mariadb://" + this.mySqlHost + "/" + this.mySqlName; } else { this.mySqlConn = "jdbc:mariadb://" + this.mySqlHost + ":" + this.mySqlPort + "/" + this.mySqlName; } /** * Check to see if we can create a connection */ if (dataStoreObj.CreateConnection(this.mySqlConn, this.mySqlUser, this.mySqlPass) == null) { com.gmt2001.Console.out .println("Could not create a connection with MySql. QuorraBot now shutting down..."); System.exit(0); } if (IniStore.instance().GetFileList().length > 0) { ini2MySql(true); } else if (SqliteStore.instance().GetFileList().length > 0) { sqlite2MySql(); } } else { dataStoreObj = SqliteStore.instance(); if (datastore.isEmpty() && IniStore.instance().GetFileList().length > 0 && SqliteStore.instance().GetFileList().length == 0) { ini2sqlite(true); } } TwitchAPIv3.instance().SetClientID(this.clientid); TwitchAPIv3.instance().SetOAuth(apioauth); this.init(); this.tcechannel = Channel.instance("tcechannel", this.ownerName, this.apioauth, EventBus.instance(), this.ownerName); //Give the bot some time in between sessions so to be sure the stream channel connects last //This needs to be done in order for the parser to detect which chat channel to use try { Thread.sleep(2000); } catch (Exception e) { // } this.channel = Channel.instance(this.channelName, this.username, this.oauth, EventBus.instance(), this.ownerName); if (SystemUtils.IS_OS_LINUX && !interactive) { try { java.lang.management.RuntimeMXBean runtime = java.lang.management.ManagementFactory .getRuntimeMXBean(); int pid = Integer.parseInt(runtime.getName().split("@")[0]); File f = new File("/var/run/QuorraBot." + this.username.toLowerCase() + ".pid"); try (FileOutputStream fs = new FileOutputStream(f, false)) { PrintStream ps = new PrintStream(fs); ps.print(pid); } f.deleteOnExit(); } catch (SecurityException | IllegalArgumentException | IOException ex) { com.gmt2001.Console.err.printStackTrace(ex); } } }
From source file:edu.msu.cme.rdp.alignment.errorcheck.RmPartialSeqs.java
public HashSet<Sequence> checkPartial(PrintStream seqOutstream, PrintStream alignOutstream) throws OverlapCheckFailedException, IOException { HashSet<Sequence> partialSeqs = new HashSet<Sequence>(); for (int i = 0; i < seqList.size(); i++) { Sequence seqx = seqList.get(i); PairwiseAlignment bestResult = null; int bestScore = Integer.MIN_VALUE; Sequence bestSeqy = null; ArrayList<NuclSeqMatch.BestMatch> matchResults = sabCalculator.findTopKMatch(seqx, knn); for (NuclSeqMatch.BestMatch match : matchResults) { Sequence seqy = refSeqMap.get(match.getBestMatch().getSeqName()); PairwiseAlignment result = PairwiseAligner.align(seqx.getSeqString().replaceAll("U", "T"), seqy.getSeqString().replaceAll("U", "T"), scoringMatrix, mode); if (bestResult == null || result.getScore() >= bestScore) { bestResult = result;// w ww. j a v a 2 s.c o m bestScore = result.getScore(); bestSeqy = seqy; } } double distance = dist.getDistance(bestResult.getAlignedSeqj().getBytes(), bestResult.getAlignedSeqi().getBytes(), 0); int beginGaps = getBeginGapLength(bestResult.getAlignedSeqi()); int endGaps = getEndGapLength(bestResult.getAlignedSeqi()); if ((beginGaps >= this.min_begin_gaps) || (endGaps >= this.min_end_gaps)) { partialSeqs.add(seqx); } else { seqOutstream.println(">" + seqx.getSeqName() + "\t" + seqx.getDesc() + "\n" + seqx.getSeqString()); } if (alignOutstream != null) { alignOutstream.println(">\t" + seqx.getSeqName() + "\t" + bestSeqy.getSeqName() + "\t" + String.format("%.3f", distance) + "\tmissingBegin=" + (beginGaps >= this.min_begin_gaps) + "\tmissingEnd=" + (endGaps >= this.min_end_gaps) + "\tbeginGaps=" + beginGaps + "\tendGaps=" + endGaps); alignOutstream.print(bestResult.getAlignedSeqi() + "\n"); alignOutstream.print(bestResult.getAlignedSeqj() + "\n"); } } seqOutstream.close(); if (alignOutstream != null) alignOutstream.close(); return partialSeqs; }
From source file:org.eclipse.php.internal.core.ast.util.Util.java
public static synchronized void verbose(String log, PrintStream printStream) { int start = 0; do {//from w w w.j a v a2 s .c o m int end = log.indexOf('\n', start); printStream.print(Thread.currentThread()); printStream.print(" "); //$NON-NLS-1$ printStream.print(log.substring(start, end == -1 ? log.length() : end + 1)); start = end + 1; } while (start != 0); printStream.println(); }