Bio-DB-Das-Chado
view release on metacpan or search on metacpan
lib/Bio/DB/Das/Chado/Segment/Feature.pm view on Meta::CPAN
my $self = shift;
return $self->{'uniquename'} = shift if @_;
return $self->{'uniquename'};
}
=head2 is_analysis()
Title : is_analysis
Usage : $obj->is_analysis($newval)
Function: holds feature.is_analysis
Returns : value of is_analysis (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub is_analysis {
my $self = shift;
return $self->{'is_analysis'} = shift if defined($_[0]);
my $dbh = $self->factory->dbh;
my $fid = $self->feature_id;
my $sth = $dbh->prepare("SELECT is_analysis FROM feature WHERE feature_id =?");
$sth->execute($fid);
my ($is_analysis) = $sth->fetchrow_array;
$sth->finish;
return $self->{'is_analysis'} = $is_analysis;
}
######################################################################
# ISA Bio::SeqFeatureI
######################################################################
=head1 SeqFeatureI methods
Bio::DB::Das::Chado::Segment::Feature implements the Bio::SeqFeatureI
interface. Methods described below, see Bio:SeqFeatureI for more
details.
=cut
=head2 attach_seq()
Title : attach_seq
Usage : $sf->attach_seq($seq)
Function: Attaches a Bio::Seq object to this feature. This
Bio::Seq object is for the *entire* sequence: ie
from 1 to 10000
Example :
Returns : TRUE on success
Args : a Bio::PrimarySeqI compliant object
=cut
sub attach_seq {
my ($self) = @_;
$self->throw_not_implemented();
}
=head2 display_name()
Title : display_name
Function: aliased to uniquename() for Bio::SeqFeatureI compatibility
=cut
*display_name = \&group;
=head2 entire_seq()
Title : entire_seq
Usage : $whole_seq = $sf->entire_seq()
Function: gives the entire sequence that this seqfeature is attached to
Example :
Returns : a Bio::PrimarySeqI compliant object, or undef if there is no
sequence attached
Args : none
=cut
sub entire_seq {
my $self = shift;
$self->SUPER::seq();
}
=head2 get_all_tags()
Title : get_all_tags
Function: aliased to all_tags() for Bio::SeqFeatureI compatibility
=cut
*get_all_tags = \&all_tags;
=head2 get_SeqFeatures()
Title : get_SeqFeatures
Function: aliased to sub_SeqFeature() for Bio::SeqFeatureI compatibility
=cut
*get_SeqFeatures = \&sub_SeqFeature;
=head2 get_tag_values()
Title : get_tag_values
Usage : $feature->get_tag_values
Function: Returns values associated with a particular tag
Returns : A list of values
Args : A string (the name of the tag)
=cut
sub get_tag_values {
my $self = shift;
my $tag = shift;
my @return = $self->attributes($tag);
return @return;
}
=head2 get_tagset_values()
Title : get_tagset_values
Usage :
Function: ???
Returns :
Args :
=cut
sub get_tagset_values {
my ($self,%arg) = @_;
$self->throw_not_implemented();
}
=head2 gff_string()
Title : gff_string
Usage :
Function: ???
Returns :
Args :
=cut
sub gff_string {
my $self = shift;
my $recurse = shift;
my $feature_id=$self->feature_id;
my $gff_init_query = "SELECT ref,source,type,fstart,fend,score,strand,phase FROM gff3view WHERE feature_id=$feature_id";
my @row_ary = $self->factory->dbh->selectrow_array($gff_init_query);
my $string = join("\t",@row_ary)."\t";
my $gff_atts_query = "SELECT type,attribute from gff3atts where feature_id=?";
my $sth = $self->factory->dbh->prepare($gff_atts_query);
$sth->execute($feature_id);
while (my $hashref = $sth->fetchrow_hashref()) {
my $attribute = uri_escape($$hashref{'attribute'});
next unless $attribute;
$string .= "$$hashref{'type'}=$attribute;";
}
if ($recurse) {
foreach($self->sub_SeqFeature) {
$string .= "\n";
$string .= $_->gff_string(1);
}
}
return $string;
}
=head2 has_tag()
Title : has_tag
Usage :
Function: ???
Returns :
Args :
=cut
sub has_tag {
my $self = shift;
my $tag = shift;
my %tags = map {$_=>1} $self->all_tags;
return $tags{$tag};
}
=head2 primary_tag()
Title : primary_tag
Function: aliased to type() for Bio::SeqFeatureI compatibility
=cut
*primary_tag = \&method;
=head2 seq()
Title : seq
Usage :
Function: ???
Returns :
Args :
=cut
#sub seq {
# my ($self,%arg) = @_;
#
# $self->throw_not_implemented();
#}
=head2 seq_id()
Title : seq_id
Usage : $obj->seq_id($newval)
Function: Set or get the name of the reference sequence that the feature
resides on.
Returns : value of seq_id (a scalar)
Args : on set, new value (a scalar or undef, optional)
=cut
sub seq_id {
my $self = shift;
return $self->{'seq_id'} = shift if @_;
return $self->{'seq_id'} if defined $self->{'seq_id'};
#OK, no seq_id found, we'll try to find one.
my $feature_id = $self->feature_id;
return unless $feature_id;
my $query =<<END
SELECT COALESCE(f.name,f.uniquename) AS seq_id
FROM feature f join featureloc fl ON (f.feature_id = fl.srcfeature_id)
WHERE fl.feature_id = $feature_id AND fl.rank = 0
END
;
my ($seq_id) = $self->factory->dbh->selectrow_array($query);
return $self->{'seq_id'} = $seq_id;
}
######################################################################
# ISA Bio::SeqFeatureI
######################################################################
=head1 Bio::RangeI methods
Bio::SeqFeatureI in turn ISA Bio::RangeI. Bio::RangeI interface
methods described below, L<Bio::RangeI> for details.
=cut
=head2 end()
Title : end
Function: inherited, L<Bio::DB::Das::Chado::Segment>
=cut
=head2 start()
Title : start
Function: inherited, L<Bio::DB::Das::Chado::Segment>
( run in 1.437 second using v1.01-cache-2.11-cpan-5735350b133 )