[Biophp-dev] sample

Can Tran biophp-dev@bioinformatics.org
Mon, 29 Mar 2004 22:12:43 -0800


--============_-1131495333==_ma============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Hi,
Sorry about my late start in biophp development.
I've been pretty busy with work.
Just wanted to run a sample function by you guys to see
if it meets coding standard. I wasn't sure if you had any
coding conventions.
Best wishes,
can

<?php

function hydropathy($sequence, $window, &$x, &$y)
{

	$aminoacids = array(
     "G"=>-0.400, "A"=>1.800, "V"=>4.200, "L"=>3.800,
     "I"=>4.500, "M"=>1.900, "F"=>2.800, "P"=>-1.600,
     "S"=>-0.800, "T"=>-0.700, "C"=>2.500, "N"=>-3.500,
     "Q"=>-3.500, "Y"=>-1.300, "W"=>-0.900, "D"=>-3.500,
     "E"=>-3.500, "H"=>-3.200, "K"=>-3.900, "R"=>-4.500
     );

	$midpt = ($window + 1) / 2;
	$length = strlen($sequence);
	for($i = 0; $i < $length - $window; $i++)
	{
		$total = 0;
		for($j = 0; $j < $window; $j++)
		{
			$total = $total + $aminoacids[$sequence[$i + $j]];
		}
		$total = $total / $window;

		$x[$i] = $i + $midpt;
		$y[$i] = $total;

		if($total > $max)
		{
			$max = $total;
		}

		if($total < $min)
		{  
			$min = $total;
		}
	}
}



$sequence = 
"MPPMLSGLLARLVKLLLGRHGSALHWRAAGAATVLLVIVLLAGSYLAVLAERGAPGAQLITYPRALWWSVETATTVGYGDLYPVTLWGRLVAVVVMVAGITSFGLVTAALATWFVGREQERRGHFVRHSEKAAEEAYTRTTRALHERFDRLERMLDDNRR";

hydropathy($sequence, 19, $array1, $array2);
echo "<PRE>";
for($i = 0; $i < count($array1); $i++)
{
	echo "$array1[$i] \t $array2[$i] \n";
}
echo "</PRE>";
?>
--============_-1131495333==_ma============
Content-Type: text/html; charset="us-ascii"

<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>sample</title></head><body>
<div>Hi,</div>
<div>Sorry about my late start in biophp development.</div>
<div>I've been pretty busy with work.</div>
<div>Just wanted to run a sample function by you guys to see</div>
<div>if it meets coding standard. I wasn't sure if you had any</div>
<div>coding conventions.</div>
<div>Best wishes,</div>
<div>can</div>
<div><br></div>
<div><tt><font size="-2" color="#000000">&lt;?php<br>
<br>
</font><font size="-2" color="#760F50">function</font><font size="-2"
color="#000000"> hydropathy($sequence, $window, &amp;$x, &amp;$y)<br>
{<br>
<br>
<x-tab> </x-tab>$aminoacids =</font><font size="-2" color="#760F50">
array</font><font size="-2" color="#000000">(<br>
&nbsp;&nbsp;&nbsp;</font><font size="-2" color="#891315">
&quot;G&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-0.400</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;A&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">1.800</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;V&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">4.200</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;L&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">3.800</font><font size="-2"
color="#000000">,<br>
&nbsp;&nbsp;&nbsp;</font><font size="-2" color="#891315">
&quot;I&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">4.500</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;M&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">1.900</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;F&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">2.800</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;P&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-1.600</font><font size="-2"
color="#000000">,<br>
&nbsp;&nbsp;&nbsp;</font><font size="-2" color="#891315">
&quot;S&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-0.800</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;T&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-0.700</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;C&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">2.500</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;N&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.500</font><font size="-2"
color="#000000">,<br>
&nbsp;&nbsp;&nbsp;</font><font size="-2" color="#891315">
&quot;Q&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.500</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;Y&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-1.300</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;W&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-0.900</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;D&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.500</font><font size="-2"
color="#000000">,<br>
&nbsp;&nbsp;&nbsp;</font><font size="-2" color="#891315">
&quot;E&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.500</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;H&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.200</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;K&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-3.900</font><font size="-2"
color="#000000">,</font><font size="-2" color="#891315">
&quot;R&quot;</font><font size="-2" color="#000000">=&gt;</font><font
size="-2" color="#0000FF">-4.500</font><font size="-2"
color="#000000"><br>
&nbsp;&nbsp;&nbsp; );<br>
<x-tab>&nbsp;&nbsp; </x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>$midpt =
($window +</font><font size="-2" color="#0000FF"> 1</font><font
size="-2" color="#000000">) /</font><font size="-2" color="#0000FF">
2</font><font size="-2" color="#000000">;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>$length =
strlen($sequence);<br>
<x-tab>&nbsp;&nbsp;&nbsp; </x-tab></font><font size="-2"
color="#760F50">for</font><font size="-2" color="#000000">($i
=</font><font size="-2" color="#0000FF"> 0</font><font size="-2"
color="#000000">; $i &lt; $length - $window; $i++)<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>{<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>$total =</font><font size="-2" color="#0000FF"> 0</font><font
size="-2" color="#000000">;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab></font><font size="-2" color="#760F50">for</font><font
size="-2" color="#000000">($j =</font><font size="-2" color="#0000FF">
0</font><font size="-2" color="#000000">; $j &lt; $window; $j++)<br>
<x-tab> </x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>{<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>$total = $total + $aminoacids[$sequence[$i + $j]];<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>}<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>$total = $total / $window;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>$x[$i] = $i + $midpt;<br>
<x-tab>&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>$y[$i] = $total;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab></font><font size="-2" color="#760F50">if</font><font
size="-2" color="#000000">($total &gt; $max)<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>{<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>$max
= $total;<br>
<x-tab>&nbsp; </x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>}<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab></font><font size="-2" color="#760F50">if</font><font
size="-2" color="#000000">($total &lt; $min)<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>{&nbsp;&nbsp;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>$min
= $total;<br>
<x-tab>&nbsp; </x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>}<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>}<br>
}<br>
<br>
<br>
<br>
$sequence =</font><font size="-2" color="#891315">
&quot;MPPMLSGLLARLVKLLLGRHGSALHWRAAGAATVLLVIVLLAGSYLAVLAERGAPGAQLITYP<span
></span
>RALWWSVETATTVGYGDLYPVTLWGRLVAVVVMVAGITSFGLVTAALATWFVGREQERRGHFVRHSEK<span
></span>AAEEAYTRTTRALHERFDRLERMLDDNRR&quot;</font><font size="-2"
color="#000000">;<br>
<br>
hydropathy($sequence,</font><font size="-2" color="#0000FF">
19</font><font size="-2" color="#000000">, $array1, $array2);<br>
</font><font size="-2" color="#760F50">echo</font><font size="-2"
color="#891315"> &quot;&lt;PRE&gt;&quot;</font><font size="-2"
color="#000000">;<br>
</font><font size="-2" color="#760F50">for</font><font size="-2"
color="#000000">($i =</font><font size="-2" color="#0000FF">
0</font><font size="-2" color="#000000">; $i &lt; count($array1);
$i++)<br>
{<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab></font><font
size="-2" color="#760F50">echo</font><font size="-2" color="#891315">
&quot;$array1[$i] \t $array2[$i] \n&quot;</font><font size="-2"
color="#000000">;<br>
}<br>
</font><font size="-2" color="#760F50">echo</font><font size="-2"
color="#891315"> &quot;&lt;/PRE&gt;&quot;</font><font size="-2"
color="#000000">;<br>
?&gt;</font></tt></div>
</body>
</html>
--============_-1131495333==_ma============--