Skip to content

Commit

Permalink
Added extraction page (to search page, because idk)+ modified search_…
Browse files Browse the repository at this point in the history
…page.php without case-sensitive search

+ modified Izem Links
  • Loading branch information
KamiRab committed Dec 9, 2021
1 parent 0efa6a7 commit a24a3cd
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Web/Assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@

echo "<tr>
<!--Link to known information about the transcript-->
<td><a href='../Web_izem/Gene-ProtPage.php?id=$id' class='title'>" . $id . "</a><!--TODO--></td>
<td><a href='../Web_izem/Genome.php?id=".$transcript['id_genome']."'>".$transcript['id_genome']."</a><!--TODO--></td>
<td><a href='Gene-ProtPage.php?id=$id' target='_blank' class='title='>" . $id . "</a><!--TODO--></td>
<td><a href='GenomePage.php?id=".$transcript['id_genome']."' target='_blank'>".$transcript['id_genome']."</a></td>
<td> <!--List of annotator-->
<label for='Role_".$id."'></label>
<select id='Role_".$id."' name='Role_".$id."'>
Expand Down
42 changes: 23 additions & 19 deletions Web/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*This page is used by Annotator_area.php to display the status of the submitted annotations by the annotator connected*/

// Connect to database and find annotated transcript status
// Connect to database
// Connect to database
include_once 'libphp/db_utils.php';
connect_db();

Expand All @@ -29,34 +29,37 @@
echo "</div>";

//For each annotation a div is created, that can accessed through the tablinks
while ($annotation = pg_fetch_assoc($annotated_results)) {
$id = $annotation['id_transcript'];
if (pg_num_rows($annotated_results) == 0) {
echo "No annotations submitted";
} else {
while ($annotation = pg_fetch_assoc($annotated_results)) {
$id = $annotation['id_transcript'];

//Display of the annotations done
/*Header*/
echo "<div class='tabcontent' id=status_" . $id . ">
<a href='Gene-ProtPage.php?id=$id' class='title'>" . $id . "</a><br>";/*TODO modify*/
//Display of the annotations done
/*Header*/
echo "<div class='tabcontent' id=status_" . $id . ">
<a href='Gene-ProtPage.php?id=$id' target='_blank' class='title'>" . $id . "</a><br>";

// Display of the validation status
if ($annotation['validated'] == 0) { /*The annotation is waiting for validation*/
echo "<table class='spaced_table'>
// Display of the validation status
if ($annotation['validated'] == 0) { /*The annotation is waiting for validation*/
echo "<table class='spaced_table'>
<tr><td class='double'>Status :</td><td class='double'><p class='info'>Waiting for validation</p></td></tr></table>";

} elseif ($annotation['validated'] == 1) { /*The annotation is validated, the commentary is displayed*/
echo "<table class='spaced_table'>
} elseif ($annotation['validated'] == 1) { /*The annotation is validated, the commentary is displayed*/
echo "<table class='spaced_table'>
<tr><td class='double'>Status :</td><td class='double'><p class='info'>Validated</p></td></tr>
<tr><td class='double'>Validator : </td><td class='double'><p class='info'>" . $annotation['validator_email'] . "</p></td></tr>
<tr><td class='double'>Commentary:</td><td class='double'><p class='info'>". $annotation['commentary']."</p></td></tr></table>";
<tr><td class='double'>Commentary:</td><td class='double'><p class='info'>" . $annotation['commentary'] . "</p></td></tr></table>";

} else { /*The annotation is rejected, the commentary is displayed*/
echo "<table class='spaced_table'>
} else { /*The annotation is rejected, the commentary is displayed*/
echo "<table class='spaced_table'>
<tr><td class='double'>Status :</td><td class='double'><p class='info'>Rejected</p></td></tr>
<tr><td class='double'>Validator : </td><td class='double'><p class='info'>" . $annotation['validator_email'] . "</p></td></tr>
<tr><td class='double'>Commentary:</td><td class='double'><p class='info'>". $annotation['commentary']."</p></td></tr></table>";
}
<tr><td class='double'>Commentary:</td><td class='double'><p class='info'>" . $annotation['commentary'] . "</p></td></tr></table>";
}

/*Fields of annotation*/
echo "<div class='title'>Annotations</div>
/*Fields of annotation*/
echo "<div class='title'>Annotations</div>
<table class='spaced_table'>
<tr>
<td class='double'>ID of gene : </td>
Expand All @@ -80,6 +83,7 @@
</tr>
</table>
</div>";
}
}
disconnect_db(); /*Disconnect from the database*/
?>
68 changes: 37 additions & 31 deletions Web/ToDo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

// Find annotations to do for annotator connected. The query select all the transcript that have been assigned to the user
// excluding waiting for validation (annotation = 0) or already validated (validated =1) annotation.
$to_annotate_query = "SELECT id_transcript,sequence_nt, sequence_p, annotation FROM website.transcript WHERE transcript.annotator_email = $1 AND annotation != 0
EXCEPT SELECT transcript.id_transcript,sequence_nt, sequence_p,annotation FROM website.transcript, website.annotate
$to_annotate_query = "SELECT id_transcript, id_genome,sequence_nt, sequence_p, annotation FROM website.transcript WHERE transcript.annotator_email = $1 AND annotation != 0
EXCEPT SELECT transcript.id_transcript,id_genome, sequence_nt,sequence_p,annotation FROM website.transcript, website.annotate
WHERE annotate.id_transcript=transcript.id_transcript AND validated IN (0,1)";
/*annotation=2 for the annotations has been assigned but no transcript has been done*/

Expand Down Expand Up @@ -48,42 +48,47 @@
echo "</div>";

// For each transcript a div is created, that can be accesed through tablinks
while ($transcript = pg_fetch_assoc($to_annotate)) {/*while there exists rows of the query result not treated*/
$id = $transcript['id_transcript'];

//Updating of database for new annotated transcrips
if (isset($_POST["submit_" . $id])) { /*Find if the submit has been clicked for this transcript*/
/*Get all the annotation entered*/
/*By filtering the input, we verify that no harmul characters like script injections are given as input*/
$gene_id = $comment = filter_var($_POST["gene_id_" . $id],FILTER_SANITIZE_STRING);
$gene_biotype = filter_var($_POST["gene_biotype_" . $id],FILTER_SANITIZE_STRING);
$gene_symbol = filter_var($_POST["gene_symbol_" . $id],FILTER_SANITIZE_STRING); /*Can be empty*/
$prot_biotype = filter_var($_POST["prot_biotype_" . $id],FILTER_SANITIZE_STRING);
$description = filter_var($_POST["description_" . $id],FILTER_SANITIZE_STRING);

if (empty($gene_symbol)){ /*if no annotation for gene_symbol was not given, no value will be inserted for gene_symbol in the DB*/
$annotation = pg_query_params($db_conn, $annotation_query, array($id, $gene_id, $gene_biotype, $prot_biotype, null, $description, $annotator)) or die("Error " . pg_last_error());
} else{
$annotation = pg_query_params($db_conn, $annotation_query, array($id, $gene_id, $gene_biotype, $prot_biotype, $gene_symbol, $description, $annotator)) or die("Error " . pg_last_error());
}
$update_status = pg_query_params($db_conn, $update_status_query, array($id)) or die("Error " . pg_last_error()); /*Status of annotation is updated to "annotation exists"*/
echo "Your annotation for " . $id . " has been submitted";

//Display of the annotations areas for all transcript
} else {/*If no annotation has been submitted the annotations fields are displayed*/
echo "<div class='tabcontent' id=todo_" . $id . ">
if (pg_num_rows($to_annotate) == 0) {
echo "No annotations have been assigned to you";
} else {
while ($transcript = pg_fetch_assoc($to_annotate)) {/*while there exists rows of the query result not treated*/
$id = $transcript['id_transcript'];

//Updating of database for new annotated transcrips
if (isset($_POST["submit_" . $id])) { /*Find if the submit has been clicked for this transcript*/
/*Get all the annotation entered*/
/*By filtering the input, we verify that no harmul characters like script injections are given as input*/
$gene_id = $comment = filter_var($_POST["gene_id_" . $id], FILTER_SANITIZE_STRING);
$gene_biotype = filter_var($_POST["gene_biotype_" . $id], FILTER_SANITIZE_STRING);
$gene_symbol = filter_var($_POST["gene_symbol_" . $id], FILTER_SANITIZE_STRING); /*Can be empty*/
$prot_biotype = filter_var($_POST["prot_biotype_" . $id], FILTER_SANITIZE_STRING);
$description = filter_var($_POST["description_" . $id], FILTER_SANITIZE_STRING);

if (empty($gene_symbol)) { /*if no annotation for gene_symbol was not given, no value will be inserted for gene_symbol in the DB*/
$annotation = pg_query_params($db_conn, $annotation_query, array($id, $gene_id, $gene_biotype, $prot_biotype, null, $description, $annotator)) or die("Error " . pg_last_error());
} else {
$annotation = pg_query_params($db_conn, $annotation_query, array($id, $gene_id, $gene_biotype, $prot_biotype, $gene_symbol, $description, $annotator)) or die("Error " . pg_last_error());
}
$update_status = pg_query_params($db_conn, $update_status_query, array($id)) or die("Error " . pg_last_error()); /*Status of annotation is updated to "annotation exists"*/
echo "Your annotation for " . $id . " has been submitted";

//Display of the annotations areas for all transcript
} else {/*If no annotation has been submitted the annotations fields are displayed*/
echo "<div class='tabcontent' id=todo_" . $id . ">
<form action=" . $_SERVER['PHP_SELF'] . " method='POST'>
<!--This form redirects to itself when the user submits his annotation-->
<!--Informations on transcript-->
<!-- Name of transcript and link for transcript-->
<a href='Gene-ProtPage.php?$id'class='title'>" . $id . "</a><br>
<a href='Gene-ProtPage.php?id=$id'class='title' target='_blank'>" . $id . "</a><br>
Genome : <a href='GenomePage.php?id=" . $transcript['id_genome'] . "' target='_blank'>" . $transcript['id_genome'] . "</a><br>
<!--Page with known informations on transcript-->
";
if ($transcript['annotation']==1){
echo "<a href='Annotation_history.php?id=$id'>$id annotations history</a><br>";
}
echo"<!--Sequences for quick access-->
if ($transcript['annotation'] == 1) { /*If a precedent annotation was rejected for this transcript*/
echo "<a href='Annotation_history.php?id=$id' target='_blank'>$id annotations history</a><br>";
}
echo "<!--Sequences for quick access-->
<div class='double'>
Nucleotidic sequence: <br>
<p class='info'>" . $transcript['sequence_nt'] . "</p><br>
Expand Down Expand Up @@ -147,6 +152,7 @@
<button name= 'submit_" . $id . "'class='little_submit_button' type='submit'> Submit</button>
</form>
</div>";
}
}
}
disconnect_db(); /*Disconnect from database*/
Expand Down
4 changes: 2 additions & 2 deletions Web/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
} else { /*The annotation have not been validated or rejected*/
echo "<div class='tabcontent' id=valid_" . $id_transcript . ">
<form action=" . $_SERVER['PHP_SELF'] . " method='POST'> <!--When the validation and rejection button is clicked the form redirects to the same page-->
<a href='Gene-ProtPage.php?id=$id_transcript'class='title'> $id_transcript</a><br> <!--TODO modify-->
<a href='Annotation_history.php?id=$id_transcript'>$id_transcript annotations history</a><br>
<a href='Gene-ProtPage.php?id=$id_transcript'class='title' target='_blank'> $id_transcript</a><br> <!--TODO modify-->
<a href='Annotation_history.php?id=$id_transcript' target='_blank'>$id_transcript annotations history</a><br>
<!--Annotation information-->
<table class='spaced_table'>
Expand Down
144 changes: 144 additions & 0 deletions Web/search_page2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php
session_start();
if (!isset($_SESSION['Email'])) {
header("Location: LoginPage.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Search </title>
<link rel="stylesheet" type="text/css" href="website.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--CSS for log out button-->
</head>
<body>
<header>
<h1>CALI</h1>
</header>
<div class="topnav">
<?php require_once 'libphp/Menu.php';
echo Menu($_SESSION['Status'], "search_page.php") ?>
</div>

<div class="center">
<h2>Extract data</h2>
<div class="container">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<?php include_once "Extract_data.php"; ?>
<form>
</div>
</div>
<div class="center">
<h2> Search </h2>
<div class="container">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<label for="species_name"><b>Species name</b> </label>
<input type="text" name="species_name" id="species_name" placeholder="Species name"><br>

<label for="strain_name"><b>Strain name</b></label>
<input type="text" name="strain_name" id="strain_name" placeholder="Strain name"><br>

<label for="genetic_support"><b>Genetic support (chromosome or name of plasmid typically)</b></label>
<input type="text" name="genetic_support" id="genetic_support" placeholder="Genetic support"><br>

<label for="chr_ID"><b>Chromosome ID</b></label>
<input type="text" id="chr_ID" name="id_genome" placeholder="Chromosome ID"><br>

<label for="seq_genome"><b>Genome sequence</b></label>
<input type="text" name="genome_seq" id="seq_genome" placeholder="Genome sequence"><br>

<label for="gene_id"><b>Gene ID</b></label>
<input type="text" id="gene_id" name="gene_id" placeholder="Gene ID"><br>

<label for="gene_symbol"><b>Gene symbol</b></label>
<input type="text" name="gene_symbol" id="gene_symbol" placeholder="Gene symbol"><br>

<label for="sequence_nt"><b>Nucleotide sequence or pattern (3 to 950 characters)</b></label>
<input type="text" id="sequence_nt" name="sequence_nt" placeholder="Nucleotide pattern" minlength="3"
maxlength="950"><br>

<label for="prot_id"><b>Protein ID</b> </label>
<input type="text" id="prot_id" name="id_transcript" placeholder="Protein ID"><br>

<label for="description"><b>Function</b></label>
<input type="text" id="description" name="description" placeholder="Function"><br>

<label for="prot_seq"><b>Protein sequence or pattern (3 to 320 characters)</b></label>
<input type="text" id="prot_seq" name="prot_seq" placeholder="Protein pattern" minlength="3"
maxlength="320"><br><br>

<label for="result_type"><b>Select type of results</b></label>
<select name="result_type" id="result_type">
<option value="gene_prot"> Gene / Protein</option>
<option value="Genome"> Genome</option>
</select><br><br>
<button class="big_submit_button" name="submit" type="submit" value="Submit"> Submit</button>
</form>
<?php

include_once 'libphp/db_utils.php';
connect_db();
if (isset($_POST["submit"])) {

$info_formulaire = ["species_name", "strain_name", "genetic_support", "id_genome", "sequence_nt", "id_transcript", "prot_seq", "gene_id", "gene_symbol", "description"];
$col_table = ["genome.species", "genome.strain", "transcript.genetic_support", "genome.id_genome",
"transcript.sequence_nt", "transcript.id_transcript", "transcript.sequence_p", "annotate.id_gene", "annotate.symbol", "annotate.description"];

if ($_POST["result_type"] == "gene_prot") { // Si on veut en résultat des genes ou des proteines
$query_sql = "SELECT distinct(annotate.id_transcript) FROM website.genome,website.transcript, website.annotate WHERE genome.id_genome = transcript.id_genome AND annotate.id_transcript = transcript.id_transcript and validated=1";
} else if ($_POST["result_type"] == "Genome") { // Si on veut en résultat des génomes
$query_sql = "SELECT distinct(genome.id_genome) FROM website.genome,website.transcript, website.annotate WHERE genome.id_genome = transcript.id_genome AND annotate.id_transcript = transcript.id_transcript and validated=1";
}

for ($i = 0; $i <= count($info_formulaire) - 1; $i++) { //Pour chaque champ du formulaire
$ch = $info_formulaire[$i]; // $ch = ensemble des ID du formulaire
$col = $col_table[$i]; // $col = ensemble des attributs des tables SQL
if (!empty($_POST[$ch])) { //Si le champ est rempli
if (isset($query_sql)) {
if (($ch == "sequence_nt") || ($ch == "sequence_p")) { // Si on recherche des motifs (nucleotidique ou proteique), on utilise un " LIKE % "
$query_sql .= "AND " . $col . " LIKE '%" . $_POST[$ch] . "%' ";
} else if (($ch == "id_genome") || ($ch == "id_transcript")) {// Si ce sont des clés primaires, on utilise " = " de façon casse sensible
$query_sql .= "AND " . $col . "='" . $_POST[$ch] . "'";
} else { //Sinon on utilise "=" en mettant tout en minuscule
$query_sql .= "AND lower(" . $col . ")=lower('" . $_POST[$ch] . "')";
}
}
}
}
$res = pg_query($db_conn, $query_sql) or die(pg_last_error());
if (pg_num_rows($res) == 0) {
echo "No results";
} else {
/*Liens vers fiches*/
echo "<table>";
while ($line = pg_fetch_assoc($res)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
if ($_POST["result_type"] == "gene_prot") {
echo "\t\t<td> <a href = 'Gene-ProtPage.php?id=$col_value' target='_blank'> $col_value </a></td>\n";
} else if ($_POST["result_type"] == "Genome") {
echo "\t\t<td> <a href = 'GenomePage.php?id=$col_value' target='_blank'> $col_value </a></td>\n";
}
}
echo "\t</tr>\n";
}
echo "</table>\n";
}


// Libère le résultat
pg_free_result($res);
}


?>
</div>
</div>
<footer>
<a href="Contact.php">Contact</a><br>
<p>© CALI 2021</p>
</footer>
</body>
</html>

0 comments on commit a24a3cd

Please sign in to comment.