Hi Can, Thanks for contributing! The code looks fine. A long time ago we all promised to adhere to the PEAR coding standards. They are described here: http://pear.php.net/manual/en/standards.php Very short summary: - Use 4 spaces instead of tabs - Curly braces: after function/object definitions on new line, otherwise at end of line - spaces in places I would not put them - Lots of comments (do not use Perl style # comments) - Use phpdoc style of commenting (http://www.phpdoc.org). It would be nice if you could add more comments in the source (preferably using the phpdoc convention). For instance, what does this function do, what do the variables mean, what are the numbers in array $aminoacids and where do they come from (a reference would be great). I hope I don't discourage you, but I do think this will make the code more useful in the long run. For 'testcases' we have a directory 'testfiles' where code demonstrating/testing functions/objects should go (with associated 'testdata' in 'testdata'). Another question is where the code should go. I plan to 'pearify' the seq_inc.php file. Currently there is a bunch of functions in this file, and two objects (protein and seq if I am not mistaken). It makes sense to me to split this out into at least three files: one with functions (maybe two: one for DNA and the other for protein), and one each for each object. As a general strategy of making biophp useful even if you do not want to use the biophp objects, I think it makes sense to make every function available outside of the object and to simply make object member functions that call the appropriate function outside of the object. Does this make sense? I probably should just get started... Best, Nico On Mon, 2004-03-29 at 22:12, Can Tran wrote: > 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>"; > ?>