Processing your request...
"; if( ereg( "========", $buf ) ) { $sign = 1; break; } } if( $sign ) { echo "
"; echo ""; while( $buf = fgets( $fr, 1024 ) ) { #echo $buf."
"; if( ereg( "========", $buf ) ) { echo "
"; break; } if( !ereg( "FONT", $buf ) ) { echo $buf."
"; } } } fclose( $fr ); return $sign; } #-------------------------------------------------------- # Get motifs information from Genebee motif file, # created by search program. #-------------------------------------------------------- function getMotGen( &$iSup, &$beg, &$len, &$maxLen, &$power, $mot_file ) { if( file_exists( $mot_file ) ) { $fmot = fopen( $mot_file, "r" ); $iSup = -1; while( $buf = fgets( $fmot, 1024 ) ) { if( ereg( "Supermot", $buf ) ) { $iMot = 0; $iSup++; $parts = split( "[ ]+", $buf, 8 ); $nMot = $parts[ 6 ]; $power[ $iSup ] = $parts[ 5 ]; } else { $parts = split( "[ ]+", $buf, 6 ); $beg[ $iSup ][ $iMot ] = $parts[ 2 ]; $len[ $iSup ][ $iMot ] = $parts[ 4 ]; if( $iMot < $nMot ) $iMot++; } } fclose( $fmot ); $maxLen = 0; $iSup++; for( $i=0; $i < $iSup; $i++) { for( $j=0; $j < count( $beg[ $i ] ); $j++) { $maxLen = max( $maxLen, ( $beg[ $i ][ $j ] + $len[ $i ][ $j ] ) ); } } return $iSup; } else return 0; } #-------------------------------------------------------- # Create Graphic Alignment GIF-file #-------------------------------------------------------- function makeGrapAli( $iSup, $beg, $len, $maxLen, $power, $gif_file, $bor, $size, $key_size, $wid, &$hei ) { $hei = $size*( 2*$iSup ) + 5*$bor + $key_size; # Header("Content-type: image/gif"); $k = imagecreate( $wid, $hei ); imagefilledrectangle( $k, 0, 0, $wid, $hei, $white ); $key = imagecreatefromPng( "/www/col_key.png" ); imagecopyresized( $k, $key, 0, 0, 0, 0, $wid, $key_size, $wid, $key_size ); $white = imagecolorallocate($k,255,255,255); $red = imagecolorallocate($k,255,0,0); $green = imagecolorallocate($k,0,128,0); $magen = imagecolorallocate($k,128,0,128); $blue = imagecolorallocate($k,0,0,255); $black = imagecolorallocate($k,0,0,0); $x = 2*$bor + $key_size; imagefilledrectangle( $k, $bor, $x, $wid - $bor, $x+$size, $red ); $x += $size + 2*$bor; for( $i=0; $i < $iSup; $i++) { if( $power[ $i ] > 20.0 ) { $color = $red; } else if( $power[ $i ] > 12.0 ) { $color = $green; } else if( $power[ $i ] > 8.0 ) { $color = $magen; } else if( $power[ $i ] > 6.0 ) { $color = $blue; } else $color = $black; for( $j=0; $j < count( $beg[ $i ] ); $j++) { $b = $bor+$beg[ $i ][ $j ]*( $wid - 2*$bor )/$maxLen; $e = $bor+($beg[ $i ][ $j ]+$len[ $i ][ $j ])*( $wid - 2*$bor )/$maxLen; imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $color ); } $x += 2*$size; } #$er = imagegif( $k, $gif_file ); $er = imagePng( $k, $gif_file ); } #-------------------------------------------------------- # Make string for displaying during mouse moving # over the graphic alignment. #-------------------------------------------------------- function makeOneStr( $buf ) { $part1 = strchr( $buf, "[" ); $len = strcspn( $part1, "]" ); $part2 = trim( strchr( $buf, "!" ) ); $res = substr( $part1, 1, $len-1 ).substr( $part2, 3 ); return $res; } #-------------------------------------------------------- # Print parameter into resulting page. If ref != 0 # is given parameter name if arranged as reference #-------------------------------------------------------- function printPar( $name, $ref, $val ) { if( $ref == "" ) echo "$name$val"; else echo "$name$val"; return 0; } function makeArrStr( $res_file, &$str ) { $fres = fopen( $res_file, "r" ); $i = 1; while( $buf = fgets( $fres, 1024 ) ) { if( ereg( "HREF", $buf ) ) break; } do { $str[ $i ] = makeOneStr( $buf ); $i++; $buf = fgets( $fres, 1024 ); } while( $buf && ereg( "HREF", $buf ) ); fclose( $fres ); } # -------------------------------------------------------- # Detect moleculare type for the given sequence. # Returns: 1 - protein, 0 - nucleotide. # -------------------------------------------------------- function getMolType( $seq ) { $upseq = strtoupper( $seq ); $len = strlen( $upseq ); $nlet = 0; $nnuc = 0; for( $i = 0; $i < $len; $i++ ) { #echo $seq[ $i ]." ".intval( $seq[ $i ] )."
"; #if( 64 < intval( $seq[ $i ] ) && intval( $seq[ $i ] ) < 91 ) { $nlet++; if( $seq[ $i ] == 'A' || $seq[ $i ] == 'C' || $seq[ $i ] == 'G' || $seq[ $i ] == 'N' || $seq[ $i ] == 'T' || $seq[ $i ] == 'U' ) $nnuc++; #} } $molType = ( 100*$nnuc > 80*$nlet ) ? 0 : 1; #echo $nlet." ".$nlet." ".$len." ".$molType."
"; return $molType; } # -------------------------------------------------------- # Check some conditions. # -------------------------------------------------------- if( $SEQ == "" ) { echo "
Dear user, it is similar that you forgot input sequence.
"; exit; } if( $TYPE == "SIM_KEY" && $KEYW == "" ) { echo "
Dear user, it is similar that you forgot input keyword string.
"; exit; } # -------------------------------------------------------- # Creats lock-file for input file # -------------------------------------------------------- $T = 5*( count( $P_BANKS ) + count( $N_BANKS ) ); if( $T == 0 ) $T = 5; echo "
Estimated time before completing your request is approximately $T minutes...
"; flush(); #$indir = "/hdisk1/g_mail/-m_in/"; $indir = "/g_mail_in/-m_in/"; $outdir = "/g_mail_out/m_out/"; $pid = getmypid(); $sem_name = $indir.$pid.".lok"; $fp = fopen( $sem_name, "w" ); fclose( $fp ); # -------------------------------------------------------- # Creates input file # -------------------------------------------------------- $inp_file = $indir.$pid; $fp = fopen( $inp_file, "w" ); fputs( $fp, "From: " ); fputs( $fp, $EMAIL."\n" ); fputs( $fp, "\n[addrfrom]\n" ); fputs( $fp, "from: WWW to: GeneBee (MOSAIC)\n" ); if( $TYPE != "SIM_KEY" ) fputs( $fp, "Screening by similarity\n" ); else fputs( $fp, "Keyword -> Similarity\n" ); fputs( $fp, "\n[receive]\n" ); fputs( $fp, "Receive Sequence= $RCV_SEQ\n" ); fputs( $fp, "3D_COORDINATE= $D_COORD\n" ); if( $SEQ_ALIGN == "SEQUENCE" || $TYPE == "SIM_KEY" ) { $molType = getMolType( $SEQ ); fputs( $fp, "[sequence]\n" ); if( $SEQ_NAME == "" ) fputs( $fp, ">Unnamed\n" ); else fputs( $fp, ">".$SEQ_NAME."\n" ); } else fputs( $fp, "[align]\n" ); fputs( $fp, $SEQ ); if( $MATR == "" ) { if( $molType == 1 ) $MATR = "blosum62"; else $MATR = "dnarna"; } fputs( $fp, "\n\n[matrix]\n" ); $fmat = fopen( "../data/".$MATR.".matrix", "r" ); while( $buf = fgets( $fmat, 128 ) ) { fputs( $fp, $buf ); } fclose( $fmat ); fputs( $fp, "\n\n[banks]\n" ); $numP = count( $P_BANKS ); $numN = count( $N_BANKS ); $numG = count( $G_BANKS ); if( $numP + $numN + $numG == 0 ) { if( $molType == 1 ) { $P_BANKS[ 0 ] = "SPR"; $numP = 1; } else { $N_BANKS[ 0 ] = "HUM"; $numN = 1; } } for( $i = 0; $i < $numP; $i++ ) fputs( $fp, $P_BANKS[ $i ]." " ); for( $i = 0; $i < $numN; $i++ ) fputs( $fp, $N_BANKS[ $i ]." " ); for( $i = 0; $i < $numG; $i++ ) fputs( $fp, $G_BANKS[ $i ]." " ); if( $TYPE == "SIM_RED" || $TYPE == "SIM_KEY" ) { // Set default parameters if REDUCE was choosen $ML_THRESH = 7; $MHP_THRESH = 0.01; $C_RATIO = 0.02; $W_WIDTH = 7; $NUM_COI = 0; $P_SIZE = 100; $MN_SHIFTS = 20; $MN_ALIGN = 100; $SP_SEQ = 0; $EP_SEQ = 100000; $GAP_PEN = 1.0; $DOTHELIX = Y; $MFR = Y; $TRANS = N; $CLUSTER = f; if( $molType == 1 ) { // The case protein $C_RATIO = 0.02; $W_WIDTH = 7; $NUM_COI = 0; $DOTHELIX = Y; } else { $C_RATIO = 0.05; $W_WIDTH = 5; $NUM_COI = 4; $DOTHELIX = N; } } fputs( $fp, "\n\n[params]\n" ); fputs( $fp, "Length threshold $ML_THRESH\n" ); fputs( $fp, "Power threshold $MP_THRESH\n" ); fputs( $fp, "Subalign. power $AP_THRESH\n" ); fputs( $fp, "Min. homology ratio $MHP_THRESH\n" ); fputs( $fp, "Coincidence ratio $C_RATIO\n" ); fputs( $fp, "Window width $W_WIDTH\n" ); fputs( $fp, "Number of coincide $NUM_COI\n" ); fputs( $fp, "Part size $P_SIZE\n" ); fputs( $fp, "Max. number of shifts $MN_SHIFTS\n" ); fputs( $fp, "Max. number of supermotifs $MN_ALIGN\n" ); fputs( $fp, "Start position $SP_SEQ\n" ); fputs( $fp, "End position $EP_SEQ\n" ); fputs( $fp, "Gap penalty $GAP_PEN\n" ); fputs( $fp, "Accurate Dothelix $DOTHELIX\n" ); fputs( $fp, "Motif frequences recalc. $MFR\n" ); fputs( $fp, "Reverse $TRANS\n" ); fputs( $fp, "Clusterization $CLUSTER\n" ); if( $TYPE == "SIM_KEY" ) { fputs( $fp, "\n\n[keyword]\n" ); fputs( $fp, "$KEYW\n" ); fputs( $fp, "\n\n[fields]\n" ); for( $i = 0; $i < count( $FIELDS ); $i++ ) { fputs( $fp, $FIELDS[ $i ]." " ); } } fclose( $fp ); chmod( $inp_file, 0666 ); unlink( $sem_name ); #........sasha - add to database......... //require("/www/db/connect.php3"); $GenebeeTaskID=2; $SenderMail=$EMAIL; //insert_message_to_db($GenebeeTaskID, $SenderMail); #............................... # ----------------------------------------------------------- # Wait while query will be ready # ----------------------------------------------------------- $nRep = 0; $myColor = array( "red", "black", "blue" ); while( file_exists( $inp_file ) ) { sleep( 1 ); clearstatcache(); if( $nRep == 0 ) { echo "Progress bar:    "; } if( $nRep % 60 == 0 ) { echo "o"; flush(); } $nRep++; } echo "
"; # ----------------------------------------------------------- # Output results. # ----------------------------------------------------------- #_________________________ Banner if( $TYPE != "SIM_KEY" ) echo "

Screening by Similarity Results


"; else echo "

Keyword -> Similarity Results


"; #_________________________ Content echo ""; #_________________________ Banks Version fron file 'banks.version'. $frel = fopen( "/www/services/banks.version", "r" ); echo "
"; echo "

Contents:


"; while( $buf = fgets( $frel, 128 ) ) echo $buf; echo "
"; fclose( $frel ); #_________________________ Parameters. echo "

Parameters

"; echo ""; echo ""; if( $EMAIL != "" ) { printPar("User Email Address","",$EMAIL); } printPar("Motif's power threshold","hlp/req1hlp.html#TAG47",$MP_THRESH); printPar("Alignment's power threshold    ","hlp/req1hlp.html#TAG48",$AP_THRESH); if( $TYPE == "SIM_FULL" ) { printPar( "Motif's length threshold","hlp/req1hlp.html#TAG46",$ML_THRESH ); printPar( "Coincidence ratio","hlp/req1hlp.html#TAG51",$C_RATIO ); printPar( "Maximum number of shifts","hlp/req1hlp.html#TAG52",$MN_SHIFTS ); printPar( "Maximum number of selected alignments","hlp/req1hlp.html#TAGXX",$MN_ALIGN ); printPar( "Start position of query sequence","hlp/req1hlp.html#TAGXX",$SP_SEQ ); printPar( "End position of query sequence","hlp/req1hlp.html#TAGXX",$EP_SEQ ); printPar( "Gap penalty","hlp/req1hlp.html#TAG57",$GAP_PEN ); $Strand = ( $TRANS == "Y" ) ? "Both" : "Only forward"; $Cluster = ( $CLUSTER == "f" ) ? "Each frame separately" : "Codirectional joinly"; printPar( "Strand","hlp/req1hlp.html#TAG65", $Strand ); printPar( "Clusterization type","hlp/req1hlp.html#TAG67", $Cluster ); printPar( "Threshold of motif's homology percentage","hlp/req1hlp.html#TAG60",$MHP_THRESH ); printPar( "Accurate dothelix","hlp/req1hlp.html#TAG15",$DOTHELIX ); printPar( "Motif frequences recalc","hlp/req1hlp.html#TAG13",$MFR ); printPar( "Receive bank sequences","hlp/req1hlp.html#TAGXX",$RCV_SEQ ); printPar( "Receive 3D coordinate","hlp/req1hlp.html#TAGXX",$D_COORD ); } #_________________________ Matrix. echo ""; echo ""; #_________________________ Databanks. echo ""; #_________________________ Query sequence. echo ""; #_________________________ Query keyword. if( $TYPE == "SIM_KEY" ) printPar( "Query keyword","Kw-help.html#TAG2",$KEYW ); echo "
Aminoacid matrix
";
 $fmat = fopen( "../data/".$MATR.".matrix", "r" );
 while( $buf = fgets( $fmat, 128 ) )    {
    echo $buf;
 }
 fclose( $fmat );
 echo  "
Databanks"; for( $i = 0; $i < count( $P_BANKS ); $i++ ) echo $P_BANKS[ $i ]."   "; for( $i = 0; $i < count( $N_BANKS ); $i++ ) echo $N_BANKS[ $i ]."   "; for( $i = 0; $i < count( $G_BANKS ); $i++ ) echo $G_BANKS[ $i ]."   "; echo "
Query sequence
$SEQ
"; $res_file = $outdir.$pid."-.ht0"; if( file_exists( $res_file ) ) { if( noAns( $res_file ) ) exit; # ----------------------------------------------------------- # Find out supermotifs information from GeneBee motif file # Here: iSup - number of supermotifs. # beg[][] - array of motifs beginnings # len[][] - array of motifs lengths # power[] - array of supermotif's powers # ----------------------------------------------------------- $mot_file = $res_file.".mot"; getMotGen( $iSup, $beg, $len, $maxLen, $power, $mot_file ); # ----------------------------------------------------------- # Create graphic alignment GIF-file. # ----------------------------------------------------------- #$gif_file = "../trash/".$pid.".gif"; $gif_file = "../trash/".$pid.".png"; if( file_exists( $gif_file ) ) { unlink( $gif_file ); } $size = 3; $bor = 5; $wid = 600; $key_size = 33; makeGrapAli( $iSup, $beg, $len, $maxLen, $power, $gif_file, $bor, $size, $key_size, $wid, $hei ); # ---------------------------------------------------------------------- # Create array of string displaying during mouse is over GIF-file. # ---------------------------------------------------------------------- makeArrStr( $res_file, $str ); echo "

Graphic Alignment

"; echo ""; $up = 4*$bor + $key_size; $down = $up + 2*$size; for( $i = 1; $i <= $iSup; $i++ ) { $a = "#a".$i; $rig = $wid-$bor; $curStr = $str[ $i ]; echo ""; $up += 2*$size; $down += 2*$size; } echo ""; echo "
"; echo "
"; # echo "res_file $res_file
"; $fres = fopen( $res_file, "r" ); echo "
"; while( $buf = fgets( $fres, 128 ) ) echo $buf; fclose( $fres ); unlink( $mot_file ); #echo "mot_file $mot_file
"; $htp_file = $outdir.$pid.".htp"; #echo "htp_file $htp_file
"; unlink( $htp_file ); } else { echo "
There are no sequences homologous to your query sequence.
"; echo " Try to change parameters:
"; $pow = $MP_THRESH-0.5; echo " Motifs power threshold $MP_THRESH --> $pow -->
"; $pow = $AP_THRESH-0.5; echo " Alignments power threshold $AP_THRESH --> $pow -->



"; } unlink( $res_file ); ?>