コード例 #1
0
ファイル: index.php プロジェクト: biophp/biophp
function FCGR_compute($input_min, $input_max)
{
    print "<p align=right><a href=" . $_SERVER["PHP_SELF"] . ">Home</a></p>\n";
    print "Computing...(time depends on sequence length and power of the server)<center><hr>";
    flush();
    // GET DATA
    if ($_POST["seq_name"]) {
        $seq_name = $_POST["seq_name"];
    } else {
        $seq_name = "No name";
    }
    $seq = strtoupper($_POST["seq"]);
    $seq = preg_replace("/\\W|\\d/", "", $seq);
    $seq_len = strlen($seq);
    // limits for length of sequence
    if ($seq_len > $input_max) {
        die("<p>Sequence is longer than {$input_max} bp.<p>At this moment we can not provide this service to such a long sequences.");
    }
    if ($seq_len < $input_min) {
        die("<p>Minumum sequence length: {$input_min} bp");
    }
    $oligo_len = $_POST["len"];
    // If double strand is requested to be computed...
    if ($_POST["s"] == 2) {
        $seq .= " " . RevComp($seq);
    }
    // compute nucleotide frequencies
    $A = substr_count($seq, "A");
    $C = substr_count($seq, "C");
    $G = substr_count($seq, "G");
    $T = substr_count($seq, "T");
    // COMPUTE OLIGONUCLEOTIDE FREQUENCIES
    //   frequencies are saved to an array named $oligos
    $oligos = find_oligos($seq, $oligo_len);
    // CREATE CHAOS GAME REPRESENTATION OF FREQUENCIES IMAGE
    //      check the function for more info on parameters
    //      $data contains a string with the data to be used to create the image map
    $for_map = create_FCGR_image($oligos, $seq_name, $A, $C, $G, $T, $seq_len, $_POST["s"], $oligo_len);
    // PRINT THE IMAGE, WHICH WILL BE A IMAGE MAP WHEN REQUESTED
    //    to avoid submission of a huge amount of data throught the net
    if ($_POST["map"] == 1) {
        // image map is requested
        print "<br><MAP NAME=Kaixo>\n{$for_map}\n</MAP>\n<img USEMAP=\\#Kaixo src=FCGR.png?" . date("U") . " width=552 hight=700 border=0>\n";
    } else {
        print "<br><img  src=FCGR.png?" . date("U") . " width=552 hight=700 border=0>";
    }
    // PRINT TEXTAREA WITH OLIGONUCLEOTIDE FREQUENCIES  WHEN REQUESTED
    if ($_POST["freq"] == 1) {
        // oligonucleotide frequencies are requested
        print "<p><p>Raw data used to generate images above: <BR><textarea cols=80 rows=10>Sequence\tOccurences\n";
        foreach ($oligos as $key => $val) {
            print "\n{$key}\t{$val}";
        }
        print "</textarea>";
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: biophp/biophp
    if (strlen($sequence) == 0) {
        die("Error: query sequence not provided. Plase go back andtry again.");
    }
    if (strlen($sequence) > 1000000) {
        die("Error: sequence is too long. Download the script from biophp.org and used it localy.");
    }
    // when length of query sequence is bellow 4^oligo_len => error (to avoid a lot of 0 frequencies);
    if (strlen($sequence) < pow(4, $oligo_len)) {
        die("Error: query sequence must be at least 4^(length of oligo) to proceed.");
    }
    // when frequencies at both strands are requested, place sequence and reverse complement of sequence in one line
    if ($strands == 2) {
        $sequence .= " " . RevComp($sequence);
    }
    // compute request and save data in an array
    $result = find_oligos($sequence, $oligo_len);
    // print the form
    print_form($sequence);
    //print out results
    print "<p>Frequencie of oligos with length {$oligo_len}<br><textarea cols=60 rows=50>";
    foreach ($result as $oligo => $frequency) {
        print "{$oligo}\t{$frequency}\n";
    }
    print "\n</textarea>\n";
}
// ######################################################################################################
// #####################################        FUNCTIONS             ###################################
// ######################################################################################################
function print_form($sequence)
{
    print "<table bgcolor=DDDDFF cellpadding=10><tr><td>\n";