Giorgio C has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
i have a question hoping you can answer me:
I have a tk script with 2 Buttons and a Scrolled text windows:
1. Button ("OPEN")
2. Button ("Get Statistics")
When i push the "Open" button i choose a .txt file and then the content is printed out in the Scrolled windows. Up to now no problem! The difficulty is this: When i push the "Get Statistic Button" it should call an external Script (that works fine alone) but i wish it worked on the opened file. (opened before with the "Open" button. Can you help me, please ? Here is the tk code and the script i would like
to integrate into.
The Tk script:
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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl tk - How to integrate external scripts
by chessgui (Scribe) on Jan 27, 2012 at 15:55 UTC | |
by Giorgio C (Novice) on Jan 27, 2012 at 16:14 UTC | |
by thundergnat (Deacon) on Jan 27, 2012 at 17:04 UTC | |
by Eliya (Vicar) on Jan 27, 2012 at 17:46 UTC | |
by chessgui (Scribe) on Jan 27, 2012 at 17:17 UTC | |
by Giorgio C (Novice) on Jan 30, 2012 at 09:19 UTC | |
by Eliya (Vicar) on Jan 30, 2012 at 12:19 UTC | |
| |
by chessgui (Scribe) on Jan 30, 2012 at 10:40 UTC | |
|
Back to
Seekers of Perl Wisdom