diff --git a/src/main/java/proteomics/ECL2.java b/src/main/java/proteomics/ECL2.java index 386da27..70e7bf1 100644 --- a/src/main/java/proteomics/ECL2.java +++ b/src/main/java/proteomics/ECL2.java @@ -234,22 +234,19 @@ private static void saveTargetResult(List result, Map proAnnotationList1 = new LinkedList<>(); + for (String s : re.pro_id_1.split(";")) { + proAnnotationList1.add(pro_annotate_map.get(s)); } - String pro_2 = re.pro_id_2; - if (re.pro_id_2.contains(";")) { - pro_2 = re.pro_id_2.split(";")[0]; + List proAnnotationList2 = new LinkedList<>(); + for (String s : re.pro_id_2.split(";")) { + proAnnotationList2.add(pro_annotate_map.get(s)); } - String annotate_1 = pro_annotate_map.get(pro_1).replace(',', ';'); - String annotate_2 = pro_annotate_map.get(pro_2).replace(',', ';'); - if (dev) { - writer.write(re.scan_num + "," + re.spectrum_id + "," + re.spectrum_mz + "," + re.spectrum_mass + "," + re.peptide_mass + "," + re.rt + "," + re.C13_correction + "," + re.charge + "," + String.format(Locale.US, "%.4f", re.score) + "," + re.delta_c + "," + String.format(Locale.US, "%.2f", re.ppm) + "," + re.seq_1 + "-" + link_site_1 + "-" + re.seq_2 + "-" + link_site_2 + "," + re.pro_id_1 + "-" + re.pro_id_2 + ",\"" + annotate_1 + "\",\"" + annotate_2 + "\"," + (cal_evalue ? String.format(Locale.US, "%E", re.e_value) : "-") + "," + String.format(Locale.US, "%.4f", re.qvalue) + ",\"" + re.mgfTitle + "\",," + re.candidate_num + "," + re.point_count + "," + String.format(Locale.US, "%.4f", re.r_square) + "," + String.format(Locale.US, "%.4f", re.slope) + "," + String.format(Locale.US, "%.4f", re.intercept) + "," + re.start_idx + "," + re.end_idx + "," + String.format(Locale.US, "%.4f", re.chain_score_1) + "," + re.chain_rank_1 + "," + String.format(Locale.US, "%.4f", re.chain_score_2) + "," + re.chain_rank_2 + "\n"); + writer.write(re.scan_num + "," + re.spectrum_id + "," + re.spectrum_mz + "," + re.spectrum_mass + "," + re.peptide_mass + "," + re.rt + "," + re.C13_correction + "," + re.charge + "," + String.format(Locale.US, "%.4f", re.score) + "," + re.delta_c + "," + String.format(Locale.US, "%.2f", re.ppm) + "," + re.seq_1 + "-" + link_site_1 + "-" + re.seq_2 + "-" + link_site_2 + "," + re.pro_id_1 + "-" + re.pro_id_2 + ",\"" + String.join(";", proAnnotationList1) + "\",\"" + String.join(";", proAnnotationList2) + "\"," + (cal_evalue ? String.format(Locale.US, "%E", re.e_value) : "-") + "," + String.format(Locale.US, "%.4f", re.qvalue) + ",\"" + re.mgfTitle + "\",," + re.candidate_num + "," + re.point_count + "," + String.format(Locale.US, "%.4f", re.r_square) + "," + String.format(Locale.US, "%.4f", re.slope) + "," + String.format(Locale.US, "%.4f", re.intercept) + "," + re.start_idx + "," + re.end_idx + "," + String.format(Locale.US, "%.4f", re.chain_score_1) + "," + re.chain_rank_1 + "," + String.format(Locale.US, "%.4f", re.chain_score_2) + "," + re.chain_rank_2 + "\n"); } else { - writer.write(re.scan_num + "," + re.spectrum_id + "," + re.spectrum_mz + "," + re.spectrum_mass + "," + re.peptide_mass + "," + re.rt + "," + re.C13_correction + "," + re.charge + "," + String.format(Locale.US, "%.4f", re.score) + "," + re.delta_c + "," + String.format(Locale.US, "%.2f", re.ppm) + "," + re.seq_1 + "-" + link_site_1 + "-" + re.seq_2 + "-" + link_site_2 + "," + re.pro_id_1 + "-" + re.pro_id_2 + ",\"" + annotate_1 + "\",\"" + annotate_2 + "\"," + (cal_evalue ? String.format(Locale.US, "%E", re.e_value) : "-") + "," + String.format(Locale.US, "%.4f", re.qvalue) + ",\"" + re.mgfTitle + "\"\n"); + writer.write(re.scan_num + "," + re.spectrum_id + "," + re.spectrum_mz + "," + re.spectrum_mass + "," + re.peptide_mass + "," + re.rt + "," + re.C13_correction + "," + re.charge + "," + String.format(Locale.US, "%.4f", re.score) + "," + re.delta_c + "," + String.format(Locale.US, "%.2f", re.ppm) + "," + re.seq_1 + "-" + link_site_1 + "-" + re.seq_2 + "-" + link_site_2 + "," + re.pro_id_1 + "-" + re.pro_id_2 + ",\"" + String.join(";", proAnnotationList1) + "\",\"" + String.join(";", proAnnotationList2) + "\"," + (cal_evalue ? String.format(Locale.US, "%E", re.e_value) : "-") + "," + String.format(Locale.US, "%.4f", re.qvalue) + ",\"" + re.mgfTitle + "\"\n"); } } } diff --git a/src/main/java/proteomics/Search/Search.java b/src/main/java/proteomics/Search/Search.java index 5f3bdd2..a3e009d 100644 --- a/src/main/java/proteomics/Search/Search.java +++ b/src/main/java/proteomics/Search/Search.java @@ -257,19 +257,27 @@ public FinalResultEntry convertResultEntry(int scanNum, ResultEntry result_entry spectrum_mass += C13_Diff_num * 1.00335483f; float ppm = (spectrum_mass - theo_mass) * 1e6f / theo_mass; - String pro_1 = ""; + Set pro1Set = new TreeSet<>(); + boolean isDecoy1 = false; for (String temp : seqProMap.get(chain_entry_1.seq.replaceAll("[^A-Znc]", ""))) { - pro_1 += temp + ";"; + pro1Set.add(temp); + if (temp.startsWith("DECOY")) { // there is no overlapped peptide between target and decoy. + isDecoy1 = true; + } } - String pro_2 = ""; + Set pro2Set = new TreeSet<>(); + boolean isDecoy2 = false; for (String temp : seqProMap.get(chain_entry_2.seq.replaceAll("[^A-Znc]", ""))) { - pro_2 += temp + ";"; + pro2Set.add(temp); + if (temp.startsWith("DECOY")) { // there is no overlapped peptide between target and decoy. + isDecoy2 = true; + } } int hit_type; // 0 = T-T; 1 = D-D; 2 = T-D; - if (pro_1.startsWith("DECOY") && pro_2.startsWith("DECOY")) { + if (isDecoy1 && isDecoy2) { hit_type = 1; - } else if (!pro_1.startsWith("DECOY") && !pro_2.startsWith("DECOY")) { + } else if (!isDecoy1 && !isDecoy2) { hit_type = 0; } else { hit_type = 2; @@ -305,7 +313,7 @@ public FinalResultEntry convertResultEntry(int scanNum, ResultEntry result_entry String final_seq_1 = addFixMod(chain_seq_1, result_entry.getLinkSite1()); String final_seq_2 = addFixMod(chain_seq_2, result_entry.getLinkSite2()); - return new FinalResultEntry(scanNum, result_entry.spectrum_id, rank, result_entry.charge, result_entry.spectrum_mz, result_entry.spectrum_mass, theo_mass, result_entry.rt, ppm, result_entry.getScore(), delta_c, final_seq_1, result_entry.getLinkSite1(), pro_1, final_seq_2, result_entry.getLinkSite2(), pro_2, cl_type, hit_type, C13_Diff_num, result_entry.getEValue(), result_entry.getScoreCount(), result_entry.getRSquare(), result_entry.getSlope(), result_entry.getIntercept(), result_entry.getStartIdx(), result_entry.getEndIdx(), result_entry.getChainScore1(), result_entry.getChainRank1(), result_entry.getChainScore2(), result_entry.getChainRank2(), result_entry.getCandidateNum(), cal_evalue, spectrumEntry.mgfTitle); + return new FinalResultEntry(scanNum, result_entry.spectrum_id, rank, result_entry.charge, result_entry.spectrum_mz, result_entry.spectrum_mass, theo_mass, result_entry.rt, ppm, result_entry.getScore(), delta_c, final_seq_1, result_entry.getLinkSite1(), String.join(";", pro1Set), final_seq_2, result_entry.getLinkSite2(), String.join(";", pro2Set), cl_type, hit_type, C13_Diff_num, result_entry.getEValue(), result_entry.getScoreCount(), result_entry.getRSquare(), result_entry.getSlope(), result_entry.getIntercept(), result_entry.getStartIdx(), result_entry.getEndIdx(), result_entry.getChainScore1(), result_entry.getChainRank1(), result_entry.getChainScore2(), result_entry.getChainRank2(), result_entry.getCandidateNum(), cal_evalue, spectrumEntry.mgfTitle); } private void linearScan(SpectrumEntry spectrumEntry, SparseVector xcorrPL, int specMaxBinIdx, ChainEntry chainEntry, int binInx, TreeMap binChainMap, List debugEntryList, Map devChainScoreMap) {