SliceAdaptor.pm 4.16 KB
Newer Older
1 2

#
Simon Potter's avatar
pod  
Simon Potter committed
3
# Ensembl module for Bio::EnsEMBL::DBSQL::SliceAdaptor
4 5 6 7 8 9 10 11 12 13 14
#
# Cared for by Ewan Birney <ensembl-dev@ebi.ac.uk>
#
# Copyright Ewan Birney
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

15
Bio::EnsEMBL::DBSQL::SliceAdaptor - Adaptors for slices
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

=head1 SYNOPSIS
  



=head1 DESCRIPTION

Factory for getting out slices of assemblies. WebSlice is the highly
accelerated version for the web site.

=head1 AUTHOR - Ewan Birney

This modules is part of the Ensembl project http://www.ensembl.org

Email ensembl-dev@ebi.ac.uk

Describe contact details here

=head1 APPENDIX

The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _

=cut


# Let the code begin...


46
package Bio::EnsEMBL::DBSQL::SliceAdaptor;
47 48 49
use vars qw(@ISA);
use strict;

50 51

# Object preamble - inherits from Bio::EnsEMBL::Root
52 53
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::Slice;
54

55

56
@ISA = ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
57 58


59 60
# new is inherieted from BaseAdaptor

61 62 63 64 65 66 67 68 69 70 71 72 73
=head2 new_slice

 Title   : new_slice
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :


=cut

sub new_slice{
74
    my ($self,$chr,$start,$end,$strand,$type) = @_;
75 76


77 78 79
    my $slice = Bio::EnsEMBL::Slice->new( -chr_name  => $chr,
					  -chr_start => $start,
					  -chr_end   => $end,
80
					  -strand    => $strand,
81 82 83 84
					  -assembly_type      => $type,
					-adaptor => $self);

    return $slice;
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
}


=head2 new_web_slice

 Title   : new_web_slice
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :


=cut

sub new_web_slice{
101
    my ($self,$chr,$start,$end,$strand,$type) = @_;
102 103 104 105
    
    die "Not implemented new slice yet";
    
}
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165


sub fetch_all_repeat_features{
  my($self, $slice, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all repeat features if con't have a slice to fetch them for\n");
  }

  my @repeats = $self->db->get_RepeatFeatureAdaptor->fetch_by_Slice($slice, $logic_name);

  return @repeats;

}

sub fetch_all_simple_features{
  my($self, $slice, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all simple features if con't have a slice to fetch them for\n");
  }

  my @simple = $self->db->get_SimpleFeatureAdaptor->fetch_by_Slice($slice, $logic_name);

  return @simple;

}

sub fetch_all_prediction_transcripts{
  my($self, $slice, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all simple features if con't have a slice to fetch them for\n");
  }

  my @prediction = $self->db->get_PredictionTranscriptAdaptor->fetch_by_Slice($slice, $logic_name);

  return @prediction;

}


sub fetch_all_similarity_features{
  my($self, $slice, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all simple features if con't have a slice to fetch them for\n");
  }
  
  my @out;

  my @dnaalign = $self->db->get_DnaAlignFeatureAdaptor->fetch_by_Slice($slice, $logic_name);
  my @pepalign = $self->db->get_ProteinAlignFeatureAdaptor->fetch_by_Slice($slice, $logic_name);

  push(@out, @dnaalign);
  push(@out, @pepalign);

  return @out;
}

166

167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
sub fetch_all_similarity_features_above_score{
  my($self, $slice, $score, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all simple features if con't have a slice to fetch them for\n");
  }
  if(!$score){
    $self->throw("need score even if it 0\n");
  }
  my @out;

  my @dnaalign = $self->db->get_DnaAlignFeatureAdaptor->fetch_by_Slice_and_score($slice, $score, $logic_name);
  my @pepalign = $self->db->get_ProteinAlignFeatureAdaptor->fetch_by_Slice_and_score($slice, $score, $logic_name);

  push(@out, @dnaalign);
  push(@out, @pepalign);

  return @out;
}


sub fetch_all_similarity_features_above_pid{
  my($self, $slice, $pid, $logic_name) = @_;

  if(!$slice){
    $self->throw("can't fetch all simple features if con't have a slice to fetch them for\n");
  }
  if(!$pid){
    $self->throw("need percent_id even if it 0\n");
  }
  my @out;

  my @dnaalign = $self->db->get_DnaAlignFeatureAdaptor->fetch_by_Slice_and_pid($slice, $pid, $logic_name);
  my @pepalign = $self->db->get_ProteinAlignFeatureAdaptor->fetch_by_Slice_and_pid($slice, $pid, $logic_name);

  push(@out, @dnaalign);
  push(@out, @pepalign);

  return @out;
}