Archive Ensembl HomeArchive Ensembl Home
AnchorSeqAdaptor.pm
Go to the documentation of this file.
00001 package Bio::EnsEMBL::Compara::Production::DBSQL::AnchorSeqAdaptor;
00002 
00003 use strict;
00004 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00005 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00006 use Bio::EnsEMBL::Utils::Exception qw(throw warning);
00007 
00008 our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00009 
00010 
00011 sub store {
00012   my ($self, @args) = @_;
00013   my ($anchor_id, $dnafrag_id, $start, $end, $strand, $mlssid, $test_mlssid, $sequence) = 
00014     rearrange([qw(ANCHOR_ID, DNAFRAG_ID, START, END, STRAND, MLSSID, SEQUENCE, LENGTH)], @args);
00015 
00016 
00017   my $dcs = $self->dbc->disconnect_when_inactive();
00018   $self->dbc->disconnect_when_inactive(0);
00019   
00020   $self->dbc->do("LOCK TABLE anchor_sequence WRITE");
00021   my $length = length($sequence);
00022 
00023   my $sth = $self->prepare("INSERT INTO anchor_sequence (sequence, 
00024     length, dnafrag_id, start, end, strand, anchor_id, method_link_species_set_id) VALUES (?,?,?,?,?,?,?,?)");    
00025   $sth->execute($sequence, $length, $dnafrag_id, $start, $end, $strand, $anchor_id, $mlssid);
00026   $sth->finish;
00027   $self->dbc->do("UNLOCK TABLES");
00028   $self->dbc->disconnect_when_inactive($dcs);
00029 }
00030 
00031 sub get_anchor_sequences {
00032     my ($self, $anc_ids_from_to) = @_;
00033         my $sth = $self->prepare("SELECT a.anchor_id, df.genome_db_id, a.dnafrag_id, a.start, a.end, a.strand, a.sequence 
00034                 FROM anchor_sequence a INNER JOIN dnafrag df ON a.dnafrag_id = df.dnafrag_id WHERE a.anchor_id 
00035                 BETWEEN ? AND ? order by a.anchor_id");
00036 
00037 #   my $sth = $self->prepare("SELECT anchor_id, anchor_seq_id, dnafrag_id, start, end, strand, sequence 
00038 #       FROM anchor_sequence WHERE anchor_id BETWEEN ? AND ? order by anchor_id");
00039     $sth->execute($anc_ids_from_to->[0], $anc_ids_from_to->[1]);
00040     my $anchor_array_ref = $sth->fetchall_arrayref; 
00041     return $anchor_array_ref;
00042 }
00043 
00044 1;
00045