From 4182e1a935b9e0615d01cc4b8b92753e67394015 Mon Sep 17 00:00:00 2001 From: valot <valot@b8ef2a07-7df7-436f-90b9-41648038564b> Date: Fri, 25 May 2012 11:29:58 +0000 Subject: [PATCH] Used String for hashsamplescan... factory instead of reference to object. Debugging maschroml streaming writer. git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@296 b8ef2a07-7df7-436f-90b9-41648038564b --- .../xtandempipeline/class_msms/MsRun.java | 2 - .../grouping/HashPeptideSet.java | 11 +-- .../grouping/HashProteinSet.java | 8 ++- .../grouping/HashSampleScanSet.java | 11 +-- .../sax_parse/MassChroQmlWriter.java | 70 +++++++++---------- 5 files changed, 50 insertions(+), 52 deletions(-) diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java index bf927ea3a..157df11fb 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java @@ -46,11 +46,9 @@ public class MsRun implements Comparable<MsRun> { if (this.sample.equals(msRunCompare.sample)) { return true; } - else { logger.debug("msRun COLLISION on " + sample + " compared to " + msRunCompare.sample); - } } return false; diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashPeptideSet.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashPeptideSet.java index adede18de..7d30ca405 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashPeptideSet.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashPeptideSet.java @@ -15,7 +15,8 @@ public class HashPeptideSet extends HashKey4GroupsSet { */ private static final Logger logger = Logger.getLogger(HashPeptideSet.class); - private HashMap<HashPeptide, HashPeptide> mapHashPeptide = new HashMap<HashPeptide, HashPeptide>( + // Uique String to be sur that wath is use for key!!! + private HashMap<String, HashPeptide> mapHashPeptide = new HashMap<String, HashPeptide>( 0); public HashPeptideSet() { @@ -24,6 +25,7 @@ public class HashPeptideSet extends HashKey4GroupsSet { @Override public void clear() { + mapHashPeptide = new HashMap<String, HashPeptide>(0); super.clear(); } @@ -33,15 +35,14 @@ public class HashPeptideSet extends HashKey4GroupsSet { throw new Exception("sampleScan is null"); } HashPeptide temp = new HashPeptide(sampleScan, sequence); - + String tmpString = temp.getMsRun().getSampleName()+temp.getScan()+temp.getSequence(); if (this.add(temp)) { // this HashPeptide is new - this.mapHashPeptide.put(temp, temp); + this.mapHashPeptide.put(tmpString, temp); return (temp); } else { // find the existing instance of the same peptide scan : - return this.mapHashPeptide.get(temp); + return this.mapHashPeptide.get(tmpString); } } - } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashProteinSet.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashProteinSet.java index 182d2e77b..49618edc1 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashProteinSet.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashProteinSet.java @@ -16,7 +16,8 @@ public class HashProteinSet extends HashKey4GroupsSet { */ private static final Logger logger = Logger.getLogger(HashProteinSet.class); - private HashMap<HashProtein, HashProtein> mapHashProtein = new HashMap<HashProtein, HashProtein>( + //Accession is String key for ensure unique protein! + private HashMap<String, HashProtein> mapHashProtein = new HashMap<String, HashProtein>( 0); public HashProteinSet() { @@ -27,16 +28,17 @@ public class HashProteinSet extends HashKey4GroupsSet { HashProtein temp = new HashProtein(accession); if (this.add(temp)) { // this HashProtein is new - this.mapHashProtein.put(temp, temp); + this.mapHashProtein.put(accession, temp); return (temp); } else { // find the existing instance of the same protein : - return this.mapHashProtein.get(temp); + return this.mapHashProtein.get(accession); } } @Override public void clear() { + mapHashProtein = new HashMap<String, HashProtein>(0); super.clear(); } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashSampleScanSet.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashSampleScanSet.java index 76bd0bb86..62de0aa33 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashSampleScanSet.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/HashSampleScanSet.java @@ -17,7 +17,9 @@ public class HashSampleScanSet extends HashSet<HashSampleScan> implements private static final long serialVersionUID = -9055338154900110371L; private static final Logger logger = Logger .getLogger(HashSampleScanSet.class); - private HashMap<HashSampleScan, HashSampleScan> mapHashSampleScan = new HashMap<HashSampleScan, HashSampleScan>( + + //String to unique key for sample scan + private HashMap<String, HashSampleScan> mapHashSampleScan = new HashMap<String, HashSampleScan>( 0); public HashSampleScanSet() { @@ -32,14 +34,14 @@ public class HashSampleScanSet extends HashSet<HashSampleScan> implements public HashSampleScan getInstance(int scan, MsRun msRun) { HashSampleScan temp = new HashSampleScan(scan, msRun); - + String tempString = msRun.getSampleName()+scan; if (this.add(temp)) { // this HashSampleScan is new - this.mapHashSampleScan.put(temp, temp); + this.mapHashSampleScan.put(tempString, temp); return (temp); } else { // find the existing instance of the same sample scan : - return this.mapHashSampleScan.get(temp); + return this.mapHashSampleScan.get(tempString); } } @@ -67,6 +69,7 @@ public class HashSampleScanSet extends HashSet<HashSampleScan> implements @Override public void clear() { + mapHashSampleScan = new HashMap<String, HashSampleScan>(0); super.clear(); } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/MassChroQmlWriter.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/MassChroQmlWriter.java index 2d727c3c1..098ebe4d5 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/MassChroQmlWriter.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/MassChroQmlWriter.java @@ -84,7 +84,6 @@ public class MassChroQmlWriter { this.writePeptides(ident); this.writeIsotopes(isotopic_mods); - this.writeIsotopes(isotopic_mods); // ajout des methodes this.writeAlignement(); @@ -110,20 +109,18 @@ public class MassChroQmlWriter { // Element result = doc.createElement("quantification_results"); writer.writeStartElement("quantification_results"); // Element output = doc.createElement("quantification_result"); - writer.writeStartElement("quantification_result"); + writer.writeEmptyElement("quantification_result"); writer.writeAttribute("output_file", "XIC_result"); writer.writeAttribute("format", "tsv"); - writer.writeEndElement();// quantification_result writer.writeEndElement();// quantification_results // Element trace = doc.createElement("quantification_traces"); writer.writeStartElement("quantification_traces"); // Element peptides_traces = doc.createElement("peptide_traces"); - writer.writeStartElement("peptide_traces"); + writer.writeEmptyElement("peptide_traces"); writer.writeAttribute("peptide_ids", "pep0 pep1"); writer.writeAttribute("output_dir", "peplist_xics_traces/"); writer.writeAttribute("format", "tsv"); - writer.writeEndElement();// peptide_traces writer.writeEndElement();// quantification_traces // Element quantify = doc.createElement("quantify"); @@ -133,7 +130,7 @@ public class MassChroQmlWriter { writer.writeAttribute("quantification_method_id", "quant1"); // Element peptides_in_peptide_list = doc // .createElement("peptides_in_peptide_list"); - writer.writeStartElement("peptides_in_peptide_list"); + writer.writeEmptyElement("peptides_in_peptide_list"); writer.writeAttribute("mode", "real_or_mean"); // ajout des labels isotopics dans la methode @@ -144,7 +141,6 @@ public class MassChroQmlWriter { } writer.writeAttribute("isotope_label_refs", label.trim()); } - writer.writeEndElement();// peptides_in_peptide_list writer.writeEndElement();// quantify writer.writeEndElement();// quantification @@ -173,11 +169,10 @@ public class MassChroQmlWriter { // selection // Element ppm_range = doc.createElement("ppm_range"); - writer.writeStartElement("ppm_range"); + writer.writeEmptyElement("ppm_range"); writer.writeAttribute("min", "10"); writer.writeAttribute("max", "10"); writer.writeComment("For XIC extraction on Da use: mz_range"); - writer.writeEndElement();// ppm_range writer.writeEndElement();// xic_extraction @@ -186,15 +181,13 @@ public class MassChroQmlWriter { writer.writeStartElement("xic_filters"); // Element anti_spike = doc.createElement("anti_spike"); - writer.writeStartElement("anti_spike"); + writer.writeEmptyElement("anti_spike"); writer.writeAttribute("half", "5"); - writer.writeEndElement();// anti_spike // Element background = doc.createElement("background"); - writer.writeStartElement("background"); + writer.writeEmptyElement("background"); writer.writeAttribute("half_mediane", "5"); writer.writeAttribute("half_min_max", "20"); - writer.writeEndElement();// background writer.writeEndElement();// xic_filters @@ -233,7 +226,8 @@ public class MassChroQmlWriter { writer.writeEndElement();// detection_zivy writer.writeEndElement();// peak_detection - + + writer.writeEndElement();// quantification_method writer.writeEndElement();// quantification_methods } catch (Exception e) { logger.error(e.getMessage()); @@ -283,11 +277,10 @@ public class MassChroQmlWriter { // groupe d'alignement // Element align = doc.createElement("align"); - writer.writeStartElement("align"); + writer.writeEmptyElement("align"); writer.writeAttribute("group_id", this.groupe_id); writer.writeAttribute("method_id", "ms2_1"); writer.writeAttribute("reference_data_id", "samp0"); - writer.writeEndElement();// align writer.writeEndElement();// alignments } catch (Exception e) { @@ -308,14 +301,13 @@ public class MassChroQmlWriter { // balise rawdata // Element data_file = doc.createElement("data_file"); - writer.writeStartElement("data_file"); + writer.writeEmptyElement("data_file"); // data_file.setAttribute("id", id_samp); writer.writeAttribute("id", id_samp); - writer.writeAttribute("type", "profile"); writer.writeAttribute("format", "mzxml"); writer.writeAttribute("path", "" + sample.getSampleName() + ".mzXML"); - writer.writeEndElement(); + writer.writeAttribute("type", "profile"); } writer.writeEndElement(); @@ -333,7 +325,7 @@ public class MassChroQmlWriter { // //balise groups // Element group = doc.createElement("group"); - writer.writeStartElement("group"); + writer.writeEmptyElement("group"); writer.writeAttribute("id", this.groupe_id); String raw_list = ""; for (MsRun sample : ident.get_samples().getMsRunList()) { @@ -363,10 +355,9 @@ public class MassChroQmlWriter { String prot_id = this.getSubGroupGroupNumber(group, sg); // Element protein = doc.createElement("protein"); - writer.writeStartElement("protein"); + writer.writeEmptyElement("protein"); writer.writeAttribute("id", prot_id); writer.writeAttribute("desc", top.get_description()); - writer.writeEndElement(); } } @@ -390,15 +381,17 @@ public class MassChroQmlWriter { try { writer.writeStartElement("peptide_list"); Hashtable<String, HashSet<String>> seqMod2protIds; - Hashtable<String, String> seqMod2xmlPeptideId; + Hashtable<String, String> xmlPeptideId2seqMod; Hashtable<String, ArrayList<Peptide>> seqMod2PeptideList; + ArrayList<String> peptideId; int i = 0; for (Group group : ident.getGrouping().getGroupList()) { seqMod2protIds = new Hashtable<String, HashSet<String>>(); - seqMod2xmlPeptideId = new Hashtable<String, String>(); + xmlPeptideId2seqMod = new Hashtable<String, String>(); seqMod2PeptideList = new Hashtable<String, ArrayList<Peptide>>(); + peptideId = new ArrayList<String>(); for (HashSampleScan hash : group.getHashSampleScanSet() .getHashSampleScanList()) { @@ -412,15 +405,16 @@ public class MassChroQmlWriter { String seqMod = pep.get_LI_sequenceModifsWithoutMs3(); if (seqMod2protIds.containsKey(seqMod)) { } else { - seqMod2xmlPeptideId.put(seqMod, "pep" + i++); + //Add new peptide id + String pepid = "pep" + i++; + xmlPeptideId2seqMod.put(pepid,seqMod); + peptideId.add(pepid); /* * <peptide id="pep0" mh="1463.626" mods="114.08" * prot_ids="P1.1" seq="TCVADESHAGCEK"> */ // table temporaire pour prot_id HashSet<String> temp = new HashSet<String>(); - // Hashtable<String, String> temp = new - // Hashtable<String, String>(); seqMod2protIds.put(seqMod, temp); seqMod2PeptideList @@ -434,17 +428,19 @@ public class MassChroQmlWriter { temp.add(this.getSubGroupGroupNumber(group, sgTemp)); } }// end loop on each scan for one group - - for (String seqMod : seqMod2xmlPeptideId.keySet()) { + + //iterated current pepid to write buffer peptide element + for (String pepid : peptideId) { + String seqMod = xmlPeptideId2seqMod.get(pepid); ArrayList<Peptide> peptideList = seqMod2PeptideList .get(seqMod); writer.writeStartElement("peptide"); - writer.writeAttribute("id", seqMod2xmlPeptideId.get(seqMod)); + writer.writeAttribute("id", pepid); Peptide peptide = peptideList.get(0); // this.seq_to_element.put(seqMod, peptide); - writer.writeAttribute("seq", peptide.get_sequence()); writer.writeAttribute("mh", "" + peptide.get_mh_theo_without_isotope(true)); + writer.writeAttribute("seq", peptide.get_sequence()); writer.writeAttribute("mods", "" + peptide.get_Modifs_formater_without_isotope()); @@ -458,17 +454,16 @@ public class MassChroQmlWriter { for (Peptide peptideScan : peptideList) { // Element observed = doc.createElement("observed_in"); - writer.writeStartElement("observed_in"); + writer.writeEmptyElement("observed_in"); // eda choisir mode export // observed.setAttribute("rt", "" + // peps[j].get_RT_in_sec()); - writer.writeAttribute("scan", - "" + peptideScan.get_scan()); writer.writeAttribute("data", this.sample2xmlId.get(peptideScan.getMsRun())); + writer.writeAttribute("scan", + "" + peptideScan.get_scan()); writer.writeAttribute("z", "" + peptideScan.get_charge()); - writer.writeEndElement(); } writer.writeEndElement(); @@ -502,11 +497,10 @@ public class MassChroQmlWriter { writer.writeStartElement("isotope_label"); writer.writeAttribute("id", "iso" + (i + 1)); // Element mod = doc.createElement("mod"); - writer.writeStartElement("mod"); + writer.writeEmptyElement("mod"); writer.writeAttribute("value", "" + mds[i].get_modvalue()); writer.writeAttribute("at", "Nter,Cter,A,K,L..."); - // isotope_label.appendChild(mod); - writer.writeEndElement(); + // isotopes.appendChild(isotope_label); writer.writeEndElement(); } -- GitLab