Thank for your answer but unfortunately it still doesn't work.
The code with your suggestions is:
# the firs button :
$mw-> Button (-text =>'Open', -command =>\&open_file)->place(-x=>240,
+ -y=>35);
#The seocnd button:
$mw-> Button (-text =>'Get Statistics',-command =>\&get_statistics)->p
+lace(-x=>320, -y=>35);
# The sub open :
sub open_file {my $open = $mw->getOpenFile(
-filetypes => $types_OPEN,
-defaultextension => '.sff');
$te->Load( "$open");}
if (defined $open and -e $open){
$te->Load( "$open");
$current_file = $open;
}
# the sub get statistic:
sub get_statistics {my $stat = Statistics::Descriptive::Full->new();
my (%distrib);
my @bins = qw/18 19 20 21 22 23 24 25 26 27 28/;
my $fastaFile = shift;
unless (defined $fastaFile){
warn "No file name supplied.\n";
return;
}
open my $FASTA, '<', $fastaFile or warn "Couldn't open file: $!\n";
my $junkFirstOne = <FASTA>;
while (<$FASTA>) {chomp;
my ($def,@seqlines) = split /\n/, $_;
my $seq = join '', @seqlines;
$stat->add_data(length($seq));}
%distrib = $stat->frequency_distribution(\@bins);
print "Total reads:\t" . $stat->count() . "\n";
print "Total nt:\t" . $stat->sum() . "\n";
print "Mean length:\t" . $stat->mean() . "\n";
print "Median length:\t" . $stat->median() . "\n";
print "Mode length:\t" . $stat->mode() . "\n";
print "Max length:\t" . $stat->max() . "\n";
print "Min length:\t" . $stat->min() . "\n";
print "Length\t# Seqs\n";
foreach (sort {$a <=> $b} keys %distrib) {
print "$_\t$distrib{$_}\n";
}};
# The scrolled window:
$te = $mw->Scrolled( q/TextUndo/, -scrollbars => 'se', -background =>
+'white', -font => [-family =>'arial',-size => '12',-weight=> 'bold'],
+-wrap => 'none',)->pack(-anchor =>'n',-side=>'right',-fill=>'none');
It say me (after load the $open file in the scrolled window and push the get_statistic button) : "No file name supplied". Where i need to correct the script to make it works ? Thanks
|