Commit 34be9763 authored by Matthew Laird's avatar Matthew Laird
Browse files

Jira ENSCORESW-1381

stable_id_version setter/getter for core object types, sets stable_id with a . delimited version or fetches stable_id with .version concatonated (if version is set)
parent a9ac8581
......@@ -1210,6 +1210,34 @@ sub version {
return $self->{'version'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $exon->stable_id("ENSE0000000001.3");
Description: Getter/setter for stable id with version for this exon.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 is_current
......
......@@ -1078,6 +1078,34 @@ sub stable_id {
return $self->{'stable_id'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $gene->stable_id("ENSG0000000001.3");
Description: Getter/setter for stable id with version for this gene.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 is_current
......
......@@ -210,6 +210,35 @@ sub version {
return $self->{'version'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $operon->stable_id("accR2.3");
Description: Getter/setter for stable id with version for this operon.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 get_all_OperonTranscripts
Example : my $ots = $operon->get_all_OperonTranscripts();
......
......@@ -199,6 +199,35 @@ sub version {
return $self->{'version'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $operon->stable_id("accR2A.3");
Description: Getter/setter for stable id with version.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 operon
Example : $operon = $ot->operon();
......
......@@ -2310,7 +2310,6 @@ sub version {
return $self->{'version'};
}
=head2 stable_id
Title : stable_id
......@@ -2328,6 +2327,34 @@ sub stable_id {
return $self->{'stable_id'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $transcript->stable_id("ENST0000000001.3");
Description: Getter/setter for stable id with version for this transcript.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 is_current
......
......@@ -474,6 +474,35 @@ sub stable_id {
return $self->{'stable_id'};
}
=head2 stable_id_version
Arg [1] : (optional) String - the stable ID with version to set
Example : $translation->stable_id("ENSP0059890.3");
Description: Getter/setter for stable id with version for this translation.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id_version {
my $self = shift;
if(my $stable_id = shift) {
# See if there's an embedded period, assume that's a
# version, might not work for some species but you
# should use ->stable_id() and version() if you're worried
# about ambiguity
my $vindex = rindex($stable_id, '.');
# Set the stable_id and version pair depending on if
# we found a version delimiter in the stable_id
($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
(substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
$stable_id, undef);
}
return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}
=head2 created_date
Arg [1] : (optional) string $created_date - created date to set
......
......@@ -242,6 +242,16 @@ $exon = $exonad->fetch_by_stable_id('ENSE00001109603');
debug("fetch_by_stable_id");
ok( $exon->dbID == 162033 );
$exon->stable_id_version('ENSE00000171455.4');
is($exon->stable_id, 'ENSE00000171455', 'Stable id set with stable_id_version');
is($exon->version, 4, 'Version set with stable_id_version');
is($exon->stable_id_version, 'ENSE00000171455.4', 'Stable id and version from stable_id_version');
$exon->stable_id_version('ENSE00000171456');
is($exon->stable_id, 'ENSE00000171456', 'Stable id set with stable_id_version');
is($exon->version, undef, 'Version undef from stable_id_version');
is($exon->stable_id_version, 'ENSE00000171456', 'Stable id and no version from stable_id_version');
$exon = $exonad->fetch_by_stable_id('ENSE00001109603.1');
ok($exon->dbID == 162033, 'fetch_by_stable_id with version');
......
......@@ -840,6 +840,16 @@ $gene = $ga->fetch_by_stable_id('ENSG00000355555');
debug("fetch_by_stable_id");
ok($gene->dbID == 18275);
$gene->stable_id_version('ENSG00000171455.4');
is($gene->stable_id, 'ENSG00000171455', 'Stable id set with stable_id_version');
is($gene->version, 4, 'Version set with stable_id_version');
is($gene->stable_id_version, 'ENSG00000171455.4', 'Stable id and version from stable_id_version');
$gene->stable_id_version('ENSG00000171456');
is($gene->stable_id, 'ENSG00000171456', 'Stable id set with stable_id_version');
is($gene->version, undef, 'Version undef from stable_id_version');
is($gene->stable_id_version, 'ENSG00000171456', 'Stable id and no version from stable_id_version');
$gene = $ga->fetch_by_stable_id("ENSG00000171456.1");
ok($gene->stable_id eq 'ENSG00000171456', "Fetch by stable_id with version");
......
......@@ -99,6 +99,16 @@ $operon = $operon_adaptor->fetch_by_stable_id('16152-16153-4840');
debug( "Operon->fetch_by_stable_id()" );
ok( $operon );
$operon->stable_id_version('16152-16153-4841.4');
is($operon->stable_id, '16152-16153-4841', 'Stable id set with stable_id_version');
is($operon->version, 4, 'Version set with stable_id_version');
is($operon->stable_id_version, '16152-16153-4841.4', 'Stable id and version from stable_id_version');
$operon->stable_id_version('16152-16153-4842');
is($operon->stable_id, '16152-16153-4842', 'Stable id set with stable_id_version');
is($operon->version, undef, 'Version undef from stable_id_version');
is($operon->stable_id_version, '16152-16153-4842', 'Stable id and no version from stable_id_version');
$operon = $operon_adaptor->fetch_by_stable_id('16152-16153-4840.1');
ok($operon->stable_id eq '16152-16153-4840', 'fetch_by_stable_id with version');
......
......@@ -237,6 +237,16 @@ $operon_transcript = $ota->fetch_by_stable_id('T16152-16153-4840');
debug( "OperonTranscript->fetch_by_stable_id()" );
ok( $operon_transcript );
$operon_transcript->stable_id_version('T16152-16153-4841.4');
is($operon_transcript->stable_id, 'T16152-16153-4841', 'Stable id set with stable_id_version');
is($operon_transcript->version, 4, 'Version set with stable_id_version');
is($operon_transcript->stable_id_version, 'T16152-16153-4841.4', 'Stable id and version from stable_id_version');
$operon_transcript->stable_id_version('T16152-16153-4842');
is($operon_transcript->stable_id, 'T16152-16153-4842', 'Stable id set with stable_id_version');
is($operon_transcript->version, undef, 'Version undef from stable_id_version');
is($operon_transcript->stable_id_version, 'T16152-16153-4842', 'Stable id and no version from stable_id_version');
$operon_transcript = $ota->fetch_by_stable_id('T16152-16153-4840.1');
ok($operon_transcript->stable_id eq 'T16152-16153-4840', 'fetch_by_stable_id with version');
......
......@@ -609,6 +609,16 @@ is( scalar(@transcripts), 1, 'Fetched all transcripts by stable_id' );
$tr = $ta->fetch_by_translation_stable_id('ENSP00000355555');
is( $tr->dbID, 21740, 'Fetched transcript by translation stable id' );
$tr->stable_id_version('ENSP00000171455.4');
is($tr->stable_id, 'ENSp00000171455', 'Stable id set with stable_id_version');
is($tr->version, 4, 'Version set with stable_id_version');
is($tr->stable_id_version, 'ENSP00000171455.4', 'Stable id and version from stable_id_version');
$tr->stable_id_version('ENSP00000171456');
is($tr->stable_id, 'ENSP00000171456', 'Stable id set with stable_id_version');
is($tr->version, undef, 'Version undef from stable_id_version');
is($tr->stable_id_version, 'ENSP00000171456', 'Stable id and no version from stable_id_version');
$tr = $ta->fetch_by_translation_stable_id('ENSP00000355555.1');
is( $tr->dbID, 21740, 'Fetched transcript by translation stable id with version' );
......@@ -681,18 +691,6 @@ is($tr->is_current, 1, 'Transcript is now current'); # 151
$multi->restore;
$tr = $ta->fetch_by_stable_id('ENST00000310998.1');
ok($tr->stable_id eq 'ENST00000310998', 'Fetch by stable_id with version');
$tr = $ta->fetch_by_stable_id('ENST00000310998.1a');
ok(! defined($tr), 'Fetch by stable_id with bad version');
$tr = $ta->fetch_by_stable_id_version('ENST00000310998', 1);
ok($tr->stable_id eq 'ENST00000310998', 'fetch_by_stable_id_version');
$tr = $ta->fetch_by_stable_id_version('ENST00000310998', '1a');
ok(! defined($tr), 'fetch_by_stable_id_version with bad version');
# UTR Tests
{
my $utr_testing = sub {
......
......@@ -107,6 +107,16 @@ ok($translation && $translation->stable_id() eq 'ENSP00000201961');
$translation = $ta->fetch_by_stable_id('ENSP00000201961');
ok($translation && $translation->dbID() == 21734);
$translation->stable_id_version('ENSP00000201962.4');
is($translation->stable_id, 'ENSP00000201962', 'Stable id set with stable_id_version');
is($translation->version, 4, 'Version set with stable_id_version');
is($translation->stable_id_version, 'ENSP00000201962.4', 'Stable id and version from stable_id_version');
$translation->stable_id_version('ENSP00000201963');
is($translation->stable_id, 'ENSP00000201963', 'Stable id set with stable_id_version');
is($translation->version, undef, 'Version undef from stable_id_version');
is($translation->stable_id_version, 'ENSP00000201963', 'Stable id and no version from stable_id_version');
$translation = $ta->fetch_by_stable_id('ENSP00000201961.1');
ok($translation && $translation->dbID() == 21734, 'fetch_by_stable_id with version');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment