~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to Bio/Tools/Phylo/Gerp.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: Gumby.pm,v 1.2 2007/06/14 18:01:52 nathan Exp $
 
2
#
 
3
# BioPerl module for Bio::Tools::Phylo::Gerp
 
4
#
 
5
# Cared for by Sendu Bala <bix@sendu.me.uk>
 
6
#
 
7
# Copyright Sendu Bala
 
8
#
 
9
# You may distribute this module under the same terms as perl itself
 
10
 
 
11
# POD documentation - main docs before the code
 
12
 
 
13
=head1 NAME
 
14
 
 
15
Bio::Tools::Phylo::Gerp - Parses output from GERP
 
16
 
 
17
=head1 SYNOPSIS
 
18
 
 
19
  use strict;
 
20
 
 
21
  use Bio::Tools::Phylo::Gerp;
 
22
 
 
23
  my $parser = Bio::Tools::Phylo::Gerp->new(-file => "alignment.rates.elems");
 
24
 
 
25
  while (my $feat = $parser->next_result) {
 
26
    my $start = $feat->start;
 
27
    my $end = $feat->end;
 
28
    my $rs_score = $feat->score;
 
29
    my $p_value = ($feat->annotation->get_Annotations('p-value'))[0]->value;
 
30
  }
 
31
 
 
32
=head1 DESCRIPTION
 
33
 
 
34
This module is used to parse the output from 'GERP' (v2) by Eugene Davydov
 
35
(originally Gregory M. Cooper et al.). You can get details here:
 
36
http://mendel.stanford.edu/sidowlab/
 
37
 
 
38
It works on the .elems files produced by gerpelem.
 
39
 
 
40
Each result is a Bio::SeqFeature::Annotated representing a single constrained
 
41
element.
 
42
 
 
43
=head1 FEEDBACK
 
44
 
 
45
=head2 Mailing Lists
 
46
 
 
47
User feedback is an integral part of the evolution of this and other
 
48
Bioperl modules. Send your comments and suggestions preferably to
 
49
the Bioperl mailing list. Your participation is much appreciated.
 
50
 
 
51
  bioperl-l@bioperl.org                  - General discussion
 
52
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
53
 
 
54
=head2 Reporting Bugs
 
55
 
 
56
Report bugs to the Bioperl bug tracking system to help us keep track
 
57
of the bugs and their resolution. Bug reports can be submitted via the
 
58
web:
 
59
 
 
60
  http://bugzilla.open-bio.org/
 
61
 
 
62
=head1 AUTHOR - Sendu Bala
 
63
 
 
64
Email bix@sendu.me.uk
 
65
 
 
66
=head1 APPENDIX
 
67
 
 
68
The rest of the documentation details each of the object methods.
 
69
Internal methods are usually preceded with a _
 
70
 
 
71
=cut
 
72
 
 
73
# Let the code begin...
 
74
 
 
75
package Bio::Tools::Phylo::Gerp;
 
76
use strict;
 
77
 
 
78
use Bio::SeqFeature::Annotated;
 
79
use Bio::Annotation::SimpleValue;
 
80
 
 
81
use base qw(Bio::Root::Root Bio::Root::IO);
 
82
 
 
83
 
 
84
=head2 new
 
85
 
 
86
 Title   : new
 
87
 Usage   : my $obj = Bio::Tools::Phylo::Gerp->new();
 
88
 Function: Builds a new Bio::Tools::Phylo::Gerp object
 
89
 Returns : Bio::Tools::Phylo::Gerp
 
90
 Args    : -file (or -fh) should contain the contents of a gerpelem .elems file
 
91
 
 
92
=cut
 
93
 
 
94
sub new {
 
95
    my ($class, @args) = @_;
 
96
    my $self = $class->SUPER::new(@args);
 
97
    
 
98
    $self->_initialize_io(@args);
 
99
    
 
100
    return $self;
 
101
}
 
102
 
 
103
=head2 next_result
 
104
 
 
105
 Title   : next_result
 
106
 Usage   : $result = $obj->next_result();
 
107
 Function: Returns the next result available from the input, or undef if there
 
108
           are no more results.
 
109
 Returns : Bio::SeqFeature::Annotated object. Features are annotated with a tag
 
110
           for 'pvalue', and a 'predicted' tag. They have no sequence id unless
 
111
           the input GERP file is non-standard, with the seq id as the 6th
 
112
           column.
 
113
 
 
114
           NB: feature coordinates are alignment columns of the alignment
 
115
           used to create the result file.
 
116
 Args    : none
 
117
 
 
118
=cut
 
119
 
 
120
sub next_result {
 
121
    my ($self) = @_;
 
122
    
 
123
    my $line = $self->_readline || return;
 
124
    
 
125
    while ($line !~ /^\d+\s+\d+\s+\d+\s+\S+\s+\S+\s*(?:\S+\s*)?$/) {
 
126
        $line = $self->_readline || return;
 
127
    }
 
128
    
 
129
    #start   end     length  RS-score        p-value
 
130
    # code elsewhere adds seq_id on the end (not valid GERP), so we capture that
 
131
    # if present
 
132
    my ($start, $end, undef, $rs_score, $p_value, $seq_id) = split(/\s+/, $line);
 
133
    my $feat = Bio::SeqFeature::Annotated->new(
 
134
        $seq_id ? (-seq_id => $seq_id) : (),
 
135
        -start        => $start, 
 
136
        -end          => $end,
 
137
        -strand       => 1,
 
138
        -score        => $rs_score,
 
139
        #-type         => 'conserved_region', ***causes 740x increase in SeqFeatureDB storage requirments!
 
140
        -source       => 'GERP');
 
141
    
 
142
    my $sv = Bio::Annotation::SimpleValue->new(-tagname => 'predicted', -value => 1);
 
143
    $feat->annotation->add_Annotation($sv);
 
144
    $sv = Bio::Annotation::SimpleValue->new(-tagname => 'pvalue', -value => $p_value);
 
145
    $feat->annotation->add_Annotation($sv);
 
146
    
 
147
    return $feat;
 
148
}
 
149
 
 
150
1;