/usr/share/perl5/GO/Model/Xref.pm is in libgo-perl 0.15-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | # $Id: Xref.pm,v 1.3 2005/02/11 05:44:56 cmungall Exp $
#
# This GO module is maintained by Chris Mungall <cjm@fruitfly.org>
#
# see also - http://www.geneontology.org
# - http://www.godatabase.org/dev
#
# You may distribute this module under the same terms as perl itself
package GO::Model::Xref;
=head1 NAME
GO::Model::Xref - cross reference to an external database
=head1 SYNOPSIS
my $xrefs = $term->dbxref_list();
foreach my $xref (@$xrefs) P
printf "Term %s has an xref %s:%s\n",
$term->name, $xref->xref_key, $xref->dbname;
}
=head1 DESCRIPTION
represents a cross reference to an external database. an Xref is made
up of a key (ie the accession number, or whatever the value of the
unique field being keyed off of is) and a database name. this should
theorerically be enough to uniquely identify any databased entity.
=head1 NOTES
Like all the GO::Model::* classes, this uses accessor methods to get
or set the attributes. by using the accessor method without any
arguments gets the value of the attribute. if you pass in an argument,
then the attribuet will be set according to that argument.
for instance
# this sets the value of the attribute
$my_object->attribute_name("my value");
# this gets the value of the attribute
$my_value = $my_object->attribute_name();
=cut
use Carp qw(cluck confess);
use Exporter;
use GO::Utils qw(rearrange);
use GO::Model::Root;
use strict;
use vars qw(@ISA);
@ISA = qw(GO::Model::Root Exporter);
sub _valid_params {
return qw(id xref_key xref_keytype xref_dbname xref_desc name);
}
sub _valid_dbnames {
return qw(go gxd sgd tair mgi fb sp sp_kw egad
ec medline pmid isbn omim embl publication U);
}
=head2 xref_key
Alias - acc
Alias - accession
Usage -
Returns -
Args -
accessor: gets/sets the key/id of the cross reference
=cut
sub xref_key {
my $self = shift;
$self->{xref_key} = shift if @_;
if ($self->{xref_dbname} &&
$self->{xref_dbname} =~ /interpro/i) {
if ($self->{xref_key} && $self->{xref_key} =~ /(\S+) (.*)/) {
$self->{xref_key} = $1;
$self->{xref_desc} = $2;
}
}
return $self->{xref_key};
}
*accession = \&xref_key;
*acc = \&xref_key;
=head2 xref_keytype
Usage -
Returns -
Args -
accessor: gets/sets the key/id type of the cross reference
=cut
sub xref_keytype {
my $self = shift;
$self->{xref_keytype} = shift if @_;
return $self->{xref_keytype};
}
=head2 as_str
Usage -
Returns -
Args -
=cut
sub as_str {
my $self=shift;
# cluck unless defined $self->xref_dbname;
# cluck unless defined $self->xref_key;
return $self->xref_dbname().":".$self->xref_key();
}
=head2 xref_dbname
Alias - dbname
Usage -
Returns -
Args -
accessor: gets/sets the database name of the cross reference
must be a valid database name
=cut
sub xref_dbname {
my $self = shift;
$self->{xref_dbname} = shift if @_;
return $self->{xref_dbname};
}
*dbname = \&xref_dbname;
=head2 xref_desc
Alias - name
Usage -
Returns -
Args -
accessor: gets/sets the description of the accession no
useful for interpro
=cut
sub xref_desc {
my $self = shift;
$self->{xref_desc} = shift if @_;
return $self->{xref_desc};
}
*name = \&xref_desc;
sub to_idl_struct {
my $self = shift;
return
{
dbname=>$self->xref_dbname,
keyvalue=>$self->xref_key,
};
}
=head2 to_xml
Usage - print $xref->to_xml()
Returns - string
Args - indent [integer]
XML representation; you probably shouldn't call this directly, this
will be called by entities that own xrefs
=cut
sub to_xml {
my $self = shift;
my $indent = shift || "";
my $text = $indent."<game:db_xref>\n";
$text .= $indent." <game:db_name>".
$self->xref_dbname."</game:db_name>\n";
if ( $self->xref_keytype ) {
if ( $self->xref_keytype =~ /personal communication/ ) {
$text .= $indent." <game:xref_type>".
$self->xref_keytype."</game:xref_type>\n";
$text .= $indent." <xref_person>".
$self->xref_key."</xref_person>\n";
}
else {
if ($self->xref_keytype !~ /acc/) {
$text .= $indent." <game:xref_type>".
$self->xref_keytype."</game:xref_type>\n";
}
$text .= $indent." <game:db_id>".
$self->xref_key."</game:db_id>\n";
}
}
else {
$text .= $indent." <game:db_id>".$self->xref_key."</game:db_id>\n";
}
$text .= $indent."</game:db_xref>\n";
return $text;
}
sub to_ptuples {
my $self = shift;
my ($th) =
rearrange([qw(tuples)], @_);
my @s = ();
my @desc = ($self->xref_desc);
pop @desc unless $desc[0];
push(@s,
["xref",
$self->as_str,
$self->xref_dbname,
$self->xref_key,
@desc,
]);
@s;
}
# **** EXPERIMENTAL CODE ****
# the idea is to be homogeneous and use graphs for
# everything; eg gene products are nodes in a graph,
# associations are arcs
# cf rdf, daml+oil etc
# args - optional graph to add to
sub graphify {
my $self = shift;
my ($ref, $subg, $opts) =
rearrange([qw(ref graph opts)], @_);
$opts = {} unless $opts;
$subg = $self->apph->create_graph_obj unless $subg;
my $t =
$self->apph->create_term_obj({name=>$self->as_str,
acc=>$self->as_str});
$subg->add_node($t);
$subg->add_arc($t, $ref, "hasXref");
return $subg;
}
1;
|