// annfrag.h
/*****
// ------------------------------------------------------
//f_scaleStep - get scale step values
// -----------------------------------------------------
function f_scaleStep2( $iL, $nmax = 30 ) {
$n = log10( $iL );
settype( $n, "integer" );
$n--;
$n = pow( 10, $n );
//echo "n(pow) = " . $n . "
";
if( $iL / $n > $nmax ) {
$r[0] = $n * 5;
$r[1] = 2; //$n * 10; //every 2nd
$r[2] = 2; //4; //$n * 20;
} else {
$r[0] = $n;
$r[1] = 5; //$n * 5; // every 5th
$r[2] = 5;
if( $iL / $n > 500 )
$r[2] = 10; //$n * 10;
if( $iL / $n < 20 )
$r[2] = 2;
if( $iL / $n < 10 )
$r[2] = 1;
}
return $r;
}
// ------------------------------------------------------
// f_clr - color index as func( power )
// -----------------------------------------------------
function f_clr( $im, $x, $pMin, $pMax ) { // P1 < x < P2 : min/max
// Colors: 450 -> 450/4
//int xP;
//double iR, iG,iB, dP; // Note: Here iR, iG, iB - double !
//int ddY;
//int iC;
$dP = 450. / ($pMax - $pMin); // Colors per power unit
$iR=0.; $iG=0.; $iB =0.;
$xP = $dP * ($x - $pMin); // int
$xP -= ($xP % 4 ); // Reduce colors to 450/4
$ddY = $xP;
if( $ddY < 200 ) {
$iR = $ddY * 0.5; $iR+= 155.;
if( $iR < 0 ) $iR = 0.;
} else {
if( $ddY <= 455 ) {
$iG = $ddY - 200;
$iR = 255.;
}
}
$iC = imageColorResolve( $im , $iR, $iG, $iB );
return $iC;
}
// ------------------------------------------------------
// f_imFrame - shadow border around...
// -----------------------------------------------------
function f_imFrame( $im_out, $iW, $iH, $dX1, $dX2, $dY1, $dY2 ) {
$white = ImageColorResolve($im_out, 255, 255, 255);
$black = ImageColorResolve($im_out, 0, 0, 0);
$gray = ImageColorResolve($im_out, 200, 200, 200);
for( $i = 0; $i < 5; $i++ ) {
//iWk = 41 - i*5; // 0 = lgray 31
$iWk = 50 - $i*5; // 0 = lgray 31
$iC = ImageColorResolve($im_out, 255 - $iWk, 255 - $iWk, 255 - $iWk);
ImageLine($im_out, 1+$i, 1+$i, $iW - $i, 1+$i, $iC);
ImageLine($im_out, 1+$i, 1+$i, 1+$i , $iH - $i, $iC);
}
ImageFilledRectangle($im_out, 1+$i, 1+$i, $iW - $i, $dY1 - 1, $iC );
ImageFilledRectangle($im_out, 1+$i, 1+$i, $dX1 - 1, $iH - $i, $iC );
$iC2 = $iC;
// Light gray at right-lower:
ImageLine($im_out, $iW - 1, $iH - 1, $iW - 1, 1 , $gray);
ImageLine($im_out, $iW - 1, $iH - 1, 1 , $iH - 1, $gray);
ImageFilledRectangle($im_out, $iW - $dX2 + 1, $dY1, $iW - $i, $iH - $i, $iC2);
ImageFilledRectangle($im_out, $dX1 , $iH - $dY2 + 1 , $iW - $i, $iH - $i, $iC2);
// White lines: (..dark lines see below)
ImageLine($im_out, $dX1 - 1 , $dY1 - 1 , $iW - $dX2 + 1, $dY1 - 1 , $white);
ImageLine($im_out, $dX1 - 1 , $dY1 - 1 , $dX1 - 1 , $iH - $dY2 + 1, $white);
ImageLine($im_out, $dX1 - 2 , $dY1 - 2 , $iW - $dX2 + 2, $dY1 - 2 , $white);
ImageLine($im_out, $dX1 - 2 , $dY1 - 2 , $dX1 - 2 , $iH - $dY2 + 2, $white);
ImageLine($im_out, $dX1 - 3 , $dY1 - 2 , $dX1 - 3 , $iH - $dY2 + 2, $white);
// Left-upper black frame:
ImageLine($im_out, 0, 0, $iW - 1, 0, $black);
ImageLine($im_out, 0, 0, 0 , $iH - 1, $black);
}
*****/
function f_clrRed( $im, $x, $pMin, $pMax ) { // P1 < x < P2 : min/max
//var $aC; //[3];
$aC = false;
return f_clrRedBase( $im, $x, $pMin, $pMax, $aC );
}
function f_clrRedBase( $im, $x, $pMin, $pMax, &$aC ) { // P1 < x <= P2 : min/max
// Colors: 450 -> 450/9 = 50
//int xP;
//double iR, iG,iB, dP; // Note: Here iR, iG, iB - double !
//int ddY;
//int iC;
//+dP = 550. / (double)(pMax - pMin); // Colors per power unit
$dP = 550. / ($pMax - $pMin); // Colors per power unit
$iR=0.; $iG=0.; $iB =0.;
$xP = intval($dP * ($x - $pMin));
//$xP -= ($xP % 8 ); // Reduce colors to 400/8 = 50
$xP -= ($xP % 11 ); // Reduce colors to 550/11 = 50
$ddY = $xP;
if( $ddY < 200 ) {
$iR = $ddY * 0.5; $iR+= 155.;
if( $iR < 0 ) $iR = 0.; // ? ***
} else {
//+if( ddY < 400 ) {
$iR = 255;
// 200 - 250
if( $ddY <= 250 ) {
$iG = ($ddY - 200) * 2; // 0 - 100
// 250 - 400
} else {
$iG = 100 + ($ddY - 250.) * 0.5;
}
}
$iC = ImageColorResolve( $im , intval($iR), intval($iG), intval($iB) );
$aC[0] = intval($iR);
$aC[1] = intval($iG);
$aC[2] = intval($iB);
return $iC;
}
function f_clrBlue( $im, $x, $pMin, $pMax ) { // P1 < x < P2 : min/max
//var $//aC; //[3];
$aC = false;
return f_clrBlueBase( $im, $x, $pMin, $pMax, $aC );
}
function f_clrBlueBase( $im, $x, $pMin, $pMax, &$aC ) { // P1 < x <= P2 : min/max
// - Colors: 350 -> 350/7 = 50
// Colors: 300 -> 300/6 = 50
//int xP;
//double iR, iG,iB, dP; // Note: Here iR, iG, iB - double ! (multiply)
//int ddY;
//int iC;
//+dP = 300. / (double)(pMax - pMin); // Colors per unit
$dP = 300. / ($pMax - $pMin); // Colors per unit
$iR=0.; $iG=0.; $iB =0.;
$xP = intval($dP * ($x - $pMin));
$xP -= ($xP % 6 ); // Reduce colors to 50
$ddY = $xP;
// <= 240
$iR = 100.; // 5
$iG = 240. - $ddY; // 240 - 160 = 80
$iB = 255.;
//// > 240
if( $ddY > 160 && $ddY <=180 ) {
$iG =80. - ($ddY - 160.)*4.; //80 -> 0
} else if( $ddY > 180 ) {
$iG = 0.;
//$iB = 75. + (300. - $(double)ddY) * 1.5; // 255 -> 135
$iB = 75. + (300. - $ddY) * 1.5; // 255 -> 135
}
$iC = ImageColorResolve( $im , intval($iR), intval($iG), intval($iB) );
$aC[0] = intval($iR);
$aC[1] = intval($iG);
$aC[2] = intval($iB);
return $iC;
}
function f_clrGreen( $im, $x, $pMin, $pMax ) { // P1 < x < P2 : min/max
//var $aC; //[3];
$aC = false;
$ret = f_clrGreenBase( $im, $x, $pMin, $pMax, $aC );
//echo "*RGB = " . $aC[0]. " ". $aC[1]. " " . $aC[2] . "
\n";
return $ret;
}
function f_clrGreenBase( $im, $x, $pMin, $pMax, &$aC) { // P1 < x <= P2 : min/max
// Colors: 150 -> 150/3 = 50
//int xP;
//double iR, iG,iB, dP; // Note: Here iR, iG, iB - double ! (multiply)
//int ddY;
//int iC;
//+dP = 150. / (double)(pMax - pMin); // Colors per unit
$dP = 150. / ($pMax - $pMin); // Colors per unit
$iR=0.; $iG=0.; $iB =0.;
$xP = intval($dP * ($x - $pMin));
$xP -= ($xP % 3 ); // Reduce colors to 50
$ddY = $xP;
// <= 240
$iR = 185. - $ddY; //*0.5;
$iG = 240. - $ddY;
$iB = 185. - $ddY; //*0.5;
$iC = ImageColorResolve( $im , intval($iR), intval($iG), intval($iB) );
$aC[0] = intval($iR);
$aC[1] = intval($iG);
$aC[2] = intval($iB);
return $iC;
}
function f_setGroupColors( $im, &$aClr0, $iRM, $iGM, $iBM ) //clrs & limits
{
//int i;
for( $i = 0; $i < ($iGM - 1); ++$i ) {
$aClr[$i] = f_clrGreen( $im, $i+1, 0, $iGM );
//echo "green
";
}
for( $i = 0; $i < ($iBM - 1); ++$i ) {
$aClr[$i+$iGM - 1] = f_clrBlue ( $im, $i+1, 0, $iBM );
//echo "blue
";
}
for( $i = 0; $i < ($iRM - 1); ++$i ) {
$aClr[$i+$iGM+$iBM - 2] = f_clrRed( $im, $iRM - $i - 1, 0, $iRM );
//echo "red
";
}
$i = 0;
while( list( $key, $val ) = each( $aClr0 ) ) {
if( $i >= ($iGM + $iBM + $iRM - 3) ) break; // ---------------->
$aClr2[ $key ] = $aClr[ $i++ ];
//echo "color $i
";
}
$aClr0 = $aClr2;
}
//
// *****
// ***
// *
function f_outTria( $k, $x, $y, $h0, $c, $bFill, $white = 0 ) {
$h = $h0 - 1;
$aPoint[0] = $x ; $aPoint[1] = $y;
$aPoint[2] = $x - $h; $aPoint[3] = $y - $h;
$aPoint[4] = $x + $h; $aPoint[5] = $y - $h;
if( $bFill )
imagefilledPolygon( $k, $aPoint, 3, $c );
else {
imagefilledPolygon( $k, $aPoint, 3, $white );
imagePolygon ( $k, $aPoint, 3, $c );
}
}
// Getting pos & len to plot one fragment:
// iP1, iP2 - frag positions,
// beg[], beg2[], len[] - starts $ lens of motifs (one supermotif),
// begX, lenX - start $ len to plot
function f_getFragPos( $iP1, $iP2, $beg, $beg2, $len, &$begX, &$lenX, &$extra ) {
//+unset( $extra ); // extra fragments ( motifs from 2nd )
//+$begX = $iP1;
//+$lenX = $iP2 - $iP1 + 1;
// _________________________________________________
//
// NOTE. ip1, ip2 pos from 1; beg, beg2 pos from 0 !
// (begX from 1.)
//__________________________________________________
--$iP1;
--$iP2;
if( $iP1 < 0 || $iP2 < 0 ) {
$lenX = 0;
$begX = 0;
return; // ---------------> dummy frag pos
}
// a) Frag is placed at one motif at most.
$iLen = count( $beg2 );
//echo "p1/2, iLen = " . $iP1. " / ". $iP2 . " / " . $iLen . "
\n";
// Search for the first motif
for( $i = 0; $i < $iLen; ++$i ) {
if( $iP1 <= ( $beg2[$i] + $len[$i] - 1 ) ) {
$b = max( $iP1, $beg2[$i] );
$e = min( $iP2, $beg2[$i] + $len[$i] - 1 );
if( $e >= $b ) {
$off = $beg2[$i] - $beg[$i]; // offset to left side
$begX = $b - $off + 1; // +1 to start from 1
$lenX = $e - $b + 1;
// next extra motifs: --------------------------------------------P30387
if( $iP2 > $e ) {
for( $j = $i+1; $j < $iLen; ++$j ) {
if( $iP2 < $beg2[$j] )
break; // ------>
$b = $beg2[$j];
$e = min( $iP2, $beg2[$j] + $len[$j] - 1 );
if( $e >= $b ) {
$off = $beg2[$j] - $beg[$j]; // offset to left side
$beX = $b - $off + 1; // +1 to start from 1
$leX = $e - $b + 1;
$extra[ $beX ] = $leX;
}
//break; // **tst
}
}
// ---------------------------------------------------- end of extra
// found but after
} else {
$lenX = 0;
$begX = 0;
}
return;
}
}
$begX = 0;
$lenX = 0; // return "NO Motif is found"
}
function f_outFrag( $aFrag, $jj, &$aFTypeQ, $k, $b, $e, $dB, $x, $size, $color, $white ) {
// &$extFrag = false ) {
// Non-single pos
//if( $aFrag[$jj+1] < $aFrag[$jj+2] ) {
if( ($aFrag[$jj+2] - $aFrag[$jj+1]) > 0 ) {
// weight 0
if( $aFrag[$jj+3] < 1 ) {
++$aFTypeQ[ $aFrag[ $jj ] ][1];
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" )
{
f_outTria( $k, $b + $dB, $x+$size, $size+2, $color, false, $white );
f_outTria( $k, $e - $dB, $x+$size, $size+2, $color, false, $white );
/**
if( !isset( $extFrag ) ) {
f_outTria( $k, $e - $dB, $x+$size, $size+2, $color, false, $white );
} else {
while( list( $beX, $leX ) = each( $extFrag ) ) {
//$b = $dx12+$bor+($beX - 1)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
$e = $dx12+$bor+($beX+$leX - 2)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
}
}
**/
imageDashedLine( $k, $b + $dB, $x+$size+1, $e - $dB, $x+$size+1 , $color );
} else {
imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $white ); // to erase motif line
imagerectangle ( $k, $b, $x, $e, $x+$size-1, $color );
}
if( $aFrag[$jj] == "HELIX" || $aFrag[$jj] == "STRAND" || $aFrag[$jj] == "TURN" ) {
imageDashedLine ( $k, $b, $x+$size, $e, $x+$size , $color );
}
// weight 1
} else {
++$aFTypeQ[ $aFrag[ $jj ] ][0];
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" )
{
f_outTria( $k, $b + $dB, $x+$size, $size+2, $color, true, $white );
f_outTria( $k, $e - $dB, $x+$size, $size+2, $color, true, $white );
imageDashedLine( $k, $b + $dB, $x+$size+1, $e - $dB, $x+$size+1 , $color );
} else {
imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $color );
}
if( $aFrag[$jj] == "HELIX" || $aFrag[$jj] == "STRAND" || $aFrag[$jj] == "TURN" ) {
imageDashedLine ( $k, $b, $x+$size, $e, $x+$size , $color );
//- imageDashedLine ( $k, $b, $x+$size-1, $e, $x+$size-1 , $white );
}
}
// Single pos
} else {
if( $aFrag[$jj+3] < 1 ) {
++$aFTypeQ[ $aFrag[ $jj ] ][3];
f_outTria( $k, ($b + $e) * 0.5, $x+$size, $size+2, $color, false, $white );
} else {
++$aFTypeQ[ $aFrag[ $jj ] ][2];
f_outTria( $k, ($b + $e) * 0.5, $x+$size, $size+2, $color, true );
}
}
//}
}
// +beg2 *** 07.22
function makeGrapFrag( $iSup, $beg, $beg2, $len, $maxLen, $power, $gif_file,
$bor, $size, $key_size, &$wid, &$hei, $aSN, $seqname, $wm,
$opt, &$DX0, &$DX1, &$DX12, $aKW01, $aPosName, $aST, &$kwMap,
&$fttMap, $aExclu = "",
$aFT = false, $aClr = false, $numClrMax = 10, $aDRN = false, $aDR = false ) {
global $SEQ_REF1, $SEQ_REF2;
//+echo "maxLen=" . $maxLen . "
";
// *** 07.22
$wid -= 40; // to be max about 750
$iWLwid = 8; // width of the Weight Line
$iWLspace = 26; // all extra space for WL & mim/max numbers
// FT fragments
/**
FT STRAND 5 8
FT TURN 13 15
FT HELIX 16 24
FT TURN 25 26
FT STRAND 30 33
FT HELIX 37 45
FT TURN 46 47
FT TURN 50 51
FT STRAND 56 59
FT TURN 60 61
FT STRAND 62 64
FT HELIX 67 77
FT TURN 78 79
FT HELIX 85 110
**/
if( $aFT == false )
$aFT = Array(
"P08263" => Array(
"STRAND", 5, 8, 1,
"TURN", 13, 15, 1,
"HELIX", 16, 24, 1,
"TURN", 25, 26, 1,
"STRAND", 30, 33, 1,
"HELIX", 37, 45, 1,
"TURN", 46, 47, 1,
"TURN", 50, 51, 1,
"STRAND", 56, 59, 1,
"TURN", 60, 61, 1,
"STRAND", 62, 64, 1,
"HELIX", 67, 77, 1,
"TURN", 78, 79, 1,
"HELIX", 85, 110, 1)
, "P09211" => Array(
"STRAND", 3, 7, 1,
"TURN", 12, 14, 1,
"HELIX", 16, 24, 1,
"TURN", 25, 26, 1,
"STRAND", 30, 33, 1,
"HELIX", 37, 45, 1,
"TURN", 46, 47, 1,
"TURN", 50, 51, 1,
"STRAND", 56, 59, 1,
"TURN", 60, 61, 1,
"STRAND", 62, 64, 1,
"HELIX", 67, 77, 1,
"TURN", 78, 79, 1,
"HELIX", 83, 109, 1)
, "Q28514" => Array(
"STRAND", 3, 7, 1,
"TURN", 12, 14, 1,
"HELIX", 16, 24, 1,
"TURN", 25, 26, 1,
"STRAND", 30, 33, 1,
"HELIX", 37, 45, 0,
"TURN", 46, 47, 1,
"TURN", 50, 51, 1,
"STRAND", 56, 59, 1,
"TURN", 60, 61, 1,
"STRAND", 62, 64, 1,
"HELIX", 67, 77, 0,
"TURN", 78, 79, 1,
"HELIX", 83, 109, 0)
, "P28801" => Array(
"STRAND", 3, 7, 0,
"TURN", 12, 14, 0,
"HELIX", 16, 24, 0,
"TURN", 25, 26, 0,
"STRAND", 30, 33, 0,
"HELIX", 37, 45, 0,
"TURN", 46, 47, 0,
"TURN", 50, 51, 0,
"STRAND", 56, 59, 0,
"TURN", 60, 61, 0,
"STRAND", 62, 64, 0,
"HELIX", 67, 77, 0,
"TURN", 78, 79, 0,
"HELIX", 83, 109, 0,
"TURN", 150, 150, 0,
"TURN", 155, 155, 1,
"TURN", 160, 160, 0,
"TURN", 162, 162, 0,
"TURN", 164, 164, 0,
"TURN", 170, 170, 1,
"TURN", 172, 172, 1,
"TURN", 174, 174, 1
)
);
//$dx1 = 50+16+40; $dx2 = 10+10+10 + 5;
$dx1 = 50+40 - 4; $dx2 = 10+10 + 5;
$dx2 += $iWLspace; // *** 07.22
$twoColLim = 20;
//+if( $iSup < 10 ) {
if( $iSup < $twoColLim ) { // *** 02.02.01
$dx1 -= 30;
$DX0 = 0;
} else
$DX0 = 45; // See below "Seq name: "
$DX1 = $dx1; // return dx1
//$dy1 = 20+10; $dy2 = 20+10;
//+$dy1 = $bor + $key_size; $dy2 = 20+5 - 4;
$dy1 = $bor + $key_size + 6; $dy2 = 20+5 - 4;
// Add space for FT keyword lines from 2nd. 5 keywords per line.
$numFLines = 1; // default
$fLineSpace = 19; // Y-space
//+echo "dy1 = " . $dy1 . " key_size = " . $key_size . " bor = " . $bor. "
\n";
if( $aClr != false ) {
// Exclude some keys
if( $aExclu != false ) {
for( $i = 0; $i < count( $aExclu ); ++$i ) {
if( isset($aClr[ $aExclu[ $i ] ]) )
unset($aClr[ $aExclu[ $i ] ]);
}
}
$numClr = count($aClr);
if( $numClr > $numClrMax )
$numClr = $numClrMax;
//$iWk = intval( count( $aClr ) / 5 );
//if( count( $aClr ) % 5 > 0 )
$iWk = intval( $numClr / 5 );
if( $numClr % 5 > 0 )
++$iWk;
$dy1 += (($iWk - 1) * $fLineSpace);
$numFLines = $iWk;
}
//$dy1 = intval( $dy1 );
//+echo "dy1 = " . $dy1 . "
\n";
// Set height:
//+$hei = $size*( 2*$iSup ) + 5*$bor + $key_size;
$space = 2; //3;
//$hei = $size*( 1*$iSup ) +$space*$iSup + 5*$bor + $key_size + $size; // *0.5;
$hei = $size*( 1*$iSup ) +$space*$iSup + 4*$bor + $size + $dy1;
$hei += $dy2; // ***
if( $hei < 220 ) $hei = 220;
// Set width:
$key_dx = 16; //20;
//+$iWk = count( $aKW01 ) * $key_dx;
$iWk = count( $aDRN ) * $key_dx;
$dx12 = $dx1 + $bor + $iWk + $bor;
$wid += ($bor + $iWk + $bor);
$DX12 = $dx12;
if( $wid < 765 ) // *** 07.31
$wid = 765;
//++ echo "*** seq/s-motif width = " . ($wid - $dx2 - $dx12) . "
\n";
# Header("Content-type: image/gif");
$k = imagecreate( $wid, $hei );
$white = imagecolorallocate($k,255,255,255);
imagefilledrectangle( $k, 0, 0, $wid, $hei, $white );
// ??? $white = imagecolorallocate($k,255,255,255);
$red = imagecolorallocate($k,255,0,0);
$red2 = imagecolorallocate($k,200,0,0);
$red3 = imagecolorallocate($k,255,100,0);
$green = imagecolorallocate($k,0,128,0);
//$lgreen= imagecolorallocate($k,0,196,0);
$lgreen= imagecolorallocate($k,0,210,0);
$lgreen2= imagecolorallocate($k,0,250,0);
// Maybe not only FT, KW, DE - so only two colors:
// cDE as 1st, cKW as 2nd
//-$cFT = imagecolorallocate($k,0,203,245);
//+$cFT = imagecolorallocate($k,223, 176, 240); // cFT - not used
$cKW = imagecolorallocate($k,0, 220, 200);
$cDE = imagecolorallocate($k,0,210,0);
$magen = imagecolorallocate($k,128,0,128);
$blue = imagecolorallocate($k,0,0,255);
$lblue = imagecolorallocate($k, 145, 0, 255);
$black = imagecolorallocate($k,0,0,0);
$lgray = imagecolorallocate($k,222,222,222);
$gray = imagecolorallocate($k,156,156,156);
//$lgray = imagecolorallocate($k,222,222,222);
$brown = imagecolorallocate($k,102, 51, 0);
//+$white2 = imagecolorallocate($k, 247, 240, 255);
$white2 = imagecolorallocate($k, 240, 233, 255);
//$lwhite = imagecolorallocate($k, 255, 240, 255);
$lwhite2 = imagecolorallocate($k, 255, 247, 255);
#________________________________ Fragment colors
/**
aClr = Array( "HELIX" => $blue,
"STRAND" => $green,
"TURN" => $red
);
**/
//if( $aClr == false ) {
if( empty($aClr) ) {
/** // *test
$aClr[ "HELIX" ] = $blue;
$aClr[ "TURN" ] = $red;
$aClr[ "STRAND" ] = $green;
**/
// aClr with unfilled color indeces
} else {
/**
$i = 0;
while( list( $key, $c ) = each( $aClr ) ) {
$iWk = $i % 3;
$c = $red;
If( $iWk == 1 ) $c = $blue;
If( $iWk == 2 ) $c = $green;
$aClr[ $key ] = $c;
++$i;
}
**/
/** See above
$numClr = count($aClr);
if( $numClr > $numClrMax )
$numClr = $numClrMax;
**/
//$iWk = $iWk2 = $iWk3 = intval(count($aClr) / 3) + 1;
$iWk = $iWk2 = $iWk3 = intval( $numClr / 3) + 1;
if( $numClr % 3 > 0 )
++$iWk; // red
if( $numClr % 3 > 1 )
++$iWk3; // blue
// R G B
f_setGroupColors( $k, $aClr, $iWk, $iWk2, $iWk3 );
//+echo "aClr num = ". count($aClr) . "
\n";
}
// 0 1 2 3
// Fragment Types: key => (non-single+weight_1, non-single+0, single+1, single+0 )
// Set init (0, 0, 0, 0) - to be accumulated while ploting fragments
$aWk = Array( 0, 0, 0, 0);
reset( $aClr );
while( list( $key, $val ) = each( $aClr ) ) {
$aFTypeQ[ $key] = $aWk;
}
f_imFrame( $k, $wid, $hei, $dx1, $dx2, $dy1, $dy2 );
imageString( $k, 3, 5, 3, $seqname, $green );
imageString( $k, 2, $wid - strlen($wm)*6 - 10, 3, $wm, $blue );
// Color keys:
//-$key = imagecreatefromgif( "/www/col_key.gif" );
//-imagecopyresized( $k, $key, 0, 0, 0, 0, $wid, $key_size, $wid, $key_size );
//$wk = "Color Key for Alignment Powers";
$wk = "FT FRAGMENTS:";
//+$x = ($wid - strlen( $wk ) * 9 ) * 0.5;
//+if( $x < 10 ) $x = 10;
$x = $dx12 + 20;
$y = 3+2;
imageString( $k, 5, $x, $y, $wk , $brown );
if( empty($aClr) )
imageString( $k, 5, $x+strlen($wk)*9+10, $y + 15, "No FT fragments are found", $red );
$xAfterTit = $x + strlen($wk) * 9;
//$x = 2*$bor + $key_size;
$x = $bor + $dy1;
// -----------
// Source seq:
// -----------
//+imagefilledrectangle( $k, $bor, $x, $wid - $bor, $x+$size, $red );
//+imagefilledrectangle( $k, $bor, $x, $wid - $bor, $x+$size, $green );
//+$x += $size + 2*$bor;
//imagefilledrectangle( $k, $bor, $x, $wid - $bor, $x+$size + $size *0.5, $green );
//+imagefilledrectangle( $k, $dx12+$bor, $x, $wid - $bor - $dx2,
//+ $x+$size + $size *0.5, $green );
imagefilledrectangle( $k, $dx12+$bor, $x - 2, $wid - $bor - $dx2,
$x+$size + $size *0.5 - 2, $gray ); // $green );
$ySave = $x;
//-$ySave++;
$wk = "\n" );
$seqmap = $wk;
/**
imageString( $k, 1, $dx12+$bor - 1, $x+$size + $size *0.5 + 1,"1", $brown );
$wk = $maxLen;
settype( $wk, "string" );
imageString( $k, 1, $wid - $bor - $dx2 - strlen($wk) * 5 + 2, $x+$size + $size *0.5+1,
$wk, $brown );
**/
// X-Scale;
//+$y = $ySave + 2;
$y = $ySave + $size + $size *0.5 - 1;
$r = f_scaleStep2( $maxLen, 50 );
//+ echo "r[0]=". $r[0] . "
";
/**/
$xScale = ( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
//+for( $n = $r[0], $i = 1; ($dx12 + $bor +$n*$xScale) < ($wid - $dx2 - $bor);
//++for( $n = 0, $i = 0; ($dx12 + $bor +$n*$xScale) < ($wid - $dx2 - $bor);
for( $n = 0, $i = 0; ($dx12 + $bor +$n*$xScale) < ($wid - $dx2 - $bor + 1 );
$n += $r[0], $i++ )
{
$x = $dx12 + $bor + $n * $xScale;
imageDashedLine( $k, $x, $y, $x, $hei - $dy2 - 2, $lgray );
$iC = $brown;
//if( $n % $r[1] == 0 ) $iC = $green;
if( $i % $r[1] == 0 ) {
imageLine( $k, $x , $y, $x , $y + 2, $iC );
imageLine( $k, $x+1, $y, $x+1, $y + 2, $iC );
imageLine( $k, $x-1, $y, $x-1, $y + 2, $iC );
} else {
//$iC = $green;
imageLine( $k, $x , $y, $x , $y + 1, $iC );
}
if( $i % $r[2] == 0 ) {
// move left if outside.
$nDig = log10( $n );
//-$wk = $nDig;
settype( $nDig, "integer" );
//-if($wk > $nDig)
$nDig++;
$nWid = $nDig * 6;
$nx = $x + 1;
if( $nx > ($wid - $dx2 - $nWid - 1) ) {
//$nx = $x - $nWid; // move left of dot if outside
$nx = $wid - $dx2 - $nWid - 1; // move left of border if outside
}
//imageString( $k, 2, $x, $y+2 - 2, $n, $black); //$brown );
//+imageString( $k, 2, $x+1, $y+2 - 2, $n, $black); //$brown );
imageString( $k, 2, $nx, $y+2 - 2, $n, $black); //$brown );
}
}
/**/
$x = $ySave;
$x += $size + 2*$bor + $size *0.5;
$x++; // *** 02.02.01
// *** req. dyScale = 12 instead of 2*bor?
// Y of the 1st supermotif/keyword: // ***
$yk0 = $x;
$imedi = $iSup * 0.5;
settype( $imedi, "integer" );
$pmedi = $power[$iSup - 1]; //$pmax; // init
$sfont = 2;
$sdy = $bor * 0.6; //$dy * 0.6; //0; //$dy * 0.4;
//+if( $iSup > 9) {
if( $iSup >= $twoColLim ) { // *** 02.02.01
$sfont = 1;
$sdy = 0; //$dy * 0.6;
}
$dB = ( $wid - 2*$bor - $dx12-$dx2) *0.5/$maxLen; // for DISULFID, etc.
for( $i=0; $i < $iSup; $i++) {
if( $i == $imedi ) $pmedi = $power[$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;
**/
// Mark every 2nd line:
//+$iC =( $i % 2 == 0 ? $lwhite2 : $white2 );
//+imagefilledrectangle( $k, $dx1+1, $x, $wid - $dx2 - 1, $x+$size - 1, $iC );
if( ($i+1) % 2 == 0 )
//imagefilledrectangle( $k, $dx1+1, $x - 1, $wid - $dx2 - 1, $x+$size, $white2 );
imagefilledrectangle( $k, $dx1 - 10, $x, $wid - $dx2 - 1, $x+$size - 1, $white2 );
//$color = f_clr( $k, $power[$i], $power[$iSup - 1], $power[0] );
$color = f_clr( $k, $power[$i], $power[0], $power[$iSup - 1] );
// Force "dummy" mot
//+if( strpos( $exclu, "," . $aSN[$i] . "," ) > 0 )
$iC = $brown;
if( ($i+1) % 2 == 0 ) $iC = $lblue;
/**
if( strpos( $exclu, "," . ($i+1) . "," ) > 0 ) {
$color = $lgray;
$iC = $gray;
}
**/
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;
$b = $dx12+$bor+$beg[ $i ][ $j ]*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
$e = $dx12+$bor+($beg[ $i ][ $j ]+$len[ $i ][ $j ])*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
//+imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $color );
//++imagerectangle( $k, $b, $x, $e, $x+$size-1, $gray );
imageLine( $k, $b, $x+($size - 1)*0.5, $e, $x+($size - 1)*0.5, $gray );
}
// WL // *** 07.22
imagefilledrectangle( $k, $wid - $iWLspace, $x, $wid - $iWLspace + $iWLwid - 1, $x+$size+$space, $color );
if( $i == 0 )
$iWL_y1 = $x - 1; // y1, y2 - to plot WL frame
$iWL_y2 = $x+$size+$space + 1;
// Display FT-fragments:
if( isset($aFT[ $aSN[ $i ] ]) ) {
$aFrag = $aFT[ $aSN[ $i ] ];
$iFragLen = count( $aFrag ) / 4; //3;
/***
$aFrag0 = $aFT[ $aSN[ $i ] ];
$iFragLen = count( $aFrag0 ) / 4; //3;
//++echo "*** i = " . $i . "
\n";
// sort aFrag
unset( $aFrag2 );
for( $j = 0; $j < $iFragLen; ++$j ) {
$aFrag2
}
***/
// Only two loops: 1st - unsingles, then - only singles
$bSingle = false;
for( $mm = 0; $mm < 2; ++$mm, $bSingle = true ) {
for( $j = 0; $j < $iFragLen; ++$j ) {
$jj = 4*$j; // 3*$j;
//++if( !isset($aClr[ $aFrag[ $jj ] ]) ) continue; // <------- no color - excluded FT-keyword
if( isset( $aClr[ $aFrag[ $jj ] ] ) )
$color = $aClr[ $aFrag[ $jj ] ];
else {
continue;
$color = $brown; // ?
}
// Skip single/unsingle
/***
if( !$bSingle ) {
if( ($aFrag[$jj+1] == $aFrag[$jj+2]) ||
$aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH"
) {
continue; //<--------
}
} else if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" ) {
// *nothing
} else if( $aFrag[$jj+1] != $aFrag[$jj+2] ) {
continue; //<--------
}
****/
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" ) {
if( !$bSingle )
continue;
} else if( !$bSingle && ($aFrag[$jj+1] == $aFrag[$jj+2]) ) {
continue;
} else if( $bSingle && ($aFrag[$jj+1] != $aFrag[$jj+2]) ) {
continue;
}
// Skip excluded keys
//if( strpos( $exclu, "," . $aFrag[$jj] . "," ) > 0 )
if( f_afind( $aExclu, $aFrag[$jj] ) > -1 )
continue;
$begX = 0; $lenX = 0;
unset( $extFrag );
f_getFragPos( $aFrag[$jj+1], $aFrag[$jj+2], $beg[$i], $beg2[$i], $len[$i],
$begX, $lenX, $extFrag );
if( $lenX > 0 ) {
// - 1 ?
$b = $dx12+$bor+($begX - 1)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
//++$e = $dx12+$bor+($begX+$lenX - 2)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
$e = $dx12+$bor+($begX+$lenX - 2)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
//$dB = ( $wid - 2*$bor - $dx12-$dx2) *0.5/$maxLen; // for DISULFID, etc.
// (see above)
if( $e > ($b+1) )
--$e; // small tune ??
//if( $lenX > 1 ) {
//+if( $aSN[ $i ] == "P26624" )
//+ echo "*P26624 - " . $aFrag[$jj+1]. " ". $aFrag[$jj+2] . "
\n";
if( $aFrag[$jj] != "DISULFID" && $aFrag[$jj] != "THIOLEST" && $aFrag[$jj] != "THIOETH" )
// &
f_outFrag( $aFrag, $jj, $aFTypeQ, $k, $b, $e, $dB, $x, $size, $color, $white );
//, $extFrag );
$b0 = $b; // save for the DISULFID group
//unset( $extra );
if( isset( $extFrag ) ) {
while( list( $beX, $leX ) = each( $extFrag ) ) {
$b = $dx12+$bor+($beX - 1)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
$e = $dx12+$bor+($beX+$leX - 2)*( $wid - 2*$bor - $dx12-$dx2)/$maxLen;
if( $e > ($b+1) )
--$e; // small tune ??
if( $aFrag[$jj] != "DISULFID" && $aFrag[$jj] != "THIOLEST" && $aFrag[$jj] != "THIOETH" )
f_outFrag( $aFrag, $jj, $aFTypeQ, $k, $b, $e, $dB, $x, $size, $color, $white );
//break; // **tst
}
}
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" )
{
f_outFrag( $aFrag, $jj, $aFTypeQ, $k, $b0, $e, $dB, $x, $size, $color, $white );
}
/***
// Non-single pos
//if( $aFrag[$jj+1] < $aFrag[$jj+2] ) {
if( ($aFrag[$jj+2] - $aFrag[$jj+1]) > 0 ) {
// weight 0
if( $aFrag[$jj+3] < 1 ) {
++$aFTypeQ[ $aFrag[ $jj ] ][1];
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" )
{
f_outTria( $k, $b + $dB, $x+$size, $size+2, $color, false, $white );
f_outTria( $k, $e - $dB, $x+$size, $size+2, $color, false, $white );
imageDashedLine( $k, $b + $dB, $x+$size+1, $e - $dB, $x+$size+1 , $color );
} else {
imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $white ); // to erase motif line
imagerectangle ( $k, $b, $x, $e, $x+$size-1, $color );
}
if( $aFrag[$jj] == "HELIX" || $aFrag[$jj] == "STRAND" || $aFrag[$jj] == "TURN" ) {
imageDashedLine ( $k, $b, $x+$size, $e, $x+$size , $color );
}
// weight 1
} else {
++$aFTypeQ[ $aFrag[ $jj ] ][0];
if( $aFrag[$jj] == "DISULFID" || $aFrag[$jj] == "THIOLEST" || $aFrag[$jj] == "THIOETH" )
{
f_outTria( $k, $b + $dB, $x+$size, $size+2, $color, true, $white );
f_outTria( $k, $e - $dB, $x+$size, $size+2, $color, true, $white );
imageDashedLine( $k, $b + $dB, $x+$size+1, $e - $dB, $x+$size+1 , $color );
} else {
imagefilledrectangle( $k, $b, $x, $e, $x+$size-1, $color );
}
if( $aFrag[$jj] == "HELIX" || $aFrag[$jj] == "STRAND" || $aFrag[$jj] == "TURN" ) {
imageDashedLine ( $k, $b, $x+$size, $e, $x+$size , $color );
//- imageDashedLine ( $k, $b, $x+$size-1, $e, $x+$size-1 , $white );
}
}
// Single pos
} else {
if( $aFrag[$jj+3] < 1 ) {
++$aFTypeQ[ $aFrag[ $jj ] ][3];
f_outTria( $k, ($b + $e) * 0.5, $x+$size, $size+2, $color, false, $white );
} else {
++$aFTypeQ[ $aFrag[ $jj ] ][2];
f_outTria( $k, ($b + $e) * 0.5, $x+$size, $size+2, $color, true );
}
}
***/
} // lenX > 0
} // for j
} // for mm
}
//$y = $dy1+$dy*$i;
$y = $x - $space; // ? * 0.5;
// Seq name:
//+if( $iSup > 9)
if( $iSup >= $twoColLim ) // *** 02.02.01
$iWk = ( $i % 2 == 0 ? 5 : 45 ) + 5;
else
$iWk = 5 + 5;
//imageString( $k, $sfont, $iWk, $y + $sdy, $aSN[ $i ], $iC ); // $brown );
imageString( $k, $sfont, $iWk, $y , $aSN[ $i ], $iC ); // $brown );
// fill kwmap: as seq names map
//echo( "" );
$iWk2 = $DX1 - 5;
if( $iSup >= $twoColLim && $i % 2 == 0 )
$iWk2 = $DX0 - 5;
$wk = "\n" );
//+$kwMap[$i] = $wk;
$kwMap[] = $wk;
//$x += 2*$size;
$x += $size + $space;
// Skip last if prev has been displayed:
//if( $iSup > 9 && (($i+1) % 5 == 1) && ($i == ($iSup - 1)) ) continue; // <---
if( ($iSup >= $twoColLim) && (($i+1) % 5 == 1)
&& ($i == ($iSup - 1)) ) continue; // <---
// Display only 1st and every 5th:
//if( $iSup > 9 && (($i+1) % 5 != 0) && $i > 0 && ($i != ($iSup - 1)) ) continue;
if( ($iSup >= $twoColLim) && (($i+1) % 5 != 0)
&& $i > 0 && ($i != ($iSup - 1))) continue; // <------
//-if( $iSup > 9 && (($i+1) % 5 != 0) && $i > 0 ) continue;
// Number
imageString( $k, 1, $wid - $dx2 +4, $y + $sdy, $i+1, $brown );
//+if( $iSup > 9 && (($i+1) % 5 == 0) )
imageline ( $k, $wid - $dx2 +3 - $bor, $y + $sdy + 3,
$wid - $dx2 , $y + $sdy + 3, $brown );
}
// Kewords: ---------------------------------------------
// get stat max:
$stV = array_values( $aST );
$stMax = 0;
for( $i = 1; $i < count( $stV ); $i++ ) {
if( $stV[ $i ] > $stMax )
$stMax = $stV[ $i ];
}
//+$aKW = array_keys( $aKW01 );
//+$aKW = array_values( $aDRN );
$aKW = array_keys( $aDRN );
$kwLen = 0;
$kwtPrev = "";
$iC = $cKW;
for( $i = 0; $i < count( $aKW ); $i++ ) {
//+$kwt = substr($aKW[$i], 0, 2);
$kwl = strlen($aKW[$i]); // - 4;
if( $kwl > $kwLen ) $kwLen = $kwl;
//+++$li = $aKW01[ $aKW[$i] ];
$dxk = $dx1 + $bor + $key_dx * $i;
$yk = $yk0;
/*****/
for( $j = 0; $j < $iSup; $j++ ) {
$sn = $aSN[ $j ];
//+if( isset($aPosName[ $sn ]) ) {
//+ $pos = $aPosName[ $sn ];
//+ if( substr( $li, $pos * 2, 1 ) != "0" ) {
if( isset( $aDR[ $sn][ $aKW[ $i ] ] ) ) {
// Adjust high level to SD value:
$ykh = $yk - 1;
$dykh =0;
/***
if( $kwtPrev != $kwt ) { // cFT - not used
$kwtPrev = $kwt;
if( $iC == $cKW ) $iC = $cDE;
else $iC = $cKW;
}
***/
$iC = $cKW;
//+imageRectangle( $k, $dxk, $ykh + $dykh, $dxk + $key_dx - 3,
imageRectangle( $k, $dxk+2, $ykh + $dykh, $dxk + $key_dx - 3 - 1,
$yk + $size - 1, $iC ); //$lgreen );
//}
}
$yk += ($size + $space);
}
/*****/
// KW, DE, FT: DR
//imageString( $k, 1, $dxk+3, $yk0 - 10, $kwt, $brown );
imageString( $k, 1, $dxk+3, $yk0 - 10, "DR", $brown );
// Vert lines:
ImageDashedLine( $k, $dxk+$key_dx - 1, $dy1, $dxk+$key_dx - 1, $hei - $dy2, $lgray);
/****/
// fill kwmap: DR
//echo( "" );
$wk = "" );
$wk .= ( " title='DR: " .$aDRN[ $aKW[$i] ] . "' >\n" );
//+$kwMap[$i] = $wk;
$kwMap[] = $wk;
/*****/
}
// Add seq map:
//+$kwMap[count($kwMap)] = $seqmap;
$kwMap[] = $seqmap;
/**/
// Display KWs:
// max num:
$yk_space = 10;
$yk = $yk0 + $kwLen * 5 + $yk_space;
/**
// Only two:
$wk = ($hei - $dy2 - $yk0)* 0.5 - $kwLen * 5; // spaces in a half
$yk_space = $wk * 0.6;
settype( $yk_space, "integer" );
$yk = $yk0 + $kwLen * 5 + $yk_space;
**/
/**/
// keywords in line:
while( $yk < ($hei - $dy2 - 3) ) {
for( $i = 0; $i < count( $aKW ); $i++ ) {
//+$kwn = substr($aKW[$i], 4);
$kwn = $aDRN[ $aKW[$i] ];
$dxk = $dx1 + $bor + $key_dx * $i;
imageStringUp( $k, 1, $dxk+3, $yk, $kwn, $black );
}
$yk += ( $kwLen * 5 + $yk_space );
}
/**/
/***
// keywords by stepwise:
$yk1 = $yk0;
$up = TRUE;
while( $yk1 < ($hei - $dy2 - 5) ) {
$yk = $yk1;
for( $i = 0; $i < count( $aKW ); $i++ ) {
$kwn_= substr($aKW[$i], 4);
$kwn = $kwn_;
$kwl_= strlen($aKW[$i]) - 4;
$kwl = $kwl_;
$kwlMax = ($hei - $dy2 - $yk - 5) * 0.2; // 5;
settype( $kwlmax, "integer" );
if( $kwl > $kwlMax ) {
$kwn = substr($aKW[$i], 4 + $kwl - $kwlMax );
$kwl = $kwlMax;
}
//+$yk += ($kwl*5);
$yk += (8*5);
if( $yk > ($hei - $dy2 - 5) ) continue; // break;
$dxk = $dx1 + $bor + $key_dx * $i;
imageStringUp( $k, 1, $dxk+3, $yk, $kwn, $black );
// upwards:
if( $up ) {
$upy = $yk - ( $kwLen * 5 * 2 + $yk_space );
while( $upy > ($yk0 + 5) ) {
if( ($upy - $kwl_ * 5) > ($yk0 + 1) ) {
imageStringUp( $k, 1, $dxk+3, $upy, $kwn_, $black );
}
$upy -= ( $kwLen * 5 * 2 + $yk_space );
}
}
//$yk += ( $kwl_ * 5 + 1 );
$yk++;
}
$yk1 += ( $kwLen * 5 * 2 + $yk_space );
$up = FALSE;
}
***/
// Internal frame
ImageRectangle ( $k, $dx1 , $dy1, $wid - $dx2, $hei - $dy2, $brown);
ImageDashedLine( $k, $dx12, $dy1, $dx12 , $hei - $dy2, $brown); //$lgray);
// KW, DE, FT ?
$kwl = 8 * 7;
if( ($dx12 - $dx1) > $kwl ) {
$wk = (($dx12 - $dx1) - $kwl ) *0.5;
ImageString( $k, 3, $dx1 + $wk, $dy1 - 14 - 4, "Keywords", $brown );
}
// Legends:
$pmax = $power[0]; $pmin = $power[$iSup - 1];
$sp = 20; // leg.space
$yleg = $dy1 - 15; //18; //20; //hei - 20;
$lleg = 60; // size
//ImageString( $k, 2, $dx1, $yleg, "Legends: ", $brown );
//$xleg = $dx1 + $bor + 40+20; //10*6; // + $sp;
//$xleg = 120; //$dx1 + $bor + 40+20; //10*6; // + $sp;
//+$xleg = $dx12 + 20; // *** 20.01.01
$xleg = $dx12; // *** 22.07.01
//$yleg = $dy1 - 19;
$yleg = $dy1 - $fLineSpace * $numFLines; // +6;
/**
$ic = f_clr( $k, $pmax, $pmax, $pmin );
//+imagefilledrectangle( $k, $xleg, $yleg+3, $xleg + $lleg, $yleg + 10, $ic );
imagefilledrectangle( $k, $xleg, $yleg+2, $xleg + $lleg, $yleg + 7, $ic );
$xleg += ($lleg + 4);
//ImageString( $k, 2, $xleg, $yleg, $pmax . " (max power)", $brown );
//+ImageString( $k, 1, $xleg, $yleg, $pmax . " (max)", $brown );
ImageString( $k, 2, $xleg, $yleg - 1, $pmax . " (max)", $brown );
$xleg += (12 * 6 + $sp);
$ic = f_clr( $k, $pmedi, $pmax, $pmin );
//+imagefilledrectangle( $k, $xleg, $yleg+3, $xleg + $lleg, $yleg + 10, $ic );
imagefilledrectangle( $k, $xleg, $yleg+2, $xleg + $lleg, $yleg + 7, $ic );
$xleg += ($lleg + 4);
ImageString( $k, 2, $xleg, $yleg - 1, $pmedi, $brown );
$xleg += (6 * 6 + $sp);
$ic = f_clr( $k, $pmin, $pmax, $pmin );
//+imagefilledrectangle( $k, $xleg, $yleg+3, $xleg + $lleg, $yleg + 10, $ic );
imagefilledrectangle( $k, $xleg, $yleg+2, $xleg + $lleg, $yleg + 7, $ic );
$xleg += ($lleg + 4);
ImageString( $k, 2, $xleg, $yleg - 1, $pmin . " (min)", $brown );
**/
// FT fragments
$dxf = 3 + 3;
$flen = 10*7 + $dxf + $dxf;
$fspace = 8;
$fhei = 13;
$i = 0;
reset( $aClr );
$yleg0 = $yleg; // save (?)
$bUnfilledObj = false; // to display unfilled msg
while( list( $frag, $ic ) = each( $aClr ) ) {
//if( $i > 4 ) break; // ----------------->
if( $i > (($numFLines*5) - 1) ) break; // ----------------->
if( $i != 0 && ($i % 5) == 0 )
$yleg += $fLineSpace;
$x = $xleg + ($flen + $fspace) * ($i % 5);
//$aWk = $aFTypeQ[ $frag ];
//if( ( $aWk[0] + $aWk[1] ) > 0 ) {
if( $frag == "DISULFID" || $frag == "THIOLEST" || $frag == "THIOETH" ) {
$iCkey = $brown;
} else if( ( $aFTypeQ[ $frag ][0] + $aFTypeQ[ $frag ][1] ) > 0 ) {
imagefilledrectangle( $k, $x, $yleg, $x + $flen, $yleg + $fhei, $ic );
$iCkey = $white;
} else {
//-imagerectangle ( $k, $x+1, $yleg+1, $x + $flen, $yleg + $fhei, $gray );
$iCkey = $brown;
}
// fill FTT map:
$wk = "\n" );
$fttMap[$i] = $wk;
//$xleg += ($lleg + 4);
if( strlen( $frag ) > 10 ) {
$fname = substr( $frag, 0, 10 );
$xname = $x + $dxf;
} else {
$fname = $frag;
$xname = $x + $dxf + (10 - strlen( $frag ) ) * 3.5;
}
if( ( $aFTypeQ[ $frag ][2] + $aFTypeQ[ $frag ][3] ) > 0 && (strlen( $frag ) >= 10) ) {
$xname -= 2;
}
if( $frag == "DISULFID" || $frag == "THIOLEST" || $frag == "THIOETH" ) {
ImageString( $k, 3, $xname, $yleg - 1, $fname, $iCkey ); //$white );
} else {
ImageString( $k, 3, $xname, $yleg, $fname, $iCkey ); //$white );
}
if( $frag == "DISULFID" || $frag == "THIOLEST" || $frag == "THIOETH" ) {
if( ( $aFTypeQ[ $frag ][0] + $aFTypeQ[ $frag ][2] ) > 0 ) { // filled
f_outTria( $k, $xname - 5, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, true );
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, true );
} else {
f_outTria( $k, $xname - 5, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, false, $lgray );
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, false, $lgray );
}
imageDashedLine( $k, $xname - 5, $yleg + $fhei - 2,
$xname + strlen( $frag ) * 7 + 4, $yleg + $fhei - 2, $ic );
} else if( $aFTypeQ[ $frag ][2] > 0 ) {
if( ( $aFTypeQ[ $frag ][0] + $aFTypeQ[ $frag ][1] ) > 0 ) {
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $iCkey, false, $ic );
} else {
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, true );
}
} else if( $aFTypeQ[ $frag ][3] > 0 ) {
if( ( $aFTypeQ[ $frag ][0] + $aFTypeQ[ $frag ][1] ) > 0 ) {
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $iCkey, false, $ic );
} else {
f_outTria( $k, $xname + strlen( $frag ) * 7 + 4, //$fhei,
$yleg + $fhei - 3, $fhei - 7, $ic, false, $lgray );
}
}
if( ( $aFTypeQ[ $frag ][1] + $aFTypeQ[ $frag ][3] ) > 0 ) { // unfilled non-single or single
$bUnfilledObj = true;
}
// frame
imagerectangle( $k, $x , $yleg , $x + $flen, $yleg + $fhei, $white );
imageLine ( $k, $x , $yleg + $fhei, $x + $flen, $yleg + $fhei, $black );
imageLine ( $k, $x+ $flen, $yleg , $x + $flen, $yleg + $fhei, $black );
if( $frag == "HELIX" || $frag == "STRAND" || $frag == "TURN" ) {
imageLine ( $k, $x , $yleg + $fhei + 1, $x + $flen, $yleg + $fhei + 1, $black );
imageDashedLine( $k, $x , $yleg + $fhei + 1, $x + $flen, $yleg + $fhei + 1, $lgray );
imageDashedLine( $k, $x , $yleg + $fhei - 1, $x + $flen, $yleg + $fhei - 1, $black );
}
++$i;
}
// unfilled warning
if( $bUnfilledObj ) {
imageString ( $k, 1, $xAfterTit + 26, 7, "Fragment objects set unfilled for " , $brown );
imageString ( $k, 1, $xAfterTit + 26, 15, "POTENTIAL, PROBABLE and BY SIMILARITY" , $brown );
}
// Opt Line:
//ImageStringUp( $k, 1, $wid - 17, $hei - $dy2 - 2, $opt, $brown );
ImageString( $k, 1, $dx1, $hei - 16, $opt, $brown );
// WL frame // *** 07.22
imagerectangle( $k, $wid - $iWLspace - 1, $iWL_y1, $wid - $iWLspace + $iWLwid, $iWL_y2, $white );
imageLine ( $k, $wid - $iWLspace - 1, $iWL_y2, $wid - $iWLspace + $iWLwid, $iWL_y2, $black );
imageLine ( $k, $wid - $iWLspace + $iWLwid, $iWL_y1, $wid - $iWLspace + $iWLwid, $iWL_y2, $black );
imageString ( $k, 1, $wid - $iWLspace - 10, $iWL_y1 - 17, "motif" , $red2 ); //brown );
imageString ( $k, 1, $wid - $iWLspace - 10, $iWL_y1 - 10, "weight", $red2 );
imageStringUp( $k, 1, $wid - $iWLspace+$iWLwid+2, $iWL_y1 + strlen($pmax)*5, $pmax, $brown );
imageStringUp( $k, 1, $wid - $iWLspace+$iWLwid+2, $iWL_y2 , $pmin, $brown );
// *******************************************
//$er = imagegif( $k, $gif_file ); // ************ Linux GIF
$er = imagePng( $k, $gif_file );
// *******************************************
}
?>