The External (get_statistic.pl) Script (it works fine like: "perl get_statistic.pl filename.txt")#The Open button: $mw-> Button (-text =>'Open',-command=>\open_file)->place(-x=>240, -y= +>35); sub open_file {my $open = $mw->getOpenFile( -filetypes => $types_OPEN, -defaultextension => '.sff'); $te->Load( "$open");} #The Get Statistic button: $mw-> Button (-text =>'Get Statistics', -command =>\&get_statistics); sub get_statistics {-------Here i need your help----}; # The Scrolled windows: $te = $mw->Scrolled( q/TextUndo/, -scrollbars => 'se', -background.... +.......);
Now i would like to run this script on the $open file and see the result in a dialog box windows. Please help !!! Thank you very much as always.# The get_statistic.pl script: use Statistics::Descriptive; 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; open (FASTA, "<$fastaFile"); $/ = ">"; 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"; }
In reply to Perl tk - How to integrate external scripts by Giorgio C
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |