From 006b3d7c631e42fbf5b333e04e09bf14ff9c1fc1 Mon Sep 17 00:00:00 2001
From: langella <langella@b8ef2a07-7df7-436f-90b9-41648038564b>
Date: Mon, 11 Feb 2013 20:54:18 +0000
Subject: [PATCH] AlgoGrouping created

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@338 b8ef2a07-7df7-436f-90b9-41648038564b
---
 .../class_msms/Identification.java            | 48 +++++++------------
 .../grouping/AlgoGrouping.java                | 36 ++++++++++++++
 .../grouping/AlgoGroupingPhospho.java         | 39 +++++++++++++++
 3 files changed, 92 insertions(+), 31 deletions(-)
 create mode 100644 xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGrouping.java
 create mode 100644 xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGroupingPhospho.java

diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Identification.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Identification.java
index 6881af988..ce07dffb4 100644
--- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Identification.java
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/Identification.java
@@ -11,12 +11,12 @@ import fr.inra.pappso.xtandempipeline.filter_print.FilterGroupFromFastaDatabase;
 import fr.inra.pappso.xtandempipeline.filter_print.filter_base;
 import fr.inra.pappso.xtandempipeline.filter_print.print_base;
 import fr.inra.pappso.xtandempipeline.filter_print.swt_table_base;
+import fr.inra.pappso.xtandempipeline.grouping.AlgoGrouping;
+import fr.inra.pappso.xtandempipeline.grouping.AlgoGroupingPhospho;
 import fr.inra.pappso.xtandempipeline.grouping.Group;
 import fr.inra.pappso.xtandempipeline.grouping.GroupSet;
-import fr.inra.pappso.xtandempipeline.grouping.HashSampleScanSetPhospho;
 import fr.inra.pappso.xtandempipeline.grouping.HashSampleScanSetProt;
 import fr.inra.pappso.xtandempipeline.grouping.SubGroup;
-import fr.inra.pappso.xtandempipeline.grouping.SubGroupSet;
 
 public class Identification {
 
@@ -31,7 +31,7 @@ public class Identification {
 	private ModifsList mods;
 
 	private MsRunSet msRunSet = new MsRunSet();
-	
+
 	private DatabaseSet databaseSet = new DatabaseSet();
 
 	public Identification() {
@@ -40,12 +40,12 @@ public class Identification {
 		this.grouping = null;
 		this.mods = new ModifsList();
 	}
-	
+
 	@Override
 	protected void finalize() throws Throwable {
 		logger.debug("finalize identification");
-		logger.debug("Match : "+protein_liste.size());
-		logger.debug("Peptide : "+peptide_liste.size());
+		logger.debug("Match : " + protein_liste.size());
+		logger.debug("Peptide : " + peptide_liste.size());
 	}
 
 	public void add_peptide(PeptideId P) {
@@ -92,7 +92,7 @@ public class Identification {
 	public MsRunSet getMsRunSet() {
 		return this.msRunSet;
 	}
-	
+
 	public Match get_match(Protein P) {
 		if (this.protein_liste.containsKey(P.getAccession()))
 			return (this.protein_liste.get(P.getAccession()));
@@ -115,7 +115,7 @@ public class Identification {
 	}
 
 	public void remove_contaminant_submatch(File database) {
-		//TODO Remove group containing prot from this database
+		// TODO Remove group containing prot from this database
 		new FilterGroupFromFastaDatabase(database).filter(grouping);
 	}
 
@@ -139,40 +139,26 @@ public class Identification {
 
 	public void performedGroupSet() throws Exception {
 		logger.info("Performed grouping");
-		GroupSet resultGroupSet = new GroupSet();
-
-		SubGroupSet subGroupSet = new SubGroupSet();
+		AlgoGrouping groupingAlgo = new AlgoGrouping();
 		for (Match m : protein_liste.values()) {
 			if (m.isIsvalidate()) {
-				subGroupSet.addHashSampleScanSetProt(new HashSampleScanSetProt(
-						m));
+				groupingAlgo
+						.addHashSampleScanSetProt(new HashSampleScanSetProt(m));
 			}
 		}
-		logger.info("Number of subgroup before group creation : "+subGroupSet.size());
-		
-		resultGroupSet.groupingSubGroupSet(subGroupSet);
-		grouping = resultGroupSet;
+
+		grouping = groupingAlgo.getGroupSet();
 	}
 
 	public void performedPhosphoGroupSet() throws Exception {
-		GroupSet resultGroupSet = new GroupSet();
-
-		SubGroupSet subGroupSet = new SubGroupSet();
+		AlgoGroupingPhospho groupingAlgoPhospho = new AlgoGroupingPhospho();
 		for (Match m : protein_liste.values()) {
 			if (m.isIsvalidate()) {
-				ArrayList<HashSampleScanSetPhospho> phosphoSites = m
-						.getHashSampleScanSetPhosphoList();
-				for (HashSampleScanSetPhospho phospho : phosphoSites) {
-					subGroupSet.addHashSampleScanSetProt(phospho);
-				}
+				groupingAlgoPhospho.addAllHashSampleScanSetPhospho(m
+						.getHashSampleScanSetPhosphoList());
 			}
 		}
-
-		/*
-		 * for (SubGroup sg:subGroupSet) { sg.loggerDebug(); }
-		 */
-		resultGroupSet.groupingSubGroupSet(subGroupSet);
-		this.grouping = resultGroupSet;
+		grouping = groupingAlgoPhospho.getGroupSet();
 	}
 
 	public ArrayList<Database> get_database_list() {
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGrouping.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGrouping.java
new file mode 100644
index 000000000..e8bf0a8e2
--- /dev/null
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGrouping.java
@@ -0,0 +1,36 @@
+package fr.inra.pappso.xtandempipeline.grouping;
+
+import org.apache.log4j.Logger;
+
+import fr.inra.pappso.xtandempipeline.MsException.MSMSException;
+
+public class AlgoGrouping {
+	private static final Logger logger = Logger.getLogger(AlgoGrouping.class);
+
+	SubGroupSet subGroupSet = new SubGroupSet();
+
+	public void addHashSampleScanSetProt(HashSampleScanSetProt hashSampleScanSetProt) {
+		subGroupSet.addHashSampleScanSetProt(hashSampleScanSetProt);
+	}
+
+	public GroupSet getGroupSet() throws Exception {
+		if (subGroupSet.size() == 0) {
+			String message = "There is nothing to group, please use the addHashSampleScanSetProt function";
+			logger.error(message);
+			throw new MSMSException(message);
+		}
+		try {
+			logger.info("Perform grouping");
+
+			logger.info("Number of subgroup before group creation : "
+					+ subGroupSet.size());
+			GroupSet resultGroupSet = new GroupSet();
+			resultGroupSet.groupingSubGroupSet(subGroupSet);
+			return resultGroupSet;
+		} catch (Exception e) {
+			String message = "ERROR in AlgoGrouping : " + e.getMessage();
+			logger.error(message);
+			throw new MSMSException(message);
+		}
+	}
+}
diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGroupingPhospho.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGroupingPhospho.java
new file mode 100644
index 000000000..f89031457
--- /dev/null
+++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/grouping/AlgoGroupingPhospho.java
@@ -0,0 +1,39 @@
+package fr.inra.pappso.xtandempipeline.grouping;
+
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+
+import fr.inra.pappso.xtandempipeline.MsException.MSMSException;
+
+public class AlgoGroupingPhospho {
+	private static final Logger logger = Logger
+			.getLogger(AlgoGroupingPhospho.class);
+	SubGroupSet subGroupSet = new SubGroupSet();
+
+	public void addAllHashSampleScanSetPhospho(
+			Collection<HashSampleScanSetPhospho> arrHashSampleScanSetPhospho) {
+		for (HashSampleScanSetPhospho HashSampleScanSetPhospho : arrHashSampleScanSetPhospho) {
+			subGroupSet.addHashSampleScanSetProt(HashSampleScanSetPhospho);
+		}
+	}
+
+	public GroupSet getGroupSet() throws Exception {
+		if (subGroupSet.size() == 0) {
+			String message = "There is nothing to group, please use the addArrHashSampleScanSetPhospho function";
+			logger.error(message);
+			throw new MSMSException(message);
+		}
+		try {
+			logger.info("Perform phospho grouping");
+			GroupSet resultGroupSet = new GroupSet();
+			resultGroupSet.groupingSubGroupSet(subGroupSet);
+			return resultGroupSet;
+		} catch (Exception e) {
+			String message = "ERROR in AlgoGroupingPhospho : " + e.getMessage();
+			logger.error(message);
+			throw new MSMSException(message);
+		}
+	}
+
+}
-- 
GitLab