Skip to content

Commit

Permalink
Merge branch 'topic/finish_sigs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Fields committed Jan 10, 2014
2 parents c97454e + 5c799a3 commit ce066bc
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 477 deletions.
47 changes: 20 additions & 27 deletions lib/Biome/Annotation/Collection.pm
@@ -1,6 +1,8 @@
package Biome::Annotation::Collection;

use Biome;
use namespace::autoclean;
use Method::Signatures;

# though this is an Annotate consumer, we do not allow extra data or object
# slots (it implements Annotate so we can nest Collections)
Expand All @@ -20,23 +22,19 @@ has 'annotation_map' => (
default => sub { {} },
);

sub get_Annotation_keys {
keys %{shift->annotation_map};
method get_Annotation_keys () {
keys %{$self->annotation_map};
}

# may combine with get_Annotation_keys, passing as an option
sub get_all_Annotation_keys {
my ($self, $method) = @_;
$method //= 'depth';
method get_all_Annotation_keys ($method='depth') {
my @keys;
for my $key ($self->get_Annotation_keys) {
push @keys, $key;
}
}

sub get_Annotations {
my ($self,@keys) = @_;

method get_Annotations (@keys){
my @anns = ();
@keys = $self->get_Annotation_keys() unless @keys;
my $map = $self->annotation_map;
Expand All @@ -51,14 +49,13 @@ sub get_Annotations {
return @anns;
}

sub get_nested_Annotations {
shift->throw_not_implemented;
method get_nested_Annotations () {
$self->throw_not_implemented;
}

# does this and get_nested_Annotations do the same thing? Seems like some
# redundancy...
sub get_all_Annotations {
my ($self,@keys) = @_;
method get_all_Annotations (@keys) {
my @ann = map {
$_->does("Biome::Role::CollectAnnotation") ?
$_->get_all_Annotations(@keys) : $_;
Expand All @@ -67,8 +64,7 @@ sub get_all_Annotations {
}

# does not return nested values, only annotation # contained in this instance
sub get_num_Annotations {
my ($self) = @_;
method get_num_Annotations () {
my $count = 0;
map { $count += scalar @$_ } values %{$self->annotation_map};
return $count;
Expand All @@ -78,8 +74,7 @@ sub get_num_Annotations {

# As implemented in BioPerl; this doesn't enforce that an incoming instance that
# Annotates have a matching tagname (key).
sub add_Annotations {
my ($self, $key, $object, $archetype) = @_;
method add_Annotations ($key, $object?, $archetype?) {
my $map = $self->annotation_map;
# if there's no key we use the tagname() as key
if(ref($key) && $key->does("Biome::Role::Annotate") && (!ref($object))) {
Expand Down Expand Up @@ -135,9 +130,7 @@ sub add_Annotations {
}

# can we remove Annotation by an identifier?
sub remove_Annotations {
my ($self, @keys) = @_;

method remove_Annotations (@keys) {
@keys = $self->get_Annotation_keys() unless @keys;
my @anns = $self->get_Annotations(@keys);
my ($annmap, $typemap) = ($self->annotation_map, $self->type_map);
Expand All @@ -149,18 +142,18 @@ sub remove_Annotations {
return @anns;
}

sub flatten_Annotations {
shift->throw_not_implemented
method flatten_Annotations () {
$self->throw_not_implemented
}

# create an iterator and return one at a time...
sub next_Annotation {
shift->throw_not_implemented
method next_Annotation () {
$self->throw_not_implemented
}

# create an iterator and return one at a time...
sub next_Collection {
shift->throw_not_implemented
method next_Collection () {
$self->throw_not_implemented
}

# Annotate Role
Expand All @@ -172,8 +165,8 @@ has '+DEFAULT_CB' => (
lazy => 1
);

sub as_text {
shift->throw_not_implemented
method as_text () {
$self->throw_not_implemented
}

no Biome;
Expand Down
5 changes: 3 additions & 2 deletions lib/Biome/Annotation/Comment.pm
Expand Up @@ -2,6 +2,8 @@
package Biome::Annotation::Comment;

use Biome;
use namespace::autoclean;
use Method::Signatures;

with 'Biome::Role::Annotate' => {
'data_slots' => [qw(text type)]
Expand All @@ -12,8 +14,7 @@ has '+DEFAULT_CB' => (
lazy => 1
);

sub as_text{
my ($self) = @_;
method as_text () {
return "Comment: ".$self->text;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/Biome/Annotation/DBLink.pm
Expand Up @@ -3,6 +3,8 @@
package Biome::Annotation::DBLink;

use Biome;
use namespace::autoclean;
use Method::Signatures;

with qw(Biome::Role::Annotate
Biome::Role::DatabaseLink
Expand All @@ -20,9 +22,7 @@ has '+namespace' => (
lazy => 1,
);

sub as_text{
my ($self) = @_;

method as_text () {
return "Direct database link to ".$self->primary_id
.($self->version ? ".".$self->version : "")
.($self->optional_id ? " (".$self->optional_id.")" : "")
Expand All @@ -35,9 +35,9 @@ sub as_text{
#
#########################################################################

sub _build_display_id {$_[1]}
sub _build_object_id {shift->primary_id(@_)}
sub _build_id {shift->display_id(@_)}
method _build_display_id ($id) { $id }
method _build_object_id ($id) {$self->primary_id($id)}
method _build_id ($id) {$self->display_id($id)}

no Biome;

Expand Down Expand Up @@ -310,4 +310,4 @@ methods. Internal methods are usually preceded with a _
For DBLink this is the same as database().
Returns : A scalar
=cut
=cut
7 changes: 4 additions & 3 deletions lib/Biome/Annotation/Relation.pm
@@ -1,11 +1,12 @@
package Bio::Annotation::Relation;

use Biome;
use namespace::autoclean;
use Method::Signatures;

with 'Biome::Role::Annotate';

sub as_text{
my ($self) = @_;
method as_text () {
return $self->type." to ".$self->to->id;
}

Expand Down Expand Up @@ -220,4 +221,4 @@ The rest of the documentation details each of the object methods. Internal metho
object or undef, optional)
=cut
=cut
7 changes: 4 additions & 3 deletions lib/Biome/Annotation/SimpleValue.pm
Expand Up @@ -2,6 +2,8 @@
package Biome::Annotation::SimpleValue;

use Biome;
use namespace::autoclean;
use Method::Signatures;

with 'Biome::Role::Annotate' => {
'data_slots' => [qw(value term)]
Expand All @@ -12,8 +14,7 @@ has '+DEFAULT_CB' => (
lazy => 1
);

sub as_text{
my ($self) = @_;
method as_text () {
return "Value: ".$self->value;
}

Expand Down Expand Up @@ -200,4 +201,4 @@ The rest of the documentation details each of the object methods. Internal metho
Args : on set, new value (a L<Bio::Ontology::TermI> compliant
object or undef, optional)
=cut
=cut
9 changes: 5 additions & 4 deletions lib/Biome/Annotation/TagTree.pm
Expand Up @@ -2,6 +2,9 @@ package Biome::Annotation::TagTree;

use 5.010;
use Biome;
use namespace::autoclean;
use Method::Signatures;

use Moose::Util::TypeConstraints;
use Data::Stag ();
no if $] >= 5.018, 'warnings', "experimental::smartmatch";
Expand Down Expand Up @@ -44,8 +47,7 @@ has '+DEFAULT_CB' => (
lazy => 1
);

sub as_text {
my ($self) = @_;
method as_text () {
return "TagTree: " . $self->value;
}

Expand All @@ -68,8 +70,7 @@ has 'node' => (
# TODO: value is not a first-class attribute (it is a method here).
# Can we shadow 'alias' attributes?

sub value {
my ($self, $value) = @_;
method value ($value?) {
if (defined $value) {
$self->node($value); # coercions shoud catch any variants
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Biome/Annotation/Target.pm
Expand Up @@ -3,6 +3,8 @@
package Biome::Annotation::Target;

use Biome;
use namespace::autoclean;
use Method::Signatures;

extends qw(Biome::Annotation::DBLink);

Expand All @@ -14,9 +16,7 @@ has '+DEFAULT_CB' => (
lazy => 1
);

sub as_text {
my ($self) = @_;

method as_text {
my $target = $self->target_id || '';
my $start = $self->start || '';
my $end = $self->end || '';
Expand Down Expand Up @@ -169,4 +169,4 @@ new value of target_id (to set)
=back
=cut
=cut

0 comments on commit ce066bc

Please sign in to comment.