Index: trunk/ippTools/share/chiptool_change_exp_state.sql
===================================================================
--- trunk/ippTools/share/chiptool_change_exp_state.sql	(revision 19526)
+++ trunk/ippTools/share/chiptool_change_exp_state.sql	(revision 19527)
@@ -1,2 +1,6 @@
+-- change state of chipRun from goto_cleaned to cleaned or goto_purged to purged
+-- when all of the consituant imfiles are in the rgith state
+-- arguments are new state (cleaned or purged) chip_id and new state again for 
+-- the chipProcessedImfile sub query
 UPDATE chipRun
     SET state = '%s'
Index: trunk/ippTools/share/chiptool_change_imfile_data_state.sql
===================================================================
--- trunk/ippTools/share/chiptool_change_imfile_data_state.sql	(revision 19526)
+++ trunk/ippTools/share/chiptool_change_imfile_data_state.sql	(revision 19527)
@@ -1,2 +1,4 @@
+-- handle changes in data_state. Used for the modes tocleanedimfile and topurgedimfile
+-- args are new data_state, chip_id, class_id, and current expected state for chipRun
 UPDATE chipProcessedImfile
     SET 
Index: trunk/ippTools/share/chiptool_pendingcleanupimfile.sql
===================================================================
--- trunk/ippTools/share/chiptool_pendingcleanupimfile.sql	(revision 19526)
+++ trunk/ippTools/share/chiptool_pendingcleanupimfile.sql	(revision 19527)
@@ -13,4 +13,5 @@
     USING(chip_id)
 WHERE
-    chipRun.state = 'goto_cleaned'
-    AND chipProcessedImfile.data_state = 'full'
+    ((chipRun.state = 'goto_cleaned' AND chipProcessedImfile.data_state = 'full')
+OR 
+    (chipRun.state = 'goto_purged' AND chipProcessedImfile.data_state != 'purged'))
Index: trunk/ippTools/share/chiptool_pendingcleanuprun.sql
===================================================================
--- trunk/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 19526)
+++ trunk/ippTools/share/chiptool_pendingcleanuprun.sql	(revision 19527)
@@ -7,3 +7,3 @@
 USING (exp_id)
 WHERE
-    chipRun.state = 'goto_cleaned'
+    (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_purged')
