From c3d2da50e0bebc9fcc0ee788cdc2f964af586459 Mon Sep 17 00:00:00 2001
From: valot <valot@b8ef2a07-7df7-436f-90b9-41648038564b>
Date: Tue, 14 Feb 2012 10:10:20 +0000
Subject: [PATCH] Add 2 modes of calculation of the mascot evalue
 (theoritical/experimental)

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@208 b8ef2a07-7df7-436f-90b9-41648038564b
---
 .../xtandempipeline/class_msms/config.java    | 15 +++++++++++--
 .../xtandempipeline/sax_parse/Mascot.java     | 13 ++++++++++-
 .../ui/swt/Filter_Windows.java                | 22 ++++++++++++++-----
 3 files changed, 41 insertions(+), 9 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 84b577d20..d2562309d 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/config.java
@@ -13,7 +13,6 @@ import fr.inra.pappso.xtandempipeline.XtandemPipelineMain;
 
 public class config {
 
-	private static final long serialVersionUID = 123L;
 	private static final Logger logger = Logger.getLogger(config.class);
 
 	private static String database_filter = "database_filter";
@@ -30,6 +29,8 @@ public class config {
 	private static String peptide_number = "peptide_number";
 	// minimum de peptides differents permettant l'identification
 	
+	private static String mascot_evalue = "mascot_evalue";
+	// Type of evalue stocked for mascot search theoritical or experimental
 	
 	//indicates that we want an export in ODS
 	private static String export_ods = "export_ods";
@@ -193,7 +194,10 @@ public class config {
 		properties.setProperty(peptide_number, "" + F);
 	}
 
-
+	public void set_mascot_evalue_theoritical(boolean F) {
+		properties.setProperty(mascot_evalue, "" + F);
+	}
+	
 	public void set_export_ods(boolean F) {
 		logger.debug("set export_ods " +F);
 		properties.setProperty(export_ods, "" + F);
@@ -246,6 +250,13 @@ public class config {
 				.getProperty(peptide_number, "2"));
 		return (value);
 	}
+	
+	public boolean get_mascot_evalue_theoritical() {
+		String value = properties.getProperty(mascot_evalue, "false");
+		if (value.equals("false"))
+			return (false);
+		return (true);
+	}
 
 	public boolean get_export_fasta() {
 		String value = properties.getProperty(export_fasta, "false");
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/Mascot.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/Mascot.java
index 7e681d404..322476470 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/Mascot.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/sax_parse/Mascot.java
@@ -11,6 +11,7 @@ import com.compomics.mascotdatfile.util.mascot.ProteinHit;
 import com.compomics.mascotdatfile.util.mascot.Query;
 import com.compomics.mascotdatfile.util.mascot.QueryToPeptideMap;
 
+import fr.inra.pappso.xtandempipeline.XtandemPipelineSession;
 import fr.inra.pappso.xtandempipeline.class_msms.Identification;
 import fr.inra.pappso.xtandempipeline.class_msms.Match;
 import fr.inra.pappso.xtandempipeline.class_msms.Modifs;
@@ -113,12 +114,22 @@ public class Mascot {
 			pep_.set_charge((int) round(
 					(pep.getPeptideMr() / query.getPrecursorMZ()), 0));
 			pep_.set_deltamass((float) pep.getDeltaMass());
-			pep_.set_evalue((float) pep.getExpectancy());
 			pep_.set_hypercorr((float) pep.getIonsScore());
 			pep_.set_mhplus_obser((float) (pep.getPeptideMr()
 					+ pep.getDeltaMass() + 1.007825));
 			pep_.set_mhplus_theo((float) (pep.getPeptideMr() + 1.007825));
 			pep_.set_sequence(pep.getSequence());
+			
+
+			if(XtandemPipelineSession.getInstance().getConfig().get_mascot_evalue_theoritical()){
+				//Evalue theoritical
+				pep_.set_evalue((float) pep.getExpectancy());
+			}else{
+				//Evalue experimental
+				double eval = (pep.getIonsScore()-pep.getHomologyThreshold())/10;
+				eval = 0.05 / Math.pow(10, eval);
+				pep_.set_evalue((float) eval);
+			}
 
 			// Add first query
 			pep_.set_scan(query.getQueryNumber());
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 6b1014960..f13dafc30 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
@@ -33,6 +33,7 @@ public class Filter_Windows {
 	private Text prot_evalue;
 	private Text pep_number;
 	private Button filter_to_all;
+	private Button theoriticalButton;
 	private Boolean Cancelled;
 	private DataType_Base type;
 
@@ -116,6 +117,18 @@ public class Filter_Windows {
 		filter_to_all.setEnabled(!type.getIs_invididual());
 		l = new Label(filter, SWT.NONE);
 		l.setText("Apply protein filter to sum of all samples");
+		
+		Group mascotEvalue = new Group(shell, SWT.SHADOW_IN);
+		mascotEvalue.setText("Mascot Evalue calculation");
+		mascotEvalue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		mascotEvalue.setLayout(new GridLayout(1, false));
+		
+	    theoriticalButton = new Button(mascotEvalue, SWT.RADIO);
+	    theoriticalButton.setText("Theoritical (The ion score threshold is the same for all spectra)");
+		theoriticalButton.setSelection(conf.get_mascot_evalue_theoritical());
+	    Button experimentalButton = new Button(mascotEvalue, SWT.RADIO);
+	    experimentalButton.setText("Experimental (The ion score threshold depend of the spectra)");
+	    experimentalButton.setSelection(!conf.get_mascot_evalue_theoritical());
 
 		Group database = new Group(shell, SWT.SHADOW_IN);
 		database.setText("Remove result from contaminants database");
@@ -158,15 +171,10 @@ public class Filter_Windows {
 	}
 
 	private void add_data() {
-		// TODO Auto-generated method stub
 		prot_evalue.setText(("" + conf.get_protein_evalue()));
 		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);
+		filter_to_all.setSelection(conf.get_protein_filter_to_complete());		
 	}
 
 	private void modified_conf() throws MSMSException {
@@ -196,6 +204,8 @@ public class Filter_Windows {
 			conf.set_protein_filter_to_complete(true);
 		else
 			conf.set_protein_filter_to_complete(false);
+		
+		conf.set_mascot_evalue_theoritical(theoriticalButton.getSelection());
 	}
 
 	private void next_clic() {
-- 
GitLab