Bio::EnsEMBL::Compara::DBSQL
ProteinTreeAdaptor
Toolbar
Summary
ProteinTreeAdaptor - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
Description
Methods
_fetch_sequence_by_id | No description | Code |
_load_tagvalues | No description | Code |
_objs_from_sth | No description | Code |
_store_tagvalue | No description | Code |
columns | No description | Code |
create_instance_from_rowhash | No description | Code |
default_where_clause | No description | Code |
delete_flattened_leaf | No description | Code |
delete_node | No description | Code |
delete_node_and_under | No description | Code |
delete_nodes_not_in_tree | No description | Code |
delete_tag | No description | Code |
fetch_AlignedMember_by_member_id_mlssID | Description | Code |
fetch_AlignedMember_by_member_id_root_id | Description | Code |
fetch_by_Member_root_id | Description | Code |
fetch_gene_for_peptide_member_id | No description | Code |
fetch_longest_peptide_member_for_gene_member_id | No description | Code |
fetch_peptides_for_gene_member_id | No description | Code |
init_instance_from_rowhash | No description | Code |
left_join_clause | No description | Code |
merge_nodes | No description | Code |
store | No description | Code |
store_node | No description | Code |
tables | No description | Code |
update_node | No description | Code |
Methods description
Arg[1] : int member_id of a peptide member (longest translation) Arg[2] : [optional] int clusterset_id (def. 0) Example :
my $aligned_member = $proteintree_adaptor->
fetch_AlignedMember_by_member_id_mlssID
(
$member->get_longest_peptide_Member->member_id, $mlssID
);
Description: Fetches from the database the protein_tree that contains the member_id
Returntype : Bio::EnsEMBL::Compara::AlignedMember
Exceptions :
Caller : |
Arg[1] : int member_id of a peptide member (longest translation) Arg[2] : [optional] int clusterset_id (def. 0) Example :
my $aligned_member = $proteintree_adaptor->
fetch_AlignedMember_by_member_id_root_id
(
$member->get_longest_peptide_Member->member_id
);
Description: Fetches from the database the protein_tree that contains the member_id
Returntype : Bio::EnsEMBL::Compara::AlignedMember
Exceptions :
Caller : |
Arg[1] : Bio::EnsEMBL::Compara::Member Arg[2] : [optional] int clusterset_id (def. 1) Example : $protein_tree = $proteintree_adaptor->fetch_by_Member_root_id($member);
Description: Fetches from the database the protein_tree that contains the member
Returntype : Bio::EnsEMBL::Compara::ProteinTree
Exceptions :
Caller : |
Methods code
_fetch_sequence_by_id | description | prev | next | Top |
sub _fetch_sequence_by_id
{ my $self = shift;
return $self->db->get_MemberAdaptor->_fetch_sequence_by_id(@_); } |
sub _load_tagvalues
{ my $self = shift;
my $node = shift;
unless($node->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $node");
}
my $sth = $self->prepare("SELECT tag,value from protein_tree_tag where node_id=?");
$sth->execute($node->node_id);
while (my ($tag, $value) = $sth->fetchrow_array()) {
$node->add_tag($tag,$value);
}
$sth->finish; } |
sub _objs_from_sth
{ my ($self, $sth) = @_;
my $node_list = [];
while(my $rowhash = $sth->fetchrow_hashref) {
my $node = $self->create_instance_from_rowhash($rowhash);
push @$node_list, $node;
}
return $node_list; } |
sub _store_tagvalue
{ my $self = shift;
my $node_id = shift;
my $tag = shift;
my $value = shift;
$value="" unless(defined($value));
my $sql = "INSERT ignore into protein_tree_tag (node_id,tag) values ($node_id,\"$tag\")";
$self->dbc->do($sql);
$sql = "UPDATE protein_tree_tag set value=\"$value\" where node_id=$node_id and tag=\"$tag\"";
$self->dbc->do($sql);
}
} |
sub columns
{ my $self = shift;
return ['t.node_id',
't.parent_id',
't.root_id',
't.left_index',
't.right_index',
't.distance_to_parent',
'tm.cigar_line',
'tm.cigar_start',
'tm.cigar_end',
@{Bio::EnsEMBL::Compara::DBSQL::MemberAdaptor->columns()}
]; } |
sub default_where_clause
{ return ""; } |
sub delete_flattened_leaf
{ my $self = shift;
my $node = shift;
my $node_id = $node->node_id;
$self->dbc->do("DELETE from protein_tree_node WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_tag WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_member WHERE node_id = $node_id"); } |
sub delete_node
{ my $self = shift;
my $node = shift;
my $node_id = $node->node_id;
$self->dbc->do("UPDATE protein_tree_node dn, protein_tree_node n SET ".
"n.parent_id = dn.parent_id WHERE n.parent_id=dn.node_id AND dn.node_id=$node_id");
$self->dbc->do("DELETE from protein_tree_node WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_tag WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_member WHERE node_id = $node_id"); } |
sub delete_node_and_under
{ my $self = shift;
my $node = shift;
my @all_subnodes = $node->get_all_subnodes;
foreach my $subnode (@all_subnodes) {
my $subnode_id = $subnode->node_id;
$self->dbc->do("DELETE from protein_tree_node WHERE node_id = $subnode_id");
$self->dbc->do("DELETE from protein_tree_tag WHERE node_id = $subnode_id");
$self->dbc->do("DELETE from protein_tree_member WHERE node_id = $subnode_id");
}
my $node_id = $node->node_id;
$self->dbc->do("DELETE from protein_tree_node WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_tag WHERE node_id = $node_id");
$self->dbc->do("DELETE from protein_tree_member WHERE node_id = $node_id");
}
} |
sub delete_nodes_not_in_tree
{
my $self = shift;
my $tree = shift;
unless($tree->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $tree");
}
my $dbtree = $self->fetch_node_by_node_id($tree->node_id);
my @all_db_nodes = $dbtree->get_all_subnodes;
foreach my $dbnode (@all_db_nodes) {
next if($tree->find_node_by_node_id($dbnode->node_id));
$self->delete_node($dbnode);
}
$dbtree->release_tree; } |
sub delete_tag
{ my $self = shift;
my $node_id = shift;
my $tag = shift;
my $sql = "DELETE from protein_tree_tag where node_id=$node_id and tag=\"$tag\"";
$self->dbc->do($sql); } |
sub fetch_AlignedMember_by_member_id_mlssID
{ my ($self, $member_id, $mlss_id) = @_;
my $constraint = "WHERE tm.member_id = $member_id and m.member_id = $member_id";
$constraint .= " AND tm.method_link_species_set_id = $mlss_id" if($mlss_id and $mlss_id>0);
my ($node) = @{$self->_generic_fetch($constraint)};
return $node;
}
} |
sub fetch_AlignedMember_by_member_id_root_id
{ my ($self, $member_id, $root_id) = @_;
my $constraint = "WHERE tm.member_id = $member_id and m.member_id = $member_id";
$constraint .= " AND t.root_id = $root_id" if($root_id and $root_id>0);
my $final_clause = "order by tm.node_id desc";
$self->final_clause($final_clause);
my ($node) = @{$self->_generic_fetch($constraint)};
return $node; } |
sub fetch_by_Member_root_id
{ my ($self, $member, $root_id) = @_;
$root_id = $root_id || 1;
my $aligned_member = $self->fetch_AlignedMember_by_member_id_root_id
(
$member->get_longest_peptide_Member->member_id,
$root_id);
return undef unless (defined $aligned_member);
my $node = $aligned_member->subroot;
return undef unless (defined $node);
my $protein_tree = $self->fetch_node_by_node_id($node->node_id);
return $protein_tree; } |
sub fetch_gene_for_peptide_member_id
{ my $self = shift;
return $self->db->get_MemberAdaptor->fetch_gene_for_peptide_member_id(@_); } |
fetch_longest_peptide_member_for_gene_member_id | description | prev | next | Top |
sub fetch_longest_peptide_member_for_gene_member_id
{ my $self = shift;
return $self->db->get_MemberAdaptor->fetch_longest_peptide_member_for_gene_member_id(@_);
}
1; } |
fetch_peptides_for_gene_member_id | description | prev | next | Top |
sub fetch_peptides_for_gene_member_id
{ my $self = shift;
return $self->db->get_MemberAdaptor->fetch_peptides_for_gene_member_id(@_); } |
sub init_instance_from_rowhash
{ my $self = shift;
my $node = shift;
my $rowhash = shift;
$self->SUPER::init_instance_from_rowhash($node, $rowhash);
if($rowhash->{'member_id'}) {
Bio::EnsEMBL::Compara::DBSQL::MemberAdaptor->init_instance_from_rowhash($node, $rowhash);
$node->cigar_line($rowhash->{'cigar_line'});
}
$node->adaptor($self);
return $node;
}
} |
sub left_join_clause
{ return "left join protein_tree_member tm on t.node_id = tm.node_id left join member m on tm.member_id = m.member_id"; } |
sub merge_nodes
{ my ($self, $node1, $node2) = @_;
unless($node1->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $node1");
}
my $sth = $self->prepare("UPDATE protein_tree_node SET
parent_id=?,
WHERE parent_id=?");
$sth->execute($node1->node_id, $node2->node_id);
$sth->finish;
$sth = $self->prepare("DELETE from protein_tree_node WHERE node_id=?");
$sth->execute($node2->node_id);
$sth->finish; } |
sub store
{ my ($self, $node) = @_;
unless($node->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $node");
}
$self->store_node($node);
my $children = $node->children;
foreach my $child_node (@$children) {
$self->store($child_node);
}
return $node->node_id; } |
sub store_node
{ my ($self, $node) = @_;
unless($node->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $node");
}
if($node->adaptor and
$node->adaptor->isa('Bio::EnsEMBL::Compara::DBSQL::NestedSetAdaptor') and
$node->adaptor eq $self)
{
return $self->update_node($node);
}
my $parent_id = 0;
my $root_id = 0;
if($node->parent) {
$parent_id = $node->parent->node_id ;
$root_id = $node->root->node_id;
}
my $sth = $self->prepare("INSERT INTO protein_tree_node
(parent_id,
root_id,
left_index,
right_index,
distance_to_parent) VALUES (?,?,?,?,?)");
$sth->execute($parent_id, $root_id, $node->left_index, $node->right_index, $node->distance_to_parent);
$node->node_id( $sth->{'mysql_insertid'} );
$node->adaptor($self);
$sth->finish;
if($node->isa('Bio::EnsEMBL::Compara::AlignedMember')) {
$sth = $self->prepare("INSERT ignore INTO protein_tree_member
(node_id,
member_id,
method_link_species_set_id,
cigar_line) VALUES (?,?,?,?)");
$sth->execute($node->node_id, $node->member_id, $node->method_link_species_set_id, $node->cigar_line);
$sth->finish;
}
return $node->node_id; } |
sub tables
{ my $self = shift;
return [['protein_tree_node', 't']]; } |
sub update_node
{ my ($self, $node) = @_;
unless($node->isa('Bio::EnsEMBL::Compara::NestedSet')) {
throw("set arg must be a [Bio::EnsEMBL::Compara::NestedSet] not a $node");
}
my $parent_id = 0;
if($node->parent) {
$parent_id = $node->parent->node_id ;
}
my $sth = $self->prepare("UPDATE protein_tree_node SET
parent_id=?,
left_index=?,
right_index=?,
distance_to_parent=?
WHERE node_id=?");
$sth->execute($parent_id, $node->left_index, $node->right_index,
$node->distance_to_parent, $node->node_id);
$node->adaptor($self);
$sth->finish;
if($node->isa('Bio::EnsEMBL::Compara::AlignedMember')) {
my $sql = "UPDATE protein_tree_member SET ".
"cigar_line='". $node->cigar_line . "'";
$sql .= ", cigar_start=" . $node->cigar_start if($node->cigar_start);
$sql .= ", cigar_end=" . $node->cigar_end if($node->cigar_end);
$sql .= ", method_link_species_set_id=" . $node->method_link_species_set_id if($node->method_link_species_set_id);
$sql .= " WHERE node_id=". $node->node_id;
$self->dbc->do($sql);
} } |
General documentation
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _