File Coverage

blib/lib/Bio/Chado/Schema/Result/Cv/Cvterm.pm
Criterion Covered Total %
statement 116 120 96.6
branch 29 52 55.7
condition 6 17 35.2
subroutine 25 25 100.0
pod 13 13 100.0
total 189 227 83.2


line stmt bran cond sub pod time code
1             package Bio::Chado::Schema::Result::Cv::Cvterm;
2             BEGIN {
3 6     6   3380 $Bio::Chado::Schema::Result::Cv::Cvterm::AUTHORITY = 'cpan:RBUELS';
4             }
5             BEGIN {
6 6     6   100 $Bio::Chado::Schema::Result::Cv::Cvterm::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   35 use strict;
  6         19  
  6         102  
13 6     6   29 use warnings;
  6         13  
  6         133  
14              
15 6     6   25 use base 'DBIx::Class::Core';
  6         13  
  6         6830  
16              
17              
18              
19             __PACKAGE__->table("cvterm");
20              
21              
22             __PACKAGE__->add_columns(
23             "cvterm_id",
24             {
25             data_type => "integer",
26             is_auto_increment => 1,
27             is_nullable => 0,
28             sequence => "cvterm_cvterm_id_seq",
29             },
30             "cv_id",
31             { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
32             "name",
33             { data_type => "varchar", is_nullable => 0, size => 1024 },
34             "definition",
35             { data_type => "text", is_nullable => 1 },
36             "dbxref_id",
37             { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
38             "is_obsolete",
39             { data_type => "integer", default_value => 0, is_nullable => 0 },
40             "is_relationshiptype",
41             { data_type => "integer", default_value => 0, is_nullable => 0 },
42             );
43             __PACKAGE__->set_primary_key("cvterm_id");
44             __PACKAGE__->add_unique_constraint("cvterm_c2", ["dbxref_id"]);
45             __PACKAGE__->add_unique_constraint("cvterm_c1", ["name", "cv_id", "is_obsolete"]);
46              
47              
48             __PACKAGE__->has_many(
49             "acquisitionprops",
50             "Bio::Chado::Schema::Result::Mage::Acquisitionprop",
51             { "foreign.type_id" => "self.cvterm_id" },
52             { cascade_copy => 0, cascade_delete => 0 },
53             );
54              
55              
56             __PACKAGE__->has_many(
57             "acquisition_relationships",
58             "Bio::Chado::Schema::Result::Mage::AcquisitionRelationship",
59             { "foreign.type_id" => "self.cvterm_id" },
60             { cascade_copy => 0, cascade_delete => 0 },
61             );
62              
63              
64             __PACKAGE__->has_many(
65             "analysisfeatureprops",
66             "Bio::Chado::Schema::Result::Companalysis::Analysisfeatureprop",
67             { "foreign.type_id" => "self.cvterm_id" },
68             { cascade_copy => 0, cascade_delete => 0 },
69             );
70              
71              
72             __PACKAGE__->has_many(
73             "analysisprops",
74             "Bio::Chado::Schema::Result::Companalysis::Analysisprop",
75             { "foreign.type_id" => "self.cvterm_id" },
76             { cascade_copy => 0, cascade_delete => 0 },
77             );
78              
79              
80             __PACKAGE__->has_many(
81             "arraydesign_platformtypes",
82             "Bio::Chado::Schema::Result::Mage::Arraydesign",
83             { "foreign.platformtype_id" => "self.cvterm_id" },
84             { cascade_copy => 0, cascade_delete => 0 },
85             );
86              
87              
88             __PACKAGE__->has_many(
89             "arraydesign_substratetypes",
90             "Bio::Chado::Schema::Result::Mage::Arraydesign",
91             { "foreign.substratetype_id" => "self.cvterm_id" },
92             { cascade_copy => 0, cascade_delete => 0 },
93             );
94              
95              
96             __PACKAGE__->has_many(
97             "arraydesignprops",
98             "Bio::Chado::Schema::Result::Mage::Arraydesignprop",
99             { "foreign.type_id" => "self.cvterm_id" },
100             { cascade_copy => 0, cascade_delete => 0 },
101             );
102              
103              
104             __PACKAGE__->has_many(
105             "assayprops",
106             "Bio::Chado::Schema::Result::Mage::Assayprop",
107             { "foreign.type_id" => "self.cvterm_id" },
108             { cascade_copy => 0, cascade_delete => 0 },
109             );
110              
111              
112             __PACKAGE__->has_many(
113             "biomaterialprops",
114             "Bio::Chado::Schema::Result::Mage::Biomaterialprop",
115             { "foreign.type_id" => "self.cvterm_id" },
116             { cascade_copy => 0, cascade_delete => 0 },
117             );
118              
119              
120             __PACKAGE__->has_many(
121             "biomaterial_relationships",
122             "Bio::Chado::Schema::Result::Mage::BiomaterialRelationship",
123             { "foreign.type_id" => "self.cvterm_id" },
124             { cascade_copy => 0, cascade_delete => 0 },
125             );
126              
127              
128             __PACKAGE__->has_many(
129             "biomaterial_treatments",
130             "Bio::Chado::Schema::Result::Mage::BiomaterialTreatment",
131             { "foreign.unittype_id" => "self.cvterm_id" },
132             { cascade_copy => 0, cascade_delete => 0 },
133             );
134              
135              
136             __PACKAGE__->has_many(
137             "cell_line_cvterms",
138             "Bio::Chado::Schema::Result::CellLine::CellLineCvterm",
139             { "foreign.cvterm_id" => "self.cvterm_id" },
140             { cascade_copy => 0, cascade_delete => 0 },
141             );
142              
143              
144             __PACKAGE__->has_many(
145             "cell_line_cvtermprops",
146             "Bio::Chado::Schema::Result::CellLine::CellLineCvtermprop",
147             { "foreign.type_id" => "self.cvterm_id" },
148             { cascade_copy => 0, cascade_delete => 0 },
149             );
150              
151              
152             __PACKAGE__->has_many(
153             "cell_lineprops",
154             "Bio::Chado::Schema::Result::CellLine::CellLineprop",
155             { "foreign.type_id" => "self.cvterm_id" },
156             { cascade_copy => 0, cascade_delete => 0 },
157             );
158              
159              
160             __PACKAGE__->has_many(
161             "cell_line_relationships",
162             "Bio::Chado::Schema::Result::CellLine::CellLineRelationship",
163             { "foreign.type_id" => "self.cvterm_id" },
164             { cascade_copy => 0, cascade_delete => 0 },
165             );
166              
167              
168             __PACKAGE__->has_many(
169             "contacts",
170             "Bio::Chado::Schema::Result::Contact::Contact",
171             { "foreign.type_id" => "self.cvterm_id" },
172             { cascade_copy => 0, cascade_delete => 0 },
173             );
174              
175              
176             __PACKAGE__->has_many(
177             "contact_relationships",
178             "Bio::Chado::Schema::Result::Contact::ContactRelationship",
179             { "foreign.type_id" => "self.cvterm_id" },
180             { cascade_copy => 0, cascade_delete => 0 },
181             );
182              
183              
184             __PACKAGE__->has_many(
185             "controls",
186             "Bio::Chado::Schema::Result::Mage::Control",
187             { "foreign.type_id" => "self.cvterm_id" },
188             { cascade_copy => 0, cascade_delete => 0 },
189             );
190              
191              
192             __PACKAGE__->has_many(
193             "cvprops",
194             "Bio::Chado::Schema::Result::Cv::Cvprop",
195             { "foreign.type_id" => "self.cvterm_id" },
196             { cascade_copy => 0, cascade_delete => 0 },
197             );
198              
199              
200             __PACKAGE__->belongs_to(
201             "cv",
202             "Bio::Chado::Schema::Result::Cv::Cv",
203             { cv_id => "cv_id" },
204             {
205             cascade_copy => 0,
206             cascade_delete => 0,
207             is_deferrable => 1,
208             on_delete => "CASCADE",
209             on_update => "CASCADE",
210             },
211             );
212              
213              
214             __PACKAGE__->belongs_to(
215             "dbxref",
216             "Bio::Chado::Schema::Result::General::Dbxref",
217             { dbxref_id => "dbxref_id" },
218             {
219             cascade_copy => 0,
220             cascade_delete => 0,
221             is_deferrable => 1,
222             on_delete => "CASCADE",
223             on_update => "CASCADE",
224             },
225             );
226              
227              
228             __PACKAGE__->has_many(
229             "cvterm_dbxrefs",
230             "Bio::Chado::Schema::Result::Cv::CvtermDbxref",
231             { "foreign.cvterm_id" => "self.cvterm_id" },
232             { cascade_copy => 0, cascade_delete => 0 },
233             );
234              
235              
236             __PACKAGE__->has_many(
237             "cvtermpath_types",
238             "Bio::Chado::Schema::Result::Cv::Cvtermpath",
239             { "foreign.type_id" => "self.cvterm_id" },
240             { cascade_copy => 0, cascade_delete => 0 },
241             );
242              
243              
244             __PACKAGE__->has_many(
245             "cvtermpath_objects",
246             "Bio::Chado::Schema::Result::Cv::Cvtermpath",
247             { "foreign.object_id" => "self.cvterm_id" },
248             { cascade_copy => 0, cascade_delete => 0 },
249             );
250              
251              
252             __PACKAGE__->has_many(
253             "cvtermpath_subjects",
254             "Bio::Chado::Schema::Result::Cv::Cvtermpath",
255             { "foreign.subject_id" => "self.cvterm_id" },
256             { cascade_copy => 0, cascade_delete => 0 },
257             );
258              
259              
260             __PACKAGE__->has_many(
261             "cvtermprop_types",
262             "Bio::Chado::Schema::Result::Cv::Cvtermprop",
263             { "foreign.type_id" => "self.cvterm_id" },
264             { cascade_copy => 0, cascade_delete => 0 },
265             );
266              
267              
268             __PACKAGE__->has_many(
269             "cvtermprops",
270             "Bio::Chado::Schema::Result::Cv::Cvtermprop",
271             { "foreign.cvterm_id" => "self.cvterm_id" },
272             { cascade_copy => 0, cascade_delete => 0 },
273             );
274              
275              
276             __PACKAGE__->has_many(
277             "cvterm_relationship_types",
278             "Bio::Chado::Schema::Result::Cv::CvtermRelationship",
279             { "foreign.type_id" => "self.cvterm_id" },
280             { cascade_copy => 0, cascade_delete => 0 },
281             );
282              
283              
284             __PACKAGE__->has_many(
285             "cvterm_relationship_objects",
286             "Bio::Chado::Schema::Result::Cv::CvtermRelationship",
287             { "foreign.object_id" => "self.cvterm_id" },
288             { cascade_copy => 0, cascade_delete => 0 },
289             );
290              
291              
292             __PACKAGE__->has_many(
293             "cvterm_relationship_subjects",
294             "Bio::Chado::Schema::Result::Cv::CvtermRelationship",
295             { "foreign.subject_id" => "self.cvterm_id" },
296             { cascade_copy => 0, cascade_delete => 0 },
297             );
298              
299              
300             __PACKAGE__->has_many(
301             "cvtermsynonym_types",
302             "Bio::Chado::Schema::Result::Cv::Cvtermsynonym",
303             { "foreign.type_id" => "self.cvterm_id" },
304             { cascade_copy => 0, cascade_delete => 0 },
305             );
306              
307              
308             __PACKAGE__->has_many(
309             "cvtermsynonyms",
310             "Bio::Chado::Schema::Result::Cv::Cvtermsynonym",
311             { "foreign.cvterm_id" => "self.cvterm_id" },
312             { cascade_copy => 0, cascade_delete => 0 },
313             );
314              
315              
316             __PACKAGE__->has_many(
317             "dbxrefprops",
318             "Bio::Chado::Schema::Result::Cv::Dbxrefprop",
319             { "foreign.type_id" => "self.cvterm_id" },
320             { cascade_copy => 0, cascade_delete => 0 },
321             );
322              
323              
324             __PACKAGE__->has_many(
325             "elements",
326             "Bio::Chado::Schema::Result::Mage::Element",
327             { "foreign.type_id" => "self.cvterm_id" },
328             { cascade_copy => 0, cascade_delete => 0 },
329             );
330              
331              
332             __PACKAGE__->has_many(
333             "element_relationships",
334             "Bio::Chado::Schema::Result::Mage::ElementRelationship",
335             { "foreign.type_id" => "self.cvterm_id" },
336             { cascade_copy => 0, cascade_delete => 0 },
337             );
338              
339              
340             __PACKAGE__->has_many(
341             "elementresult_relationships",
342             "Bio::Chado::Schema::Result::Mage::ElementresultRelationship",
343             { "foreign.type_id" => "self.cvterm_id" },
344             { cascade_copy => 0, cascade_delete => 0 },
345             );
346              
347              
348             __PACKAGE__->has_many(
349             "environment_cvterms",
350             "Bio::Chado::Schema::Result::Genetic::EnvironmentCvterm",
351             { "foreign.cvterm_id" => "self.cvterm_id" },
352             { cascade_copy => 0, cascade_delete => 0 },
353             );
354              
355              
356             __PACKAGE__->has_many(
357             "expression_cvterm_cvterms",
358             "Bio::Chado::Schema::Result::Expression::ExpressionCvterm",
359             { "foreign.cvterm_id" => "self.cvterm_id" },
360             { cascade_copy => 0, cascade_delete => 0 },
361             );
362              
363              
364             __PACKAGE__->has_many(
365             "expression_cvterm_cvterm_types",
366             "Bio::Chado::Schema::Result::Expression::ExpressionCvterm",
367             { "foreign.cvterm_type_id" => "self.cvterm_id" },
368             { cascade_copy => 0, cascade_delete => 0 },
369             );
370              
371              
372             __PACKAGE__->has_many(
373             "expression_cvtermprops",
374             "Bio::Chado::Schema::Result::Expression::ExpressionCvtermprop",
375             { "foreign.type_id" => "self.cvterm_id" },
376             { cascade_copy => 0, cascade_delete => 0 },
377             );
378              
379              
380             __PACKAGE__->has_many(
381             "expressionprops",
382             "Bio::Chado::Schema::Result::Expression::Expressionprop",
383             { "foreign.type_id" => "self.cvterm_id" },
384             { cascade_copy => 0, cascade_delete => 0 },
385             );
386              
387              
388             __PACKAGE__->has_many(
389             "features",
390             "Bio::Chado::Schema::Result::Sequence::Feature",
391             { "foreign.type_id" => "self.cvterm_id" },
392             { cascade_copy => 0, cascade_delete => 0 },
393             );
394              
395              
396             __PACKAGE__->has_many(
397             "feature_cvterms",
398             "Bio::Chado::Schema::Result::Sequence::FeatureCvterm",
399             { "foreign.cvterm_id" => "self.cvterm_id" },
400             { cascade_copy => 0, cascade_delete => 0 },
401             );
402              
403              
404             __PACKAGE__->has_many(
405             "feature_cvtermprops",
406             "Bio::Chado::Schema::Result::Sequence::FeatureCvtermprop",
407             { "foreign.type_id" => "self.cvterm_id" },
408             { cascade_copy => 0, cascade_delete => 0 },
409             );
410              
411              
412             __PACKAGE__->has_many(
413             "feature_expressionprops",
414             "Bio::Chado::Schema::Result::Expression::FeatureExpressionprop",
415             { "foreign.type_id" => "self.cvterm_id" },
416             { cascade_copy => 0, cascade_delete => 0 },
417             );
418              
419              
420             __PACKAGE__->has_many(
421             "feature_genotypes",
422             "Bio::Chado::Schema::Result::Genetic::FeatureGenotype",
423             { "foreign.cvterm_id" => "self.cvterm_id" },
424             { cascade_copy => 0, cascade_delete => 0 },
425             );
426              
427              
428             __PACKAGE__->has_many(
429             "featuremaps",
430             "Bio::Chado::Schema::Result::Map::Featuremap",
431             { "foreign.unittype_id" => "self.cvterm_id" },
432             { cascade_copy => 0, cascade_delete => 0 },
433             );
434              
435              
436             __PACKAGE__->has_many(
437             "featureprops",
438             "Bio::Chado::Schema::Result::Sequence::Featureprop",
439             { "foreign.type_id" => "self.cvterm_id" },
440             { cascade_copy => 0, cascade_delete => 0 },
441             );
442              
443              
444             __PACKAGE__->has_many(
445             "feature_pubprops",
446             "Bio::Chado::Schema::Result::Sequence::FeaturePubprop",
447             { "foreign.type_id" => "self.cvterm_id" },
448             { cascade_copy => 0, cascade_delete => 0 },
449             );
450              
451              
452             __PACKAGE__->has_many(
453             "feature_relationships",
454             "Bio::Chado::Schema::Result::Sequence::FeatureRelationship",
455             { "foreign.type_id" => "self.cvterm_id" },
456             { cascade_copy => 0, cascade_delete => 0 },
457             );
458              
459              
460             __PACKAGE__->has_many(
461             "feature_relationshipprops",
462             "Bio::Chado::Schema::Result::Sequence::FeatureRelationshipprop",
463             { "foreign.type_id" => "self.cvterm_id" },
464             { cascade_copy => 0, cascade_delete => 0 },
465             );
466              
467              
468             __PACKAGE__->has_many(
469             "libraries",
470             "Bio::Chado::Schema::Result::Library::Library",
471             { "foreign.type_id" => "self.cvterm_id" },
472             { cascade_copy => 0, cascade_delete => 0 },
473             );
474              
475              
476             __PACKAGE__->has_many(
477             "library_cvterms",
478             "Bio::Chado::Schema::Result::Library::LibraryCvterm",
479             { "foreign.cvterm_id" => "self.cvterm_id" },
480             { cascade_copy => 0, cascade_delete => 0 },
481             );
482              
483              
484             __PACKAGE__->has_many(
485             "libraryprops",
486             "Bio::Chado::Schema::Result::Library::Libraryprop",
487             { "foreign.type_id" => "self.cvterm_id" },
488             { cascade_copy => 0, cascade_delete => 0 },
489             );
490              
491              
492             __PACKAGE__->has_many(
493             "nd_experiments",
494             "Bio::Chado::Schema::Result::NaturalDiversity::NdExperiment",
495             { "foreign.type_id" => "self.cvterm_id" },
496             { cascade_copy => 0, cascade_delete => 0 },
497             );
498              
499              
500             __PACKAGE__->has_many(
501             "nd_experimentprops",
502             "Bio::Chado::Schema::Result::NaturalDiversity::NdExperimentprop",
503             { "foreign.type_id" => "self.cvterm_id" },
504             { cascade_copy => 0, cascade_delete => 0 },
505             );
506              
507              
508             __PACKAGE__->has_many(
509             "nd_experiment_stocks",
510             "Bio::Chado::Schema::Result::NaturalDiversity::NdExperimentStock",
511             { "foreign.type_id" => "self.cvterm_id" },
512             { cascade_copy => 0, cascade_delete => 0 },
513             );
514              
515              
516             __PACKAGE__->has_many(
517             "nd_experiment_stockprops",
518             "Bio::Chado::Schema::Result::NaturalDiversity::NdExperimentStockprop",
519             { "foreign.type_id" => "self.cvterm_id" },
520             { cascade_copy => 0, cascade_delete => 0 },
521             );
522              
523              
524             __PACKAGE__->has_many(
525             "nd_geolocationprops",
526             "Bio::Chado::Schema::Result::NaturalDiversity::NdGeolocationprop",
527             { "foreign.type_id" => "self.cvterm_id" },
528             { cascade_copy => 0, cascade_delete => 0 },
529             );
530              
531              
532             __PACKAGE__->has_many(
533             "nd_protocolprops",
534             "Bio::Chado::Schema::Result::NaturalDiversity::NdProtocolprop",
535             { "foreign.type_id" => "self.cvterm_id" },
536             { cascade_copy => 0, cascade_delete => 0 },
537             );
538              
539              
540             __PACKAGE__->has_many(
541             "nd_protocol_reagents",
542             "Bio::Chado::Schema::Result::NaturalDiversity::NdProtocolReagent",
543             { "foreign.type_id" => "self.cvterm_id" },
544             { cascade_copy => 0, cascade_delete => 0 },
545             );
546              
547              
548             __PACKAGE__->has_many(
549             "nd_reagents",
550             "Bio::Chado::Schema::Result::NaturalDiversity::NdReagent",
551             { "foreign.type_id" => "self.cvterm_id" },
552             { cascade_copy => 0, cascade_delete => 0 },
553             );
554              
555              
556             __PACKAGE__->has_many(
557             "nd_reagentprops",
558             "Bio::Chado::Schema::Result::NaturalDiversity::NdReagentprop",
559             { "foreign.type_id" => "self.cvterm_id" },
560             { cascade_copy => 0, cascade_delete => 0 },
561             );
562              
563              
564             __PACKAGE__->has_many(
565             "nd_reagent_relationships",
566             "Bio::Chado::Schema::Result::NaturalDiversity::NdReagentRelationship",
567             { "foreign.type_id" => "self.cvterm_id" },
568             { cascade_copy => 0, cascade_delete => 0 },
569             );
570              
571              
572             __PACKAGE__->has_many(
573             "organismprops",
574             "Bio::Chado::Schema::Result::Organism::Organismprop",
575             { "foreign.type_id" => "self.cvterm_id" },
576             { cascade_copy => 0, cascade_delete => 0 },
577             );
578              
579              
580             __PACKAGE__->has_many(
581             "phendescs",
582             "Bio::Chado::Schema::Result::Genetic::Phendesc",
583             { "foreign.type_id" => "self.cvterm_id" },
584             { cascade_copy => 0, cascade_delete => 0 },
585             );
586              
587              
588             __PACKAGE__->has_many(
589             "phenotype_assays",
590             "Bio::Chado::Schema::Result::Phenotype::Phenotype",
591             { "foreign.assay_id" => "self.cvterm_id" },
592             { cascade_copy => 0, cascade_delete => 0 },
593             );
594              
595              
596             __PACKAGE__->has_many(
597             "phenotype_attrs",
598             "Bio::Chado::Schema::Result::Phenotype::Phenotype",
599             { "foreign.attr_id" => "self.cvterm_id" },
600             { cascade_copy => 0, cascade_delete => 0 },
601             );
602              
603              
604             __PACKAGE__->has_many(
605             "phenotype_observables",
606             "Bio::Chado::Schema::Result::Phenotype::Phenotype",
607             { "foreign.observable_id" => "self.cvterm_id" },
608             { cascade_copy => 0, cascade_delete => 0 },
609             );
610              
611              
612             __PACKAGE__->has_many(
613             "phenotype_cvalues",
614             "Bio::Chado::Schema::Result::Phenotype::Phenotype",
615             { "foreign.cvalue_id" => "self.cvterm_id" },
616             { cascade_copy => 0, cascade_delete => 0 },
617             );
618              
619              
620             __PACKAGE__->has_many(
621             "phenotype_comparison_cvterms",
622             "Bio::Chado::Schema::Result::Genetic::PhenotypeComparisonCvterm",
623             { "foreign.cvterm_id" => "self.cvterm_id" },
624             { cascade_copy => 0, cascade_delete => 0 },
625             );
626              
627              
628             __PACKAGE__->has_many(
629             "phenotype_cvterms",
630             "Bio::Chado::Schema::Result::Phenotype::PhenotypeCvterm",
631             { "foreign.cvterm_id" => "self.cvterm_id" },
632             { cascade_copy => 0, cascade_delete => 0 },
633             );
634              
635              
636             __PACKAGE__->has_many(
637             "phenstatements",
638             "Bio::Chado::Schema::Result::Genetic::Phenstatement",
639             { "foreign.type_id" => "self.cvterm_id" },
640             { cascade_copy => 0, cascade_delete => 0 },
641             );
642              
643              
644             __PACKAGE__->has_many(
645             "phylonodes",
646             "Bio::Chado::Schema::Result::Phylogeny::Phylonode",
647             { "foreign.type_id" => "self.cvterm_id" },
648             { cascade_copy => 0, cascade_delete => 0 },
649             );
650              
651              
652             __PACKAGE__->has_many(
653             "phylonodeprops",
654             "Bio::Chado::Schema::Result::Phylogeny::Phylonodeprop",
655             { "foreign.type_id" => "self.cvterm_id" },
656             { cascade_copy => 0, cascade_delete => 0 },
657             );
658              
659              
660             __PACKAGE__->has_many(
661             "phylonode_relationships",
662             "Bio::Chado::Schema::Result::Phylogeny::PhylonodeRelationship",
663             { "foreign.type_id" => "self.cvterm_id" },
664             { cascade_copy => 0, cascade_delete => 0 },
665             );
666              
667              
668             __PACKAGE__->has_many(
669             "phylotrees",
670             "Bio::Chado::Schema::Result::Phylogeny::Phylotree",
671             { "foreign.type_id" => "self.cvterm_id" },
672             { cascade_copy => 0, cascade_delete => 0 },
673             );
674              
675              
676             __PACKAGE__->has_many(
677             "projectprops",
678             "Bio::Chado::Schema::Result::Project::Projectprop",
679             { "foreign.type_id" => "self.cvterm_id" },
680             { cascade_copy => 0, cascade_delete => 0 },
681             );
682              
683              
684             __PACKAGE__->has_many(
685             "project_relationships",
686             "Bio::Chado::Schema::Result::Project::ProjectRelationship",
687             { "foreign.type_id" => "self.cvterm_id" },
688             { cascade_copy => 0, cascade_delete => 0 },
689             );
690              
691              
692             __PACKAGE__->has_many(
693             "protocols",
694             "Bio::Chado::Schema::Result::Mage::Protocol",
695             { "foreign.type_id" => "self.cvterm_id" },
696             { cascade_copy => 0, cascade_delete => 0 },
697             );
698              
699              
700             __PACKAGE__->has_many(
701             "protocolparam_unittypes",
702             "Bio::Chado::Schema::Result::Mage::Protocolparam",
703             { "foreign.unittype_id" => "self.cvterm_id" },
704             { cascade_copy => 0, cascade_delete => 0 },
705             );
706              
707              
708             __PACKAGE__->has_many(
709             "protocolparam_datatypes",
710             "Bio::Chado::Schema::Result::Mage::Protocolparam",
711             { "foreign.datatype_id" => "self.cvterm_id" },
712             { cascade_copy => 0, cascade_delete => 0 },
713             );
714              
715              
716             __PACKAGE__->has_many(
717             "pubs",
718             "Bio::Chado::Schema::Result::Pub::Pub",
719             { "foreign.type_id" => "self.cvterm_id" },
720             { cascade_copy => 0, cascade_delete => 0 },
721             );
722              
723              
724             __PACKAGE__->has_many(
725             "pubprops",
726             "Bio::Chado::Schema::Result::Pub::Pubprop",
727             { "foreign.type_id" => "self.cvterm_id" },
728             { cascade_copy => 0, cascade_delete => 0 },
729             );
730              
731              
732             __PACKAGE__->has_many(
733             "pub_relationships",
734             "Bio::Chado::Schema::Result::Pub::PubRelationship",
735             { "foreign.type_id" => "self.cvterm_id" },
736             { cascade_copy => 0, cascade_delete => 0 },
737             );
738              
739              
740             __PACKAGE__->has_many(
741             "quantificationprops",
742             "Bio::Chado::Schema::Result::Mage::Quantificationprop",
743             { "foreign.type_id" => "self.cvterm_id" },
744             { cascade_copy => 0, cascade_delete => 0 },
745             );
746              
747              
748             __PACKAGE__->has_many(
749             "quantification_relationships",
750             "Bio::Chado::Schema::Result::Mage::QuantificationRelationship",
751             { "foreign.type_id" => "self.cvterm_id" },
752             { cascade_copy => 0, cascade_delete => 0 },
753             );
754              
755              
756             __PACKAGE__->has_many(
757             "stocks",
758             "Bio::Chado::Schema::Result::Stock::Stock",
759             { "foreign.type_id" => "self.cvterm_id" },
760             { cascade_copy => 0, cascade_delete => 0 },
761             );
762              
763              
764             __PACKAGE__->has_many(
765             "stockcollections",
766             "Bio::Chado::Schema::Result::Stock::Stockcollection",
767             { "foreign.type_id" => "self.cvterm_id" },
768             { cascade_copy => 0, cascade_delete => 0 },
769             );
770              
771              
772             __PACKAGE__->has_many(
773             "stockcollectionprops",
774             "Bio::Chado::Schema::Result::Stock::Stockcollectionprop",
775             { "foreign.type_id" => "self.cvterm_id" },
776             { cascade_copy => 0, cascade_delete => 0 },
777             );
778              
779              
780             __PACKAGE__->has_many(
781             "stock_cvterms",
782             "Bio::Chado::Schema::Result::Stock::StockCvterm",
783             { "foreign.cvterm_id" => "self.cvterm_id" },
784             { cascade_copy => 0, cascade_delete => 0 },
785             );
786              
787              
788             __PACKAGE__->has_many(
789             "stock_dbxrefprops",
790             "Bio::Chado::Schema::Result::Stock::StockDbxrefprop",
791             { "foreign.type_id" => "self.cvterm_id" },
792             { cascade_copy => 0, cascade_delete => 0 },
793             );
794              
795              
796             __PACKAGE__->has_many(
797             "stockprops",
798             "Bio::Chado::Schema::Result::Stock::Stockprop",
799             { "foreign.type_id" => "self.cvterm_id" },
800             { cascade_copy => 0, cascade_delete => 0 },
801             );
802              
803              
804             __PACKAGE__->has_many(
805             "stock_relationships",
806             "Bio::Chado::Schema::Result::Stock::StockRelationship",
807             { "foreign.type_id" => "self.cvterm_id" },
808             { cascade_copy => 0, cascade_delete => 0 },
809             );
810              
811              
812             __PACKAGE__->has_many(
813             "stock_relationship_cvterms",
814             "Bio::Chado::Schema::Result::Stock::StockRelationshipCvterm",
815             { "foreign.cvterm_id" => "self.cvterm_id" },
816             { cascade_copy => 0, cascade_delete => 0 },
817             );
818              
819              
820             __PACKAGE__->has_many(
821             "studydesignprops",
822             "Bio::Chado::Schema::Result::Mage::Studydesignprop",
823             { "foreign.type_id" => "self.cvterm_id" },
824             { cascade_copy => 0, cascade_delete => 0 },
825             );
826              
827              
828             __PACKAGE__->has_many(
829             "studyfactors",
830             "Bio::Chado::Schema::Result::Mage::Studyfactor",
831             { "foreign.type_id" => "self.cvterm_id" },
832             { cascade_copy => 0, cascade_delete => 0 },
833             );
834              
835              
836             __PACKAGE__->has_many(
837             "studyprops",
838             "Bio::Chado::Schema::Result::Mage::Studyprop",
839             { "foreign.type_id" => "self.cvterm_id" },
840             { cascade_copy => 0, cascade_delete => 0 },
841             );
842              
843              
844             __PACKAGE__->has_many(
845             "studyprop_features",
846             "Bio::Chado::Schema::Result::Mage::StudypropFeature",
847             { "foreign.type_id" => "self.cvterm_id" },
848             { cascade_copy => 0, cascade_delete => 0 },
849             );
850              
851              
852             __PACKAGE__->has_many(
853             "synonyms",
854             "Bio::Chado::Schema::Result::Sequence::Synonym",
855             { "foreign.type_id" => "self.cvterm_id" },
856             { cascade_copy => 0, cascade_delete => 0 },
857             );
858              
859              
860             __PACKAGE__->has_many(
861             "treatments",
862             "Bio::Chado::Schema::Result::Mage::Treatment",
863             { "foreign.type_id" => "self.cvterm_id" },
864             { cascade_copy => 0, cascade_delete => 0 },
865             );
866              
867              
868             # Created by DBIx::Class::Schema::Loader v0.07006 @ 2011-02-15 16:07:00
869             # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+7waNqcJG6AuNftjx9h76g
870              
871 6     6   40 use Carp;
  6         15  
  6         6060  
872              
873              
874             __PACKAGE__->has_many(
875             "cvtermprops",
876             "Bio::Chado::Schema::Result::Cv::Cvtermprop",
877             { "foreign.cvterm_id" => "self.cvterm_id" },
878             { cascade_copy => 0, cascade_delete => 0 },
879             );
880              
881             __PACKAGE__->has_many(
882             "cvtermsynonyms",
883             "Bio::Chado::Schema::Result::Cv::Cvtermsynonym",
884             { "foreign.cvterm_id" => "self.cvterm_id" },
885             { cascade_copy => 0, cascade_delete => 0 },
886             );
887              
888              
889              
890             sub add_synonym {
891 2     2 1 37708 my ($self, $synonym, $opts) = @_;
892 2         20 my $schema = $self->result_source->schema;
893 2   50     29 $opts ||= {};
894             $opts->{cv_name} = 'synonym_type'
895 2 50       11 unless defined $opts->{cv_name};
896             $opts->{db_name} = 'null'
897 2 50       11 unless defined $opts->{db_name};
898             $opts->{dbxref_accession_prefix} = 'autocreated:'
899 2 50       13 unless defined $opts->{dbxref_accession_prefix};
900 2         5 my $data;
901 2         8 $data->{synonym} = $synonym;
902              
903 2 50       8 if (defined $opts->{synonym_type} ) {
904 2         5 my $synonym_type= $opts->{synonym_type} ;
905 2         4 my $synonym_db; #< set as needed below
906 2         5 my $synonym_cv = do {
907 2         12 my $cvrs = $schema->resultset('Cv::Cv');
908 2 50       659 my $find_or_create = $opts->{autocreate} ? 'find_or_create' : 'find';
909             $cvrs->$find_or_create({ name => $opts->{cv_name}},
910 2 50       16 { key => 'cv_c1' })
911             or croak "cv '$opts->{cv_name}' not found and autocreate option not passed, cannot continue";
912             };
913              
914             # find/create cvterm and dbxref for the synonym,
915              
916 2         5276 my $existing_cvterm =
917             $synonym_cv->find_related('cvterms',
918             { name => $synonym_type,
919             is_obsolete => 0,
920             },
921             { key => 'cvterm_c1' },
922             );
923              
924             # if there is no existing cvterm for this synonym type, and we
925             # have the autocreate flag set true, then create a cvterm,
926             # dbxref, and db for it if necessary
927 2 100       8669 unless( $existing_cvterm ) {
928             $opts->{autocreate}
929 1 50       20 or croak "cvterm not found for cvterm synonym type '$synonym_type', and autocreate option not passed, cannot continue";
930              
931             # look up the db object if we don't already have it, now
932             # that we know we need it
933             $synonym_db ||=
934             $self->result_source->schema
935             ->resultset('General::Db')
936             ->find_or_create( { name => $opts->{db_name} },
937 1   33     8 { key => 'db_c1' }
938             );
939              
940             # find or create the dbxref for this cvterm we are about
941             # to create
942 1         2423 my $dbx_acc = $synonym_type;
943 1   33     28 my $dbxref =
944             $synonym_db->find_or_create_related('dbxrefs',{ accession => $dbx_acc })
945             || $synonym_db->create_related('dbxrefs',{ accession => $dbx_acc,
946             version => 1,
947             });
948              
949             # look up any definition we might have been given for this
950             # propname, so we can insert it if given
951 1         8998 my $def = $opts->{definition};
952              
953              
954 1 50       27 my $synonym_type_cvterm= $synonym_cv->create_related('cvterms',
955             { name => $synonym_type,
956             is_obsolete => 0,
957             dbxref_id => $dbxref->dbxref_id,
958             $def ? (definition => $def) : (),
959             }
960             );
961 1         2320 $data->{type_id} = $synonym_type_cvterm->cvterm_id();
962             } else {
963 1         44 $data->{type_id} = $existing_cvterm->cvterm_id();
964             }
965             }
966              
967             my ($cvtermsynonym)= $self->search_related('cvtermsynonyms', {
968 2         184 type_id => $data->{type_id} })->
969             search({ 'lower(synonym)' => {like => lc($synonym) } } );
970              
971             #search({ 'lower(synonym)' => { like => 'blah'}})
972             #my $rs = $c->model("DB::Dbentry")->$search({
973             #'lower('.$key.')' => $q },
974              
975             #search({ \'lower(synonym)' => { like => 'blah'}})
976 2 100       12662 $cvtermsynonym= $self->create_related('cvtermsynonyms' , $data) unless defined $cvtermsynonym;
977              
978 2         2800 return $cvtermsynonym;
979             }
980              
981              
982              
983             sub delete_synonym {
984 1     1 1 788 my $self=shift;
985 1         3 my $synonym=shift;
986              
987 1         4 my $schema = $self->result_source->schema;
988              
989 1         14 $self->result_source
990             ->schema
991             ->resultset("Cv::Cvtermsynonym")
992             ->search( { cvterm_id => $self->get_column('cvterm_id'),
993             synonym => { 'like' , lc($synonym) }
994             })
995             ->delete();
996             }
997              
998              
999              
1000              
1001             sub get_secondary_dbxrefs {
1002 2     2 1 951 my $self=shift;
1003 2         8 my $schema = $self->result_source->schema;
1004 2         24 my @list;
1005 2         17 my @s = $self->search_related('cvterm_dbxrefs' , { is_for_definition => 0} );
1006 2         5607 foreach (@s) {
1007 1         9 my $accession = $_->dbxref->accession;
1008 1         4278 my $db_name = $_->dbxref->db->name;
1009 1         3184 push @list, $db_name . ":" . $accession;
1010             }
1011 2         14 return @list;
1012             }
1013              
1014              
1015              
1016             sub add_secondary_dbxref {
1017 1     1 1 7454 my ($self, $accession, $def)=@_;
1018 1 50       5 $def = 0 if !$def;
1019              
1020 1         5 my $schema = $self->result_source->schema;
1021 1         16 my ($db_name, $acc) = split (/:/, $accession);
1022 1 50 33     7 if (!$db_name || !$acc) { croak "Accession must be of the form :. You passed '$accession'" ; }
  0         0  
1023 1         5 my $db = $schema->resultset("General::Db")->find_or_create(
1024             { name => $db_name },
1025             { key => 'db_c1' }
1026             );
1027 1   33     3613 my $dbxref =
1028             $db->search_related('dbxrefs', { accession => $acc })->first
1029             || $db->create_related('dbxrefs', { accession => $acc });
1030              
1031 1         5306 my $cvterm_dbxref = $schema->resultset("Cv::CvtermDbxref")->search(
1032             { dbxref_id => $dbxref->get_column('dbxref_id'),
1033             cvterm_id => $self->get_column('cvterm_id') }
1034             )->first();
1035 1 50       2277 if ($cvterm_dbxref) {
1036 0 0       0 $cvterm_dbxref->update( { is_for_definition => $def } ) if $def;
1037             }else {
1038 1         118 $cvterm_dbxref = $schema->resultset("Cv::CvtermDbxref")->create(
1039             { dbxref_id => $dbxref->get_column('dbxref_id'),
1040             cvterm_id => $self->get_column('cvterm_id'),
1041             is_for_definition => $def,
1042             } );
1043             }
1044 1         2180 return $cvterm_dbxref;
1045             }
1046              
1047              
1048              
1049             sub delete_secondary_dbxref {
1050 1     1 1 1239 my $self=shift;
1051 1         2 my $accession=shift;
1052 1         15 my $schema = $self->result_source->schema;
1053 1         15 my ($db_name, $acc) = split (/:/, $accession);
1054 1 50 33     10 if (!$db_name || !$accession) { croak "Did not pass a legal accession! ($accession)" ; }
  0         0  
1055              
1056 1         5 my ($cvterm_dbxref) = $schema->resultset("General::Db")->search(
1057             { name => $db_name } )->
1058             search_related('dbxrefs' , { accession => $acc } )->
1059             search_related('cvterm_dbxrefs', { cvterm_id => $self->get_column('cvterm_id') } );
1060 1 50       11659 if ($cvterm_dbxref) { $cvterm_dbxref->delete() ; }
  1         82  
1061              
1062             }
1063              
1064              
1065              
1066             sub create_cvtermprops {
1067 1     1 1 4317 my ($self, $props, $opts) = @_;
1068              
1069             # process opts
1070             $opts->{cv_name} = 'cvterm_property'
1071 1 50       7 unless defined $opts->{cv_name};
1072 1         9 return Bio::Chado::Schema::Util->create_properties
1073             ( properties => $props,
1074             options => $opts,
1075             row => $self,
1076             prop_relation_name => 'cvtermprops',
1077             );
1078             }
1079              
1080              
1081              
1082             sub root {
1083 1     1 1 17384 my $self = shift;
1084 1         8 my $root = $self->search_related('cvtermpath_subjects',
1085             {} ,
1086             {
1087             order_by => { -desc => 'pathdistance'},
1088             rows => 1,
1089             }
1090             )
1091             ->single
1092             ->find_related('object' , {});
1093              
1094 1         7417 return $root;
1095             }
1096              
1097              
1098             sub children {
1099 1     1 1 835 shift->search_related('cvterm_relationship_objects');
1100             }
1101              
1102              
1103             sub direct_children {
1104 1     1 1 9023 my $self = shift;
1105             return
1106 1         7 $self->search_related (
1107             'cvtermpath_subjects',
1108             {
1109             pathdistance => { '<' => 0 },
1110             } )->search_related('object');
1111             }
1112              
1113             #the same using cvtermpath
1114             # return $self->search_related('cvtermpath_objects' , undef , {
1115             #pathdistance => 1 , }
1116             #);
1117              
1118              
1119             sub recursive_children {
1120 1     1 1 18991 my $self = shift;
1121             return
1122 1         10 $self->search_related(
1123             'cvtermpath_objects',
1124             {
1125             pathdistance => { '>' => 0 },
1126             }
1127             )->search_related('subject');
1128             }
1129              
1130              
1131              
1132             sub parents {
1133 1     1 1 16727 shift->search_related('cvterm_relationship_subjects');
1134             }
1135              
1136              
1137             sub direct_parents {
1138 1     1 1 8690 my $self = shift;
1139             return
1140 1         6 $self->search_related(
1141             'cvtermpath_objects',
1142             {
1143             pathdistance => { '<' => 0 } ,
1144             } )->search_related( 'subject');
1145             }
1146              
1147              
1148             sub recursive_parents {
1149 1     1 1 11218 my $self = shift;
1150             return
1151 1         13 $self->search_related(
1152             'cvtermpath_subjects',
1153             {
1154             pathdistance => { '>' => 0 } ,
1155             } )->search_related( 'object');
1156             }
1157              
1158             ############ CVTERM CUSTOM RESULTSET PACKAGE #############################
1159              
1160              
1161             __PACKAGE__->resultset_class('Bio::Chado::Schema::Result::Cv::Cvterm::ResultSet');
1162             package Bio::Chado::Schema::Result::Cv::Cvterm::ResultSet;
1163             BEGIN {
1164 6     6   138 $Bio::Chado::Schema::Result::Cv::Cvterm::ResultSet::AUTHORITY = 'cpan:RBUELS';
1165             }
1166             BEGIN {
1167 6     6   106 $Bio::Chado::Schema::Result::Cv::Cvterm::ResultSet::VERSION = '0.08001'; # TRIAL
1168             }
1169 6     6   35 use base qw/ DBIx::Class::ResultSet /;
  6         18  
  6         410  
1170              
1171 6     6   38 use Carp;
  6         16  
  6         2064  
1172              
1173              
1174             sub create_with {
1175 6     6   131103 my ($self, $opts) = @_;
1176 6 50       30 $opts or croak 'must provide a hashref of values to create_with';
1177 6 50       28 $opts->{name} or croak 'must provide a name for the new cvterm';
1178              
1179             # cv and db default to 'null'
1180 6 50       26 $opts->{cv} = 'null' unless defined $opts->{cv};
1181 6 100       25 $opts->{db} = 'null' unless defined $opts->{db};
1182              
1183             # dbxref defaults to autocreated:
1184             $opts->{dbxref} = 'autocreated:'.$opts->{name}
1185 6 100       28 unless defined $opts->{dbxref};
1186              
1187             # if cv, dbxref, or db are row objects, make sure that they are
1188             # actually stored in the db, since we need to make foreign key
1189             # relationships to them
1190             $_->insert_or_update
1191 6         20 for grep ref, @{$opts}{qw| cv dbxref db |};
  6         27  
1192              
1193 6         44 my $schema = $self->result_source->schema;
1194              
1195             # use, find, or create the given cv
1196             my $cv = ref $opts->{cv} ? $opts->{cv}
1197             : $schema->resultset('Cv::Cv')
1198 6 50       361 ->find_or_create({ name => $opts->{cv} });
1199              
1200             # return our cvterm if it exists already
1201 6 50       47177 if( my $cvterm = $cv->find_related( 'cvterms',
1202             {
1203             name => $opts->{name},
1204             is_obsolete => '0',
1205             }) ) {
1206 0         0 return $cvterm;
1207             }
1208              
1209             # now figure out which dbxref to use (creating the dbxref and db if necessary)
1210 6         50877 my $dbx = _find_dbxref( $schema, $opts->{dbxref}, $opts->{db} );
1211              
1212             # and finally make a cvterm to go with the cv and dbxref we found
1213             return $cv->create_related( 'cvterms',
1214             { name => $opts->{name},
1215 6         60875 dbxref_id => $dbx->dbxref_id,
1216             }
1217             );
1218             }
1219             sub _find_dbxref {
1220 6     6   115 my ( $schema, $dbx, $db ) = @_;
1221              
1222             # if we have a dbxref object to begin with, use it
1223 6 50       26 return $dbx if ref $dbx;
1224              
1225             ### otherwise, need to find the db
1226 6 50       21 unless( ref $db ) {
1227             # convert db name string into object if necessary
1228 6         31 $db = $schema->resultset('General::Db')
1229             ->find_or_create({ name => $db });
1230             }
1231              
1232             #now find or create the dbxref from the db
1233 6         29445 return $db->find_or_create_related('dbxrefs',
1234             { accession => $dbx },
1235             );
1236             }
1237              
1238              
1239              
1240             1;
1241              
1242             __END__