List of usage examples for java.util TreeSet iterator
public Iterator<E> iterator()
From source file:org.archive.crawler.admin.StatisticsTracker.java
protected Iterator<SeedRecord> getSeedRecordsSortedByStatusCode(Iterator<String> i) { TreeSet<SeedRecord> sortedSet = new TreeSet<SeedRecord>(new Comparator<SeedRecord>() { public int compare(SeedRecord sr1, SeedRecord sr2) { int code1 = sr1.getStatusCode(); int code2 = sr2.getStatusCode(); if (code1 == code2) { // If the values are equal, sort by URIs. return sr1.getUri().compareTo(sr2.getUri()); }/*from w w w . j a v a 2 s . c o m*/ // mirror and shift the nubmer line so as to // place zero at the beginning, then all negatives // in order of ascending absolute value, then all // positives descending code1 = -code1 - Integer.MAX_VALUE; code2 = -code2 - Integer.MAX_VALUE; return new Integer(code1).compareTo(new Integer(code2)); } }); while (i.hasNext()) { String seed = i.next(); SeedRecord sr = (SeedRecord) processedSeedsRecords.get(seed); if (sr == null) { sr = new SeedRecord(seed, SEED_DISPOSITION_NOT_PROCESSED); } sortedSet.add(sr); } return sortedSet.iterator(); }
From source file:org.bigtextml.topics.ParallelTopicModel.java
/** Return an array (one element for each topic) of arrays of words, which * are the most probable words for that topic in descending order. These * are returned as Objects, but will probably be Strings. * * @param numWords The maximum length of each topic's array of words (may be less). *///from w ww. java 2 s . com public Object[][] getTopWords(int numWords) { ArrayList<TreeSet<IDSorter>> topicSortedWords = getSortedWords(); Object[][] result = new Object[numTopics][]; for (int topic = 0; topic < numTopics; topic++) { TreeSet<IDSorter> sortedWords = topicSortedWords.get(topic); // How many words should we report? Some topics may have fewer than // the default number of words with non-zero weight. int limit = numWords; if (sortedWords.size() < numWords) { limit = sortedWords.size(); } result[topic] = new Object[limit]; Iterator<IDSorter> iterator = sortedWords.iterator(); for (int i = 0; i < limit; i++) { IDSorter info = iterator.next(); result[topic][i] = alphabet.lookupObject(info.getID()); } } return result; }
From source file:org.dbflute.maven.plugin.CreateClientPlugin.java
protected String extractLatestVersion(String enginePrefix, List<String> engineDirNameList) { final TreeSet<String> versionOrderedSet = new TreeSet<String>(new Comparator<String>() { public int compare(String o1, String o2) { final String comp1; final String comp2; if (startsWithDBFlute(o1) && startsWithDBFlute(o2)) { comp1 = filterPriority(extractVersion(o1)); comp2 = filterPriority(extractVersion(o2)); } else { comp1 = (startsWithDBFlute(o1) ? "9" : "0") + o1; comp2 = (startsWithDBFlute(o2) ? "9" : "0") + o2; }/* w ww . ja v a2 s . co m*/ return -comp1.compareTo(comp2); // ordering bigger } protected String extractVersion(String o1) { return o1.substring(o1.indexOf("-") + "-".length()); } protected boolean startsWithDBFlute(String str) { return str.startsWith(enginePrefix); } protected String filterPriority(String ver) { if (!ver.contains("-")) { // e.g. dbflute-1.1.0 (B. next priority) return ver + "-77"; } // contains hyphen here if (ver.contains("-sp")) { // e.g. 1.1.0-sp1 (A. most priority) return ver.replace("-sp", "-99"); } else if (ver.contains("-RC")) { // e.g. 1.1.0-RC1 (C. middle priority) return ver.replace("-RC", "-55"); } else if (ver.contains("-SNAPSHOT")) { // e.g. 1.1.0-RC1 (D. low priority) return ver.substring(0, ver.indexOf("-")) + "-33" + ver.substring(ver.indexOf("-")); } else { // e.g. 1.1.0-pilot1 (E. low priority) return ver.substring(0, ver.indexOf("-")) + "-11" + ver.substring(ver.indexOf("-")); } } }); versionOrderedSet.addAll(engineDirNameList); final String latestVersionEngineName = versionOrderedSet.iterator().next(); return latestVersionEngineName.substring(latestVersionEngineName.indexOf("-") + "-".length()); }
From source file:guineu.modules.filter.Alignment.RANSAC.RansacAlignerTask.java
/** * * @param peakList/*from w w w . j ava 2 s.c o m*/ * @return */ private HashMap<PeakListRow, PeakListRow> getAlignmentMap(Dataset peakList) { // Create a table of mappings for best scores HashMap<PeakListRow, PeakListRow> alignmentMapping = new HashMap<PeakListRow, PeakListRow>(); if (alignedPeakList.getNumberRows() < 1) { return alignmentMapping; } // Create a sorted set of scores matching TreeSet<RowVsRowScore> scoreSet = new TreeSet<RowVsRowScore>(); // RANSAC algorithm List<AlignStructMol> list = ransacPeakLists(alignedPeakList, peakList); PolynomialFunction function = this.getPolynomialFunction(list, ((SimpleLCMSDataset) alignedPeakList).getRowsRTRange()); PeakListRow allRows[] = peakList.getRows().toArray(new PeakListRow[0]); for (PeakListRow row : allRows) { double rt = 0.0; try { rt = function.value(((SimplePeakListRowLCMS) row).getRT()); } catch (NullPointerException e) { rt = ((SimplePeakListRowLCMS) row).getRT(); } if (Double.isNaN(rt) || rt == -1) { rt = ((SimplePeakListRowLCMS) row).getRT(); } Range mzRange = this.mzTolerance.getToleranceRange(((SimplePeakListRowLCMS) row).getMZ()); Range rtRange = this.rtToleranceAfterRTcorrection.getToleranceRange(rt); // Get all rows of the aligned peaklist within parameter limits PeakListRow candidateRows[] = ((SimpleLCMSDataset) alignedPeakList).getRowsInsideRTAndMZRange(rtRange, mzRange); for (PeakListRow candidate : candidateRows) { RowVsRowScore score; try { score = new RowVsRowScore(row, candidate, mzTolerance.getTolerance(), rtToleranceAfterRTcorrection.getTolerance(), rt); scoreSet.add(score); errorMessage = score.getErrorMessage(); } catch (Exception e) { e.printStackTrace(); setStatus(TaskStatus.ERROR); return null; } } progress = (double) processedRows++ / (double) totalRows; } // Iterate scores by descending order Iterator<RowVsRowScore> scoreIterator = scoreSet.iterator(); while (scoreIterator.hasNext()) { RowVsRowScore score = scoreIterator.next(); // Check if the row is already mapped if (alignmentMapping.containsKey(score.getPeakListRow())) { continue; } // Check if the aligned row is already filled if (alignmentMapping.containsValue(score.getAlignedRow())) { continue; } alignmentMapping.put(score.getPeakListRow(), score.getAlignedRow()); } return alignmentMapping; }
From source file:org.wise.vle.utils.FileManager.java
/** * Retrieves the files in the folders and calls compareFolder on all * of those files.//from w w w . j a v a2s .c om * @param sourceLocation the file or folder from the parent project * @param targetLocation the file or folder from the child project * @throws IOException */ public static void compareFolderHelper(File sourceLocation, File targetLocation, HashMap<String, String> parentFileNameToNodeId, HashMap<String, String> htmlToHt, HashMap<String, String> nodeIdToModified) throws IOException { //used to retrieve all the file names TreeSet<String> files = new TreeSet<String>(); if (sourceLocation.isDirectory()) { //get all the files in the child project folder String[] sourceChildren = sourceLocation.list(); //add the file names to the files collection addFileNamesToCollection(files, sourceChildren); } if (targetLocation.isDirectory()) { //get all the files in the parent project folder String[] targetChildren = targetLocation.list(); //add the file names to the files collection addFileNamesToCollection(files, targetChildren); } //loop through all the file names Iterator<String> iterator = files.iterator(); while (iterator.hasNext()) { //get a file name String file = iterator.next(); /* * call compareFolder on the file which compares the file in the * parent and child project folders even if the file exists or not */ compareFolder(new File(sourceLocation, file), new File(targetLocation, file), parentFileNameToNodeId, htmlToHt, nodeIdToModified); } }
From source file:org.wise.vle.utils.FileManager.java
/** * Compare all the sequences in the parent project and the child project. * We will determine whether an activity or a step was added, deleted, * or moved./* w w w . j a v a 2s . c o m*/ * @param parentProjectNode the JSONObject for the parent project * @param childProjectNode the JSONObject for the child project */ public static void compareSequences(JSONObject parentProjectNode, JSONObject childProjectNode, HashMap<String, JSONObject> parentNodeIdToNodeOrSequence, HashMap<String, JSONObject> childNodeIdToNodeOrSequence, HashMap<String, String> parentNodeIdToStepNumber, HashMap<String, String> childNodeIdToStepNumber, HashMap<String, String> nodeIdToStatus, HashMap<String, String> nodeIdToModified) { //a TreeSet to gather all the unique sequence ids from the parent and child projects TreeSet<String> sequenceIds = new TreeSet<String>(); try { //get the sequences in the parent project JSONArray parentProjectSequences = parentProjectNode.getJSONArray("sequences"); //get the sequences in the child project JSONArray childProjectSequences = childProjectNode.getJSONArray("sequences"); //retrieve all the sequence ids from the parent and child projects extractNodeIdsFromSequenceNodeJSONArray(sequenceIds, parentProjectSequences); extractNodeIdsFromSequenceNodeJSONArray(sequenceIds, childProjectSequences); //loop through all the sequence ids we have just collected Iterator<String> sequenceIdsIterator = sequenceIds.iterator(); while (sequenceIdsIterator.hasNext()) { //get a sequence id String sequenceId = sequenceIdsIterator.next(); /* * try to retrieve the sequence JSONObject from the child and parent project. * the sequence id may be in only one of the projects if one of the projects * has been changed. */ JSONObject childSequence = childNodeIdToNodeOrSequence.get(sequenceId); JSONObject parentSequence = parentNodeIdToNodeOrSequence.get(sequenceId); if (childSequence != null && parentSequence != null) { /* * both parent and child projects have this sequence so we will compare * the nodes within them */ //get the array of child ids from both sequences JSONArray parentRefs = parentSequence.getJSONArray("refs"); JSONArray childRefs = childSequence.getJSONArray("refs"); //a TreeSet to collect all the node ids for the current sequence TreeSet<String> nodeIds = new TreeSet<String>(); //retrieve all the sequence ids from the current parent and child sequence extractNodeIdsFromJSONArray(nodeIds, parentRefs); extractNodeIdsFromJSONArray(nodeIds, childRefs); /* * flag to be set if there is a difference between the parent and * child sequence in terms of node existence and node comparison. * this will not take into consideration the modification of a * node's content. node modification is handled somewhere else. */ boolean sequenceModified = false; //loop through all the node ids we found Iterator<String> nodeIdsIterator = nodeIds.iterator(); while (nodeIdsIterator.hasNext()) { //get a node id String nodeId = nodeIdsIterator.next(); //get the node from the parent and child project JSONObject parentNode = parentNodeIdToNodeOrSequence.get(nodeId); JSONObject childNode = childNodeIdToNodeOrSequence.get(nodeId); if (childNode != null && parentNode != null) { /* * node exists in both parent and child project so we will * check if the node is in the same position or if it was moved */ //get the step number for the node in the parent and child project String parentStepNumber = parentNodeIdToStepNumber.get(nodeId); String childStepNumber = childNodeIdToStepNumber.get(nodeId); if (childStepNumber != null && parentStepNumber != null) { if (!childStepNumber.equals(parentStepNumber)) { //step numbers are different so the step was moved nodeIdToStatus.put(nodeId, "moved"); //the sequence is different between parent and child project sequenceModified = true; } } } else if (childNode != null && parentNode == null) { /* * node was only found in the child project which means * the node will be deleted from child project */ nodeIdToStatus.put(nodeId, "deleted"); //the sequence is different between parent and child project sequenceModified = true; } else if (childNode == null && parentNode != null) { /* * node was only found in the parent project which means * the node will be added to child project */ nodeIdToStatus.put(nodeId, "added"); //the sequence is different between parent and child project sequenceModified = true; } } if (sequenceModified) { //sequence was modified nodeIdToModified.put(sequenceId, "true"); } else { //sequence was not modified nodeIdToModified.put(sequenceId, "false"); } } else if (childSequence != null && parentSequence == null) { /* * child project has this sequence but parent project does not so * we will check if the nodes in the child project sequence are * new to the parent project because it is possible the child * project had the nodes moved to a new sequence. */ /* * set the status of this sequence to be deleted since the parent * project does not have this sequence */ nodeIdToStatus.put(sequenceId, "deleted"); //get the array of node ids in the sequence from the child project JSONArray childRefs = childSequence.getJSONArray("refs"); //loop through all the node ids for (int x = 0; x < childRefs.length(); x++) { //get a node id String nodeId = childRefs.getString(x); //try to retrieve the node with the given node id from the parent project JSONObject parentNode = parentNodeIdToNodeOrSequence.get(nodeId); if (parentNode == null) { //parent does not have this node so it will be deleted nodeIdToStatus.put(nodeId, "deleted"); } else { //parent does have this node so it was just moved to another sequence nodeIdToStatus.put(nodeId, "moved"); } } } else if (childSequence == null && parentSequence != null) { /* * parent project has this sequence but child project does not so * we will check if the nodes in the parent project sequence are * new to the child project */ /* * set the status of this sequence to be added since the child * project does not have this sequence */ nodeIdToStatus.put(sequenceId, "added"); //get the array of node ids in the sequence from the child project JSONArray parentRefs = parentSequence.getJSONArray("refs"); //loop through all the node is for (int x = 0; x < parentRefs.length(); x++) { //get a node id String nodeId = parentRefs.getString(x); //try to retrieve the node with the given node id from the child project JSONObject childNode = childNodeIdToNodeOrSequence.get(nodeId); if (childNode == null) { //child does not have this node so it will be added nodeIdToStatus.put(nodeId, "added"); } else { //child does have this node so it was just moved to another sequence nodeIdToStatus.put(nodeId, "moved"); } } } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:net.sourceforge.fenixedu.domain.student.Student.java
public PersonalIngressionData getLatestPersonalIngressionData() { TreeSet<PersonalIngressionData> personalInformations = new TreeSet<PersonalIngressionData>( Collections.reverseOrder(PersonalIngressionData.COMPARATOR_BY_EXECUTION_YEAR)); ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear(); for (PersonalIngressionData pid : getPersonalIngressionsDataSet()) { if (!pid.getExecutionYear().isAfter(currentExecutionYear)) { personalInformations.add(pid); }/*from w w w . ja va 2s.co m*/ } if (personalInformations.isEmpty()) { return null; } return personalInformations.iterator().next(); }
From source file:com.hichinaschool.flashcards.libanki.Sched.java
private TreeSet<Object[]> _groupChildrenMain(TreeSet<Object[]> grps, int depth) { TreeSet<Object[]> tree = new TreeSet<Object[]>(new DeckNameCompare()); // group and recurse Iterator<Object[]> it = grps.iterator(); Object[] tmp = null;//from w ww. j av a2 s .co m while (tmp != null || it.hasNext()) { Object[] head; if (tmp != null) { head = tmp; tmp = null; } else { head = it.next(); } String[] title = (String[]) head[0]; long did = (Long) head[1]; int newCount = (Integer) head[2]; int lrnCount = (Integer) head[3]; int revCount = (Integer) head[4]; TreeSet<Object[]> children = new TreeSet<Object[]>(new DeckNameCompare()); while (it.hasNext()) { Object[] o = it.next(); if (((String[]) o[0])[depth].equals(title[depth])) { // add to children children.add(o); } else { // proceed with this as head tmp = o; break; } } children = _groupChildrenMain(children, depth + 1); // tally up children counts, but skip deeper sub-decks for (Object[] ch : children) { if (((String[]) ch[0]).length == ((String[]) head[0]).length + 1) { newCount += (Integer) ch[2]; lrnCount += (Integer) ch[3]; revCount += (Integer) ch[4]; } } // limit the counts to the deck's limits JSONObject conf = mCol.getDecks().confForDid(did); JSONObject deck = mCol.getDecks().get(did); try { if (conf.getInt("dyn") == 0) { revCount = Math.max(0, Math.min(revCount, conf.getJSONObject("rev").getInt("perDay") - deck.getJSONArray("revToday").getInt(1))); newCount = Math.max(0, Math.min(newCount, conf.getJSONObject("new").getInt("perDay") - deck.getJSONArray("newToday").getInt(1))); } } catch (JSONException e) { throw new RuntimeException(e); } tree.add(new Object[] { title, did, newCount, lrnCount, revCount, children }); } TreeSet<Object[]> result = new TreeSet<Object[]>(new DeckNameCompare()); for (Object[] t : tree) { result.add(new Object[] { t[0], t[1], t[2], t[3], t[4] }); result.addAll((TreeSet<Object[]>) t[5]); } return result; }
From source file:ee.sk.digidoc.factory.SAXDigiDocFactory.java
private void addNamespaceIfMissing(TreeSet ts, String ns, String pref) { boolean bF = false; Iterator iNs = ts.iterator(); while (iNs.hasNext()) { String s = (String) iNs.next(); if (s != null && s.indexOf(ns) != -1) { bF = true;/* ww w. j a v a 2s. co m*/ break; } } if (!bF) { StringBuffer sb = new StringBuffer("xmlns"); if (pref != null) { sb.append(":"); sb.append(pref); } sb.append("=\""); sb.append(ns); sb.append("\""); ts.add(sb.toString()); } }
From source file:massbank.BatchSearchWorker.java
/** * T}t@C???iHTML`?j/*from www . j a v a 2s . c om*/ * @param resultFile t@C * @param htmlFile YtpHTMLt@C */ private void createSummary(File resultFile, File htmlFile) { LineNumberReader in = null; PrintWriter out = null; try { //(1) t@C? String line; int cnt = 0; ArrayList<String> nameList = new ArrayList<String>(); ArrayList<String> top1LineList = new ArrayList<String>(); TreeSet<String> top1IdList = new TreeSet<String>(); in = new LineNumberReader(new FileReader(resultFile)); while ((line = in.readLine()) != null) { line = line.trim(); if (line.equals("")) { cnt = 0; } else { cnt++; if (cnt == 1) { nameList.add(line); } else if (cnt == 2) { if (line.equals("-1")) { top1LineList.add("Invalid"); } if (line.equals("0")) { top1LineList.add("0"); } } else if (cnt == 4) { String[] vals = line.split("\t"); String id = vals[0]; top1IdList.add(id); top1LineList.add(line); } } } //? http://www.massbank.jp/ T?[o??KEGG???s HashMap<String, ArrayList> massbank2mapList = new HashMap<String, ArrayList>(); //(2)p HashMap<String, String> massbank2keggList = new HashMap<String, String>(); //(2)p HashMap<String, ArrayList> map2keggList = new HashMap<String, ArrayList>(); //(3)p ArrayList<String> mapNameList = new ArrayList<String>(); //(4)p boolean isKeggReturn = false; // if (serverUrl.indexOf("www.massbank.jp") == -1) { // isKeggReturn = false; // } if (isKeggReturn) { //(2) KEGG ID, Map IDDB String where = "where MASSBANK in("; Iterator it = top1IdList.iterator(); while (it.hasNext()) { String id = (String) it.next(); where += "'" + id + "',"; } where = where.substring(0, where.length() - 1); where += ")"; String sql = "select MASSBANK, t1.KEGG, MAP from " + "(SELECT MASSBANK,KEGG FROM OTHER_DB_IDS " + where + ") t1, PATHWAY_CPDS t2" + " where t1.KEGG=t2.KEGG order by MAP,MASSBANK"; ArrayList<String> mapList = null; try { Class.forName("com.mysql.jdbc.Driver"); String connectUrl = "jdbc:mysql://localhost/MassBank_General"; Connection con = DriverManager.getConnection(connectUrl, "bird", "bird2006"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(sql); String prevId = ""; while (rs.next()) { String id = rs.getString(1); String kegg = rs.getString(2); String map = rs.getString(3); if (!id.equals(prevId)) { if (!prevId.equals("")) { massbank2mapList.put(prevId, mapList); } mapList = new ArrayList<String>(); massbank2keggList.put(id, kegg); } mapList.add(map); prevId = id; } massbank2mapList.put(prevId, mapList); rs.close(); stmt.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } if (mapList != null) { //(3) Pathway Map?FtXg?? it = massbank2mapList.keySet().iterator(); while (it.hasNext()) { String id = (String) it.next(); String kegg = (String) massbank2keggList.get(id); ArrayList<String> list1 = massbank2mapList.get(id); for (int i = 0; i < list1.size(); i++) { String map = list1.get(i); ArrayList<String> list2 = null; if (map2keggList.containsKey(map)) { list2 = map2keggList.get(map); list2.add(kegg); } else { list2 = new ArrayList<String>(); list2.add(kegg); map2keggList.put(map, list2); } } } //(4) SOAPPathway Map?Ft?\bh?s it = map2keggList.keySet().iterator(); List<Callable<HashMap<String, String>>> tasks = new ArrayList(); while (it.hasNext()) { String map = (String) it.next(); mapNameList.add(map); ArrayList<String> list = map2keggList.get(map); String[] cpds = list.toArray(new String[] {}); Callable<HashMap<String, String>> task = new ColorPathway(map, cpds); tasks.add(task); } Collections.sort(mapNameList); // Xbhv?[10 ExecutorService exsv = Executors.newFixedThreadPool(10); List<Future<HashMap<String, String>>> results = exsv.invokeAll(tasks); // Pathway mapi[?? String saveRootPath = MassBankEnv.get(MassBankEnv.KEY_TOMCAT_APPTEMP_PATH) + "pathway"; File rootDir = new File(saveRootPath); if (!rootDir.exists()) { rootDir.mkdir(); } // String savePath = saveRootPath + File.separator + this.jobId; // File newDir = new File(savePath); // if ( !newDir.exists() ) { // newDir.mkdir(); // } //(6) Pathway mapURL for (Future<HashMap<String, String>> future : results) { HashMap<String, String> res = future.get(); it = res.keySet().iterator(); String map = (String) it.next(); String mapUrl = res.get(map); String filePath = saveRootPath + File.separator + this.jobId + "_" + map + ".png"; FileUtil.downloadFile(mapUrl, filePath); } } } //(7) ?o out = new PrintWriter(new BufferedWriter(new FileWriter(htmlFile))); // wb_?[?o String reqIonStr = "Both"; try { if (Integer.parseInt(this.ion) > 0) { reqIonStr = "Positive"; } else if (Integer.parseInt(this.ion) < 0) { reqIonStr = "Negative"; } } catch (NumberFormatException nfe) { nfe.printStackTrace(); } String title = "Summary of Batch Service Results"; out.println("<html>"); out.println("<head>"); out.println("<title>" + title + "</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>" + title + "</h1>"); out.println("<hr>"); out.println("<h3>Request Date : " + this.time + "</h3>"); out.println("Instrument Type : " + this.inst + "<br>"); out.println("MS Type : " + this.ms + "<br>"); out.println("Ion Mode : " + reqIonStr + "<br>"); out.println("<br>"); out.println("<hr>"); out.println("<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">"); String cols = String.valueOf(mapNameList.size()); out.println("<tr>"); out.println("<th bgcolor=\"LavenderBlush\" rowspan=\"1\">No.</th>"); out.println("<th bgcolor=\"LavenderBlush\" rowspan=\"1\">Query Name</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">Score</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">Hit</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">MassBank ID</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">Record Title</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">Formula</th>"); out.println("<th bgcolor=\"LightCyan\" rowspan=\"1\">Exact Mass</th>"); if (isKeggReturn) { out.println("<th bgcolor=\"LightYellow\" rowspan=\"2\">KEGG ID</th>"); out.println( "<th bgcolor=\"LightYellow\" colspan=\"" + cols + "\">Colored Pathway Maps</th>"); } out.println("</tr>"); out.print("<tr bgcolor=\"moccasin\">"); for (int i = 0; i < mapNameList.size(); i++) { out.print("<th>MAP" + String.valueOf(i + 1) + "</th>"); } out.println("</tr>"); for (int i = 0; i < nameList.size(); i++) { out.println("<tr>"); String no = String.format("%5d", i + 1); no = no.replace(" ", " "); out.println("<td>" + no + "</td>"); // Query Name String queryName = nameList.get(i); out.println("<td nowrap>" + queryName + "</td>"); line = top1LineList.get(i); if (line.equals("0")) { if (isKeggReturn) { cols = String.valueOf(mapNameList.size() + 5); } else { cols = String.valueOf(6); } out.println("<td colspan=\"" + cols + "\">No Hit Record</td>"); } else if (line.equals("Invalid")) { if (isKeggReturn) { cols = String.valueOf(mapNameList.size() + 5); } else { cols = String.valueOf(4); } out.println("<td colspan=\"" + cols + "\">Invalid Query</td>"); } else { String[] data = formatLine(line); String id = data[0]; String recTitle = data[1]; String formula = data[2]; String emass = data[3]; String score = data[4]; String hit = data[5]; boolean isHiScore = false; if (Integer.parseInt(hit) >= 3 && Double.parseDouble(score) >= 0.8) { isHiScore = true; } // Score if (isHiScore) { out.println("<td><b>" + score + "</b></td>"); } else { out.println("<td>" + score + "</td>"); } // hit peak if (isHiScore) { out.println("<td align=\"right\"><b>" + hit + "</b></td>"); } else { out.println("<td align=\"right\">" + hit + "</td>"); } // MassBank ID & Link out.println("<td><a href=\"" + serverUrl + "jsp/FwdRecord.jsp?id=" + id + "\" target=\"_blank\">" + id + "</td>"); // Record Title out.println("<td>" + recTitle + "</td>"); // Formula out.println("<td nowrap>" + formula + "</td>"); // Exact Mass out.println("<td nowrap>" + emass + "</td>"); // KEGG ID & Link if (isKeggReturn) { String keggLink = " -"; if (massbank2keggList.containsKey(id)) { String keggUrl = "http://www.genome.jp/dbget-bin/www_bget?"; String kegg = massbank2keggList.get(id); switch (kegg.charAt(0)) { case 'C': keggUrl += "cpd:" + kegg; break; case 'D': keggUrl += "dr:" + kegg; break; case 'G': keggUrl += "gl:" + kegg; break; } keggLink = "<a href=\"" + keggUrl + "\" target=\"_blank\">" + kegg + "</a>"; } out.println("<td>" + keggLink + "</td>"); // Pathway Map Link if (massbank2mapList.containsKey(id)) { ArrayList<String> list = massbank2mapList.get(id); for (int l1 = mapNameList.size() - 1; l1 >= 0; l1--) { boolean isFound = false; String map = ""; for (int l2 = list.size() - 1; l2 >= 0; l2--) { map = list.get(l2); if (map.equals(mapNameList.get(l1))) { isFound = true; break; } } if (isFound) { ArrayList<String> list2 = map2keggList.get(map); String mapUrl = serverUrl + "temp/pathway/" + this.jobId + "_" + map + ".png"; out.println("<td nowrap><a href=\"" + mapUrl + "\" target=\"_blank\">map:" + map + "(" + list2.size() + ")</a></td>"); } else { out.println("<td> -</td>"); } } } else { for (int l1 = mapNameList.size() - 1; l1 >= 0; l1--) { out.println("<td> -</td>"); } } } } out.println("</tr>"); } out.println("</table>"); } catch (Exception e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } } catch (IOException e) { } if (out != null) { out.flush(); out.close(); } } }