maint: restructure to use Dist::Zilla
[bioperl-live.git] / lib / Bio / Variation / SNP.pm
blobbafdf0d12a0800adb14d75fbf951d1d26b632091
1 # bioperl module for Bio::Variation::SNP
3 # Copyright Allen Day <allenday@ucla.edu>, Stan Nelson <snelson@ucla.edu>
4 # Human Genetics, UCLA Medical School, University of California, Los Angeles
6 =head1 NAME
8 Bio::Variation::SNP - submitted SNP
10 =head1 SYNOPSIS
12 $SNP = Bio::Variation::SNP->new ();
14 =head1 DESCRIPTION
16 Inherits from Bio::Variation::SeqDiff and Bio::Variation::Allele, with
17 additional methods that are (db)SNP specific (ie, refSNP/subSNP IDs, batch
18 IDs, validation methods).
20 =head1 FEEDBACK
22 =head2 Mailing Lists
24 User feedback is an integral part of the evolution of this and other
25 Bioperl modules. Send your comments and suggestions preferably to one
26 of the Bioperl mailing lists. Your participation is much appreciated.
28 bioperl-l@bioperl.org - General discussion
29 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
31 =head2 Support
33 Please direct usage questions or support issues to the mailing list:
35 I<bioperl-l@bioperl.org>
37 rather than to the module maintainer directly. Many experienced and
38 reponsive experts will be able look at the problem and quickly
39 address it. Please include a thorough description of the problem
40 with code and data examples if at all possible.
42 =head2 Reporting Bugs
44 Report bugs to the Bioperl bug tracking system to help us keep track
45 the bugs and their resolution. Bug reports can be submitted via the
46 web:
48 https://github.com/bioperl/bioperl-live/issues
50 =head1 AUTHOR
52 Allen Day E<lt>allenday@ucla.eduE<gt>
54 =head1 APPENDIX
56 The rest of the documentation details each of the object
57 methods. Internal methods are usually preceded with a _
59 =cut
61 # Let the code begin...
63 package Bio::Variation::SNP;
65 use strict;
66 use vars qw($AUTOLOAD);
67 use Bio::Root::Root;
69 use base qw(Bio::Variation::SeqDiff Bio::Variation::Allele);
71 =head2 get/set-able methods
73 Usage : $is = $snp->method()
74 Function: for getting/setting attributes
75 Returns : a value. probably a scalar.
76 Args : if you're trying to set an attribute, pass in the new value.
78 Methods:
79 --------
81 type
82 observed
83 seq_5
84 seq_3
85 ncbi_build
86 ncbi_chr_hits
87 ncbi_ctg_hits
88 ncbi_seq_loc
89 ucsc_build
90 ucsc_chr_hits
91 ucsc_ctg_hits
92 heterozygous
93 heterozygous_SE
94 validated
95 genotype
96 handle
97 batch_id
98 method
99 locus_id
100 symbol
101 mrna
102 protein
103 functional_class
105 =cut
108 my %OK_AUTOLOAD = (
109 id => '',
110 type => '',
111 observed => [],
112 seq_5 => '',
113 seq_3 => '',
114 ncbi_build => '',
115 ncbi_chr_hits => '',
116 ncbi_ctg_hits => '',
117 ncbi_seq_loc => '',
118 ucsc_build => '',
119 ucsc_chr_hits => '',
120 ucsc_ctg_hits => '',
121 heterozygous => '',
122 heterozygous_SE => '',
123 validated => '',
124 genotype => '',
125 handle => '',
126 batch_id => '',
127 method => '',
128 locus_id => '',
129 symbol => '',
130 mrna => '',
131 protein => '',
132 functional_class => '',
135 sub AUTOLOAD {
136 my $self = shift;
137 my $param = $AUTOLOAD;
138 $param =~ s/.*:://;
139 $self->throw(__PACKAGE__." doesn't implement $param") unless defined $OK_AUTOLOAD{$param};
141 if( ref $OK_AUTOLOAD{$param} eq 'ARRAY' ) {
142 push @{$self->{$param}}, shift if @_;
143 return $self->{$param}->[scalar(@{$self->{$param}}) - 1];
144 } else {
145 $self->{$param} = shift if @_;
146 return $self->{$param};
151 #foreach my $slot (keys %RWSLOT){
152 # no strict "refs"; #add class methods to package
153 # *$slot = sub {
154 # shift;
155 # $RWSLOT{$slot} = shift if @_;
156 # return $RWSLOT{$slot};
157 # };
161 =head2 is_subsnp
163 Title : is_subsnp
164 Usage : $is = $snp->is_subsnp()
165 Function: returns 1 if $snp is a subSNP
166 Returns : 1 or undef
167 Args : NONE
169 =cut
171 sub is_subsnp {
172 return shift->{is_subsnp};
175 =head2 subsnp
177 Title : subsnp
178 Usage : $subsnp = $snp->subsnp()
179 Function: returns the currently active subSNP of $snp
180 Returns : Bio::Variation::SNP
181 Args : NONE
183 =cut
185 sub subsnp {
186 my $self = shift;
187 return $self->{subsnps}->[ scalar($self->each_subsnp) - 1 ];
190 =head2 add_subsnp
192 Title : add_subsnp
193 Usage : $subsnp = $snp->add_subsnp()
194 Function: pushes the previous value returned by subsnp() onto a stack,
195 accessible with each_subsnp().
196 Sets return value of subsnp() to a new Bio::Variation::SNP
197 object, and returns that object.
198 Returns : Bio::Varitiation::SNP
199 Args : NONE
201 =cut
203 sub add_subsnp {
204 my $self = shift;
205 $self->throw("add_subsnp(): cannot add subSNP to subSNP, only to refSNP")
206 if $self->is_subsnp;
208 my $subsnp = Bio::Variation::SNP->new;
209 push @{$self->{subsnps}}, $subsnp;
210 $self->subsnp->{is_subsnp} = 1;
211 return $self->subsnp;
214 =head2 each_subsnp
216 Title : each_subsnp
217 Usage : @subsnps = $snp->each_subsnp()
218 Function: returns a list of the subSNPs of a refSNP
219 Returns : list
220 Args : NONE
222 =cut
224 sub each_subsnp {
225 my $self = shift;
226 $self->throw("each_subsnp(): cannot be called on a subSNP")
227 if $self->is_subsnp;
228 return @{$self->{subsnps}};