Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9504)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9505)
@@ -18,4 +18,22 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2009/09/08 Daniela Dorner
+
+   * datacenter/db/include.php:
+     - exchanged ON/Off checkboxes with ON/Off/Not radio-buttons for 
+       builddatasets.php
+     - bugfix for display of total number of displayed results
+     - added button for displaying all not-selected sequences (also for
+       builddatasets.php)
+
+   * datacenter/db/builddatasets.php:
+     - adapted to usage of radio buttons
+     - adapted to usage of 'Display Not-Selected Sequences' button
+     - improvement of WARN and ERROR messages
+     - bugfix for observation mode display in data set summary
+     - added remark that pressing 'Get Data Set' button is neccessary
+
+
 
  2009/08/31 Daniela Dorner
Index: trunk/MagicSoft/Mars/datacenter/db/builddatasets.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/builddatasets.php	(revision 9504)
+++ trunk/MagicSoft/Mars/datacenter/db/builddatasets.php	(revision 9505)
@@ -78,5 +78,5 @@
                     if ($_SESSION[$key]=="On")
                         if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff")
-                            if (!(ereg("^[0-9]*ON$", $key) || ereg("^[0-9]*Off$", $key)))
+                            if (!(ereg("^DSSeq[0-9]*$", $key)))
                                 if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
                                     $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
@@ -94,5 +94,6 @@
                 $query0 .= GetJoin($fromtable,$key);
 
-        if ($_SESSION["DisplaySelected"]!="yes" || ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" "))
+        if ($_SESSION["DisplaySelected"]!="yes"
+            || ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" "))
         {
             if ($_SESSION["fTest"]!="On")
@@ -199,4 +200,17 @@
                 $starstop=substr($_SESSION["fStarStop"], 0, 10);
                 $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
+            }
+
+            if ($_SESSION["DisplaySelected"]=="inverse")
+            {
+                $displsequ=str_replace("  ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]);
+                $displsequ=ereg_replace("^ ", "(", $displsequ);
+                $displsequ=ereg_replace("$", ")", $displsequ);
+                $displsequ=str_replace(" ",  ",", $displsequ);
+
+                if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
+                    $query0 .= " AND ";
+
+                $query0 .= " fSequenceFirst NOT IN " . $displsequ;
             }
 
@@ -232,5 +246,5 @@
             $displsequ=str_replace("  ", " ", $_SESSION["sequon"].$_SESSION["sequoff"]);
             $displsequ=ereg_replace("^ ", "(", $displsequ);
-            $displsequ=ereg_replace(" $", ")", $displsequ);
+            $displsequ=ereg_replace("$", ")", $displsequ);
             $displsequ=str_replace(" ",  ",", $displsequ);
 
@@ -395,15 +409,8 @@
                 PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, "yes");
 
-                if ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" ")
+                if (!(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
                 {
                     printf("<div align='left'>\n");
                     printf("Remark: To store your selection you have to press 'Update Data Set'<br> \n");
-                    if ($_SESSION["DisplaySelected"]!="yes" && ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" "))
-                    {
-                        printf("Remark: To be able to remove sequence(s) from your selection you have to \n");
-                        printf("'Display Selected Sequences'");
-//                        printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
-                        printf(" only.<br>\n");
-                    }
                     printf("<br>\n");
 
@@ -412,4 +419,17 @@
                     $on=str_replace(" ", ",", trim($_SESSION["sequon"]));
                     $off=str_replace(" ", ",", trim($_SESSION["sequoff"]));
+
+                    //set observation mode
+                    if ($_SESSION["sequoff"]==" ")
+                        $obsmode="Wobble";
+                    else
+                        $obsmode="On";
+
+                    //get key from db for insert query
+                    $query   = "SELECT fObservationModeKEY FROM ObservationMode WHERE fObservationModeName='".$obsmode."'";
+                    $result  = mysql_query($query);
+                    $row = mysql_fetch_assoc($result);
+                    $_SESSION["obsmode"] = $row["fObservationModeKEY"];
+                    mysql_free_result($result);
 
                     $values=array("Sum(fRunTime)/60"         => $runtime,
@@ -555,34 +575,34 @@
 
                             if ($values["Min(fNumStarsCorMed)"][$val]<$numstarscorlimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences has less than %s correlated stars (%s). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has less than %s correlated stars (%s). </li>\n",
                                        $color["WARN"], "WARN", $val, $numstarscorlimit, $values["Min(fNumStarsCorMed)"][$val]);
                             if ($values["Min(fNumStarsMed)"][$val]<$numstarslimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences has less than %s identified stars (%s). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has less than %s identified stars (%s). </li>\n",
                                        $color["WARN"], "WARN", $val, $numstarslimit, $values["Min(fNumStarsMed)"][$val]);
                             if ($values["Min(fRunTime)/60"][$val]<$runtimelimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences is shorter than %s min (%s min). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences is shorter than %s min (%s min). </li>\n",
                                        $color["INFO"], "INFO", $val, $runtimelimit, $values["Min(fRunTime)/60"][$val]);
                             if ($values["Max(fInhomogeneity)"][$val]>$inhomlimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences has an inhomogeneity larger than %s (%s). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has an inhomogeneity larger than %s (%s). </li>\n",
                                        $color["WARN"], "WARN", $val, $inhomlimit, $values["Max(fInhomogeneity)"][$val]);
                             if ($values["Max(fUnsuitableInner)"][$val]>$unsuitablemaxlimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s unsuitable inner pixel (%s). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s unsuitable inner pixel (%s). </li>\n",
                                        $color["WARN"], "WARN", $val, $unsuitablemaxlimit, $values["Max(fUnsuitableInner)"][$val]);
                             if ($values["Max(fIsolatedInner)"][$val]>$isolatedlimit)
-                            printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s isolated inner pixel (%s). </li>\n",
-                                   $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s isolated inner pixel (%s). </li>\n",
+                                       $color["WARN"], "WARN", $val, $isolatedlimit, $values["Max(fIsolatedInner)"][$val]);
                             if ($values["Max(fIsolatedMaxCluster)"][$val]>$imclimit)
-                                printf("<li style='color:%s'>%s: One of your %s-sequences has more than %s isolated max cluster (%s). </li>\n",
+                                printf("<li style='color:%s'>%s: At least one of your %s-sequences has more than %s isolated max cluster (%s). </li>\n",
                                        $color["WARN"], "WARN", $val, $imclimit, $values["Max(fIsolatedMaxCluster)"][$val]);
                         }
                         //check selected dataset for errors
                         if (!empty($on) && $values["Max(fMeanPedRmsInner)"]["on"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
-                            printf("<li style='color:%s'>%s: One of your on-sequences has a PedRms larger than %s (%s).</li>\n",
+                            printf("<li style='color:%s'>%s: At least one of your on-sequences has a PedRms larger than %s (%s).</li>\n",
                                    $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["on"]);
                         if (!empty($off) && $values["Max(fMeanPedRmsInner)"]["off"]>$values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms)
-                            printf("<li style='color:%s'>%s: One of your off-sequences has a PedRms larger than %s (%s). </li>\n",
+                            printf("<li style='color:%s'>%s: At least one of your off-sequences has a PedRms larger than %s (%s). </li>\n",
                                    $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]+$pedrmsrms, $values["Max(fMeanPedRmsInner)"]["off"]);
                         if (!empty($off) && $values["Min(fMeanPedRmsInner)"]["off"]<$values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms)
-                            printf("<li style='color:%s'>%s: One of your off-sequences has a PedRms smaller than %s (%s). </li>\n",
+                            printf("<li style='color:%s'>%s: At least one of your off-sequences has a PedRms smaller than %s (%s). </li>\n",
                                    $color["WARN"], "WARN", $values["Avg(fMeanPedRmsInner)"]["on"]-$pedrmsrms, $values["Min(fMeanPedRmsInner)"]["off"]);
                         $scale=$values["Sum(fRunTime)/60"]["on"]/$values["Sum(fRunTime)/60"]["off"];
@@ -598,6 +618,6 @@
                         if ($obskey!=$_SESSION["obsmode"])
                         {
-                            printf("<li style='color:%s'>%s: You have not selected any Off sequences. </li>\n",
-                                   $color["ERROR"], "ERROR", $doubleseq);
+                            printf("<li style='color:%s'>%s: You have a mistake in your observation mode. </li>\n",
+                                   $color["ERROR"], "ERROR");
                             $numerr=$numerr+1;
                         }
@@ -659,15 +679,4 @@
                             printf("SequencesOff: %s<br>\n", $_SESSION["sequoff"]);
 
-                        //set observation mode
-                        if ($_SESSION["sequoff"]==" ")
-                            $obsmode="Wobble";
-                        else
-                            $obsmode="On";
-                        //get key from db for insert query
-                        $query   = "SELECT fObservationModeKEY FROM ObservationMode WHERE fObservationModeName='".$obsmode."'";
-                        $result  = mysql_query($query);
-                        $row = mysql_fetch_assoc($result);
-                        $_SESSION["obsmode"] = $row["fObservationModeKEY"];
-                        mysql_free_result($result);
                         printf("Observation mode: %s <br>\n", $obsmode);
                         printf("RunTime: %s min <br>\n", $_SESSION["runtime"]);
@@ -738,5 +747,8 @@
                 }
                 else
+                {
                     printf("<input type='submit' value='Get Data Set'><br><br>\n");
+                    printf("Remark: To store your selection you have to press 'Get Data Set'<br> \n");
+                }
 
                 printf("</div>\n");
@@ -789,41 +801,26 @@
             $_SESSION[$element]=$value;
 
-
-
     if ($debug)
         print_r($_SESSION);
 
-    // remove sequence from selection
-    if (!empty($_POST) && $_SESSION["DisplaySelected"]=="yes" && $_SESSION["DisplaySelectedOld"]=="yes")
-        foreach ($_SESSION as $key => $element)
-            if (($_SESSION[$key]=="On") //value is set
-                && (ereg("^[0-9]*ON$", $key) || ereg("^[0-9]*Off$", $key)) // it is a sequence number
-                && (!$_POST[$key]==On)) // the sequence is not given in $_POST any more
-                unset($_SESSION[$key]);
-
-    //store old value of $_SESSION["DisplaySelected"]
     if ($_SESSION["DisplaySelected"]=="yes")
     {
         unset($_SESSION["fNumStart"]);
         $_GET["fNumStart"]=0;
-        $_SESSION["DisplaySelectedOld"]="yes";
-    }
-    else
-        $_SESSION["DisplaySelectedOld"]="no";
-
-    $_SESSION["sequon"]=" ";
-    $_SESSION["sequoff"]=" ";
+    }
+
+    $_SESSION["sequon"]="";
+    $_SESSION["sequoff"]="";
     foreach($_SESSION as $key => $val)
-        if ($val=="On")
-        {
-            if (ereg("^[0-9]*ON$", $key))
-                $_SESSION["sequon"].=str_replace("ON", " ", $key);
-            if (ereg("^[0-9]*Off$", $key))
-                $_SESSION["sequoff"].=str_replace("Off", " ", $key);
-        }
-    if ($_SESSION["sequon"]==" " && $_SESSION["sequoff"]==" ")
-    {
-        $_SESSION["DisplaySelected"]="no";
-        $_SESSION["DisplaySelectedOld"]="no";
+    {
+        if ($val=="ON" && ereg("^DSSeq[0-9]*$", $key))
+            $_SESSION["sequon"].=str_replace("DSSeq", " ", $key);
+
+        if ($val=="Off" && ereg("^DSSeq[0-9]*$", $key))
+            $_SESSION["sequoff"].=str_replace("DSSeq", " ", $key);
+
+        if ($val=="Not" && ereg("^DSSeq[0-9]*$", $key))
+            unset($_SESSION[$key]);
+
     }
 
@@ -855,4 +852,5 @@
         {
 //            echo crypt($_SERVER['PHP_AUTH_PW']). "<br>";
+//            echo "with crypt: " . crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"]) . " for user " . $userrow["fUserName"]. "<br>";
             if (crypt($_SERVER['PHP_AUTH_PW'], $userrow["fPassword"])==$userrow["fPassword"]
                 && $_SERVER['PHP_AUTH_USER']==$userrow["fUserName"])
@@ -882,5 +880,4 @@
             header("Content-Disposition: attachment; filename=dataset_".str_replace(" ", "_", $_SESSION["name"]).".txt");
             PrintDataSetFile();
-            echo "hallo\n";
         }
         unset($_SESSION["fSendTxt"]);
Index: trunk/MagicSoft/Mars/datacenter/db/include.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 9504)
+++ trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 9505)
@@ -301,4 +301,14 @@
 }
 
+function RadioButton($name, $value, $text)
+{
+    if ($_SESSION[$name]==$value)
+        $checked = "checked";
+    else
+        $checked = "";
+
+    printf("    <td><input type='radio' name='%s' value='%s' %s>%s</td>\n", $name, $value, $checked, $text);
+}
+
 function CheckWhere($column)
 {
@@ -417,8 +427,11 @@
 function PrintDisplaySequencesButtons()
 {
-    if ($_SESSION["DisplaySelected"]!="yes" && ($_SESSION["sequon"]!=" " || $_SESSION["sequoff"]!=" "))
+    if ((empty($_SESSION["DisplaySelected"]) || $_SESSION["DisplaySelected"]=="no")
+        && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
     {
         PrintUpdateDataSetButton();
-        printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'><br><br>\n", GetClearedURL("yes"));
+        printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
+        printf("&nbsp;&nbsp;&nbsp;<input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
+        printf("<br><br>\n");
     }
 
@@ -426,12 +439,27 @@
     {
         PrintUpdateDataSetButton();
-        printf("<input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
+        printf("<input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
+        printf("&nbsp;&nbsp;&nbsp;<input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
         printf("&nbsp;&nbsp;&nbsp;<i>Currently only selected sequences are displayed.</i><br><br>\n");
     }
-}
-
-
-function ReplaceInUri($name, $rows, $direction, $result1=0)
-{
+
+    if ($_SESSION["DisplaySelected"]=="inverse")
+    {
+        PrintUpdateDataSetButton();
+        printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
+        printf("&nbsp;&nbsp;&nbsp;<input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
+        printf("&nbsp;&nbsp;&nbsp;<i>Currently only NOT selected sequences are displayed.</i><br><br>\n");
+    }
+}
+
+
+function ReplaceInUri($name, $rows, $direction, $totalnumrows=0)
+{
+    //direction:
+    // 0: Prev Link
+    // 1: Next Link
+    // 2: First Link
+    // 3: Last Link
+
     $uri = htmlspecialchars($_SERVER["REQUEST_URI"]);
     $pos = strpos($uri, "fNumStart");
@@ -460,6 +488,5 @@
         break;
     case 3:
-        $row1 = mysql_fetch_assoc($result1);
-        $pos = $row1["FOUND_ROWS()"]-$rows+1;
+        $pos = $totalnumrows-$rows+1;
         break;
     }
@@ -487,5 +514,5 @@
 }
 
-function CreateMenu($rows, $result1)
+function CreateMenu($rows, $totalnumrows)
 {
     $menu = "";
@@ -510,5 +537,5 @@
     {
         $menu .= ReplaceInUri("fNumStart", $rows, 1);
-        $menu .= ReplaceInUri("fNumStart", $rows, 3, $result1);
+        $menu .= ReplaceInUri("fNumStart", $rows, 3, $totalnumrows);
     }
     return $menu;
@@ -517,4 +544,8 @@
 function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, $form="")
 {
+    $row1 = mysql_fetch_assoc($result1);
+    $totalnumrows=$row1["FOUND_ROWS()"];
+//    echo "res0: " . $row . " res1: " . $row1["FOUND_ROWS()"] . "<br>";
+
     $col   = FALSE;
     $first = TRUE;
@@ -530,5 +561,5 @@
 
 
-    $menu = CreateMenu(mysql_num_rows($result0), $result1);
+    $menu = CreateMenu(mysql_num_rows($result0), $totalnumrows);
 
     if ($form)
@@ -550,5 +581,5 @@
             $first = FALSE;
             if ($form)
-                printf("<td>ON</td><td>Off</td>");
+                printf("<td>ON</td><td>Off</td><td>Not</td>");
             foreach ($row0 as $key => $element)
             {
@@ -582,6 +613,9 @@
         if ($form)
         {
-            CheckBox2($row0["Sequ"]."ON","");
-            CheckBox2($row0["Sequ"]."Off","");
+//            CheckBox2($row0["Sequ"]."ON","");
+//            CheckBox2($row0["Sequ"]."Off","");
+            RadioButton("DSSeq".$row0["Sequ"],  "ON", "");
+            RadioButton("DSSeq".$row0["Sequ"], "Off", "");
+            RadioButton("DSSeq".$row0["Sequ"], "Not", "");
         }
         foreach ($row0 as $key => $element)
@@ -671,6 +705,5 @@
      */
 
-    $row1 = mysql_fetch_assoc($result1);
-    printf("<P><B>Number of displayed results: %d of %s in total</B><P><P>\n", mysql_num_rows($result0), $row1["FOUND_ROWS()"]);
+    printf("<P><B>Number of displayed results: %d of %s in total</B><P><P>\n", mysql_num_rows($result0), $totalnumrows);
     if (empty($_GET["fPrintTable"]))
         printf("%s\n", $menu);
