Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/DBSQL/ProxySNPAdaptor.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 =head1 LICENSE | |
2 | |
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
4 Genome Research Limited. All rights reserved. | |
5 | |
6 This software is distributed under a modified Apache license. | |
7 For license details, please see | |
8 | |
9 http://www.ensembl.org/info/about/code_licence.html | |
10 | |
11 =head1 CONTACT | |
12 | |
13 Please email comments or questions to the public Ensembl | |
14 developers list at <dev@ensembl.org>. | |
15 | |
16 Questions may also be sent to the Ensembl help desk at | |
17 <helpdesk@ensembl.org>. | |
18 | |
19 =cut | |
20 | |
21 =head1 NAME | |
22 | |
23 Bio::EnsEMBL::DBSQL::ProxySNPAdaptor | |
24 | |
25 =head1 SYNOPSIS | |
26 | |
27 Designed as an abstraction over the database specific SNPAdaptors. This | |
28 is written right now to serve as a replacement for a core SNPadaptor | |
29 which doesn''t even exist yet and probably never will since SNPs are | |
30 taken from external databases. In the future some sort of DBRegistry may | |
31 remove the need for this class. | |
32 | |
33 =head1 METHODS | |
34 | |
35 =cut | |
36 | |
37 package Bio::EnsEMBL::DBSQL::ProxySNPAdaptor; | |
38 | |
39 use strict; | |
40 | |
41 use Bio::EnsEMBL::DBSQL::BaseAdaptor; | |
42 use Bio::EnsEMBL::Utils::Exception qw(throw); | |
43 | |
44 use vars ('@ISA', '$AUTOLOAD'); | |
45 | |
46 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor); | |
47 | |
48 =head2 fetch_attributes_only | |
49 | |
50 Arg [1] : int refsnp_id | |
51 Arg [2] : (optional) string source | |
52 Example : none | |
53 Description: Retrieves a snp objcet from the SNP database but does not | |
54 populate the location information. This is necessary given | |
55 the current state of the snp database because location | |
56 information has to be retrieved differently for different | |
57 species! | |
58 Returntype : Bio::EnsEMBL::SNP | |
59 Exceptions : none | |
60 Caller : snpview | |
61 | |
62 =cut | |
63 | |
64 | |
65 | |
66 sub fetch_attributes_only{ | |
67 my ( $self, @args ) = @_; | |
68 | |
69 my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite'); | |
70 my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP'); | |
71 | |
72 if( defined $snp_db ) { | |
73 my $snp_adaptor = $snp_db->get_SNPAdaptor(); | |
74 return $snp_adaptor->fetch_attributes_only( @args ); | |
75 } | |
76 | |
77 if( defined $lite_db ) { | |
78 my $snp_adaptor = $lite_db->get_SNPAdaptor(); | |
79 return $snp_adaptor->fetch_attributes_only( @args ); | |
80 } | |
81 | |
82 } | |
83 | |
84 | |
85 | |
86 | |
87 =head2 AUTOLOAD | |
88 | |
89 Arg [1] : list of arbitrary values @args | |
90 a list of arguments to pass to the request method | |
91 Example : - | |
92 Description: AUTOLOAD method should not be called directly. It is called | |
93 implicitly when a method requested from this class cannot be | |
94 found. This method first tries to execute the requested method | |
95 in the primary adaptor. If the method cannot be found then | |
96 it searches the other attached databases for equivalent adaptors | |
97 and tries then one at a time. | |
98 Returntype : arbitrary | |
99 Exceptions : thrown if the requested method cannot be found on the primary | |
100 adaptor or on any of the attached databases. | |
101 Caller : called implicitly by perl | |
102 | |
103 =cut | |
104 | |
105 sub AUTOLOAD { | |
106 my ($self, @args) = @_; | |
107 | |
108 #determine the method which was called | |
109 my $method = $AUTOLOAD; | |
110 | |
111 #strip out fully qualified method name | |
112 $method =~ s/.*:://; | |
113 | |
114 my $lite_db = Bio::EnsEMBL::Registry->get_db($self->db(),'lite'); | |
115 my $snp_db = Bio::EnsEMBL::Registry->get_db($self->db(),'SNP'); | |
116 | |
117 if( defined $lite_db ) { | |
118 my $snp_adaptor = $lite_db->get_SNPAdaptor(); | |
119 if($snp_adaptor->can($method)) { | |
120 return $snp_adaptor->$method(@args); | |
121 } | |
122 } | |
123 | |
124 if( defined $snp_db ) { | |
125 my $snp_adaptor = $snp_db->get_SNPAdaptor(); | |
126 if($snp_adaptor->can($method)) { | |
127 return $snp_adaptor->$method(@args); | |
128 } | |
129 } | |
130 | |
131 | |
132 | |
133 throw("The requested method $method could not be found in lite or snp" ); | |
134 } | |
135 | |
136 sub DESTROY { | |
137 } | |
138 | |
139 1; | |
140 | |
141 __END__ |