Skip to content
Snippets Groups Projects
Commit 7115c414 authored by Ondřej Novák's avatar Ondřej Novák
Browse files

add web presentation

parent b7d8691a
No related branches found
No related tags found
No related merge requests found
web/img/A-baze.png

2.34 KiB

web/img/C-baze.png

2.29 KiB

web/img/DNA_acgt.jpg

113 KiB

web/img/DNA_large.jpg

1.29 MiB

web/img/G-baze.png

2.22 KiB

web/img/T-baze.png

2.28 KiB

web/img/false.png

28.5 KiB

web/img/result.ico

136 KiB

web/img/speed.png

3.46 KiB

web/img/true.png

11.2 KiB

<?php
// Počáteční hodnoty při prvním spuštění
$comments = "";
$result_picture = "type=\"image\" src=\"img/true.png\" name=\"result_img\" value=\"M\" width=\"30\" height=\"30\" style=\"display: none;\"";
$raw_string = "";
$baze_a = "0";
$baze_c = "0";
$baze_g = "0";
$baze_t = "0";
$speed = "100";
// Dosazení původních hodnot, aby nedocházelo k resetování formuláře
if (isset($_POST['StringInput']))
{
$raw_string = $_POST['StringInput'];
if (strpos($_POST['StringInput'],' ') !== false)
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Sekvence bází musí být zadána bez mezery!</font>";
}
else
{
$result_picture = "type=\"image\" src=\"img/true.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
}
}
if (isset($_FILES['fileToUpload']) && file_exists($_FILES['fileToUpload']['tmp_name']))
{
$extension = pathinfo($_FILES['fileToUpload']['name'], PATHINFO_EXTENSION);
if (1 || $extension == "ffn")
{
$result_picture = "type=\"image\" src=\"img/true.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
}
else
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Vstupní soubor musí být typu *.ffn!</font>";
}
}
if (isset($_POST['speed']))
{
$speed = $_POST['speed'];
if (!ctype_digit($_POST['speed']))
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Přesnost výpočtu musí být celé číslo!</font>";
}
}
if (isset($_POST['A-baze']))
{
$baze_a = $_POST['A-baze'];
if (!preg_match('/^-?[0-9]{1,4}$/', $_POST['A-baze']))
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Váha báze A musí být celé číslo!</font>";
}
}
if (isset($_POST['C-baze']))
{
$baze_c = $_POST['C-baze'];
if (!preg_match('/^-?[0-9]{1,4}$/', $_POST['C-baze']))
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Váha báze C musí být celé číslo!</font>";
}
}
if (isset($_POST['G-baze']))
{
$baze_g = $_POST['G-baze'];
if (!preg_match('/^-?[0-9]{1,4}$/', $_POST['G-baze']))
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Váha báze G musí být celé číslo!</font>";
}
}
if (isset($_POST['T-baze']))
{
$baze_t = $_POST['T-baze'];
if (!preg_match('/^-?[0-9]{1,4}$/', $_POST['T-baze']))
{
$result_picture = "type=\"image\" src=\"img/false.png\" name=\"mat\" value=\"M\" width=\"30\" height=\"30\"";
$comments = "<font color='red'>Váha báze T musí být celé číslo!</font>";
}
}
?>
<html>
<head>
<style type="text/css">
body {
background: url("img/DNA_acgt.jpg") fixed;
background-position: top right;
background-repeat: no-repeat;
background-size: contain;
}
</style>
<meta charset="UTF-8">
<title>Zpracovani DNA</title>
</head>
<body>
<form enctype="multipart/form-data" method='post'>
<p><h2>Zarovnávání DNA sekvencí převedených na časové řady</h2></p>
<p><h3>Přímý vstup:</h3></p>
<textarea class="FormElement" name="StringInput" id="StringInput" style="height: 3em;"><?php echo $raw_string?></textarea>
<br>
<p><h3>Vstup ze souboru:</h3></p>
<input type="file" name="fileToUpload">
<br><br>
<p><h3>Přesnost výpočtu:</h3></p>
<input type="image" src="img/speed.png" name="mat" value="M" width="50" height="17">
<input type= "text" name="speed" size="2" maxlength="3" value="<?php echo $speed?>">
% <i>(čím větší číslo, tím déle bude výpočet trvat)</i><br>
<p><h3>Váhy jednotlivých bází: <i>(obvykle od -20 do 20)</h3></i></p>
<input type="image" src="img/A-baze.png" name="mat" value="M" width="76" height="17">
<input type= "text" name="A-baze" size="2" maxlength="5" value="<?php echo $baze_a?>">
<br><br>
<input type="image" src="img/C-baze.png" name="mat" value="M" width="76" height="17">
<input type= "text" name="C-baze" size="2" maxlength="5" value="<?php echo $baze_c?>">
<br><br>
<input type="image" src="img/G-baze.png" name="mat" value="M" width="76" height="17">
<input type= "text" name="G-baze" size="2" maxlength="5" value="<?php echo $baze_g?>">
<br><br>
<input type="image" src="img/T-baze.png" name="mat" value="M" width="76" height="17">
<input type= "text" name="T-baze" size="2" maxlength="5" value="<?php echo $baze_t?>">
<br><br>
<input type= "submit" name="run">
<br>
<p><h3>Výsledek:&nbsp;&nbsp;
<input <?php echo $result_picture?>>&nbsp;&nbsp;<i><?php echo $comments?></i>
</h3></p>
<input type="image" src="img/result.ico" name="mat" value="M" width="50" height="17">
<?php
// Tlačítko odeslat bylo zmákčnuto
if (isset($_POST['run']))
{
if (isset($_POST['A-baze']) && isset($_POST['C-baze']) && isset($_POST['G-baze']) && isset($_POST['T-baze']) && isset($_POST['speed']))
{
// Číselné hodnoty v bázích
if (preg_match('/^-?[0-9]{1,4}$/', $_POST['A-baze']) && preg_match('/^-?[0-9]{1,4}$/', $_POST['C-baze']) && preg_match('/^-?[0-9]{1,4}$/', $_POST['G-baze']) && preg_match('/^-?[0-9]{1,4}$/', $_POST['T-baze']) && ctype_digit($_POST['speed']))
{
// Prvně beru přímý vstup = kontroluji pouze výskyt mezery
// TODO mezera - if/else
if (isset($_POST['StringInput']) && $_POST['StringInput'] != '' && strpos($_POST['StringInput'],' ') === false)
{
exec("cd .. && ./prg " . $_POST['A-baze'] . " " . $_POST['C-baze'] . " " . $_POST['G-baze'] . " " . $_POST['T-baze'] . " " . $_POST['speed'] . " " . $_POST['StringInput'], $output, $return_value);
$counter = 0;
foreach ($output as &$value)
{
if ($counter == 0)
{
echo "<span style=\"padding-left:0px\">" . $value . "</span><br>";
}
else
{
echo "<span style=\"padding-left:54px\">" . $value . "</span><br>";
}
$counter++;
}
}
// Pokud není přímý vstup, sleduji, zda je k dispozici soubor
else if ($_FILES['fileToUpload']['tmp_name'])
{
$extension = pathinfo($_FILES['fileToUpload']['name'], PATHINFO_EXTENSION);
// Soubor musí mít příponu ffn
if (1 || $extension == "ffn")
{
$file_content = file_get_contents($_FILES['fileToUpload']['tmp_name']);
exec("cd .. && ./prg " . $_POST['A-baze'] . " " . $_POST['C-baze'] . " " . $_POST['G-baze'] . " " . $_POST['T-baze'] . " " . $_POST['speed'] . " " . $file_content, $output, $return_value);
$counter = 0;
foreach ($output as &$value)
{
if ($counter == 0)
{
echo "<span style=\"padding-left:0px\">" . $value . "</span><br>";
}
else
{
echo "<span style=\"padding-left:54px\">" . $value . "</span><br>";
}
$counter++;
}
}
else
{
echo "<b>Žádný</b>";
}
}
else
{
echo "<b>Žádný</b>";
}
}
else
{
echo "<b>Žádný</b>";
}
}
else
{
echo "<b>Žádný</b>";
}
}
?>
</form>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment