Created
June 16, 2010 18:45
-
-
Save j1n3l0/441095 to your computer and use it in GitHub Desktop.
HowTo: possible solution to compare two bioseq objects [perl,bioperl,prototype,compare]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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