hobbs.cleverdomain.org
- Website: hobbs.cleverdomain.org/
Recent Actions
-
Commented on FASTA splitter
If BioPerl6 becomes a thing, I won't mind at all :)...
-
Commented on The sad story of pseudohash criticism
Maybe someday the extent of your feigned respect will even go so far that you'll bother to spell his fucking name right....
-
Commented on Inline::C optimizations
I'd go even a step further on the pure-perl route. Lose the state machine, lose "ord", lose the conditional. Build a table of codes and what they generate, and put it in a hash. Do my $codes_regex = join '|',...
-
Commented on Grepping exact values
Combinining Nilson's and Sawyer's observations: if you're only testing for existence of a fixed string or number -- there's no need to return the values, since you already know what they are, and it's only rarely that you're looking for...
Comment Threads
-
Ken Youens-Clark commented on
FASTA splitter
BioPerl6 is a thing and a very good thing it is (https://github.com/cjfields/bioperl6). Sorry, I should have mentioned that I could have used their FASTA parser. Here I wanted to present a self-contained script for purposes of exploring just a couple of ideas.
-
Pawel bbkr Pabian commented on
FASTA splitter
Thanks for sharing your knowledge. I've learned about $*SPEC from your post :)
I'm not FASTA expert, but my approach would be to use ">" as input separator instead of "\n". And then simply push 100 lines (=sequences) into each file through rotor:
# beware first empty element
writer($_) for $fasta.IO.lines( nl-in => '>').[1..*].rotor(100, :partial);sub writer (@seqs) {
...
# restore sequence start character
$out.print('>', $_); for $seqs;
};Of course TIMTOWTDI, however - from my experience - delimiter approach is waaa…
-
Pawel bbkr Pabian commented on
FASTA splitter
My mistake, should be:
$out.print('>', $_); for @seqs;
-
Ken Youens-Clark commented on
FASTA splitter
Sorry, there's a bug in there in that I didn't re-incorporate the newlines from the original sequences. How embarrassing. Here's a corrected version:
#!/usr/bin/env perl6
sub MAIN (
Str :$fasta! where *.IO.f,
Int :$number=100,
Str :$out-dir=$*PROGRAM.IO.d
) {
mkdir $out-dir unless $out-dir.IO.d;my $ext = $fasta.IO.extension;
my $basename = $fasta.IO.basename;
$basename ~~ s/\.$ext$//;sub writer (@seqs) {
state $fnum = 0;
my $fname = $*SPEC.catfile( -
Ken Youens-Clark commented on
FASTA splitter
Nice use of "rotor" and "nl-in" to shorten up the code, Pawel! Here's a new version that I like much better using those ideas:
#!/usr/bin/env perl6
sub MAIN (
Str :$fasta! where *.IO.f,
Int :$number=100,
Str :$out-dir=$*PROGRAM.IO.d
) {
mkdir $out-dir unless $out-dir.IO.d;my $ext = $fasta.IO.extension;
(my $base = $fasta.IO.basename) ~~ s/\.$ext$//;
my $fh = open $fasta, :r, nl-in => '>';
my $fnum = 0;for $fh.lines.[1..*].rotor($number, :partial) -> @seqs {
…
About blogs.perl.org
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.