stephenbrooks.orgForumMuon1GeneralPHP code for the genome-comparison script
Username: Password:
Search site:
Subscribe to thread via RSS
Stephen Brooks
2005-08-22 11:40:41
I made a small toy here to let people see the distances between genomes.  Here is the source code in case anyone wants to make improvements, e.g. a highlighted list of which parameters differ etc. Also export of various sorts would be cool - for instance generating genomes 10% of the way from one to another, so you can use them in a queue file.
<html><body>
<?php
function gparse($gen)
{
$gen=explode(';',$gen);
foreach ($gen as $n => $g)
{
unset($gen[$n]);
if (!ctype_space($g))
{
list($p,$v)=explode('=',$g);
$gen[$p]=$v;
}
}
return $gen;
}
foreach ($_POST as $k => $v) $$k=gparse($v);
if ($g1 && $g2)
{
$c=array();
foreach ($g1 as $p => $v) if (isset($g2[$p])) $c[]=$p;
$m=count($c);
echo "<p>$m common parameters, ".(count($g1)-$m)." only in genome #1, ".(count($g2)-$m)." only in genome #2.</p>";
$same=0; $d1=$d2=$dm=0;
foreach ($c as $p)
{
$d=$g2[$p]-$g1[$p];
$d1+=abs($d); $d2+=$d*$d;
if ($d==0) $same++;
$dm=ma$dm,abs($d));
}
echo "<p>$same parameters the same, ".($m-$same)." different.<br />Maximum difference = $dm<br />Sum of differences = $d1 (max possible ".($m*999).")<br />Mean difference = ".($d1/$m)." (max possible 999)<br />Sum of squared differences = $d2 (max possible ".($m*999*999).")<br />Euclidean distance = ".sqrt($d2)." (max possible ".(sqrt($m)*999).")<br />RMS difference = ".sqrt($d2/$m)." (max possible 999)</p>";
}
?>
<form action='genomedistance.php' method='post'>
<p>Enter genome #1:
<textarea name='g1' wrap='virtual' cols='80' rows='10' /></p>
<p>Enter genome #2:
<textarea name='g2' wrap='virtual' cols='80' rows='10' /></p>
<button type='submit'>Calculate</button>
</form>
</body></html>
K`Tetch
2005-08-22 18:27:40
this is a most handy tool.  Many thanks stephen
: contact : - - -
E-mail: sbstrudel characterstephenbrooks.orgTwitter: stephenjbrooksMastodon: strudel charactersjbstrudel charactermstdn.io RSS feed

Site has had 26783988 accesses.