Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bioi2 changes #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
ini_set('display_errors', 'Off');
// ini_set('error_log','../migenis.log');

function console_log($output) {
echo '<script>';
echo 'console.log(' . json_encode($output) . ');';
echo '</script>';
}

function get_setting($key) {
global $settings;
if (isset($settings[ $key ])) {
Expand Down Expand Up @@ -67,6 +73,7 @@ function print_header($type=null, $name=null) {

function print_nav($type=null, $name=null) {
$dir = '.';
$sep = "&nbsp;> ";
echo "<div id='entete_links'>";
if ($type == 'viewer' || $type == 'aligner') {
# If the database is given
Expand Down Expand Up @@ -96,13 +103,14 @@ function print_sidebar() {
echo "<span class='mynav-logo-banner'>";
echo "<a href='$dir' style='padding: 1px; text-align: center;'><img src='" . "css/logo_bioi2_no_title_s.png" . "' alt='logo_bioi2' id='bioi2_menu_logo'/></a>";
// echo "<br>";
echo "<a href='index.php'>Home page</a>";
echo "<a href='explore_db.php'>Explore databases</a>";
echo "<a href='createdb.php'>Create database</a>";
echo "<a href='upload_db.php'>Upload database</a>";
echo "<a href='search.php'>Search databases</a>";
echo "<a href='direct_access.php'>Genomic islands</a>";
echo "<a href='help_pages.php'>Help page</a>";
echo "<a href='contact.php'>Contact us</a>";
echo "<a href='index.php'>Back to home page</a>";
echo "</span>";
echo "</div>";
}
Expand Down
16 changes: 11 additions & 5 deletions createdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
<div id="content">
<div class="centered_box">
<h2><?php site_name(); ?> database creator</h2>
<p>This page helps to create a <?php site_name(); ?> database (in sqlite3 format) based on genomes uploaded by the user.</p>
<p> The final database can be downloaded for local analyzis, or it can be explored on the <?php site_name(); ?> site.</p>
<p>Alternatively you can <a href="upload_db.php">upload a Synteruptor database</a> directly if you have generated a database yourself.</p>
<p>Use this page to create a <?php site_name(); ?> database (in sqlite3 format) based on uploaded genomes.</p>
<p> The final database can be downloaded for local analyzis, or it can be explored on the <?php site_name(); ?> web site.</p>
<p>Alternatively you can <a href="upload_db.php">upload a <?php site_name(); ?> database</a> directly if you have already generated a database yourself.</p>

<?php

if (isset($_GET["id"])) {
Expand All @@ -57,7 +58,9 @@
echo "</div>";
echo "<div class='button_container'><a href='createdb_start.php'><div class='button_link'>Start a new project</div></a></div>";
exit;
}
}else{
if(!in_array($id,$_SESSION["db_ids"])){$_SESSION["db_ids"][]=$id;};
};

# List the genome files in the dir
$gbks = scan_gbks();
Expand All @@ -66,6 +69,7 @@
echo "<ol>";
print_gbks($gbks);
$config = get_config();

if ($ngbks < $max_gbks && (!isset($config) || $config['status'] == 'preparation')) {
$diff = $max_gbks - $ngbks;
echo '<form id="uploader" action="createdb_add.php?id=' . $id . '" method="post" enctype="multipart/form-data">';
Expand All @@ -86,7 +90,7 @@
echo '<div class="infobox">';
echo '<h3>Information about the data provided and generated</h3>';
echo "<ul>";
echo "<li>The job will send you an e-mail (mandatory) when the database creation starts and when it ends. You can also check the progress by bookmarking this page: <a href='$builder?id=$id'>$site_name job: $id</a>.</li>";
echo "<li>The job will send you an e-mail (if provided) when the database creation starts and when it ends. You can also check the progress on this page: <a href='$builder?id=$id'>$site_name job: $id</a> (if you didn't provide your email address, we strongly recommend that bookmark this page).</li>";
echo "<li>The mail provided will only be used to send the progress information.</li>";
echo "<li>The files uploaded will be conserved until the database has been built, and they will then be deleted from our servers.</li>";
echo "<li>The created database is not made public and can only be accessed with the random id created for it ($id).</li>";
Expand All @@ -97,6 +101,8 @@
} else {
echo "<div class='button_container'><a href='createdb_start.php'><div class='button_link'>Start a new project</div></a></div>";
}


?>
</div>
</div>
Expand Down
35 changes: 17 additions & 18 deletions createdb_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,41 @@ function check_blocks_tol($btol) {

function start_job() {
$config = get_config();

# Change from "preparation" to "waiting"
if (isset($config) && isset($config['status']) && $config["status"] == 'preparation') {
$config["status"] = "waiting";
# Get a mail address too?
if (isset($_GET["mail"])) {
$mail = check_mail($_GET["mail"]);
if ($mail == '') {
return array(
'status' => "mail_error",
);
} else {
if ($mail != '') {
$config["mail"] = $mail;
// } else { // [CQ] 2024-03-22 -> remove this check to avoid error if mail not set
// return array(
// 'status' => "mail_error",
// );
}
}
# Get an author?
if (isset($_GET["author"])) {
$author = check_text($_GET["author"]);
if ($author == '') {
return array(
'status' => "author_error",
);
} else {
if ($author != '') {
$config["author"] = $author;
// } else {
// return array(
// 'status' => "author_error",
// );
}
}
# Get a description?
if (isset($_GET["description"])) {
$description = check_text($_GET["description"]);
if ($description == '') {
return array(
'status' => "description_error",
);
} else {
if ($description != '') {
$config["description"] = $description;
// } else {
// return array(
// 'status' => "description_error",
// );
}
}
# Get a blocks tolerance value?
Expand All @@ -84,7 +84,7 @@ function start_job() {
} else {
return array(
'status' => "error",
'details' => "Status already exists (" . $status['status'] . ")",
'details' => "Status already exists (" . $config['status'] . ")",
);
}
}
Expand All @@ -99,7 +99,6 @@ function start_job() {
);
} else if (isset($_GET["command"])) {
$command = $_GET["command"];

# Check for the status of the current working dir
if ($command == "check") {
$output = get_config();
Expand Down
5 changes: 3 additions & 2 deletions css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ a.table-row {
}

@media screen and (max-width: 800px) {
#databases {
#databases,#userdatabases {
width: 100%;
overflow-x: auto;
}
}


/*
#databases table {
border-spacing: 3px;
Expand All @@ -182,7 +183,7 @@ a.table-row {
}
*/

#databases td {
#databases,#userdatabases td {
padding: 6px;
}

Expand Down
2 changes: 1 addition & 1 deletion direct_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<div class='index_box'>
<?php
$allowed = get_available_dbs_list(true, $_SESSION['db_ids']);
$allowed = get_available_dbs_list("all", $_SESSION['db_ids']);
if ($allowed) {
echo "<p>Select a public database:";
echo "<div id='databases'></div>";
Expand Down
4 changes: 2 additions & 2 deletions download.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<div class='box'>
Downloads:<br />
<ul>
<li><a href='dl/synteruptor.tar.gz'><?php echo $site_name ?> scripts</a></li>
<li><a href='dl/synteruptor_web.tar.gz'><?php echo $site_name ?> website</a></li>
<li><a href='https://github.com/i2bc/synteruptor'><?php echo $site_name ?> scripts</a></li>
<li><a href='https://github.com/i2bc/synteruptor_web'><?php echo $site_name ?> website</a></li>
</ul>
</div>
<a href="index.php">&lt; Back to Main Page</a>
Expand Down
55 changes: 46 additions & 9 deletions explore_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php site_name(); ?> help pages</title>
<title><?php site_name(); ?> database exploration</title>
<link rel="icon" type="image/png" href="css/Synteruptor_logo_square.png">
<link rel="stylesheet" type="text/css" href="css/common.css">
<script type="text/javascript" src="js/jquery/jquery-1.12.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/index.js"></script>

</head>

<nav>
<?php
print_sidebar();
Expand All @@ -26,15 +27,16 @@
<?php
print_header();
?>

<div id="content">
<div class="centered_box">
<h2>Available databases</h2>
<div class='index_box'>
<?php
// Display public databases (if any)
$allowed = get_available_dbs_list();
$allowed = get_available_dbs_list("dbs");
if ($allowed) {
echo "<p>The following databases were generated with preselected genomes and can be freely explored:</p>";
echo "<p>The following databases were generated with preselected genomes and can be freely explored (they might take a few seconds to load):</p>";
echo "<div id='databases'></div>";
} else {
echo "<p>No public database available</p>";
Expand All @@ -47,25 +49,60 @@
<h2>User databases</h2>
<div class='index_box'>
<?php
$available_dbs = get_available_dbs_list(true, $_SESSION['db_ids']);

// Check what user DBs are still available and list only those
$available_dbs = get_available_dbs_list("user", $_SESSION['db_ids']);
foreach ($_SESSION['db_ids'] as $key => $value){
if(!in_array($value.".sqlite",$available_dbs)){
console_log("removing".$value);
unset($_SESSION['db_ids'][$key]);
}
}
if (empty($_SESSION['db_ids'])){
echo "<p>No user databases found in web browser history</p>";
if (empty($available_dbs)){
echo "<p>No user databases found in web browser cache (/!\ note that jobs older than 30 days are automatically wiped)...</p>";
}else{
echo "<p>The following databases were generated:</p>";
foreach ($_SESSION['db_ids'] as &$value){
echo "<p>The following databases were found in your web cache:</p>";
echo "<div id='userdatabases'></div>";
echo "<p>/!\ note that jobs older than 30 days are automatically wiped.</p>";

// foreach ($_SESSION['db_ids'] as &$value){
// $site_host = get_setting('site_host');
// $site_host_subdir = get_setting('site_host_subdir');
// echo "<p><a href='$site_host/$site_host_subdir/summary.php?version=$value'>$value</a></p>";
// }
}
?>
</div>
</div>
<div class="centered_box">
<h2>User searches</h2>
<div class='index_box'>
<?php

// // Check what user DBs are still available and list only those
// $available_dbs = get_available_dbs_list("user", $_SESSION['db_ids']);
// foreach ($_SESSION['blast_ids'] as $key => $value){
// if(!in_array($value.".sqlite",$available_dbs)){
// console_log("removing".$value);
// unset($_SESSION['db_ids'][$key]);
// }
// }
if (empty($_SESSION['blast_ids'])){
echo "<p>No user searches found in web browser cache (/!\ note that jobs older than 30 days are automatically wiped)...</p>";
}else{
echo "<p>The following user searches were found in your web cache:</p>";

foreach ($_SESSION['blast_ids'] as &$value){
$site_host = get_setting('site_host');
$site_host_subdir = get_setting('site_host_subdir');
echo "<p><a href='$site_host/$site_host_subdir/summary.php?version=$value'>$value</a></p>";
echo "<p><a href='$site_host/$site_host_subdir/search.php?id=$value'>$value</a></p>";
}
echo "<p>/!\ note that jobs older than 30 days are automatically wiped.</p>";
}
?>
</div>
</div>

</div>
</body>
</html>
Expand Down
20 changes: 13 additions & 7 deletions get_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ function get_genes_list($dbh) {
}
}

function get_databases($all = false, $authorised = array()) {
$data = get_databases_data($all, $authorised);
function get_databases($show = 'dbs', $userauthorised = array()) {
$data = get_databases_data($show, $userauthorised);
return $data;
}

Expand All @@ -174,14 +174,20 @@ function get_databases($all = false, $authorised = array()) {
// MAIN
// Special: list of all databases
if (isset($_GET['type']) && $_GET['type'] == 'databases') {
$all = false;
$authorised = array();
$show = 'dbs';
$userauthorised = array();
if (isset($_GET['userdb']) && $_GET['userdb']=='true'){
$all = true;
$authorised = $_SESSION['db_ids'];
$userauthorised = $_SESSION['db_ids'];
$show = 'all';
}
$data = get_databases($all, $authorised);
$data = get_databases($show, $userauthorised);
print json_encode($data);
} elseif (isset($_GET['type']) && $_GET['type'] == 'userdatabases'){
$show = "user";
$userauthorised = $_SESSION['db_ids'];
$data = get_databases($show, $userauthorised);
print json_encode($data);

} else {
$dbh = get_db();

Expand Down
1 change: 1 addition & 0 deletions help_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<div class='index_box'>
<!--<img src='css/Synteruptor_logo_full.png' id='logo' alt='logo' />-->
<p><?php echo $site_name ?> is a tool designed to find synteny breaks between closely related bacterial genomes. The breaks found can be explored with this web interface to find clusters of genes of interest.</p>
<p>DOI on BioRxiv: <a href="https://www.biorxiv.org/content/10.1101/2024.01.03.573040v1">10.1101/2024.01.03.573040v1</a></p>
<br /><span id="last_update">Last update: <?php echo get_setting("last_update"); ?></span>
<br /><span id="contact">Contact: <?php echo get_mail(); ?></span>
<span style="float:right;"><a href="download.php">Download <?php echo $site_name ?></a></span>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<?php
// Display public databases (if any)
echo "<h3 id='availdb'>Available databases</h3>";
$allowed = get_available_dbs_list();
$allowed = get_available_dbs_list("dbs");
if ($allowed) {
echo "<p>The following databases were generated with preselected genomes and can be freely explored:</p>";
echo "<div id='databases'></div>";
Expand Down
2 changes: 0 additions & 2 deletions js/aligner.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function get_max(genes) {
}

function draw_alignment(data) {
console.log(data);
// Number of sequences in the alignment
var num = Object.keys(data.genomes).length;

Expand Down Expand Up @@ -479,7 +478,6 @@ $(function() {
loading_off();
}).fail(function() {
$( "#message" ).html("<span>Error: data retrieval failed.</span>");
console.log(urls.get_data + '?' + $.param(pars));
loading_off();
});
}
Expand Down
Loading