Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add simple example scripts
  • Loading branch information
cjfields committed Sep 10, 2016
1 parent 01e6c7e commit f972f09
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/parse-fasta/README.md
@@ -0,0 +1,9 @@
# Example FASTA parsing

The three examples here parse a FASTA file in three ways:

1. `fasta.pl6` - using bioperl6's implementation of Bio::SeqIO

2. `grammar.pl6` - using bioperl6's low-level grammar

3. `fasta-from-p5.pl` - using p5 Bio::SeqIO within Perl 6
17 changes: 17 additions & 0 deletions examples/parse-fasta/fasta-from-p5.pl6
@@ -0,0 +1,17 @@
use v6;

# This is using p5 BioPerl Bio::SeqIO
use Bio::SeqIO:from<Perl5>;

my $file = @*ARGS.shift;

# Note: left side needs quotes; keys are not automaically strings in p6
my $in = Bio::SeqIO.new('-format' => 'fasta', '-file' => $file);

my $ct = 0;

while $in.next_seq -> $record {
$ct++;
}

say "Count: $ct";
13 changes: 13 additions & 0 deletions examples/parse-fasta/fasta.pl6
@@ -0,0 +1,13 @@
use v6;
use Bio::SeqIO;

my $file = @*ARGS.shift;
my $in = Bio::SeqIO.new(:format<fasta>, :file($file));

my $ct = 0;

while $in.next-Seq -> $record {
$ct++;
}

say "Count: $ct";
12 changes: 12 additions & 0 deletions examples/parse-fasta/grammar.pl6
@@ -0,0 +1,12 @@
use v6;
use Bio::Grammar::Fasta;

my $file = @*ARGS.shift;
my $data = Bio::Grammar::Fasta.parsefile($file);

my $ct = 0;
for $data<record> -> $record {
$ct++;
}

say $ct;

0 comments on commit f972f09

Please sign in to comment.