Skip to content

Instantly share code, notes, and snippets.

@swuecho
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swuecho/67a8cedf03ed4d6b5e02 to your computer and use it in GitHub Desktop.
Save swuecho/67a8cedf03ed4d6b5e02 to your computer and use it in GitHub Desktop.
use v5.20;
use DDP;
package Seq {
use Moo;
has [ 'id', 'comment', 'sequence' ] => ( is => 'rw' );
1;
}
my $parser = do {
use Regexp::Grammars;
qr/
<TOP>
<nocontext:>
<token: TOP> <[record]>+
<objtoken: Seq=record> <.start=(\>)><id><comment>?\n<sequence>
<token: id> [^\-\s\n]+
<token: comment> \s[^\n]+
<token: sequence> <dna>|<rna>|<aa>
<token: dna> [ACGTRYKMSWBDHVNX\-\n]+
<token: rna> [ACGURYKMSWBDHVNX\-\n]+
<token: aa> [A-Z\*\-\n]+
/;
};
my $content = <<'END';
>hello
GCTATATAAGC
>world prot
TATAKEKEKELKL
END
if ( $content =~ $parser ) {
p %/;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment