#!perl -w
# Filter the sequence,
# only gc> minimal GC amount sequence be passed to output
use strict;
use Boulder::Stream;
my $debug = grep(/-d/, @ARGV); # look for -d option
shift @ARGV if $debug; # get rid of -d option
my $verbose = 0;
my $stream = Boulder::Stream->new( );
my ($stone, $dna, $gc);
my $miniGC = 0.50;
while ( $stone = $stream->get( ) ){
$dna = $stone->Sequence;
$gc = calc_gc($dna);
if ( $debug ) {
print "The dna in Boulderfilter is ", length($dna),
" bp long.\n";
print "The calculated gc content is: $gc\n";
print "The cut off for GC content is: $miniGC\n";
print $dna if $verbose;
} else {
next unless $gc > $miniGC;
$stone->insert(GCcontent => $gc);
$stream->put($stone);
}
}
# functions
# my $GC_content = calc_gc($dna);
sub calc_gc {
my $seq = shift;
my $count = 0;
$count++ while ($seq =~ m/[GC]/gi);
my $num = $count / length($seq);
my ($percent) = $num =~ /(\S{0,6})/;
return $percent;
}