Skip to content

Commit

Permalink
Made name a private attribute, added a getter/setter for it and also …
Browse files Browse the repository at this point in the history
…created two aliases for name: info and seqname.
  • Loading branch information
Takadonet committed Apr 1, 2011
1 parent d0a6cda commit 8db42eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 11 additions & 10 deletions lib/Bio/SeqFeature/Lite.pm
Expand Up @@ -3,9 +3,7 @@ class Bio::SeqFeature::Lite {
# use base qw(Bio::Root::Root Bio::SeqFeatureI Bio::LocationI Bio::SeqI Bio::RangeI);

# alias for functions
# *stop = \&end;
# *info = \&name;
# *seqname = \&name;

# *exons = *sub_SeqFeature = *merged_segments = \&segments;
# *get_all_SeqFeatures = *get_SeqFeatures = \&segments;
# *method = \&primary_tag;
Expand Down Expand Up @@ -65,7 +63,7 @@ has $!phase is rw;
has $!seq is rw;
has $!class is rw;

has $.name is rw;
has $!name is rw;
has $.desc is rw;
has $!subtype is rw;

Expand Down Expand Up @@ -207,12 +205,15 @@ method primary_tag($value?) {
}
return $!type;
}
# method name {
# my $self = shift;
# my $d = self->{name};
# self->{name} = shift if @_;
# $d;
# }
method name($value?) {
my $d = $!name;
$!name = $value if $value;
$d;
}
#alias for name
method info($value?) { self.name($value);}
method seqname($value?) { self.name($value);}


method seq_id($value?){
my $d = $.ref;
Expand Down
8 changes: 7 additions & 1 deletion t/SeqFeature/Lite.t
Expand Up @@ -4,7 +4,7 @@ BEGIN {
}

use Test;
plan 66;
plan 75;
eval_lives_ok 'use Bio::SeqFeature::Lite', 'Can use Bio::SeqFeature::Lite';

use Bio::SeqFeature::Lite;
Expand All @@ -24,6 +24,9 @@ is($lite.stop,2000,'correct stop');
is($lite.type,'transcript','Got correct transcript');
is($lite.desc,'an enzyme inhibitor','Got desc');
is($lite.display_name,"alpha-1 antitrypsin");
is($lite.name,'alpha-1 antitrypsin');
is($lite.seqname,'alpha-1 antitrypsin');
is($lite.info,'alpha-1 antitrypsin');
is($lite.display_id,"alpha-1 antitrypsin");
is($lite.dna,'');
is($lite.start_pos_type,"EXACT");
Expand All @@ -50,6 +53,7 @@ is($lite.length,1001);
is($lite.type,'gapped_alignment');
is($lite.desc,Any);
is($lite.display_name,"ABC-3");
is($lite.name,'ABC-3');
is($lite.display_id,"ABC-3");
is($lite.dna,'');
is($lite.start_pos_type,"EXACT");
Expand Down Expand Up @@ -92,6 +96,7 @@ $lite = Bio::SeqFeature::Lite.new(segments=>[$e1,$e2,$e3],type=>'gene',seq_id=>
is($e1.type,'exon');
is($e2.type,'exon');
is($e3.type,'exon');
is($e3.name,Any);

is($lite.start,1,'correct start');
is($lite.stop,500,'correct stop');
Expand All @@ -102,6 +107,7 @@ is($lite.high(),'500');
is($lite.location_string,'1..100,150..200,300..500');
is($lite.score,Any);
is($lite.length,500);
is($lite.name,Any);

#they should still keep their type as 'exon'
for ($lite.segments) -> $x {
Expand Down

0 comments on commit 8db42eb

Please sign in to comment.