Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
no aliases for now
  • Loading branch information
cjfields committed Jul 18, 2016
1 parent bfefabb commit 684cf15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 48 deletions.
12 changes: 1 addition & 11 deletions lib/Bio/Role/Describable.pm6
Expand Up @@ -4,15 +4,5 @@ role Bio::Role::Describable {

has Str $.display-name is rw = 'new-id';
has Str $.description is rw;

# TODO: best way would to have aliased working again - takadonet
# Working again but not on roles - cjfields

#has Str $.description is rw is aliased<desc>;

method desc ($desc?) {
self.description = $desc if $desc;
return self.description;
}


}
27 changes: 16 additions & 11 deletions lib/Bio/Role/Identifiable.pm6
Expand Up @@ -8,19 +8,14 @@ role Bio::Role::Identifiable {

# Do we need other IDs here? Or should we use a simple key-value store with
# custom ID types allowed?
has Str $.id is rw;

has Str $.display-id is rw;
has Str $.primary-id is rw;
has Int $.version is rw;
has Str $.authority is rw;
has Str $.namespace is rw;
has Str $.accession is rw;

# 'display_id' is an alias of 'id'
method display-id($id?) {
$.id = $id if $id;
$.id
}

method object-id() {
self.accession || ~self
}
Expand All @@ -39,14 +34,24 @@ role Bio::Role::Identifiable {

}

=begin object_id
=begin display-id
Title : display-id
Usage : $string = $obj.display-id()
Function:
Returns : A scalar Str
Status : Virtual
=end display-id

=begin object-id
Title : object_id
Usage : $string = $obj.object_id()
Title : object-id
Usage : $string = $obj.object-id()
Function: a string which represents the stable primary identifier
in this namespace of this object. For DNA sequences this
is its accession, similarly for protein sequences
Returns : A scalar
Status : Virtual
=end object_id
=end object-id
18 changes: 2 additions & 16 deletions lib/Bio/Role/PrimarySeq.pm6
Expand Up @@ -3,29 +3,15 @@ use Bio::Tools::CodonTable;

role Bio::Role::PrimarySeq {

# below is intended to disambiguate seq (raw sequence) from # needs some type-checking, just simple for now
# below is intended to disambiguate seq (raw sequence) from
# needs some type-checking, just simple for now
has Str $.seq is rw;
has SequenceType $.alphabet is rw = dna;
has Bool $.is-circular is rw = False;

# this is mainly to deal with display-id being an alias for 'id', and 'desc' being shorthand for 'description'
# This probabky should be re-thought, at least until we can create an 'is aliased' trait again

method new(*%args) {
#allow for both 'id' and 'display-id' to initialize $!id attributes
if (%args{'display-id'}:exists) {
%args{'id'}= %args{'display-id'};
%args{'display-id'}:delete;
}

#allow for both 'desc' and 'description' to initalize $.description attributes
if (%args{'desc'}:exists) {
%args{'description'} = %args{'desc'};
%args{'desc'}:delete;
}
return self.bless(|%args);
}

# TODO: lazily set the alphabet; left here until we decide on proper semantics, but
# the default 'always guess' is not really great for performance
method set-alphabet() {
Expand Down
11 changes: 1 addition & 10 deletions t/PrimarySeq.t
Expand Up @@ -12,7 +12,7 @@ my $seq = Bio::PrimarySeq.new(
seq => 'TTGGTGGCGTCAACT',
display-id => 'new-id',
alphabet => dna,
accession => 'X677667',
accession => 'X677667',
description => 'Sample Bio::Seq object'
);

Expand Down Expand Up @@ -224,15 +224,6 @@ $seq.seq = 'TTGGTGGCG?CAACT';
# test for character '?' in the sequence string
is($seq.seq, 'TTGGTGGCG?CAACT');

# test for some aliases
$seq = Bio::PrimarySeq.new(
id => 'aliasid' ,
description => 'Alias desc'
);
is( $seq.description, 'Alias desc' );
is( $seq.desc('new desc'), 'new desc' );
is( $seq.display-id, 'aliasid' );

# test that x's are ignored and n's are assumed to be dna no longer true!
# See Bug 2438. There are protein sequences floating about which are all 'X'
# (unknown aa)
Expand Down

0 comments on commit 684cf15

Please sign in to comment.