Archive Ensembl HomeArchive Ensembl Home
DnaFragRegionAdaptor.pm
Go to the documentation of this file.
00001 #
00002 # Ensembl module for Bio::EnsEMBL::Compara::DnaFragRegionAdaptor
00003 #
00004 # Cared for by Abel Ureta-Vidal <abel@ebi.ac.uk>
00005 #
00006 # Copyright GRL and EBI
00007 #
00008 # You may distribute this module under the same terms as perl itself
00009 
00010 # POD documentation - main docs before the code
00011 
00012 =head1 NAME
00013 
00014 Bio::EnsEMBL::Compara::DBSQL::DnaFragRegionAdaptor - DESCRIPTION of Object
00015 
00016 =head1 SYNOPSIS
00017 
00018 Give standard usage here
00019 
00020 =head1 DESCRIPTION
00021 
00022 Describe the object here
00023 
00024 =head1 CONTACT
00025 
00026 Ensembl - dev@ensembl.org
00027 
00028 =head1 APPENDIX
00029 
00030 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
00031 
00032 =cut
00033 
00034 package Bio::EnsEMBL::Compara::DBSQL::DnaFragRegionAdaptor;
00035 
00036 use strict;
00037 use Bio::EnsEMBL::Utils::Exception;
00038 use Bio::EnsEMBL::Compara::DnaFragRegion;
00039 
00040 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00041 our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00042 
00043 sub fetch_by_synteny_region_id {
00044   my ($self, $synteny_region_id) = @_;
00045   
00046   if( !defined $synteny_region_id ) {
00047     throw("fetch_by_synteny_region_id with no synteny_region_id!");
00048   }
00049 #  print "synteny_region_id : $synteny_region_id\n";
00050   my $sth = $self->prepare("select synteny_region_id, dnafrag_id, dnafrag_start, dnafrag_end, dnafrag_strand from dnafrag_region where synteny_region_id = $synteny_region_id");
00051   $sth->execute;
00052 
00053   
00054   my ($dnafrag_id, $dnafrag_start, $dnafrag_end, $dnafrag_strand);
00055   $sth->bind_columns(\$synteny_region_id, \$dnafrag_id, \$dnafrag_start, \$dnafrag_end, \$dnafrag_strand);
00056   
00057   my $dfrs;
00058   while ($sth->fetch()) {
00059     my $dfr = new Bio::EnsEMBL::Compara::DnaFragRegion;
00060     $dfr->synteny_region_id($synteny_region_id);
00061     $dfr->dnafrag_id($dnafrag_id);
00062     $dfr->dnafrag_start($dnafrag_start);
00063     $dfr->dnafrag_end($dnafrag_end);
00064     $dfr->dnafrag_strand($dnafrag_strand);
00065     $dfr->adaptor($self);
00066     push @{$dfrs}, $dfr;
00067   }
00068   return $dfrs;
00069 }
00070 
00071 sub store{
00072    my ($self,$dfr) = @_;
00073 
00074    if( !ref $dfr || !$dfr->isa("Bio::EnsEMBL::Compara::DnaFragRegion") ) {
00075        throw("$dfr is not a DnaFragRegion object");
00076    }
00077 
00078    my $sth = $self->prepare("insert into dnafrag_region (synteny_region_id, dnafrag_id, dnafrag_start, dnafrag_end, dnafrag_strand) VALUES (?,?,?,?,?)");
00079    
00080    $sth->execute($dfr->synteny_region_id, $dfr->dnafrag_id, $dfr->dnafrag_start, $dfr->dnafrag_end, $dfr->dnafrag_strand);
00081    $dfr->adaptor($self);
00082    
00083    return 1;
00084 }
00085 
00086 1;
00087 
00088 
00089 
00090 
00091 
00092 
00093