From abez at abez.ca Wed Jun 19 11:50:16 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: Meeting Message-ID: I'm trying to confirm that there is a Victoria-pm meeting today at the UVIC library tonight? -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ From nkuipers at uvic.ca Wed Jun 19 12:12:37 2002 From: nkuipers at uvic.ca (nkuipers) Date: Wed Aug 4 00:11:05 2004 Subject: Meeting Message-ID: <3D10BC93@wm2.uvic.ca> Good question. I was also under the impression that the meeting was tonight in said location. As to time? No idea... Nathanael From abez at abez.ca Wed Jun 19 12:51:55 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: Meeting In-Reply-To: <3D10BC93@wm2.uvic.ca> Message-ID: The announcement said 6:30; although it sounds like 6:30 to 7:00 is a safe bet. I know I'll have trouble getting there by 6:30. Oh and to non UVIC people parking is free after 6 in general and reserved parking spots but not in "reserved 24 hrs" parking spots. On Wed, 19 Jun 2002, nkuipers wrote: > Good question. I was also under the impression that the meeting was tonight > in said location. As to time? No idea... > > Nathanael > -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ From abez at abez.ca Thu Jun 20 01:00:57 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: Meeting (fwd) Message-ID: Well this explains it :) -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ ---------- Forwarded message ---------- Date: Wed, 19 Jun 2002 15:55:02 -0700 From: Mark McLaughlin To: abez Subject: RE: Meeting I beleive so, unfortunately it coincides with the WEAV - Web Enthusiasts of Association of Victoria monthly General Meeting. www.weav.bc.ca Any hope of alternate nights in future? Cheers Mark McLaughlin ---------------------------------------------------------------- Best Color Video Production CD-ROM Website Design mailto:mark@bestcolorvideo.com Ph. 250-744-4111 Fx. www.bestcolorvideo.com/ www.BCVnet.com Website Hosting & Server Colocation " We Produce Videos & Internet Websites for YOUR Business " ---------------------------------------------------------------- > -----Original Message----- > From: owner-victoria-pm@pm.org [mailto:owner-victoria-pm@pm.org]On > Behalf Of abez > Sent: June 19, 2002 9:50 AM > To: victoria-pm@pm.org > Subject: Meeting > > > I'm trying to confirm that there is a Victoria-pm meeting today at the > UVIC library tonight? > > -- > ABeZ------------ ------- ------ - ---------- -- ------------ > http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) > ---- ------- ----------- ----------- - - ------ --------ABeZ > From abez at abez.ca Thu Jun 20 12:40:29 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: print time Message-ID: In reference to the discussion on obfuscated perl and the final "print time" command. This link shows how you to can redefine built in functions pointlessly as well! http://perlcircus.com/site/subs.html Create a subroutine that overrides a built-in function use subs 'int'; sub int{ my $arg = shift; return CORE::int($arg)*10; } print int("5.7"); RESULT: 50 DISCUSSION: Perl's built-in subroutines, like int can be redefined with your own subroutines if you wish. Normally int would return the integer portion of a number (in this case 5), but for some reason I wish to return the integer times ten. In order to avoid a recursive call back to my own subroutine I first call the original int in the CORE package, and then multiply that by 10 before returning the final result. You could have accomplished the same thing without using "int" as the name of your subroutine -- "int_times_10" might seem like a good idea, but this trick would be just the what you need to easily dynamically alter existing functionality at runtime. -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ From abez at abez.ca Thu Jun 20 12:46:25 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: Array Returns Message-ID: http://groups.google.com/groups?q=perl+return+array&hl=en&lr=&ie=UTF8&oe=UTF8&selm=dwolfe.874517873%40talos4&rnum=1 In summary return @ret; is slower than return \@ret; >From the message: Benchmark: timing 10000 iterations of Explicitly return a ref to an array, Explicitly return an array, Implicitly return a ref to an array, Implicitly return an array... Explicitly return a ref to an array: 0 secs ( 0.30 usr 0.00 sys = 0.30 cpu) (warning: too few iterations for a reliable count) Explicitly return an array: 38 secs (37.45 usr 0.00 sys = 37.45 cpu) Implicitly return a ref to an array: 0 secs ( 0.24 usr 0.00 sys = 0.24 cpu) (warning: too few iterations for a reliable count) Implicitly return an array: 38 secs (37.12 usr 0.00 sys = 37.12 cpu) -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ From nkuipers at uvic.ca Thu Jun 20 13:17:27 2002 From: nkuipers at uvic.ca (nkuipers) Date: Wed Aug 4 00:11:05 2004 Subject: revamped source code Message-ID: <3D11C731@wm2.uvic.ca> Hey all, I implemented *some* of the changes y'all suggested yesterday...the parts I could follow, basically. =) You'll note the shorter regexes, passing by reference, and the complete absence of any arrays. Here is what I have, and [I think] it works; at least, it is giving output that looks suspiciously like what I am looking for. So now it's just running it by more brains to make sure I am not being hoodwinked by some Perl internal I am not aware of, and see if I can squeak by with some more speed... Eventually it will accept multiple filter strengths at the command line and iterate through all of them, each iteration being faster than the last because of the delete call to the "find-this" hash (%queryid). #Program name: getparsedfasta #Author: Nathanael Kuipers, nkuipers@uvic.ca #Date written: June 12, 2002 #Last updated: June 20, 2002 #Purpose: conditionally formats parsed blastn xml as FASTA #Use: >perl getparsedfasta inputfilename int #!/usr/bin/perl -w use strict; my $infile = shift; my $filterstrength = shift; my %queryid = (); my $header = ''; my %wholeid = (); open IN, "$infile" or die; for () { if (/(\(query:.*)/) { $queryid{$1}++;} } close IN; &build_filter($filterstrength, \%queryid); open IN, "$infile" or die; for () { if (/Hit:\s(.*)/) { $header = "$1"; next;} elsif (s/\s+HSP\s\d+\s=\s//) { chomp $_; $wholeid{$_} = $header unless exists $wholeid{$_}; next;} } close IN; &get_filtered($filterstrength, \%queryid, \%wholeid); ######################################################### sub build_filter { my ($int, $href) = @_; while (my $key = each %$href) { delete $$href{$key} if $$href{$key} < $int;} } sub get_filtered { my ($int, $href1, $href2) = @_; my $regex = ''; open OUT, ">$infile" . ".fil." . "$int" or die; while (my $key1 = each %$href1) { $regex = quotemeta $key1; while (my $key2 = each %$href2) { if ($$href2{$key2} =~ /${regex}/) { print OUT ">$$href2{$key2}\n$key2\n";} } } } ######################################################### "Luckily, we have computers." From abez at abez.ca Thu Jun 20 15:28:24 2002 From: abez at abez.ca (abez) Date: Wed Aug 4 00:11:05 2004 Subject: revamped source code In-Reply-To: <3D11C731@wm2.uvic.ca> Message-ID: What was the change in performance? On Thu, 20 Jun 2002, nkuipers wrote: > Hey all, > > I implemented *some* of the changes y'all suggested yesterday...the parts I > could follow, basically. =) You'll note the shorter regexes, passing by > reference, and the complete absence of any arrays. > > Here is what I have, and [I think] it works; at least, it is giving output > that looks suspiciously like what I am looking for. So now it's just running > it by more brains to make sure I am not being hoodwinked by some Perl internal > I am not aware of, and see if I can squeak by with some more speed... > > Eventually it will accept multiple filter strengths at the command line and > iterate through all of them, each iteration being faster than the last because > of the delete call to the "find-this" hash (%queryid). > > #Program name: getparsedfasta > #Author: Nathanael Kuipers, nkuipers@uvic.ca > #Date written: June 12, 2002 > #Last updated: June 20, 2002 > #Purpose: conditionally formats parsed blastn xml as FASTA > #Use: >perl getparsedfasta inputfilename int > > #!/usr/bin/perl -w > > use strict; > > my $infile = shift; > my $filterstrength = shift; > my %queryid = (); > my $header = ''; > my %wholeid = (); > > open IN, "$infile" or die; > for () { > if (/(\(query:.*)/) { > $queryid{$1}++;} > } > close IN; > > &build_filter($filterstrength, \%queryid); > > open IN, "$infile" or die; > for () { > if (/Hit:\s(.*)/) { > $header = "$1"; next;} > elsif (s/\s+HSP\s\d+\s=\s//) { > chomp $_; > $wholeid{$_} = $header > unless exists $wholeid{$_}; > next;} > } > close IN; > > &get_filtered($filterstrength, \%queryid, \%wholeid); > > ######################################################### > > sub build_filter { > my ($int, $href) = @_; > while (my $key = each %$href) { > delete $$href{$key} if $$href{$key} < $int;} > } > > sub get_filtered { > my ($int, $href1, $href2) = @_; > my $regex = ''; > open OUT, ">$infile" . ".fil." . "$int" or die; > while (my $key1 = each %$href1) { > $regex = quotemeta $key1; > while (my $key2 = each %$href2) { > if ($$href2{$key2} =~ /${regex}/) { > print OUT ">$$href2{$key2}\n$key2\n";} > } > } > } > > ######################################################### > > "Luckily, we have computers." > -- ABeZ------------ ------- ------ - ---------- -- ------------ http://www.indexdirect.com/abez/ Abram Hindle (abez@abez.ca) ---- ------- ----------- ----------- - - ------ --------ABeZ From Peter at PSDT.com Thu Jun 20 16:37:28 2002 From: Peter at PSDT.com (Peter Scott) Date: Wed Aug 4 00:11:05 2004 Subject: revamped source code In-Reply-To: <3D11C731@wm2.uvic.ca> Message-ID: <4.3.2.7.2.20020620143637.00b63940@shell2.webquarry.com> At 11:17 AM 6/20/02 -0700, nkuipers wrote: >sub build_filter { > my ($int, $href) = @_; > while (my $key = each %$href) { > delete $$href{$key} if $$href{$key} < $int;} >} Style suggestion: You'll find it easier to program with references if you write $href->{$key} instead of $$href{$key} -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ From Peter at PSDT.com Thu Jun 20 18:55:31 2002 From: Peter at PSDT.com (Peter Scott) Date: Wed Aug 4 00:11:05 2004 Subject: Last night's meeting Message-ID: <4.3.2.7.2.20020620162129.00b6a420@shell2.webquarry.com> ... was a moderate success; four of us migrated to a room and had a darned good discussion ranging over improving performance of a script that has to parse .5GB of DNA data to how arrays are represented internally. According to a guy sitting by the fountain, there were other people trying to find us, but their information about the location didn't seem to go further than the fountain. Perhaps the documentation was too lengthy :-) We agreed to meet monthly - we'll put the date up for review next time to avoid any conflicts like WEAV - and have a lecture followed by open season in the same location. Possible lecture topics include Object-Oriented Perl. Let us know what you'd like. Unresolved questions from last night: (1) Yes, turning warnings on reveals that when a hash is followed by a scalar in a list assignment, the hash will swallow the corresponding scalar even though there's no corresponding value: % perl -Mstrict -wle 'foo(1..5); sub foo{ my (%hash, $scalar) = @_ }' Odd number of elements in hash assignment at -e line 1. (2) Could the internal representation of an array be different (and affect performance) if the same array was constructed by different means (push vs list assignment, that kind of thing)? Best reference I know of is http://gisle.aas.no/perl/illguts/. Look for the section "AV". Given the structure there, it would appear that no matter how a given array was constructed, it ought to have the same internal representation (modulo some possible but insignificant differences in a couple of pointers). (3) Is there any performance difference between iterating through an array by index number and by element? Answer: Yes, the more natural way is also faster: % perl -MBenchmark=cmpthese -le '@x = 1..1000; cmpthese(1000, { for => sub { for(my $i=0; $i <= $#x; $i++){ $x[$i]++ } }, foreach => sub { for (@x) { $_++ } } })' Benchmark: timing 1000 iterations of for, foreach ... for: 9 wallclock secs ( 9.51 usr + 0.00 sys = 9.51 CPU) @ 105.15/s (n=1000) foreach: 2 wallclock secs ( 3.45 usr + 0.00 sys = 3.45 CPU) @ 289.86/s (n=1000) Rate for foreach for 105/s -- -64% foreach 290/s 176% -- -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/