From 28590df0b280aa9420d590c378a40a7fa7868c4f Mon Sep 17 00:00:00 2001 From: langella <langella@b8ef2a07-7df7-436f-90b9-41648038564b> Date: Mon, 6 Feb 2012 16:28:54 +0000 Subject: [PATCH] introducing IdentificationDataFile git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@188 b8ef2a07-7df7-436f-90b9-41648038564b --- .../IdentificationDataFile.java | 36 ++++ .../IdentificationXtandemFile.java | 10 + .../xtandempipeline/class_msms/MsRun.java | 9 +- .../xtandempipeline/class_msms/Peptide.java | 8 +- .../sax_parse/XtandemPhospho.java | 10 +- .../sax_parse/load_project.java | 4 +- .../xtandempipeline/sax_parse/parse_file.java | 6 +- .../xtandempipeline/sax_parse/xtandem.java | 10 +- .../sax_parse/xtandem_params.java | 33 ++-- .../xtandempipeline/thread/combined.java | 40 ++-- .../xtandempipeline/thread/individual.java | 41 ++-- .../xtandempipeline/thread/phosphosite.java | 10 +- .../xtandempipeline/thread/process.java | 28 +-- .../thread/xtandem_analysis.java | 106 +++++----- .../ui/swt/Filter_Windows.java | 185 +++++++++--------- .../ui/swt/Xtandem_Analysis_Param.java | 12 +- .../ui/swt/Xtandem_preset.java | 51 +++-- 17 files changed, 332 insertions(+), 267 deletions(-) create mode 100644 xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationDataFile.java create mode 100644 xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationXtandemFile.java diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationDataFile.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationDataFile.java new file mode 100644 index 000000000..4fbaecd42 --- /dev/null +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationDataFile.java @@ -0,0 +1,36 @@ +package fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile; + +import java.io.File; + +public class IdentificationDataFile implements + Comparable<IdentificationDataFile> { + + protected File file = null; + + public static IdentificationDataFile newIdentificationDataFile(String value) { + File file = new File(value); + return new IdentificationXtandemFile(file); + } + + public String getName() { + return this.file.getName(); + } + + public String getAbsolutePath() { + return this.file.getAbsolutePath(); + } + + public File getFile() { + return this.file; + } + + public boolean exists() { + return this.file.exists(); + } + + @Override + public int compareTo(IdentificationDataFile toCompare) { + return this.file.compareTo(toCompare.file); + } + +} diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationXtandemFile.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationXtandemFile.java new file mode 100644 index 000000000..3d8603bf9 --- /dev/null +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/IdentificationDataFile/IdentificationXtandemFile.java @@ -0,0 +1,10 @@ +package fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile; + +import java.io.File; + +public class IdentificationXtandemFile extends IdentificationDataFile { + + public IdentificationXtandemFile (File xtandemFile) { + this.file = xtandemFile; + } +} 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 606dc0fb1..be5ac5818 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java @@ -1,26 +1,27 @@ package fr.inra.pappso.xtandempipeline.class_msms; -import java.io.File; import java.util.HashSet; import org.apache.log4j.Logger; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; + public class MsRun implements Comparable<MsRun>{ private static final Logger logger = Logger.getLogger(MsRun.class); private String sample; - private HashSet<File> files = new HashSet<File>(0); + private HashSet<IdentificationDataFile> files = new HashSet<IdentificationDataFile>(0); public MsRun(String sample_name) { logger.debug("MsRun begin"); sample = sample_name; } - public File addFile(File file) { + public IdentificationDataFile addFile(IdentificationDataFile file) { if(files.add(file)) { return file; } - for (File otherFile:this.files) { + for (IdentificationDataFile otherFile:this.files) { if (file.equals(otherFile)) { return otherFile; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Peptide.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Peptide.java index bdf1f2941..9bd0ee916 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Peptide.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Peptide.java @@ -1,11 +1,11 @@ package fr.inra.pappso.xtandempipeline.class_msms; -import java.io.File; import java.util.ArrayList; import org.apache.log4j.Logger; import fr.inra.pappso.xtandempipeline.XtandemPipelineSession; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.grouping.HashPeptide; import fr.inra.pappso.xtandempipeline.grouping.HashSampleScan; @@ -14,7 +14,7 @@ public class Peptide implements Comparable<Peptide> { final static float phospho_mass = (float) 79.96633; - private File sample_file; + private IdentificationDataFile sample_file; private int scan_in_xtandem; @@ -100,7 +100,7 @@ public class Peptide implements Comparable<Peptide> { return (cle); } - public void set_sample_id(MsRun msRun, File origin) { + public void set_sample_id(MsRun msRun, IdentificationDataFile origin) { this.sample_file = msRun.addFile(origin); if (this.hashSampleScan == null) { hashSampleScan = XtandemPipelineSession.getInstance() @@ -350,7 +350,7 @@ public class Peptide implements Comparable<Peptide> { return S; } - public File getSample_file() { + public IdentificationDataFile getSample_file() { return sample_file; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/XtandemPhospho.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/XtandemPhospho.java index 4466b7700..bcfd00391 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/XtandemPhospho.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/XtandemPhospho.java @@ -2,17 +2,17 @@ package fr.inra.pappso.xtandempipeline.sax_parse; import org.apache.log4j.Logger; import org.xml.sax.*; -import java.io.File; import java.util.Hashtable; import java.util.Vector; import fr.inra.pappso.xtandempipeline.class_msms.*; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; public class XtandemPhospho extends org.xml.sax.helpers.DefaultHandler { private static final Logger logger = Logger.getLogger(XtandemPhospho.class); - private File sample_; + private IdentificationDataFile sample_; private Protein prot_; @@ -55,19 +55,19 @@ public class XtandemPhospho extends org.xml.sax.helpers.DefaultHandler { identification_ = new Identification(); } - public XtandemPhospho(File S) { + public XtandemPhospho(IdentificationDataFile S) { super(); identification_ = new Identification(); sample_ = S; } - public XtandemPhospho(Identification L, File S) { + public XtandemPhospho(Identification L, IdentificationDataFile S) { super(); identification_ = L; sample_ = S; } - public void set_sample(File S) { + public void set_sample(IdentificationDataFile S) { sample_ = S; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/load_project.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/load_project.java index 9353d5314..aa677a1b4 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/load_project.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/load_project.java @@ -16,6 +16,7 @@ import fr.inra.pappso.xtandempipeline.class_msms.Match; import fr.inra.pappso.xtandempipeline.class_msms.Modifs; import fr.inra.pappso.xtandempipeline.class_msms.Peptide; import fr.inra.pappso.xtandempipeline.class_msms.Protein; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.thread.DataType_Base; import fr.inra.pappso.xtandempipeline.thread.process; @@ -219,7 +220,8 @@ public class load_project extends org.xml.sax.helpers.DefaultHandler { if (attrs.getValue("sample_file") == null) { throw new MSMSException("sample_file is null"); } - File sample_file = new File(attrs.getValue("sample_file")); + IdentificationDataFile sample_file = IdentificationDataFile + .newIdentificationDataFile(attrs.getValue("sample_file")); pep_.set_sample_id( this.identification_.getMsRunSet().getInstance( sample_file.getName()), sample_file); diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/parse_file.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/parse_file.java index eaf3bb969..9aa73debb 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/parse_file.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/parse_file.java @@ -10,6 +10,7 @@ import org.apache.log4j.Logger; import org.apache.xerces.impl.io.MalformedByteSequenceException; import fr.inra.pappso.xtandempipeline.MsException.MSMSException; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParser; @@ -25,11 +26,12 @@ public class parse_file { // private File file_to_parse; - public parse_file(DefaultHandler h, File f) throws Exception { + public parse_file(DefaultHandler h, IdentificationDataFile f) + throws Exception { logger.debug("parse_file begin"); // on recupere le handler et le fichier à parser this.handler = h; - File file_to_parse = f; + File file_to_parse = f.getFile(); logger.info("Parsing xml file : " + f.getName()); if (!file_to_parse.exists()) throw new MSMSException("The file " diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem.java index 2f459f5ac..f484d10cd 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem.java @@ -2,16 +2,16 @@ package fr.inra.pappso.xtandempipeline.sax_parse; import org.apache.log4j.Logger; import org.xml.sax.*; -import java.io.File; import java.util.Hashtable; import java.util.Vector; import fr.inra.pappso.xtandempipeline.class_msms.*; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; public class xtandem extends org.xml.sax.helpers.DefaultHandler { private static final Logger logger = Logger.getLogger(xtandem.class); - private File sample_; + private IdentificationDataFile sample_; private Protein prot_; @@ -54,19 +54,19 @@ public class xtandem extends org.xml.sax.helpers.DefaultHandler { identification_ = new Identification(); } - public xtandem(File S) { + public xtandem(IdentificationDataFile S) { super(); identification_ = new Identification(); sample_ = S; } - public xtandem(Identification L, File S) { + public xtandem(Identification L, IdentificationDataFile S) { super(); identification_ = L; sample_ = S; } - public void set_sample(File S) { + public void set_sample(IdentificationDataFile S) { sample_ = S; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem_params.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem_params.java index f710feb73..e98d0237d 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem_params.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/xtandem_params.java @@ -1,38 +1,39 @@ package fr.inra.pappso.xtandempipeline.sax_parse; -import java.io.File; import java.io.InputStream; import java.util.Vector; import org.apache.log4j.Logger; - import fr.inra.pappso.xtandempipeline.MsException.MSMSException; import fr.inra.pappso.xtandempipeline.class_msms.xtandem_param; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationXtandemFile; public class xtandem_params { private static final Logger logger = Logger.getLogger(xtandem_params.class); - + private Vector<xtandem_param> params; private Vector<String> groups; - private InputStream template = this.getClass().getResourceAsStream("/resources/xtandem_model.xml"); + private InputStream template = this.getClass().getResourceAsStream( + "/resources/xtandem_model.xml"); public xtandem_params() { this.params = new Vector<xtandem_param>(); this.groups = new Vector<String>(); } - public void load_xml(File xml) throws Exception { - logger.info("Load xtandem param from : "+xml.getName()); - new parse_file(new xml_xtandem_param(this),xml); + public void load_xml(IdentificationXtandemFile xml) throws Exception { + logger.info("Load xtandem param from : " + xml.getName()); + new parse_file(new xml_xtandem_param(this), xml); } public void load_new_param() throws Exception { - if (template==null) - throw new MSMSException("Problem accessing resource : xtandem_model.xml"); + if (template == null) + throw new MSMSException( + "Problem accessing resource : xtandem_model.xml"); new_xtandem_param handler = new new_xtandem_param(this); new parse_file(handler, template); logger.debug(this.groups.size()); @@ -64,16 +65,16 @@ public class xtandem_params { return (groups); } - public void save_to_xml(File xml) throws Exception{ + public void save_to_xml(IdentificationXtandemFile xml) throws Exception { msms_output out = new msms_output(); out.open(xml.getAbsolutePath()); - out.write("<?xml version=\"1.0\"?>"+"\n"); - out.write("<bioml label=\"example api document\">"+"\n"); - for(int i=0;i<this.params.size();i++){ - out.write(params.elementAt(i).write_to_xml()+"\n"); + out.write("<?xml version=\"1.0\"?>" + "\n"); + out.write("<bioml label=\"example api document\">" + "\n"); + for (int i = 0; i < this.params.size(); i++) { + out.write(params.elementAt(i).write_to_xml() + "\n"); } - out.write("</bioml>"+"\n"); + out.write("</bioml>" + "\n"); out.close(); } - + } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/combined.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/combined.java index 6ced58b89..1f4459739 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/combined.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/combined.java @@ -1,13 +1,12 @@ package fr.inra.pappso.xtandempipeline.thread; -import java.io.File; import java.util.Vector; - import fr.inra.pappso.xtandempipeline.XtandemPipelineSession; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; import fr.inra.pappso.xtandempipeline.class_msms.Identification; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.filter_print.filter_index_and_order_match_scan; import fr.inra.pappso.xtandempipeline.filter_print.filter_protein_evalue; import fr.inra.pappso.xtandempipeline.filter_print.filter_protein_evalue_to; @@ -18,13 +17,13 @@ import fr.inra.pappso.xtandempipeline.filter_print.filter_peptide_evalue; import fr.inra.pappso.xtandempipeline.sax_parse.parse_file; import fr.inra.pappso.xtandempipeline.sax_parse.xtandem; - public class combined extends process { - private Vector<File> xtandem; + private Vector<IdentificationDataFile> xtandem; -// private ArrayList<Identification> identifications = XtandemPipelineSession -// .getInstance().getIdentificationList(); + // private ArrayList<Identification> identifications = + // XtandemPipelineSession + // .getInstance().getIdentificationList(); public combined(config conf) { super(conf); @@ -32,7 +31,7 @@ public class combined extends process { protected void processing() throws Exception { logger.info("Process result in Combine mode"); - + // Ecrire le process et penser à relever des StopException xtandem handler = new xtandem(); for (int i = 0; i < xtandem.size(); i++) { @@ -51,22 +50,22 @@ public class combined extends process { // filtering this.set_view("Parsing finished\n" + "Filtering peptides"); Identification ident = handler.get_identifications(); - - //on mets à jour les liens + + // on mets à jour les liens ident.filtered_match(new filter_index_and_order_match_scan()); - //filtre evalue peptide + // filtre evalue peptide ident.filtered_match(new filter_peptide_evalue((conf .get_peptide_evalue()))); - + // verification pas arreté if (this.isStop()) throw new StopException(""); this.add_current_progress(); - + // calcul de la evalue globale et modification evalue sample ident.filtered_match(new filter_recalcul_protein_evalue()); - + // verification pas arreté if (this.isStop()) throw new StopException(""); @@ -91,10 +90,9 @@ public class combined extends process { this.add_current_progress(); // creation des submatchs - this.set_view("Grouping\n" - + "Be patient, this step can take some time"); + this.set_view("Grouping\n" + "Be patient, this step can take some time"); ident.performedGroupSet(); - + // verification pas arreté if (this.isStop()) throw new StopException(""); @@ -103,7 +101,8 @@ public class combined extends process { // elimination des protéines contaminantes ident.remove_contaminant_submatch(conf.get_database_filter()); - //ArrayList<Identification> identifications = XtandemPipelineSession.getInstance().getIdentificationList(); + // ArrayList<Identification> identifications = + // XtandemPipelineSession.getInstance().getIdentificationList(); XtandemPipelineSession.getInstance().getIdentificationList().add(ident); // Verification pas arrete @@ -113,12 +112,13 @@ public class combined extends process { } - public void setXtandem(Vector<File> xtandem) { + @Override + public void setXtandem(Vector<IdentificationDataFile> xtandem) { this.xtandem = xtandem; - this.set_max_progress(xtandem.size()+5); + this.set_max_progress(xtandem.size() + 5); } - public Vector<File> getXtandem() { + public Vector<IdentificationDataFile> getXtandem() { return xtandem; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/individual.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/individual.java index 7c63c5752..63578377b 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/individual.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/individual.java @@ -1,6 +1,5 @@ package fr.inra.pappso.xtandempipeline.thread; -import java.io.File; import java.util.ArrayList; import java.util.Vector; @@ -10,6 +9,7 @@ import fr.inra.pappso.xtandempipeline.class_msms.MsRun; import fr.inra.pappso.xtandempipeline.class_msms.MsRunSet; import fr.inra.pappso.xtandempipeline.class_msms.config; import fr.inra.pappso.xtandempipeline.class_msms.Identification; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.filter_print.filter_index_and_order_match_scan; import fr.inra.pappso.xtandempipeline.filter_print.filter_protein_evalue_to; import fr.inra.pappso.xtandempipeline.filter_print.filter_recalcul_protein_evalue; @@ -20,10 +20,11 @@ import fr.inra.pappso.xtandempipeline.sax_parse.xtandem; public class individual extends process { - private Vector<File> xtandem; - -// private ArrayList<Identification> identifications = XtandemPipelineSession -// .getInstance().getIdentificationList(); + private Vector<IdentificationDataFile> xtandem; + + // private ArrayList<Identification> identifications = + // XtandemPipelineSession + // .getInstance().getIdentificationList(); public individual(config conf) { super(conf); @@ -31,9 +32,10 @@ public class individual extends process { protected void processing() throws Exception { logger.info("Process result in Individual mode"); - - ArrayList<Identification> identifications = XtandemPipelineSession.getInstance().getIdentificationList(); - + + ArrayList<Identification> identifications = XtandemPipelineSession + .getInstance().getIdentificationList(); + // Ecrire le process et penser à relever des StopException for (int i = 0; i < xtandem.size(); i++) { // parsing @@ -53,7 +55,7 @@ public class individual extends process { else handler = new xtandem(xtandem.get(i)); new parse_file(handler, xtandem.get(i)); - + if (identtemp == null) identifications.add(handler.get_identifications()); @@ -67,16 +69,11 @@ public class individual extends process { for (int j = 0; j < identifications.size(); j++) { Identification ident = identifications.get(j); // filtering - this.set_view("Analysing file : " - + (j + 1) - + "/" - + identifications.size() - + "\n" - + "Filtering file : " - + ident.get_samples().getMsRunList() - .get(0).getSampleName()); - - //on mets à jour les liens + this.set_view("Analysing file : " + (j + 1) + "/" + + identifications.size() + "\n" + "Filtering file : " + + ident.get_samples().getMsRunList().get(0).getSampleName()); + + // on mets à jour les liens ident.filtered_match(new filter_index_and_order_match_scan()); ident.filtered_match(new filter_peptide_evalue((conf @@ -104,14 +101,14 @@ public class individual extends process { } - public void setXtandem(Vector<File> xtandem) { + @Override + public void setXtandem(Vector<IdentificationDataFile> xtandem) { this.xtandem = xtandem; this.set_max_progress(xtandem.size() * 2); } - public Vector<File> getXtandem() { + public Vector<IdentificationDataFile> getXtandem() { return xtandem; } - } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/phosphosite.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/phosphosite.java index 6bf587aae..22a6685a9 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/phosphosite.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/phosphosite.java @@ -1,6 +1,5 @@ package fr.inra.pappso.xtandempipeline.thread; -import java.io.File; import java.util.ArrayList; import java.util.Vector; @@ -8,6 +7,7 @@ import fr.inra.pappso.xtandempipeline.XtandemPipelineSession; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; import fr.inra.pappso.xtandempipeline.class_msms.Identification; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.filter_print.filter_index_and_order_match_scan; import fr.inra.pappso.xtandempipeline.filter_print.filter_peptide_redondancy; import fr.inra.pappso.xtandempipeline.filter_print.filter_protein_evalue; @@ -21,7 +21,7 @@ import fr.inra.pappso.xtandempipeline.sax_parse.parse_file; public class phosphosite extends process { - private Vector<File> xtandem; + private Vector<IdentificationDataFile> xtandem; private ArrayList<Identification> identifications = XtandemPipelineSession .getInstance().getIdentificationList(); @@ -58,7 +58,6 @@ public class phosphosite extends process { ident.filtered_match(new filter_peptide_evalue((conf .get_peptide_evalue()))); ident.filtered_match(new filter_peptide_redondancy()); - // verification pas arreté if (this.isStop()) @@ -112,12 +111,13 @@ public class phosphosite extends process { } - public void setXtandem(Vector<File> xtandem) { + @Override + public void setXtandem(Vector<IdentificationDataFile> xtandem) { this.xtandem = xtandem; this.set_max_progress(xtandem.size() + 7); } - public Vector<File> getXtandem() { + public Vector<IdentificationDataFile> getXtandem() { return xtandem; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/process.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/process.java index 9ed1ddbe6..9815f2436 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/process.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/process.java @@ -1,12 +1,12 @@ package fr.inra.pappso.xtandempipeline.thread; -import java.io.File; import java.util.Vector; import org.apache.log4j.Logger; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; public class process extends Thread { @@ -17,11 +17,11 @@ public class process extends Thread { private Exception error; protected config conf; - + private int maxprogress; - + private int currentprogress; - + protected static final Logger logger = Logger.getLogger(process.class); public process(config conf) { @@ -30,7 +30,7 @@ public class process extends Thread { this.setStop(false); this.view = ""; this.setConf(conf); - this.currentprogress=0; + this.currentprogress = 0; this.maxprogress = 1; } @@ -43,7 +43,8 @@ public class process extends Thread { try { long start = System.currentTimeMillis(); this.processing(); - logger.info("Execution time = "+(System.currentTimeMillis()-start)/1000); + logger.info("Execution time = " + + (System.currentTimeMillis() - start) / 1000); } catch (StopException e) { logger.info("Process were stopping"); } catch (Exception e) { @@ -51,11 +52,11 @@ public class process extends Thread { logger.error("Process were stopping"); logger.error(e.getMessage()); StackTraceElement[] f = e.getStackTrace(); - for(int i = 0;i<f.length;i++){ + for (int i = 0; i < f.length; i++) { logger.error(f[i]); } this.set_view("Error:\n" + e.getMessage()); - //this.setStop(true); + // this.setStop(true); } } @@ -69,7 +70,7 @@ public class process extends Thread { public void set_view(String v) { if (v.length() > 1000) - this.view = v.substring(v.length()-999); + this.view = v.substring(v.length() - 999); else this.view = v; } @@ -95,25 +96,26 @@ public class process extends Thread { return conf; } - public void setXtandem(Vector<File> xtandem) { + public void setXtandem(Vector<IdentificationDataFile> xtandem) { } synchronized public int get_max_progress() { return this.maxprogress; } - + public void set_max_progress(int max) { this.maxprogress = max; } - + synchronized public int get_current_progress() { return this.currentprogress; } - + public void add_current_progress() { this.currentprogress++; } + public void set_current_progress(int p) { this.currentprogress = p; } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/xtandem_analysis.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/xtandem_analysis.java index 8d853e75e..25c51b1fe 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/xtandem_analysis.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/xtandem_analysis.java @@ -2,22 +2,22 @@ package fr.inra.pappso.xtandempipeline.thread; import java.io.File; - import fr.inra.pappso.xtandempipeline.MsException.MSMSException; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationXtandemFile; import fr.inra.pappso.xtandempipeline.sax_parse.msms_output; import fr.inra.pappso.xtandempipeline.sax_parse.xtandem_params; public class xtandem_analysis extends process { private File[] xtandem; - + private File[] databases; - + private File save_dir; - - private File model; + + private IdentificationXtandemFile model; public xtandem_analysis(config conf) { super(conf); @@ -25,67 +25,79 @@ public class xtandem_analysis extends process { protected void processing() throws Exception { logger.info("Xtandem analysis start"); - //creation du fichier database - File databasexml = new File(this.save_dir.getAbsolutePath()+System.getProperty("file.separator")+"database.xml"); + // creation du fichier database + File databasexml = new File(this.save_dir.getAbsolutePath() + + System.getProperty("file.separator") + "database.xml"); msms_output out = new msms_output(); out.open(databasexml.getAbsolutePath()); - out.write("<?xml version=\"1.0\"?>"+"\n"); - out.write("<bioml label=\"x! taxon-to-file matching list\">"+"\n"); - out.write("<taxon label=\"usedefined\">"+"\n"); - for(int j = 0;j<databases.length;j++){ - out.write("<file format=\"peptide\" URL=\""+databases[j].getAbsolutePath()+"\" />"+"\n"); + out.write("<?xml version=\"1.0\"?>" + "\n"); + out.write("<bioml label=\"x! taxon-to-file matching list\">" + "\n"); + out.write("<taxon label=\"usedefined\">" + "\n"); + for (int j = 0; j < databases.length; j++) { + out.write("<file format=\"peptide\" URL=\"" + + databases[j].getAbsolutePath() + "\" />" + "\n"); } - out.write("</taxon>"+"\n"); - out.write("</bioml>"+"\n"); + out.write("</taxon>" + "\n"); + out.write("</bioml>" + "\n"); out.close(); - File infile = new File(this.save_dir.getAbsolutePath()+System.getProperty("file.separator")+"infile.xml"); - - //Correction du fichier de parametres + File infile = new File(this.save_dir.getAbsolutePath() + + System.getProperty("file.separator") + "infile.xml"); + + // Correction du fichier de parametres logger.info("Corrected xtandem preset error"); xtandem_params params = new xtandem_params(); params.load_new_param(); params.load_xml(model); params.save_to_xml(model); - + for (int i = 0; i < xtandem.length; i++) { - logger.info("Xtandem analysis on : "+xtandem[i].getName()); + logger.info("Xtandem analysis on : " + xtandem[i].getName()); File result_out = new File(this.get_out(xtandem[i])); // parsing - //creation du fichier infile + // creation du fichier infile out.open(infile.getAbsolutePath()); - out.write("<?xml version=\"1.0\"?>"+"\n"); - out.write("<bioml label=\""+xtandem[i].getName()+"\">"+"\n"); - out.write("<note type=\"heading\">Paths</note>"+"\n"); - out.write("<note type=\"input\" label=\"list path, default parameters\">"+model.getAbsolutePath()+"</note>"+"\n"); - out.write("<note type=\"input\" label=\"list path, taxonomy information\">"+databasexml.getAbsolutePath()+"</note>"+"\n"); - out.write("<note type=\"input\" label=\"spectrum, path\">"+xtandem[i].getAbsolutePath()+"</note>"+"\n"); - out.write("<note type=\"heading\">Protein general</note>"+"\n"); - out.write("<note type=\"input\" label=\"protein, taxon\">usedefined</note>"+"\n"); - out.write("<note type=\"heading\">Output</note>"+"\n"); - out.write("<note type=\"input\" label=\"output, path\">"+result_out.getAbsolutePath()+"</note>"+"\n"); - out.write("</bioml>"+"\n"); + out.write("<?xml version=\"1.0\"?>" + "\n"); + out.write("<bioml label=\"" + xtandem[i].getName() + "\">" + "\n"); + out.write("<note type=\"heading\">Paths</note>" + "\n"); + out.write("<note type=\"input\" label=\"list path, default parameters\">" + + model.getAbsolutePath() + "</note>" + "\n"); + out.write("<note type=\"input\" label=\"list path, taxonomy information\">" + + databasexml.getAbsolutePath() + "</note>" + "\n"); + out.write("<note type=\"input\" label=\"spectrum, path\">" + + xtandem[i].getAbsolutePath() + "</note>" + "\n"); + out.write("<note type=\"heading\">Protein general</note>" + "\n"); + out.write("<note type=\"input\" label=\"protein, taxon\">usedefined</note>" + + "\n"); + out.write("<note type=\"heading\">Output</note>" + "\n"); + out.write("<note type=\"input\" label=\"output, path\">" + + result_out.getAbsolutePath() + "</note>" + "\n"); + out.write("</bioml>" + "\n"); out.close(); - - //creation des fichiers + + // creation des fichiers base_shell pipe = new base_shell(); - pipe.set_commande(new String[]{conf.getXtandem_link().getAbsolutePath(),infile.getAbsolutePath()}); + pipe.set_commande(new String[] { + conf.getXtandem_link().getAbsolutePath(), + infile.getAbsolutePath() }); pipe.start_process(); while (pipe.status()) { Thread.currentThread(); Thread.sleep(100); - if (this.isStop()){ + if (this.isStop()) { pipe.stop_process(); throw new StopException(""); } - this.set_view("Analyse file : " + (i+1) + "/" + xtandem.length - + "\n" + xtandem[i].getName()+"\n"+pipe.get_Stdout()); - //System.out.println(pipe.getStatus()); - + this.set_view("Analyse file : " + (i + 1) + "/" + + xtandem.length + "\n" + xtandem[i].getName() + "\n" + + pipe.get_Stdout()); + // System.out.println(pipe.getStatus()); + } - if (pipe.get_error()!=null) + if (pipe.get_error() != null) throw pipe.get_error(); - if(!result_out.exists()) - throw new MSMSException("Analysis of '"+xtandem[i].getName()+" give no result'\n"+pipe.get_Stdout()); + if (!result_out.exists()) + throw new MSMSException("Analysis of '" + xtandem[i].getName() + + " give no result'\n" + pipe.get_Stdout()); logger.info("finish"); this.add_current_progress(); @@ -93,7 +105,6 @@ public class xtandem_analysis extends process { databasexml.delete(); infile.delete(); - } public void setXtandem(File[] xtandem) { @@ -121,22 +132,23 @@ public class xtandem_analysis extends process { return save_dir; } - public void setModel(File model) { + public void setModel(IdentificationXtandemFile model) { this.model = model; } - public File getModel() { + public IdentificationXtandemFile getModel() { return model; } + private String get_out(File out) { String basename = out.getName(); basename = basename.replaceFirst(".mzXML$", ""); basename = basename.replaceFirst(".mgf$", ""); basename = basename.replaceFirst(".mzData$", ""); basename = basename.replaceFirst(".mzML$", ""); - basename = basename.replaceFirst(".pkl$", ""); + basename = basename.replaceFirst(".pkl$", ""); basename = basename.replaceFirst(".xml$", ""); - + return (this.getSave_dir().getAbsolutePath() + System.getProperty("file.separator") + basename + "." + "xml"); } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Filter_Windows.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Filter_Windows.java index b208718d6..5c94389fc 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Filter_Windows.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Filter_Windows.java @@ -17,16 +17,16 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; - import fr.inra.pappso.xtandempipeline.XtandemPipelineSession; import fr.inra.pappso.xtandempipeline.MsException.MSMSException; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile; import fr.inra.pappso.xtandempipeline.thread.DataType_Base; public class Filter_Windows { protected config conf; - private Vector<File> add_xml; + private Vector<IdentificationDataFile> add_xml; private String current_directory; private Shell shell; private Text pep_evalue; @@ -35,14 +35,15 @@ public class Filter_Windows { private Button filter_to_all; private Boolean Cancelled; private DataType_Base type; - + public Filter_Windows(Main_Windows controlleur) { Cancelled = true; this.conf = XtandemPipelineSession.getInstance().getConfig(); - this.type = XtandemPipelineSession.getInstance().getDataTypeBase(); - this.add_xml = new Vector<File>(); + this.type = XtandemPipelineSession.getInstance().getDataTypeBase(); + this.add_xml = new Vector<IdentificationDataFile>(); current_directory = conf.getXmlresult().getAbsolutePath(); - shell = new Shell(controlleur.getDisplay(),SWT.DIALOG_TRIM|SWT.APPLICATION_MODAL); + shell = new Shell(controlleur.getDisplay(), SWT.DIALOG_TRIM + | SWT.APPLICATION_MODAL); shell.setImages(controlleur.getImages()); // initialise la fenetre init(); @@ -51,7 +52,7 @@ public class Filter_Windows { // regle et affiche la fenetre shell.pack(); - //shell.setSize(500, 600); + // shell.setSize(500, 600); shell.open(); while (!shell.isDisposed()) { if (!controlleur.getDisplay().readAndDispatch()) { @@ -60,23 +61,23 @@ public class Filter_Windows { } } - private void init() { + private void init() { shell.setText("Configuration of the filtering parameters"); - GridLayout layout = new GridLayout(1,false); + GridLayout layout = new GridLayout(1, false); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10; layout.verticalSpacing = 10; shell.setLayout(layout); - //AJout des filtres - + // AJout des filtres + Group add_xtandem = new Group(shell, SWT.SHADOW_IN); add_xtandem.setText("Set X!Tandem result files"); add_xtandem.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - add_xtandem.setLayout(new GridLayout(2,false)); - - Text add_result = new Text(add_xtandem, SWT.SINGLE|SWT.READ_ONLY); + add_xtandem.setLayout(new GridLayout(2, false)); + + Text add_result = new Text(add_xtandem, SWT.SINGLE | SWT.READ_ONLY); add_result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); add_result.setText("No selected"); - Button add = new Button(add_xtandem,SWT.PUSH); + Button add = new Button(add_xtandem, SWT.PUSH); add.setText("Add files"); add.setData("text", add_result); add.addSelectionListener(new SelectionAdapter() { @@ -84,12 +85,12 @@ public class Filter_Windows { Filter_Windows.this.add_clic((Button) e.widget); } }); - + Group filter = new Group(shell, SWT.SHADOW_IN); filter.setText("Filter result to"); filter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - filter.setLayout(new GridLayout(2,false)); - + filter.setLayout(new GridLayout(2, false)); + pep_evalue = new Text(filter, SWT.SINGLE); pep_evalue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label l = new Label(filter, SWT.NONE); @@ -105,30 +106,29 @@ public class Filter_Windows { l = new Label(filter, SWT.NONE); l.setText("Maximal protein log(E value) to conserve a protein"); - - Label separator = new Label(filter,SWT.SEPARATOR|SWT.HORIZONTAL); + Label separator = new Label(filter, SWT.SEPARATOR | SWT.HORIZONTAL); GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=2; + data.horizontalSpan = 2; separator.setLayoutData(data); - + filter_to_all = new Button(filter, SWT.CHECK); filter_to_all.setText(" "); filter_to_all.setEnabled(!type.getIs_invididual()); l = new Label(filter, SWT.NONE); - l.setText("Apply protein filter to sum of all samples"); - + l.setText("Apply protein filter to sum of all samples"); + Group database = new Group(shell, SWT.SHADOW_IN); database.setText("Remove result from contaminants database"); - //data = new GridData(GridData.FILL_HORIZONTAL); - //data.horizontalSpan=2; - //database.setLayoutData(data); + // data = new GridData(GridData.FILL_HORIZONTAL); + // data.horizontalSpan=2; + // database.setLayoutData(data); database.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - database.setLayout(new GridLayout(2,false)); - - Text data_conta = new Text(database, SWT.SINGLE|SWT.READ_ONLY); + database.setLayout(new GridLayout(2, false)); + + Text data_conta = new Text(database, SWT.SINGLE | SWT.READ_ONLY); data_conta.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); data_conta.setText(conf.get_database_filter().getName()); - Button select = new Button(database,SWT.PUSH); + Button select = new Button(database, SWT.PUSH); select.setText("Select"); select.setData("text", data_conta); select.addSelectionListener(new SelectionAdapter() { @@ -136,15 +136,15 @@ public class Filter_Windows { Filter_Windows.this.select_clic((Button) e.widget); } }); - - separator = new Label(shell,SWT.SEPARATOR|SWT.HORIZONTAL); -// data = (new GridData(GridData.FILL_HORIZONTAL)); -// data.horizontalSpan=2; + + separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); + // data = (new GridData(GridData.FILL_HORIZONTAL)); + // data.horizontalSpan=2; separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - -// l = new Label(shell,SWT.NONE); -// l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Button next = new Button(shell,SWT.PUSH); + + // l = new Label(shell,SWT.NONE); + // l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Button next = new Button(shell, SWT.PUSH); next.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); next.setText("Next"); next.setEnabled(false); @@ -154,9 +154,8 @@ public class Filter_Windows { } }); add.setData("next", next); - + } - private void add_data() { // TODO Auto-generated method stub @@ -164,13 +163,12 @@ public class Filter_Windows { pep_evalue.setText(("" + conf.get_peptide_evalue())); pep_number.setText(("" + conf.get_peptide_number())); filter_to_all.setSelection(conf.get_protein_filter_to_complete()); -// if (conf.get_protein_filter_to_complete()) -// filter_to_all.setSelection(true); -// else -// filter_to_all.setSelection(false); + // if (conf.get_protein_filter_to_complete()) + // filter_to_all.setSelection(true); + // else + // filter_to_all.setSelection(false); } - - + private void modified_conf() throws MSMSException { float fl1; float fl2; @@ -178,14 +176,12 @@ public class Filter_Windows { try { fl1 = Float.valueOf(prot_evalue.getText()).floatValue(); } catch (Exception e) { - throw new MSMSException( - "Log(E value) protein must be like '-8'"); + throw new MSMSException("Log(E value) protein must be like '-8'"); } try { fl2 = Float.valueOf(pep_evalue.getText()).floatValue(); } catch (Exception e) { - throw new MSMSException( - "Peptide E value must be like '0.05'"); + throw new MSMSException("Peptide E value must be like '0.05'"); } try { it = Integer.parseInt(pep_number.getText()); @@ -210,15 +206,19 @@ public class Filter_Windows { Cancelled = false; shell.dispose(); } catch (MSMSException e) { - MessageBox messageBox = new MessageBox(shell, SWT.ERROR); - messageBox.setMessage("Problems trying to save the configuration :\n" + e.getMessage()); - messageBox.open(); - } catch (Exception e) { + MessageBox messageBox = new MessageBox(shell, SWT.ERROR); + messageBox + .setMessage("Problems trying to save the configuration :\n" + + e.getMessage()); + messageBox.open(); + } catch (Exception e) { StackTraceElement[] f = e.getStackTrace(); String error = e.getMessage() + "\nat : " + f[0].toString(); - MessageBox messageBox = new MessageBox(shell, SWT.ERROR); - messageBox.setMessage("Problems trying to save the configuration :\n" + error); - messageBox.open(); + MessageBox messageBox = new MessageBox(shell, SWT.ERROR); + messageBox + .setMessage("Problems trying to save the configuration :\n" + + error); + messageBox.open(); e.printStackTrace(); } } @@ -230,13 +230,14 @@ public class Filter_Windows { conf.set_database_filter(files); } catch (StopException S) { - + } catch (Exception e) { StackTraceElement[] f = e.getStackTrace(); String error = e.getMessage() + "\nat : " + f[0].toString(); - MessageBox messageBox = new MessageBox(shell, SWT.ERROR); - messageBox.setMessage("Problems during database selection :\n" + error); - messageBox.open(); + MessageBox messageBox = new MessageBox(shell, SWT.ERROR); + messageBox.setMessage("Problems during database selection :\n" + + error); + messageBox.open(); e.printStackTrace(); } finally { database_filter.setText(conf.get_database_filter().getName()); @@ -246,75 +247,77 @@ public class Filter_Windows { private void add_clic(Button but) { try { - File[] files = this.get_file_xml(); - for (int m = 0 ; m < files.length; m++) { + IdentificationDataFile[] files = this.get_file_xml(); + for (int m = 0; m < files.length; m++) { if (!add_xml.contains(files[m])) add_xml.add(files[m]); } -// for (int i = 0; i < files.length; i++) -// add_xml.add(files[i]); + // for (int i = 0; i < files.length; i++) + // add_xml.add(files[i]); Text t = (Text) but.getData("text"); t.setText(add_xml.size() + " files selected"); t.update(); - - if(add_xml.size()>0) + + if (add_xml.size() > 0) ((Button) but.getData("next")).setEnabled(true); } catch (StopException S) { - + } catch (Exception e) { StackTraceElement[] f = e.getStackTrace(); String error = e.getMessage() + "\nat : " + f[0].toString(); - MessageBox messageBox = new MessageBox(shell, SWT.ERROR); - messageBox.setMessage("Problems during xml files selection :\n" + error); - messageBox.open(); + MessageBox messageBox = new MessageBox(shell, SWT.ERROR); + messageBox.setMessage("Problems during xml files selection :\n" + + error); + messageBox.open(); e.printStackTrace(); } finally { // database_filter.setText(conf.get_database_filter().getName()); } } - + private File get_file_fasta() throws StopException { - FileDialog dlg = new FileDialog(shell, SWT.OPEN|SWT.SINGLE); - dlg.setFilterPath(conf.getProtein_database().getPath()); - dlg.setText("Select the contaminants database"); - dlg.setFilterExtensions(new String[]{"*.fasta","*.*"}); - dlg.setFilterNames(new String[]{"Fasta file","All files"}); - String fileName = dlg.open(); - if (fileName == null) - throw new StopException("No fasta selected"); + FileDialog dlg = new FileDialog(shell, SWT.OPEN | SWT.SINGLE); + dlg.setFilterPath(conf.getProtein_database().getPath()); + dlg.setText("Select the contaminants database"); + dlg.setFilterExtensions(new String[] { "*.fasta", "*.*" }); + dlg.setFilterNames(new String[] { "Fasta file", "All files" }); + String fileName = dlg.open(); + if (fileName == null) + throw new StopException("No fasta selected"); return (new File(fileName)); } - private File[] get_file_xml() throws Exception { + private IdentificationDataFile[] get_file_xml() throws Exception { FileDialog dlg = new FileDialog(shell, SWT.OPEN | SWT.MULTI); dlg.setFilterExtensions(new String[] { "*.xml", "*.*" }); - dlg.setFilterNames(new String[] { "X!Tandem result files", - "All files" }); + dlg.setFilterNames(new String[] { "X!Tandem result files", "All files" }); dlg.setFilterPath(current_directory); dlg.setText("Add new xml result files to analyse"); String fileName = dlg.open(); if (fileName == null) throw new StopException("No xml file selected"); String[] f = dlg.getFileNames(); - File[] files = new File[f.length]; - for (int i =0;i<f.length;i++) { - files[i] = (new File(dlg.getFilterPath() - + System.getProperty("file.separator") + f[i])); + IdentificationDataFile[] files = new IdentificationDataFile[f.length]; + for (int i = 0; i < f.length; i++) { + files[i] = (IdentificationDataFile.newIdentificationDataFile(dlg + .getFilterPath() + + System.getProperty("file.separator") + + f[i])); } Arrays.sort(files); current_directory = dlg.getFilterPath(); return (files); } - - public Vector<File> get_Add_xml() { + + public Vector<IdentificationDataFile> get_Add_xml() { return add_xml; } public boolean isCancelled() { return Cancelled; } - + } diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_Analysis_Param.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_Analysis_Param.java index 302f7a4cb..4a4cdb7d5 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_Analysis_Param.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_Analysis_Param.java @@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Text; import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationXtandemFile; import fr.inra.pappso.xtandempipeline.thread.xtandem_analysis; public class Xtandem_Analysis_Param { @@ -86,7 +87,7 @@ public class Xtandem_Analysis_Param { else comboPresetList.select(0); - this.bEditPreset.setEnabled(true); + this.bEditPreset.setEnabled(true); if (models.size() == 0) { this.bEditPreset.setEnabled(false); } @@ -321,10 +322,11 @@ public class Xtandem_Analysis_Param { this.xtandem.setDatabases(fasta); // Vector<File> all_models = (Vector<File>) this.params.getData(); - this.xtandem.setModel(new File(this.comboPresetList.getData("path") - + System.getProperty("file.separator") - + this.comboPresetList.getItem(this.comboPresetList - .getSelectionIndex()))); + this.xtandem.setModel(new IdentificationXtandemFile(new File( + this.comboPresetList.getData("path") + + System.getProperty("file.separator") + + this.comboPresetList.getItem(this.comboPresetList + .getSelectionIndex())))); this.xtandem.setSave_dir(out_dir); // on indique que la fenetre n'a pas ete cancel diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_preset.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_preset.java index 41aa18c1c..c6542647b 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_preset.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Xtandem_preset.java @@ -24,11 +24,10 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; - - import fr.inra.pappso.xtandempipeline.MsException.StopException; import fr.inra.pappso.xtandempipeline.class_msms.config; import fr.inra.pappso.xtandempipeline.class_msms.xtandem_param; +import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationXtandemFile; import fr.inra.pappso.xtandempipeline.sax_parse.xtandem_params; public class Xtandem_preset { @@ -50,7 +49,7 @@ public class Xtandem_preset { private Vector<Text> text_field; private Vector<Combo> combo_field; - + private boolean is_full; public Xtandem_preset(Main_Windows controlleur, config conf) { @@ -67,13 +66,12 @@ public class Xtandem_preset { shell.pack(); shell.open(); } - public Xtandem_preset(Shell modal, config conf, String xmlfilename) { - is_full=false; + is_full = false; System.out.println("edit param xtandem"); this.conf = conf; - shell = new Shell(modal, SWT.SHELL_TRIM| SWT.APPLICATION_MODAL); + shell = new Shell(modal, SWT.SHELL_TRIM | SWT.APPLICATION_MODAL); shell.setImages(modal.getImages()); this.defined_interface(); // on rempli les données avec un nouveau model @@ -82,15 +80,14 @@ public class Xtandem_preset { shell.pack(); shell.open(); - - if(xmlfilename==null){ + + if (xmlfilename == null) { this.restore_default_value(); - } - else{ + } else { this.set_model_list(xmlfilename); this.load_value_to_xml(); } - + while (!shell.isDisposed()) { if (!modal.getDisplay().readAndDispatch()) { modal.getDisplay().sleep(); @@ -168,14 +165,13 @@ public class Xtandem_preset { open.setEnabled(is_full); save_and_select.pack(); - } + } protected void close_on_non_full() { - if(!is_full) + if (!is_full) shell.dispose(); } - private void set_model_list(String name) { try { Vector<File> xmls = conf.getXtandem_models(); @@ -268,23 +264,23 @@ public class Xtandem_preset { } private void delete_xml_file() { - File xml = this.get_current_xml(model_list.getItem(model_list - .getSelectionIndex())); + IdentificationXtandemFile xml = this.get_current_xml(model_list + .getItem(model_list.getSelectionIndex())); if (xml.exists()) { MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO); messageBox.setMessage("Deleted the model file :\n" + xml.getName()); int response = messageBox.open(); - if(response==SWT.YES){ - xml.delete(); - this.set_model_list(xml.getName()); + if (response == SWT.YES) { + xml.getFile().delete(); + this.set_model_list(xml.getName()); } } } private void load_value_to_xml() { try { - File xml = this.get_current_xml(model_list.getItem(model_list - .getSelectionIndex())); + IdentificationXtandemFile xml = this.get_current_xml(model_list + .getItem(model_list.getSelectionIndex())); this.params.load_xml(xml); for (Combo com : combo_field) { xtandem_param param = (xtandem_param) com.getData("param"); @@ -304,16 +300,16 @@ public class Xtandem_preset { } - private File get_current_xml(String filename) { + private IdentificationXtandemFile get_current_xml(String filename) { File c = new File(conf.getXtandem_model() + System.getProperty("file.separator") + filename); - return c; + return new IdentificationXtandemFile(c); } private void save_value_to_xml() { try { String name = modelname.getText().replaceFirst("\\.xml$", ""); - File xml = this.get_current_xml(name + ".xml"); + IdentificationXtandemFile xml = this.get_current_xml(name + ".xml"); System.out.println(xml.getAbsolutePath()); int count = 0; @@ -337,14 +333,15 @@ public class Xtandem_preset { throw new StopException(count + " values are wrong"); if (xml.exists()) { MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO); - messageBox.setMessage("The model file : " + xml.getName()+" exist.\n Do you want to overwrite?"); + messageBox.setMessage("The model file : " + xml.getName() + + " exist.\n Do you want to overwrite?"); int reponse = messageBox.open(); - if(reponse==SWT.YES) + if (reponse == SWT.YES) params.save_to_xml(xml); } else params.save_to_xml(xml); System.out.println("save"); - + this.set_model_list(xml.getName()); } catch (StopException e) { MessageBox messageBox = new MessageBox(shell, SWT.ERROR); -- GitLab