File: view_sequence.php

package info (click to toggle)
stacks 2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,108 kB
  • sloc: cpp: 36,453; php: 4,059; sh: 2,122; perl: 1,163; python: 497; sql: 389; makefile: 148
file content (79 lines) | stat: -rw-r--r-- 2,042 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
//
// Copyright 2010-2016, Julian Catchen <jcatchen@illinois.edu>
//
// This file is part of Stacks.
//
// Stacks is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Stacks is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Stacks.  If not, see <http://www.gnu.org/licenses/>.
//
require_once("header.php");

$database = isset($_GET['db']) ? $_GET['db'] : "";
$seq_id   = isset($_GET['id']) ? $_GET['id'] : 0;

// Connect to the database
$db = db_connect($database);

// Save these variables for automatic URL formation later on.
$display = array();
$display['db']     = $database;
$display['seq_id'] = $seq_id;

//
// Prepare some SQL queries
//
$query = 
    "SELECT id, catalog_id, seq_id, type, seq FROM sequence " . 
    "WHERE id=?";
if (!($db['seq_sth'] = $db['dbh']->prepare($query)))
    write_db_error($db['dbh'], __FILE__, __LINE__);


$page_title = "Catalog RAD-Tag Sequence Viewer";
write_compact_header($page_title);

if (!$db['seq_sth']->bind_param("i", $seq_id))
    write_db_error($db['seq_sth'], __FILE__, __LINE__);
if (!$db['seq_sth']->execute())
    write_db_error($db['seq_sth'], __FILE__, __LINE__);
$res = $db['seq_sth']->get_result();

$row = $res->fetch_assoc();

//
// Line wrap the sequence to 80 characters
//
$full_seq = $row['seq'];
$seq = "";

do {
    $seq     .= substr($full_seq, 0, 80) . "\n";
    $full_seq = substr($full_seq, 80);
} while (strlen($full_seq) > 80);
        
if (strlen($seq) > 0) {
    $seq .= $full_seq . "\n";
}

    echo <<< EOQ
<pre>
>$row[catalog_id]|$row[seq_id]|$row[type]
$seq
</pre>

EOQ;

write_compact_footer();

?>