in reply to Re^5: Perl tk - How to integrate external scripts
in thread Perl tk - How to integrate external scripts
my $open; $mw-> Button (-text =>'Open', -command =>\&open_file)->place(-x=>240, +-y=>35); $mw-> Button (-text =>'Get Statistics',-command =>[\&get_statistics, $ +open])->place(-x=>320, -y=>35); sub open_file {$open = $mw->getOpenFile( -filetypes => $types_OPEN, -defaultextension => '.sff'); $te->Load( "$open");} if (defined $open and -e $open){ $te->Load( "$open"); $fastaFile = $open; } 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 = $open; 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"; }};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Perl tk - How to integrate external scripts
by Eliya (Vicar) on Jan 31, 2012 at 12:26 UTC | |
by Giorgio C (Novice) on Jan 31, 2012 at 12:53 UTC | |
by Eliya (Vicar) on Jan 31, 2012 at 14:06 UTC | |
by Giorgio C (Novice) on Jan 31, 2012 at 14:40 UTC | |
by Giorgio C (Novice) on Feb 01, 2012 at 11:35 UTC | |
by Anonymous Monk on Feb 01, 2012 at 11:38 UTC | |
|