/usr/share/perl5/GO/Model/Seq.pm is in libgo-perl 0.13-3.
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 | # $Id: Seq.pm,v 1.4 2005/01/25 06:17:28 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::Seq;
=head1 NAME
GO::Model::Seq - biological sequence
=head1 SYNOPSIS
print $gene_product->seq->seq;
=head1 DESCRIPTION
represents a biological sequence; uses the bioperl Bio::PrimarySeq class
any call that you can do on a bioperl sequence object, you can do
here, with the addition of the calls below
to get bioperl, see http://www.bioperl.org
=cut
use Carp;
use Exporter;
use GO::Utils qw(rearrange);
use GO::Model::Root;
use strict;
use vars qw(@ISA $AUTOLOAD);
@ISA = qw(GO::Model::Root Exporter);
sub _valid_params {
return qw(id xref_list pseq description);
}
sub _initialize
{
my $self = shift;
my ($paramh) = @_;
my @bpargs = @_;
my %h = ();
if (ref($paramh) eq "HASH") {
@bpargs = ();
foreach my $k (keys %$paramh) {
if (grep {$k eq $_} $self->_valid_params) {
$h{$k} = $paramh->{$k};
}
else {
push(@bpargs, "-".$k, $paramh->{$k});
}
}
}
require "Bio/PrimarySeq.pm";
my $pseq = Bio::PrimarySeq->new(@bpargs);
$self->pseq($pseq);
$self->SUPER::_initialize(\%h);
}
=head2 pseq
Usage -
Returns - Bio::PrimarySeq
Args -
=cut
sub pseq {
my $self = shift;
if (@_) {
$self->{pseq} = shift;
if ($self->{pseq}->isa("Bio::Seq::RichSeqI")) {
my $annot = $self->{pseq}->annotation;
# foreach my $link ( $annot->each_DBLink ) {
foreach my $link ( $annot->get_Annotations('dblink') ) {
my $xref =
GO::Model::Xref->new;
$xref->xref_key($link->primary_id);
$xref->xref_dbname($link->database);
$self->add_xref($xref);
}
}
}
return $self->{pseq};
}
sub id {
my $self = shift;
$self->{id} = shift if @_;
return $self->{id};
}
sub residues {shift->pseq->seq(@_)}
=head2 md5checksum
Usage - my $md5 = $seq->md5checksum() OR $seq->md5checksum($md5)
Returns - 32 char hex string
Args - 32 char hex string [optional]
checksum for seq - easy way to check if it has been changed etc
(requires Digest::MD5 module from CPAN)
=cut
sub md5checksum {
my $self = shift;
# we want to be able to manipulte the checksum
# even if the actual residues are not in memory at this time
if (@_) {
$self->{md5checksum} = shift;
}
my $res = $self->pseq->seq();
if (!$res) {
return $self->{md5checksum};
}
require "Digest/MD5.pm";
my $md5 = Digest::MD5->new;
$md5->add($self->residues);
my $hex = $md5->hexdigest;
$self->{md5checksum} = $hex;
return $self->{md5checksum};
}
=head2 to_fasta
Usage -
Returns -
Args -
=cut
sub to_fasta {
my $self = shift;
my $res = $self->seq;
$res =~ s/(.{50})/$1\n/g;
my $hdr = $self->description || $self->display_id;
# my $hdr = $self->display_id;
return
sprintf(">%s\n%s\n",
$hdr,
$res);
}
=head2 add_xref
- Usage : $term->add_xref($xref);
- Args : GO::Term::Xref
=cut
sub add_xref {
my $self = shift;
if (@_) {
my $xref = shift;
$self->xref_list([]) unless $self->xref_list;
$xref->isa("GO::Model::Xref") || confess("Not an Xref");
push(@{$self->xref_list}, $xref);
}
}
# delegate calls to Bio::Seq object
sub AUTOLOAD {
my $self = shift || confess;
my $name = $AUTOLOAD;
$name =~ s/.*://; # strip fully-qualified portion
if ($name eq "DESTROY") {
# we dont want to propagate this!!
return;
}
if (!$self->pseq) { confess("assertion error") }
if ($self->pseq->can($name)) {
return $self->pseq->$name(@_);
}
if ($self->is_valid_param($name)) {
$self->{$name} = shift if @_;
return $self->{$name};
}
else {
confess("can't do $name on $self");
}
}
1;
|