Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created June 16, 2010 18:45
Show Gist options
  • Save j1n3l0/441095 to your computer and use it in GitHub Desktop.
Save j1n3l0/441095 to your computer and use it in GitHub Desktop.
HowTo: possible solution to compare two bioseq objects [perl,bioperl,prototype,compare]
#!/usr/bin/env perl
use Modern::Perl;
{
package BioSeq;
use Moose;
extends 'Bio::Seq';
sub compare {
my ( $self, $other ) = @_;
return 1 if $self->seq eq $other->seq;
return 1 if $self->seq eq $other->revcom->seq;
return;
}
}
die "usage: perl $0 <one> <two>\n" unless @ARGV == 2;
my $one = BioSeq->new( -seq => shift );
my $two = BioSeq->new( -seq => shift );
say 'Sequences ' . ( $one->compare($two) ? '' : 'do not ' ) . 'match';
#!/usr/bin/env perl
use Modern::Perl;
use Test::Most;
{
package BioSeq;
use Moose;
extends 'Bio::Seq';
sub compare {
my ( $self, $other ) = @_;
return 1 if $self->seq eq $other->seq;
return 1 if $self->seq eq $other->revcom->seq;
return;
}
}
ok my $seq = BioSeq->new( -seq => 'acgtgca' ), 'created the BioSeq';
ok my $rev = BioSeq->new( -seq => 'tgcacgt' ), 'created the BioSeq->revcom';
is $seq->seq, 'acgtgca', 'has the right sequence';
is $rev->seq, 'tgcacgt', 'has the right sequence';
ok $seq->compare( $rev ), 'compare works';
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment