upgraded to work with the upgraded MainPipelineScript
authorRami Rauch <rrauch@stanford.edu>
Thu, 14 May 2009 22:05:59 +0000 (22:05 +0000)
committerRami Rauch <rrauch@stanford.edu>
Thu, 14 May 2009 22:05:59 +0000 (22:05 +0000)
htswdataprod/scripts/MPListener

index 676d41ead6eb958c8b5bd3b462cc7b86a61b244a..fda816be70254aa61923ce2a41c3bad60690a940 100755 (executable)
@@ -1,53 +1,78 @@
 #!/bin/sh                                                                                                                           
-# Solexa Pipeline "Listener". Checks for finished.txt in each main directory of the pipeline                                                                      
+# Illumina Data Analysis Pipeline "Listener" fr Standard or IPAR mode. Checks for finished.txt in each main directory of the pipeline                                                                      
 
-# some vars
-#exptrackmainsc="$HOME/EXPTRACK/exp_track_main.py"
-exptrackmainsc="exp_track_main.py" 
+# params
+exptrackmainsc="/usr/local/src/EXPTRACK/exp_track_main.py"
 fcid=$1
-fullpath=$2
-runfolder=`echo $fullpath | sed -e 's/^.*\///'`
+runfolder=$2
 tocycle=$3
 
-## Make sure we find the Firecrest folder, then check "Makefile" in the 3 directories
-firecrestdir=`ls $fullpath/Data | grep "^C1-$tocycle.*_Firecrest.*"`
-countdirs=`ls $fullpath/Data | grep -c "^C1-$tocycle.*_Firecrest.*"`
+
+
+## DBG: python $exptrackmainsc updsts $fcid $runfolder 1 ListenerStarted
+
+
+analysis_mode='standard'
+pipeline_version='1.3'
+## The Command that runs the making of the "make" files
+if [ -d Data/IPAR_$pipeline_version ]
+then
+  datadir=Data/IPAR_$pipeline_version
+  analysis_mode='IPAR'
+else
+  datadir=Data
+fi
+
+## Make sure we find the ONE specific Start folder (Firecrest or Standard / Bustard for IPAR)
+if [ $analysis_mode == 'IPAR' ]
+then
+  #firecrestdir=`ls $datadir | grep "Firecrest"`
+  #countdirs=`ls $datadir | grep -c Firecrest`
+  #Rami
+  startdir=`ls $datadir | grep Bustard$pipeline_version`
+  countdirs=`ls $datadir | grep -c Bustard$pipeline_version`
+else
+  startdir=`ls $datadir | grep C1-[0-9][0-9]_Firecrest`
+  countdirs=`ls $datadir | grep -c C1-[0-9][0-9]_Firecrest`
+fi
+
 if [ $countdirs == 1 ]
 then
-  echo "" ## ok. firecrest folder '$firecrestdir' found"
+  echo "ok. start folder '$startdir' found"
 else
   if [ $countdirs -gt 1 ]
   then
-    echo "ERROR: Found too many ($countdirs) firecrest directories. You need to be more specific. Found:"
+    echo "MPListner ERROR: Found too many ($countdirs) start  directories (firecrest/bustard(for IPAR)). You need to specify ONE folder or REMOVE duplicates. Found:"
     echo ""
-    echo $firecrestdir
-    ## python $exptrackmainsc updsts $fcid $runfolder 3 ERROR:_Need_Specific_Firecrest_Dir
+    echo $startdir
+    python $exptrackmainsc updsts $fcid $runfolder 0 ERROR:_Need_Specific_Start_Dir
     exit
   else
-    echo "MPListener ERROR: Firecrest directory NOT FOUND."
-    ## python $exptrackmainsc updsts $fcid $runfolder 3 ERROR:_Firecrest_Dir_Not_Found
+    echo "MPListner ERROR: Start (firecrest/bustard(for IPAR)) directory NOT FOUND."
+    python $exptrackmainsc updsts $fcid $runfolder 0 ERROR:_Start_Dir_Not_Found
     exit
   fi
 fi
 
+# ---------------------- Check for finished.txt in each main directory of the pipeline ------------                                
 
-#firecrestdir=`ls Data | grep C1.*_Firecrest.*_encode`   
-# firecrestdir=`ls Data | grep C1.*_Firecrest.*_*`
-# if [ -d Data/$firecrestdir ]
-# then echo "firecrest folder '$firecrestdir' found"
-# else echo "firecrest folder '$firecrestdir' NOT found. can not check further"
-# fi
+if [ $analysis_mode == 'IPAR' ]
+then
+  firecrestfinished=$datadir/$startdir/finished.txt # dummy check, since there's no need to check this one in IPAR
+  bustfinished=$datadir/$startdir/finished.txt
+  gerfinished=$datadir/$startdir/GERALD_*/finished.txt
+else
+  firecrestfinished=$datadir/$startdir/finished.txt
+  bustfinished=$datadir/$startdir/Bustard*_*/finished.txt
+  gerfinished=$datadir/$startdir/Bustard*_*/GERALD_*/finished.txt
+fi
 
-# ---------------------- Check for finished.txt in each main directory of the pipeline ------------                                
-firecrestfinished=$fullpath/Data/$firecrestdir/finished.txt
-bustfinished=$fullpath/Data/$firecrestdir/Bustard*_*/finished.txt
-gerfinished=$fullpath/Data/$firecrestdir/Bustard*_*/GERALD_*/finished.txt
 # Wait for 48 hours max                                                                                                  
 timeremain=`expr 60 \* 60 \* 72`
 interval=10
 
 ## ---- Wait for Firecrest -----                                                                                                    
-while [ ! -f $firecrestfinished ] && [ $timeremain -gt 0 ]
+while [ $analysis_mode != 'IPAR' ] && [ ! -f $firecrestfinished ] && [ $timeremain -gt 0 ]
 do
   #echo "wating $interval secs more to check for firecrestfinished ($timeremain secs left)"
   sleep $(( $interval ))
@@ -56,8 +81,11 @@ done
 
 if [ $timeremain -gt 0 ]
 then
-  echo "Firecrest finished at `date`"
-  python $exptrackmainsc updsts $fcid $runfolder 1 Firecrest_finished
+  if [ $analysis_mode != 'IPAR' ]
+  then
+    echo "Firecrest finished at `date`"
+    python $exptrackmainsc updsts $fcid $runfolder 1 Firecrest_finished
+  fi
 else
   echo "Script time expired while waiting for Firecrest to finish."
   python $exptrackmainsc updsts $fcid $runfolder 2 Script_time_expired_during_Firecrest
@@ -83,7 +111,7 @@ fi
 ## -------- Wait for Gerald ------                                                                                     
 while [ ! -f $gerfinished ] && [ $timeremain -gt 0 ]
 do
-  #echo "wating $interval secs more to check for $gerfinished  ($timeremain secs left)"
+  echo "wating $interval secs more to check for $gerfinished  ($timeremain secs left)"
   sleep $(( $interval ))
   timeremain=`expr $timeremain - $interval`
 done
@@ -92,17 +120,15 @@ done
 if [ $timeremain -gt 0 ]
 then
   echo "Gerald finished at `date`"
-  python $exptrackmainsc updsts $fcid $runfolder 3 Gerald_finished
+  python $exptrackmainsc updsts $fcid $runfolder 3 Gerald_finished__Starting_DataAnalysis
   echo "Finished LISTENING TO SOLEXA PIPELINE ..."
-  echo "Starting DATA COLLECTION PHASE ..."
-  echo ".. here CollectData starts. Will run from the 'runner' bot."
-  ./MPCollectData $fcid $fullpath
+  echo "Starting DATA ANALYSIS PHASE ..."
+  /usr/local/src/EXPTRACK/MPAnalysis $fcid $runfolder
 else
   echo "Script time expired while waiting for Gerald to finish."
   python $exptrackmainsc updsts $fcid $runfolder 2 Script_time_expired_during_Gerald
 fi
 
-echo "exiting MPListner .."
 exit
 
 ## ---------------------------------------------------------------------------------