File Coverage

blib/lib/Bio/Chado/Schema/Result/Sequence/Feature.pm
Criterion Covered Total %
statement 50 69 72.4
branch 6 20 30.0
condition 1 6 16.6
subroutine 16 22 72.7
pod 9 9 100.0
total 82 126 65.0


line stmt bran cond sub pod time code
1             package Bio::Chado::Schema::Result::Sequence::Feature;
2             BEGIN {
3 6     6   2983 $Bio::Chado::Schema::Result::Sequence::Feature::AUTHORITY = 'cpan:RBUELS';
4             }
5             BEGIN {
6 6     6   108 $Bio::Chado::Schema::Result::Sequence::Feature::VERSION = '0.08001'; # TRIAL
7             }
8              
9             # Created by DBIx::Class::Schema::Loader
10             # DO NOT MODIFY THE FIRST PART OF THIS FILE
11              
12 6     6   38 use strict;
  6         16  
  6         114  
13 6     6   32 use warnings;
  6         13  
  6         137  
14              
15 6     6   29 use base 'DBIx::Class::Core';
  6         12  
  6         2934  
16              
17              
18              
19             __PACKAGE__->table("feature");
20              
21              
22             __PACKAGE__->add_columns(
23             "feature_id",
24             {
25             data_type => "integer",
26             is_auto_increment => 1,
27             is_nullable => 0,
28             sequence => "feature_feature_id_seq",
29             },
30             "dbxref_id",
31             { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
32             "organism_id",
33             { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
34             "name",
35             { data_type => "varchar", is_nullable => 1, size => 255 },
36             "uniquename",
37             { data_type => "text", is_nullable => 0 },
38             "residues",
39             { data_type => "text", is_nullable => 1 },
40             "seqlen",
41             { data_type => "integer", is_nullable => 1 },
42             "md5checksum",
43             { data_type => "char", is_nullable => 1, size => 32 },
44             "type_id",
45             { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
46             "is_analysis",
47             { data_type => "boolean", default_value => \"false", is_nullable => 0 },
48             "is_obsolete",
49             { data_type => "boolean", default_value => \"false", is_nullable => 0 },
50             "timeaccessioned",
51             {
52             data_type => "timestamp",
53             default_value => \"current_timestamp",
54             is_nullable => 0,
55             original => { default_value => \"now()" },
56             },
57             "timelastmodified",
58             {
59             data_type => "timestamp",
60             default_value => \"current_timestamp",
61             is_nullable => 0,
62             original => { default_value => \"now()" },
63             },
64             );
65             __PACKAGE__->set_primary_key("feature_id");
66             __PACKAGE__->add_unique_constraint("feature_c1", ["organism_id", "uniquename", "type_id"]);
67              
68              
69             __PACKAGE__->has_many(
70             "analysisfeatures",
71             "Bio::Chado::Schema::Result::Companalysis::Analysisfeature",
72             { "foreign.feature_id" => "self.feature_id" },
73             { cascade_copy => 0, cascade_delete => 0 },
74             );
75              
76              
77             __PACKAGE__->has_many(
78             "cell_line_features",
79             "Bio::Chado::Schema::Result::CellLine::CellLineFeature",
80             { "foreign.feature_id" => "self.feature_id" },
81             { cascade_copy => 0, cascade_delete => 0 },
82             );
83              
84              
85             __PACKAGE__->has_many(
86             "elements",
87             "Bio::Chado::Schema::Result::Mage::Element",
88             { "foreign.feature_id" => "self.feature_id" },
89             { cascade_copy => 0, cascade_delete => 0 },
90             );
91              
92              
93             __PACKAGE__->belongs_to(
94             "type",
95             "Bio::Chado::Schema::Result::Cv::Cvterm",
96             { cvterm_id => "type_id" },
97             {
98             cascade_copy => 0,
99             cascade_delete => 0,
100             is_deferrable => 1,
101             on_delete => "CASCADE",
102             on_update => "CASCADE",
103             },
104             );
105              
106              
107             __PACKAGE__->belongs_to(
108             "dbxref",
109             "Bio::Chado::Schema::Result::General::Dbxref",
110             { dbxref_id => "dbxref_id" },
111             {
112             cascade_copy => 0,
113             cascade_delete => 0,
114             is_deferrable => 1,
115             join_type => "LEFT",
116             on_delete => "CASCADE",
117             on_update => "CASCADE",
118             },
119             );
120              
121              
122             __PACKAGE__->belongs_to(
123             "organism",
124             "Bio::Chado::Schema::Result::Organism::Organism",
125             { organism_id => "organism_id" },
126             {
127             cascade_copy => 0,
128             cascade_delete => 0,
129             is_deferrable => 1,
130             on_delete => "CASCADE",
131             on_update => "CASCADE",
132             },
133             );
134              
135              
136             __PACKAGE__->has_many(
137             "feature_cvterms",
138             "Bio::Chado::Schema::Result::Sequence::FeatureCvterm",
139             { "foreign.feature_id" => "self.feature_id" },
140             { cascade_copy => 0, cascade_delete => 0 },
141             );
142              
143              
144             __PACKAGE__->has_many(
145             "feature_dbxrefs",
146             "Bio::Chado::Schema::Result::Sequence::FeatureDbxref",
147             { "foreign.feature_id" => "self.feature_id" },
148             { cascade_copy => 0, cascade_delete => 0 },
149             );
150              
151              
152             __PACKAGE__->has_many(
153             "feature_expressions",
154             "Bio::Chado::Schema::Result::Expression::FeatureExpression",
155             { "foreign.feature_id" => "self.feature_id" },
156             { cascade_copy => 0, cascade_delete => 0 },
157             );
158              
159              
160             __PACKAGE__->has_many(
161             "feature_genotype_features",
162             "Bio::Chado::Schema::Result::Genetic::FeatureGenotype",
163             { "foreign.feature_id" => "self.feature_id" },
164             { cascade_copy => 0, cascade_delete => 0 },
165             );
166              
167              
168             __PACKAGE__->has_many(
169             "feature_genotype_chromosomes",
170             "Bio::Chado::Schema::Result::Genetic::FeatureGenotype",
171             { "foreign.chromosome_id" => "self.feature_id" },
172             { cascade_copy => 0, cascade_delete => 0 },
173             );
174              
175              
176             __PACKAGE__->has_many(
177             "featureloc_features",
178             "Bio::Chado::Schema::Result::Sequence::Featureloc",
179             { "foreign.feature_id" => "self.feature_id" },
180             { cascade_copy => 0, cascade_delete => 0 },
181             );
182              
183              
184             __PACKAGE__->has_many(
185             "featureloc_srcfeatures",
186             "Bio::Chado::Schema::Result::Sequence::Featureloc",
187             { "foreign.srcfeature_id" => "self.feature_id" },
188             { cascade_copy => 0, cascade_delete => 0 },
189             );
190              
191              
192             __PACKAGE__->has_many(
193             "feature_phenotypes",
194             "Bio::Chado::Schema::Result::Phenotype::FeaturePhenotype",
195             { "foreign.feature_id" => "self.feature_id" },
196             { cascade_copy => 0, cascade_delete => 0 },
197             );
198              
199              
200             __PACKAGE__->has_many(
201             "featurepos_feature",
202             "Bio::Chado::Schema::Result::Map::Featurepos",
203             { "foreign.feature_id" => "self.feature_id" },
204             { cascade_copy => 0, cascade_delete => 0 },
205             );
206              
207              
208             __PACKAGE__->has_many(
209             "featurepos_map_features",
210             "Bio::Chado::Schema::Result::Map::Featurepos",
211             { "foreign.map_feature_id" => "self.feature_id" },
212             { cascade_copy => 0, cascade_delete => 0 },
213             );
214              
215              
216             __PACKAGE__->has_many(
217             "featureprops",
218             "Bio::Chado::Schema::Result::Sequence::Featureprop",
219             { "foreign.feature_id" => "self.feature_id" },
220             { cascade_copy => 0, cascade_delete => 0 },
221             );
222              
223              
224             __PACKAGE__->has_many(
225             "feature_pubs",
226             "Bio::Chado::Schema::Result::Sequence::FeaturePub",
227             { "foreign.feature_id" => "self.feature_id" },
228             { cascade_copy => 0, cascade_delete => 0 },
229             );
230              
231              
232             __PACKAGE__->has_many(
233             "featurerange_leftendfs",
234             "Bio::Chado::Schema::Result::Map::Featurerange",
235             { "foreign.leftendf_id" => "self.feature_id" },
236             { cascade_copy => 0, cascade_delete => 0 },
237             );
238              
239              
240             __PACKAGE__->has_many(
241             "featurerange_rightstartfs",
242             "Bio::Chado::Schema::Result::Map::Featurerange",
243             { "foreign.rightstartf_id" => "self.feature_id" },
244             { cascade_copy => 0, cascade_delete => 0 },
245             );
246              
247              
248             __PACKAGE__->has_many(
249             "featurerange_rightendfs",
250             "Bio::Chado::Schema::Result::Map::Featurerange",
251             { "foreign.rightendf_id" => "self.feature_id" },
252             { cascade_copy => 0, cascade_delete => 0 },
253             );
254              
255              
256             __PACKAGE__->has_many(
257             "featurerange_leftstartfs",
258             "Bio::Chado::Schema::Result::Map::Featurerange",
259             { "foreign.leftstartf_id" => "self.feature_id" },
260             { cascade_copy => 0, cascade_delete => 0 },
261             );
262              
263              
264             __PACKAGE__->has_many(
265             "featurerange_features",
266             "Bio::Chado::Schema::Result::Map::Featurerange",
267             { "foreign.feature_id" => "self.feature_id" },
268             { cascade_copy => 0, cascade_delete => 0 },
269             );
270              
271              
272             __PACKAGE__->has_many(
273             "feature_relationship_subjects",
274             "Bio::Chado::Schema::Result::Sequence::FeatureRelationship",
275             { "foreign.subject_id" => "self.feature_id" },
276             { cascade_copy => 0, cascade_delete => 0 },
277             );
278              
279              
280             __PACKAGE__->has_many(
281             "feature_relationship_objects",
282             "Bio::Chado::Schema::Result::Sequence::FeatureRelationship",
283             { "foreign.object_id" => "self.feature_id" },
284             { cascade_copy => 0, cascade_delete => 0 },
285             );
286              
287              
288             __PACKAGE__->has_many(
289             "feature_synonyms",
290             "Bio::Chado::Schema::Result::Sequence::FeatureSynonym",
291             { "foreign.feature_id" => "self.feature_id" },
292             { cascade_copy => 0, cascade_delete => 0 },
293             );
294              
295              
296             __PACKAGE__->has_many(
297             "library_features",
298             "Bio::Chado::Schema::Result::Library::LibraryFeature",
299             { "foreign.feature_id" => "self.feature_id" },
300             { cascade_copy => 0, cascade_delete => 0 },
301             );
302              
303              
304             __PACKAGE__->has_many(
305             "phylonodes",
306             "Bio::Chado::Schema::Result::Phylogeny::Phylonode",
307             { "foreign.feature_id" => "self.feature_id" },
308             { cascade_copy => 0, cascade_delete => 0 },
309             );
310              
311              
312             __PACKAGE__->has_many(
313             "studyprop_features",
314             "Bio::Chado::Schema::Result::Mage::StudypropFeature",
315             { "foreign.feature_id" => "self.feature_id" },
316             { cascade_copy => 0, cascade_delete => 0 },
317             );
318              
319              
320             # Created by DBIx::Class::Schema::Loader v0.07001 @ 2010-08-16 23:01:56
321             # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1rnPsx4awJbpI2wm1doDlA
322              
323 6     6   41 use Carp;
  6         19  
  6         408  
324              
325              
326 6     6   32 { no warnings 'once';
  6         12  
  6         273  
327             *parent_relationships = \&feature_relationship_objects;
328             }
329              
330              
331 6     6   29 { no warnings 'once';
  6         13  
  6         1197  
332             *child_relationships = \&feature_relationship_subjects;
333             }
334              
335              
336              
337             __PACKAGE__->belongs_to
338             ( 'primary_dbxref',
339             'Bio::Chado::Schema::Result::General::Dbxref',
340             { 'foreign.dbxref_id' => 'self.dbxref_id' },
341             );
342              
343              
344             __PACKAGE__->many_to_many
345             (
346             'parent_features',
347             'feature_relationship_subjects' => 'object',
348             );
349              
350              
351              
352             __PACKAGE__->many_to_many
353             (
354             'child_features',
355             'feature_relationship_objects' => 'subject',
356             );
357              
358              
359             __PACKAGE__->many_to_many
360             (
361             'dbxrefs_mm',
362             'feature_dbxrefs' => 'dbxref',
363             );
364              
365              
366             __PACKAGE__->many_to_many
367             (
368             'secondary_dbxrefs',
369             'feature_dbxrefs' => 'dbxref',
370             );
371              
372              
373              
374             sub create_featureprops {
375 0     0 1 0 my ($self, $props, $opts) = @_;
376              
377             # process opts
378             $opts->{cv_name} = 'feature_property'
379 0 0       0 unless defined $opts->{cv_name};
380 0         0 return Bio::Chado::Schema::Util->create_properties
381             ( properties => $props,
382             options => $opts,
383             row => $self,
384             prop_relation_name => 'featureprops',
385             );
386             }
387              
388              
389             sub search_featureprops {
390 0     0 1 0 my ( $self, $cvt_criteria ) = @_;
391              
392 0 0       0 $cvt_criteria = { name => $cvt_criteria }
393             unless ref $cvt_criteria;
394              
395 0         0 $self->result_source->schema
396             ->resultset('Cv::Cvterm')
397             ->search( $cvt_criteria )
398             ->search_related('featureprops',
399             { feature_id => $self->feature_id },
400             );
401             }
402              
403              
404              
405 6     6   36 use base qw/ Bio::PrimarySeq /;
  6         14  
  6         2823  
406              
407              
408 6     6   307247 { no warnings 'once';
  6         18  
  6         387  
409             *display_id = \&name;
410             *id = \&name;
411             *primary_id = \&name;
412             }
413              
414              
415 6     6   34 { no warnings 'once';
  6         18  
  6         1532  
416             *seq = \&residues;
417             }
418              
419              
420             sub subseq {
421 5     5 1 34248 my $self = shift;
422              
423             # use the normal subseq if normal residues
424 5 100       113 if( $self->residues ) {
425 2         58 local $self->{seq} = $self->residues; #< stupid hack for Bio::PrimarySeq's subseq to work
426 2         42 return $self->SUPER::subseq( @_ );
427             }
428              
429 3         92 my ( $start, $end ) = @_;
430 3 50       13 croak "must provide start, end to subseq" unless $start;
431 3 50 33     25 croak "subseq() on large_residues only supports ( $start, $end ) calling style"
432             if ref $start || !$end;
433              
434 3         8 my $length = $end - $start + 1;
435 3 50       9 return '' unless $length > 0;
436              
437             return
438 3         12 $self->result_source
439             ->schema
440             ->resultset('Cv::Cvterm')
441             ->search({ name => 'large_residues' })
442             ->search_related( 'featureprops', { feature_id => $self->feature_id } )
443             ->search(
444             undef,
445             { select => { substr => [ 'featureprops.value', $start, $length ] },
446             as => 'mysubstring',
447             }
448             )
449             ->get_column('mysubstring')
450             ->single;
451             }
452              
453              
454             sub trunc {
455 3     3 1 21847 my $self = shift;
456              
457 3         80 return Bio::PrimarySeq->new(
458             -id => $self->name,
459             -seq => $self->subseq( @_ ),
460             );
461             }
462              
463              
464              
465              
466             sub accession_number {
467 0     0 1 0 my $self= shift;
468              
469 0 0 0     0 my $pd = $self->primary_dbxref
470             || $self->secondary_dbxrefs->first
471             or return;
472              
473 0         0 my $acc = $pd->accession;
474 0         0 my $v = $pd->version;
475 0 0       0 $v = $v ? ".$v" : '';
476              
477 0         0 return $acc.$v;
478             }
479              
480 6     6   43 { no warnings 'once';
  6         14  
  6         418  
481             *accession = \&accession_number;
482             }
483              
484              
485              
486             sub length {
487 3     3 1 72399 my $self = shift;
488 3         74 my $l = $self->seqlen;
489 3 50       64 return $l if defined $l;
490 0           return CORE::length( $self->residues );
491             }
492              
493              
494 6     6   34 { no warnings 'once';
  6         13  
  6         817  
495             *description = \&desc;
496             }
497             sub desc {
498 0     0 1   my $self = shift;
499 0           my $desc_fp =
500             $self->search_featureprops( 'description')
501             ->first;
502 0 0         return unless $desc_fp;
503 0           return $desc_fp->value;
504             }
505              
506              
507             sub alphabet {
508 0     0 1   shift()->throw_not_implemented()
509             }
510              
511             # signal to BioPerl that this sequence can't be cloned
512 0     0 1   sub can_call_new { 0 }
513              
514             1;
515              
516              
517             __END__