6 ## to do: add concept of trait short name; provide alternate constructors for term, shortname, and synonyms etc.
8 has
'bcs_schema' => ( isa
=> 'Bio::Chado::Schema',
13 has
'cvterm_id' => (isa
=> 'Int',
18 has
'cvterm' => ( isa
=> 'Bio::Chado::Schema::Result::Cv::Cvterm',
22 has
'name' => ( isa
=> 'Str',
27 return $self->cvterm->name();
32 has
'display_name' => (isa
=> 'Str',
38 my $name = $self->name();
39 my $accession = $self->accession();
40 #print STDERR $db." ".$name." ".$accession."\n";
41 if ($db && $name && $accession ) {
42 return $name ."|".$db.":".$accession;
48 has
'accession' => (isa
=> 'Str',
53 my $rs = $self->bcs_schema()->resultset("Cv::Cvterm")
54 -> search
( { cvterm_id
=> $self->cvterm_id() })
55 -> search_related
("dbxref");
56 if ($rs->count() ==1) {
57 my $accession = $rs->first()->get_column("accession");
65 has
'term' => (isa
=> 'Str',
70 my $accession = $self->accession();
72 if ($accession && $db) {
73 return "$db:$accession";
79 has
'db' => ( isa
=> 'Str',
84 my $rs = $self->bcs_schema()->resultset("Cv::Cvterm")->search( { cvterm_id
=> $self->cvterm_id()})->search_related("dbxref")->search_related("db");
85 if ($rs->count() == 1) {
86 my $db_name = $rs->first()->get_column("name");
87 #print STDERR "DBNAME = $db_name\n";
101 my $rs = $self->cvterm->search_related("dbxref");
102 if ($rs->count() == 1) {
103 my $db_id = $rs->first()->get_column("db_id");
104 #print STDERR "DBID = $db_id\n";
111 has
'definition' => (isa
=> 'Maybe[Str]',
116 return $self->cvterm->definition();
121 has
'format' => (isa
=> 'Str',
127 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
129 cvterm_id
=> $self->cvterm_id(), 'type.name' => 'trait_format'
135 return $row->value();
141 has
'default_value' => (
147 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
148 { cvterm_id
=> $self->cvterm_id(), 'type.name' => 'trait_default_value' },
153 return $row->value();
165 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
166 { cvterm_id
=> $self->cvterm_id(), 'type.name' => 'trait_minimum' },
171 return $row->value();
183 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
184 { cvterm_id
=> $self->cvterm_id(), 'type.name' => 'trait_maximum' },
189 return $row->value();
195 has
'categories' => (
201 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
202 { cvterm_id
=> $self->cvterm_id(), 'type.name' => 'trait_categories' },
207 return $row->value();
213 has
'associated_plots' => ( isa
=> 'Str',
216 default => sub { "not yet implemented" }
219 has
'associated_accessions' => ( isa
=> 'Str',
222 default => sub { "not yet implemented" }
225 has
'uri' => (isa
=> 'Str',
230 my $row = $self->bcs_schema()->resultset("Cv::Cvtermprop")->find(
231 {cvterm_id
=> $self->cvterm_id(), 'type.name' => 'uri'},
236 return $row->value();
243 #print STDERR "BUILDING...\n";
245 my $cvterm = $self->bcs_schema()->resultset("Cv::Cvterm")->find( { cvterm_id
=> $self->cvterm_id() });
247 #print STDERR "Cvterm with ID ".$self->cvterm_id()." was found!\n";
249 $self->cvterm($cvterm);