From cbe66a3b87a0bb05837a4c52262d0767f7e95640 Mon Sep 17 00:00:00 2001
From: langella <langella@b8ef2a07-7df7-436f-90b9-41648038564b>
Date: Tue, 30 Apr 2013 15:17:35 +0000
Subject: [PATCH] new checkbox to export redundant peptide list

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@368 b8ef2a07-7df7-436f-90b9-41648038564b
---
 .../xtandempipeline/class_msms/config.java    | 27 +++++++++++++++++++
 .../output/OdsRedundantPeptideOutput.java     |  2 +-
 .../xtandempipeline/thread/printing_base.java |  5 ++--
 .../ui/swt/Export_Windows.java                | 10 +++++++
 4 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java
index 01b803e55..a89d2ed24 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java
@@ -33,6 +33,11 @@ public class config {
 	private static String mascot_evalue = "mascot_evalue";
 	// Type of evalue stocked for mascot search theoritical or experimental
 
+	// indicates that we want an export redundant peptide in ODS
+	private static String export_redundant_ods = "export_redundant_ods";
+	// indicates that we want an export redundant peptide in CSV
+	private static String export_redundant_csv = "export_redundant_csv";
+
 	// indicates that we want an export in ODS
 	private static String export_ods = "export_ods";
 	// indicates that we want an export in TXT
@@ -258,6 +263,14 @@ public class config {
 		properties.setProperty(export_proticdbml, "" + F);
 	}
 
+	public void set_export_redundant_ods(boolean F) {
+		properties.setProperty(export_redundant_ods, "" + F);
+	}
+
+	public void set_export_redundant_csv(boolean F) {
+		properties.setProperty(export_redundant_csv, "" + F);
+	}
+
 	public void set_export_masschroq(boolean F) {
 		properties.setProperty(export_masschroq, "" + F);
 	}
@@ -336,6 +349,20 @@ public class config {
 		return (true);
 	}
 
+	public boolean get_export_redundant_ods() {
+		String value = properties.getProperty(export_redundant_ods, "false");
+		if (value.equals("false"))
+			return (false);
+		return (true);
+	}
+
+	public boolean get_export_redundant_csv() {
+		String value = properties.getProperty(export_redundant_csv, "false");
+		if (value.equals("false"))
+			return (false);
+		return (true);
+	}
+
 	public boolean get_export_txt() {
 		String value = properties.getProperty(export_txt, "false");
 		if (value.equals("false"))
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/output/OdsRedundantPeptideOutput.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/output/OdsRedundantPeptideOutput.java
index e9d41ba65..bdbb44234 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/output/OdsRedundantPeptideOutput.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/output/OdsRedundantPeptideOutput.java
@@ -55,6 +55,7 @@ public class OdsRedundantPeptideOutput {
 			throws MSMSException {
 		try {
 			odsTable = new OdsDocWriter(outputStream);
+			odsTable.writeSheet("peptides");
 		} catch (IOException e) {
 			String message = "IOException " + e.getMessage();
 			logger.error(message);
@@ -83,7 +84,6 @@ public class OdsRedundantPeptideOutput {
 
 	public void write(Identification ident) throws MSMSException {
 		try {
-			odsTable.writeSheet("peptides");
 
 			this.writeHeaders();
 			for (Group group : ident.getGrouping().getGroupList()) {
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/printing_base.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/printing_base.java
index 907552a86..40d53c396 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/printing_base.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/thread/printing_base.java
@@ -158,7 +158,7 @@ public class printing_base extends process {
 
 		// redundant peptide output (containing start and stop positions on
 		// proteins)
-		if (true) {
+		if (conf.get_export_redundant_ods()) {
 			FileOutputStream outputStream = new FileOutputStream(new File(this
 					.getfileout().getAbsolutePath() + "_pep_redundant.ods"));
 			OdsRedundantPeptideOutput odsRedOutput = new OdsRedundantPeptideOutput(
@@ -167,7 +167,8 @@ public class printing_base extends process {
 				odsRedOutput.write(ident);
 			}
 			odsRedOutput.close();
-
+		}
+		if (conf.get_export_redundant_csv()) {
 			FileOutputStream csvStream = new FileOutputStream(new File(this
 					.getfileout().getAbsolutePath() + "_pep_redundant.csv"));
 			CsvRedundantPeptideOutput csvRedOutput = new CsvRedundantPeptideOutput(
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Export_Windows.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Export_Windows.java
index 4f2f1fa12..f5b3a7085 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Export_Windows.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/ui/swt/Export_Windows.java
@@ -38,6 +38,8 @@ public class Export_Windows {
 
 	private Button choice_spreadsheet_export;
 
+	private Button choice_redundant_ods_export;
+
 	private Button choice_fasta_export;
 
 	private Button choice_protic_export;
@@ -144,6 +146,12 @@ public class Export_Windows {
 			}
 		});
 
+		choice_redundant_ods_export = new Button(group, SWT.CHECK);
+		choice_redundant_ods_export
+				.setText("Redundant peptide list (containing start and stop on protein sequence)");
+		choice_redundant_ods_export.setSelection(conf
+				.get_export_redundant_ods());
+
 		choice_fasta_export = new Button(group, SWT.CHECK);
 		choice_fasta_export.setText("Identified proteins to a fasta file");
 		choice_fasta_export.setSelection(conf.get_export_fasta());
@@ -326,6 +334,8 @@ public class Export_Windows {
 			conf.set_export_proticdbml(this.choice_protic_export.getSelection());
 			conf.set_export_masschroq(this.choice_quantimscpp_export
 					.getSelection());
+			conf.set_export_redundant_ods(this.choice_redundant_ods_export
+					.getSelection());
 			// on sauve
 			conf.savePropertiestoXml();
 			datatype.getPrint().setfileout(out);
-- 
GitLab