1 | <?php
|
---|
2 |
|
---|
3 | ini_set("display_errors", "On");
|
---|
4 |
|
---|
5 | include("plotinclude.php");
|
---|
6 | //print header
|
---|
7 | printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
|
---|
8 | printf("<html>\n<head>\n");
|
---|
9 | printf("<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>\n");
|
---|
10 | printf("<title>show plots</title>\n");
|
---|
11 | printf("<link rel='stylesheet' type='text/css' href='lamouette.css'>\n");
|
---|
12 | printf("</head>\n");
|
---|
13 | printf("<body>\n");
|
---|
14 |
|
---|
15 | //init
|
---|
16 | $ds=0;
|
---|
17 | if (!empty($_GET["ds"]))
|
---|
18 | $ds=$_GET["ds"];
|
---|
19 | $tabnum=1;
|
---|
20 | if (!empty($_GET["tabnum"]))
|
---|
21 | $tabnum=$_GET["tabnum"];
|
---|
22 | $type2="calib";
|
---|
23 | if (!empty($_GET["type2"]))
|
---|
24 | $type2=$_GET["type2"];
|
---|
25 | $plot="";
|
---|
26 | $nextseq=0;
|
---|
27 | $prevseq=0;
|
---|
28 | $seq=0;
|
---|
29 | if (!empty($_GET["prevseq"]) && !empty($_GET["prev"]))
|
---|
30 | $seq=$_GET["prevseq"];
|
---|
31 | if (!empty($_GET["nextseq"]) && !empty($_GET["next"]))
|
---|
32 | $seq=$_GET["nextseq"];
|
---|
33 | $next=0;
|
---|
34 | $prev=0;
|
---|
35 | $numseq=0;
|
---|
36 |
|
---|
37 | //check if dataset file is existing
|
---|
38 | if (!empty($ds))
|
---|
39 | {
|
---|
40 | $num=sprintf("%08d",$ds);
|
---|
41 | $num2=substr($num,0,5);
|
---|
42 | $datasetfile="./datasets/" . $num2 . "/dataset" . $num . ".txt";
|
---|
43 | if (!file_exists($datasetfile))
|
---|
44 | {
|
---|
45 | printf("Sorry, there's no file for dataset %s available.", $ds);
|
---|
46 | //set dataset and sequence numbers to 0 for next checks
|
---|
47 | $ds=0;
|
---|
48 | $seq=0;
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | //in case of a valid dataset
|
---|
53 | if (!empty($ds))
|
---|
54 | {
|
---|
55 | //get sequences from dataset file
|
---|
56 | // alternative: query it from db
|
---|
57 | $dataset=file_get_contents($datasetfile);
|
---|
58 | $onpos=strpos($dataset, "SequencesOn:");
|
---|
59 | $offpos=strpos($dataset, "SequencesOff:");
|
---|
60 | $possource=strpos($dataset, "SourceName:");
|
---|
61 | $sequoff="";
|
---|
62 | if (!empty($offpos))
|
---|
63 | $sequoff=split(" ", trim(substr($dataset, $offpos+13, $possource-($offpos+13))));
|
---|
64 | if (empty($offpos))
|
---|
65 | $offpos=$possource;
|
---|
66 | $sequon=split(" ", trim(substr($dataset, $onpos+12, $offpos-($onpos+12))));
|
---|
67 | $sequences=$sequon;
|
---|
68 | if (!empty($sequoff))
|
---|
69 | $sequences=array_merge($sequences,$sequoff);
|
---|
70 | if ($seq!=0 && !in_array($seq, $sequences))
|
---|
71 | $seq=0;
|
---|
72 |
|
---|
73 | //get next, current and previous sequence
|
---|
74 | foreach($sequences as $key => $sequ)
|
---|
75 | {
|
---|
76 | if ($seq==0)
|
---|
77 | $seq=$sequ;
|
---|
78 | if ($next==1)
|
---|
79 | {
|
---|
80 | $nextseq=$sequ;
|
---|
81 | if ($prevseq!=0)
|
---|
82 | break;
|
---|
83 | $next=0;
|
---|
84 | }
|
---|
85 | if ($sequ==$seq)
|
---|
86 | {
|
---|
87 | $next=1;
|
---|
88 | continue;
|
---|
89 | }
|
---|
90 | $prevseq=$sequ;
|
---|
91 | }
|
---|
92 | $numseq=count($sequences);
|
---|
93 |
|
---|
94 | //in case a dataset consists of less than 3 sequences
|
---|
95 | if ($numseq==2)
|
---|
96 | $nextseq=$prevseq;
|
---|
97 | }
|
---|
98 |
|
---|
99 | //get link for plot
|
---|
100 | $type=gettypename($type2);
|
---|
101 | $plot=getplotname($seq, $tabnum, $type, $type2);
|
---|
102 |
|
---|
103 | //print form for choosing dataset and plots
|
---|
104 | printf("<form action='showplots-ds.php' method='GET'>\n");
|
---|
105 | printf("<table width='100%%' border='0'>\n");
|
---|
106 | printf("<tr><td valign='top'>\n<tr>\n");
|
---|
107 | PrintHomeHelp();
|
---|
108 | printf("<td align='center'>\n");
|
---|
109 | if (!empty($prevseq))
|
---|
110 | printf("%d ", $prevseq);
|
---|
111 | if ($numseq>1)
|
---|
112 | printf("<input type='submit' value='<< Prev Plot' name='prev'>\n");
|
---|
113 | printf("<input type='text' name='ds' size='5' maxlength='5' value='%s'>\n", $ds);
|
---|
114 | PrintType2PullDown($type2);
|
---|
115 | printf("<input type='text' name='tabnum' size='2' maxlenght='2' value='%s'>\n", $tabnum);
|
---|
116 | printf("<input type='hidden' name='prevseq' size='2' maxlenght='2' value='%s'>\n", $prevseq);
|
---|
117 | printf("<input type='hidden' name='nextseq' size='2' maxlenght='2' value='%s'>\n", $nextseq);
|
---|
118 | if ($numseq>1)
|
---|
119 | printf("<input type='submit' value='Next Plot >>' name='next'>\n");
|
---|
120 | else
|
---|
121 | printf("<input type='submit' value='Plot' name='next'>\n");
|
---|
122 | if (!empty($nextseq))
|
---|
123 | printf(" %d ", $nextseq);
|
---|
124 | if ($numseq>0)
|
---|
125 | {
|
---|
126 | printf(" [ %d sequence", $numseq);
|
---|
127 | if ($numseq>1)
|
---|
128 | printf("s");
|
---|
129 | print(" ] \n");
|
---|
130 | }
|
---|
131 | printf("</td><td align='right'>\n");
|
---|
132 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"showplots-ds.php\"'>\n");
|
---|
133 | printf("</td>\n</tr>\n<tr>\n<td align='center' colspan='3'>\n");
|
---|
134 | if (!empty($seq))
|
---|
135 | {
|
---|
136 | if (in_array($seq, $sequon))
|
---|
137 | printf("<font color='green'>\n");
|
---|
138 | else
|
---|
139 | printf("<font color='red'>\n");
|
---|
140 | printf("%s <img src='%s'>", $plot, $plot);
|
---|
141 | }
|
---|
142 | else
|
---|
143 | printf("You have to insert a dataset number into the first field.");
|
---|
144 | printf("</td>\n</tr>\n</table>\n");
|
---|
145 | printf("</form>\n");
|
---|
146 | printf("</body>\n");
|
---|
147 | printf("</html>\n");
|
---|
148 |
|
---|
149 | ini_set("display_errors", "Off");
|
---|
150 |
|
---|
151 | ?>
|
---|