[Bioperl-l] Script Request

Razi Khaja razi at genet.sickkids.on.ca
Tue Jan 4 15:44:15 EST 2005


Not sure if this is what you want but try the script below.  You should read O'Reilly Learning Perl http://www.oreilly.com/catalog/lperl3/
 
#!/usr/bin/perl
use strict;
 
my( $file, $col ) = @ARGV;
 
my $total=0;
my $n=0;
 
open( FILE, $file );
while( <FILE> ) {
    my @field = split(/\s+/, $_);
    $total += $field[$col];
    $n++;
}
close( FILE );
 
my $avg = $total / $n;
print "$avg\n";

Razi

 


Damion Colin Nero <dcn208 at nyu.edu> wrote:
I am looking for a perl script that can average small groups of numbers down columns (i.e. 50 out of 500 numbers).  I know this is a simple thing to do but I am a new user and have been having problems with it so if you have a script that I could use or that might be a good reference please let me know.  thanks.

Damion Nero 
Coruzzi Lab 
Department of Biology 
New York University 
766 Waverly building 
New York, NY 10003-6688 
Tel: (212) 998-3963 
email: dcn208 at nyu.edu 


_______________________________________________
Bioperl-l mailing list
Bioperl-l at portal.open-bio.org
http://portal.open-bio.org/mailman/listinfo/bioperl-l

/**
 * Razi Khaja, Bioinformatics Analyst
 * The Hospital for Sick Children, Toronto
 * The Centre for Applied Genomics, www.tcag.ca
 * Tel 416-813-7032, Fax 416-813-8319
 */


More information about the Bioperl-l mailing list