Bio-DB-GFF
view release on metacpan or search on metacpan
lib/Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
max(fstop),
fstrand,
feature_name as gname
FROM fdata,cmap_feature,fattribute,fattribute_to_feature
WHERE fattribute_to_feature.fattribute_value LIKE ?
AND cmap_feature.gclass=?
AND cmap_feature.feature_id=fdata.feature_id
AND fattribute.fattribute_name='Alias'
AND fattribute_to_feature.fattribute_id=fattribute.fattribute_id
AND fattribute_to_feature.fid=fdata.fid
GROUP BY fref,fstrand,feature_name
END
;
use constant GETFORCEDSEQCOORDS =><<END;
SELECT fref,
IF(ISNULL(gclass),'Sequence',gclass),
min(fstart),
max(fstop),
fstrand
FROM fdata,cmap_feature
WHERE cmap_feature.feature_name=?
AND cmap_feature.gclass=?
AND fdata.fref=?
AND cmap_feature.feature_id=fdata.feature_id
GROUP BY fref,fstrand
END
;
use constant FULLTEXTSEARCH => <<END;
SELECT distinct gclass,feature_name,fattribute_value,MATCH(fattribute_value) AGAINST (?) as score
FROM cmap_feature,fattribute_to_feature,fdata
WHERE cmap_feature.feature_id=fdata.feature_id
AND fdata.fid=fattribute_to_feature.fid
AND MATCH(fattribute_value) AGAINST (?)
END
;
=head1 DESCRIPTION
This adaptor implements a specific mysql database schema that is
compatible with Bio::DB::GFF. It inherits from
Bio::DB::GFF::Adaptor::dbi, which itself inherits from Bio::DB::GFF.
The schema uses several tables:
=over 4
=item fdata
This is the feature data table. Its columns are:
-
fid feature ID (integer)
fref reference sequence name (string)
fstart start position relative to reference (integer)
fstop stop position relative to reference (integer)
ftypeid feature type ID (integer)
fscore feature score (float); may be null
fstrand strand; one of "+" or "-"; may be null
fphase phase; one of 0, 1 or 2; may be null
feature_id group ID used to be 'gid' (integer)
ftarget_start for similarity features, the target start position (integer)
ftarget_stop for similarity features, the target stop position (integer)
Note that it would be desirable to normalize the reference sequence
name, since there are usually many features that share the same
reference feature. However, in the current schema, query performance
suffers dramatically when this additional join is added.
=item cmap_feature (replaces fgroup)
This is the group table. There is one row for each group. This is the
shared table between CMap and GBrowse. There are many CMap related
columns but only a few that GBrowse uses.
GBrowse Columns:
feature_id the group ID (integer)
gclass the class of the group (string)
feature_name the name of the group (string)
The group table serves multiple purposes. As you might expect, it is
used to cluster features that logically belong together, such as the
multiple exons of the same transcript. It is also used to assign a
name and class to a singleton feature. Finally, the group table is
used to identify the target of a similarity hit. This is consistent
with the way in which the group field is used in the GFF version 2
format.
The cmap_feature.feature_id field joins with the fdata.feature_id field.
Examples:
mysql> select * from cmap_feature where feature_name='sjj_2L52.1';
+--------------+-------------+--------------+
| feature_id | gclass | feature_name |
+--------------+-------------+--------------+
| 69736 | PCR_product | sjj_2L52.1 |
+--------------+-------------+--------------+
1 row in set (0.70 sec)
mysql> select fref,fstart,fstop from fdata,cmap_feature
where gclass='PCR_product' and feature_name = 'sjj_2L52.1'
and fdata.feature_id=cmap_feature.feature_id;
+---------------+--------+-------+
| fref | fstart | fstop |
+---------------+--------+-------+
| CHROMOSOME_II | 1586 | 2355 |
+---------------+--------+-------+
1 row in set (0.03 sec)
=item ftype
This table contains the feature types, one per row. Columns are:
ftypeid the feature type ID (integer)
fmethod the feature type method name (string)
fsource the feature type source name (string)
The ftype.ftypeid field joins with the fdata.ftypeid field. Example:
lib/Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm view on Meta::CPAN
FROM cmap_feature,fattribute_to_feature,fdata
WHERE cmap_feature.feature_id=fdata.feature_id
AND fdata.fid=fattribute_to_feature.fid
END
;
$query .= " AND ($search) " if ($search);
my $sth = $self->dbh->do_query($query);
my @results;
while (my ($class,$name,$note) = $sth->fetchrow_array) {
next unless $class && $name; # sorry, ignore NULL objects
my @matches = $note =~ /($regex)/g;
my $relevance = 10*@matches;
my $featname = Bio::DB::GFF::Featname->new($class=>$name);
push @results,[$featname,$note,$relevance];
last if $limit && @results >= $limit;
}
@results;
}
# sub search_notes {
# my $self = shift;
# my ($search_string,$limit) = @_;
# my $query = FULLTEXTSEARCH;
# $query .= " limit $limit" if defined $limit;
# my $sth = $self->dbh->do_query($query,$search_string,$search_string);
# my @results;
# while (my ($class,$name,$note,$relevance) = $sth->fetchrow_array) {
# next unless $class && $name; # sorry, ignore NULL objects
# $relevance = sprintf("%.2f",$relevance); # trim long floats
# my $featname = Bio::DB::GFF::Featname->new($class=>$name);
# push @results,[$featname,$note,$relevance];
# }
# @results;
# }
=head2 make_features_order_by_part
Title : make_features_order_by_part
Usage : ($query,@args) = $db->make_features_order_by_part()
Function: make the ORDER BY part of the features() query
Returns : a SQL fragment and bind arguments, if any
Args : none
Status : protected
This method creates the part of the features query that immediately
follows the ORDER BY part of the query issued by features() and
related methods.
=cut
sub make_features_order_by_part {
my $self = shift;
my $options = shift || {};
return "cmap_feature.feature_name";
}
=head2 create_cmap_viewer_link
Title : create_cmap_viewer_link
Usage : $link_str = $db->create_cmap_viewer_link(data_source=>$ds,group_id=>$gid)
Function:
Returns :
Args :
Status :
=cut
sub create_cmap_viewer_link {
my $self = shift;
my %args = @_;
my $data_source = $args{'data_source'};
my $gid = $args{'group_id'};
my $link_str = undef;
my $db = $self->features_db;
my $sql_str = qq[
select f.feature_name,
f.feature_type_accession feature_type_aid,
m.accession_id as map_aid,
ms.accession_id as map_set_aid
from cmap_feature f,
cmap_map m,
cmap_map_set ms
where f.map_id=m.map_id
and ms.map_set_id=m.map_set_id
and f.feature_id=$gid
];
my $result_ref = $db->selectrow_hashref($sql_str,{ Columns => {} });
if ( $result_ref ) {
$link_str='/cgi-bin/cmap/viewer?ref_map_set_aid='
. $result_ref->{'map_set_aid'}
. '&ref_map_aids='
. $result_ref->{'map_aid'}
. '&data_source='
. $data_source
. '&highlight='
.$result_ref->{'feature_name'}
. '&feature_type_'
.$result_ref->{'feature_type_aid'}
. '=2';
}
return $link_str;
}
1;
__END__
=head1 BUGS
none ;-)
=head1 SEE ALSO
L<Bio::DB::GFF>, L<bioperl>
=head1 AUTHOR
Ben Faga E<lt>faga@cshl.orgE<gt>.
Modified from mysql.pm by:
Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
Copyright (c) 2002 Cold Spring Harbor Laboratory.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
( run in 0.551 second using v1.01-cache-2.11-cpan-5735350b133 )