1 #---------------------------------------------------------
3 #ISA SiteMatrix, HAS InstanceSite
7 Bio::Matrix::PSM::Psm - handle combination of site matricies
11 use Bio::Matrix::PSM::IO;
13 #To get a Psm object from a file use the Psm parser:
14 my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'meme', -file=>$file);
16 # Now go through all entities in the file with next_psm, which
17 # returns a Psm object see Bio::Matrix::PSM::IO for detailed
18 # documentation (matrix predictions or matrix sequence matches or
21 while (my $psm=$psmIO->next_psm) {
22 my %psm_header=$psm->header;
23 my $ic=$psm_header{IC};
24 my $sites=$psm_header{sites};
25 my $width=$psm_header{width};
26 my $score=$psm_header{e_val};
27 my $IUPAC=$psm->IUPAC;
28 my $instances=$psm->instances;
29 foreach my $instance (@{$instances}) {
30 my $id=$instance->primary_id;
31 #Do something with the id
35 #or create from memmory:
36 my $psm= Bio::Matrix::PSM::Psm->new( -pA=>\@pA,-pC=>\@pC,-pG=>\@pG,-pT=>\@pT,
38 -instances=>$instances, -e_val=>$e_val,
39 -IC=>$ic, -width=>$width, -sites=>$sites)
41 # where pA through pG are the respective frequencies of the matrix (see also
42 # Bio::Matrix::PSM::SiteMatrix), and everything else is self-explenatory,
43 # except for -instances (reference to an array of
44 # Bio::Matrix::PSM::InstanceSite objects) which is documented below.
48 To handle a combination of site matrices and/or their corresponding
49 sequence matches (instances). This object inherits from
50 Bio::Matrix::PSM::SiteMatrix, so you can use the respective
51 methods. It may hold also an array of Bio::Matrix::PSM::InstanceSite
52 object, but you will have to retrieve these through
53 Bio::Matrix::PSM::Psm-E<gt>instances method (see below). To some extent
54 this is an expanded SiteMatrix object, holding data from analysis that
55 also deal with sequence matches of a particular matrix.
60 This does not make too much sense to me I am mixing PSM with PSM
61 sequence matches Though they are very closely related, I am not
62 satisfied by the way this is implemented here. Heikki suggested
63 different objects when one has something like meme But does this mean
64 we have to write a different objects for mast, meme, transfac,
65 theiresias, etc.? To me the best way is to return SiteMatrix object +
66 arrray of InstanceSite objects and then mast will return undef for
67 SiteMatrix and transfac will return undef for InstanceSite. Probably I
68 cannot see some other design issues that might arise from such
69 approach, but it seems more straightforward. Hilmar does not like
70 this because it is an exception from the general BioPerl rules Should
71 I leave this as an option? Also the header rightfully belongs the
72 driver object, and could be retrieved as hashes. I do not think it
73 can be done any other way, unless we want to create even one more
74 object with very unclear content.
80 User feedback is an integral part of the evolution of this
81 and other Bioperl modules. Send your comments and suggestions preferably
82 to one of the Bioperl mailing lists.
83 Your participation is much appreciated.
85 bioperl-l@bioperl.org - General discussion
86 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
90 Please direct usage questions or support issues to the mailing list:
92 I<bioperl-l@bioperl.org>
94 rather than to the module maintainer directly. Many experienced and
95 reponsive experts will be able look at the problem and quickly
96 address it. Please include a thorough description of the problem
97 with code and data examples if at all possible.
101 Report bugs to the Bioperl bug tracking system to help us keep track
102 the bugs and their resolution. Bug reports can be submitted via the
105 https://github.com/bioperl/bioperl-live/issues
107 =head1 AUTHOR - Stefan Kirov
114 This software is provided "as is" without warranty of any kind.
118 SiteMatrix, meme, transfac, InstanceSite
125 # Let the code begin...
126 package Bio
::Matrix
::PSM
::Psm
;
127 use Bio
::Matrix
::PSM
::InstanceSite
;
130 use base
qw(Bio::Matrix::PSM::SiteMatrix Bio::Matrix::PSM::PsmI Bio::Annotation::Collection);
132 @Bio::Matrix
::PSM
::Psm
::HEADER
= qw(e_val sites IC width);
137 Usage : my $psm= Bio::Matrix::PSM::Psm->new( -pA=>\@pA,-pC=>\@pC,
138 -pG=>\@pG,-pT=>\@pT,-id=>$id,
139 -instances=>$instances,
141 -IC=>$ic, -width=>$width,
143 Function: Creates a new Bio::Matrix::PSM::Psm object
146 Returns : Bio::Matrix::PSM::Psm object
153 my ($caller,@args) = @_;
154 my $class = ref($caller) || $caller;
155 my $self = $class->SUPER::new
(@args);
156 $self->{'_annotation'} = {}; #Init from Annotation::Collection
157 $self->_typemap(Bio
::Annotation
::TypeManager
->new()); #same
158 ($self->{instances
})=$self->_rearrange(['INSTANCES'], @args);
166 Usage : my @instances=@{$psm->instances};
167 Function: Gets/sets the instances (Bio::Matrix::PSM::InstanceSite objects)
168 associated with the Psm object
171 Returns : array reference (Bio::Matrix::PSM::InstanceSite objects)
172 Args : array reference (Bio::Matrix::PSM::InstanceSite objects)
178 my $prev = $self->{instances
};
179 if (@_) { $self->{instances
} = shift; }
187 Usage : my %header=$psm->header;
188 my $ic=$psm->header('IC');
189 Function: Gets the general information, common for most files,
190 dealing with PSM such as information content (IC), score
191 (e-value, etc.), number of sites (sites) and width. This
192 list may expand. The current list should be in
193 @Bio::Matrix::PSM::Psm::HEADER. Returns undef if an
194 argument is supplied that is not in
195 @Bio::Matrix::PSM::meme::HEADER.
198 Returns : hash or string
199 Args : string (IC, e_val...)
205 return if ($self->{end
});
207 if (@_) {my $key=shift; return $self->{$key}; }
208 foreach my $key (@Bio::Matrix
::PSM
::Psm
::HEADER
) {
209 $header{$key}=$self->{$key};
218 Usage : my $matrix=$psm->matrix;
219 Function: Gets/sets the SiteMatrix related information
222 Returns : Bio::Matrix::PSM::SiteMatrix objects
223 Args : Bio::Matrix::PSM::SiteMatrix objects
230 my $prev = Bio
::Matrix
::PSM
::SiteMatrix
->new(-pA
=>$self->{probA
},
239 -e_val
=>$self->{e_val
},
243 $self->{IC
} = $matrix->IC;
244 $self->{probA
}=$matrix->{probA
};
245 $self->{probC
}=$matrix->{probC
};
246 $self->{probG
}=$matrix->{probG
};
247 $self->{probT
}=$matrix->{probT
};
248 $self->{e_val
}=$matrix->e_val;
249 $self->{id
}=$matrix->id;