Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
get basic Bio::PrimarySeq returned
  • Loading branch information
cjfields committed Nov 2, 2014
1 parent 51d4c53 commit 9511726
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/Bio/SeqIO/fasta.pm6
Expand Up @@ -2,19 +2,11 @@ use v6;

use Bio::Role::SeqStream;
use Bio::Grammar::Fasta;

class Bio::Grammar::Fasta::Actions {

method record($/) {
make $<sequence>
}
}
use Bio::PrimarySeq;

role Bio::SeqIO::fasta does Bio::Role::SeqStream {
has $!buffer;

has $!actions = Bio::Grammar::Fasta::Actions.new();

# TODO: this is a temporary iterator to return one sequence record at a
# time; two future optimizations require implementation in Rakudo:
# 1) Chunking in IO::Handle using nl => "\n>"
Expand Down Expand Up @@ -46,10 +38,17 @@ role Bio::SeqIO::fasta does Bio::Role::SeqStream {
method next-Seq {
my $chunk = self!chunkify;
return if !?$chunk.defined;
my $t = Bio::Grammar::Fasta.subparse($chunk, actions => $!actions, rule => 'record');
return $t;
my $t = Bio::Grammar::Fasta.parse($chunk, rule => 'record');
my $seq = Bio::PrimarySeq.new(
seq => ~$t<sequence>,
description => ~$t<description_line><description>,
display_id => ~$t<description_line><id>
);
return $seq;
}

method write-Seq { ... }
method write-Seq(Bio::PrimarySeq $seq) {
#self.fh.print(">");
}

}

0 comments on commit 9511726

Please sign in to comment.