[Bio] / Sprout / SHSigGenes.pm Repository:
ViewVC logotype

Annotation of /Sprout/SHSigGenes.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     package SHSigGenes;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :     use SearchHelper;
8 :     use CGI;
9 :     use HTML;
10 :     use Sprout;
11 :    
12 :     our @ISA = qw(SearchHelper);
13 :    
14 :     =head1 Gene Discrimination Feature Search Helper
15 :    
16 :     =head2 Introduction
17 :    
18 :     This search performs a signature genes comparison. The user selects two genome sets,
19 :     and the search returns genes from a given genome which are common only in the first set
20 :     and not in the second. If the second set is empty, the search will return genes from
21 :     the given genome that are common in the first set.
22 :    
23 :     Gene identity will be computed in this case using bidirectional best hits. If gene X
24 :     from the given genome has a BBH in a specified genome Y, then it is said to occur
25 :     in whatever set includes genome Y. A gene is considered I<common> if it occurs in a
26 :     certain percentage of the genomes of the set.
27 :    
28 :     This search has the following extra parameters.
29 :    
30 :     =over 4
31 :    
32 :     =item given
33 :    
34 :     The ID of the given genome.
35 :    
36 :     =item target[]
37 :    
38 :     The IDs of the genomes in the first (target) set. The given genome is
39 :     automatically considered a part of this set, so it can never be empty.
40 :    
41 :     =item exclusion[]
42 :    
43 :     The IDs of the genomes in the second (exclusion) set. If this set is empty, then
44 :     no genes will be considered common in set 2, causing all genes common in set 1
45 :     to be selected.
46 :    
47 :     =item commonality
48 :    
49 :     Minimum score for a gene to be considered common. The score is equal to the number
50 :     of genomes containing a bidirectional best hit of the gene divided by the total
51 :     number of genomes. The default is C<0.8>. A value of C<1> means a gene must have
52 :     BBHs in all of the genomes to be considered common; a value of C<0> is invalid.
53 :    
54 :     =item cutoff
55 :    
56 :     Maximum match difference for a BBH hit to be considered valid. The default is C<1e-10>.
57 :    
58 :     =back
59 :    
60 :     =head2 Virtual Methods
61 :    
62 :     =head3 Form
63 :    
64 :     C<< my $html = $shelp->Include(); >>
65 :    
66 :     Generate the HTML for a form to request a new search.
67 :    
68 :     =cut
69 :    
70 :     sub Form {
71 :     # Get the parameters.
72 :     my ($self) = @_;
73 :     # Get the CGI and sprout objects.
74 :     my $cgi = $self->Q();
75 :     my $sprout = $self->DB();
76 :     # Start the form.
77 :     my $retVal = $self->FormStart("Signature Genes");
78 :     # The bulk of this form will be two genome selection menus, one for the first
79 :     # (target) set and one for the second (exclusion) set. Above these two controls
80 :     # there is the selector for the given genome, the commonality and cutoff values,
81 :     # and the submit button. Our first task, then, is to get the genome selection
82 :     # menus.
83 :     my $givenMenu = $self->NmpdrGenomeMenu('given', { size => 1 }, [$cgi->param('genome')]);
84 :     my $targetMenu = $self->NmpdrGenomeMenu('target', { size => 10, multiple => 'multiple' },
85 :     [$cgi->param('target')]);
86 :     my $excludeMenu = $self->NmpdrGenomeMenu('exclusion', { size => 10, multiple => 'multiple' },
87 :     [$cgi->param('exclusion')]);
88 :     # Get the default values to use for the commonality and cutoff controls.
89 :     my $commonality = $cgi->param('commonality') || "0.8";
90 :     my $cutoff = $cgi->param('cutoff') || "1e-10";
91 :     # Now we build the table rows. The top contains the two numeric parameters and
92 :     # the submit button.
93 :     my @rows = ();
94 :     push @rows, $cgi->Tr($cgi->td("Commonality"),
95 :     $cgi->td($cgi->textfield(-name => 'commonality',
96 :     -value => $commonality,
97 :     -size => 5)));
98 :     push @rows, $cgi->Tr($cgi->td("Cutoff"),
99 :     $cgi->td($cgi->textfield(-name => 'cutoff',
100 :     -value => $cutoff,
101 :     -size => 5)));
102 :     push @rows, $self->SubmitRow();
103 :     # The next rows have the three genome menus.
104 :     push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Given Genome"),
105 :     $cgi->td({colspan => 2}, $givenMenu));
106 :     push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Target Genomes (Set 1)"),
107 :     $cgi->td({colspan => 2}, $targetMenu));
108 :     push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Exclusion Genomes (Set 2)"),
109 :     $cgi->td({colspan => 2}, $excludeMenu));
110 :     # Create the table.
111 :     $retVal .= $self->MakeTable(\@rows);
112 :     # Close the form.
113 :     $retVal .= $self->FormEnd();
114 :     # Return the result.
115 :     return $retVal;
116 :     }
117 :    
118 :     =head3 Find
119 :    
120 :     C<< my $resultCount = $shelp->Find(); >>
121 :    
122 :     Conduct a search based on the current CGI query parameters. The search results will
123 :     be written to the session cache file and the number of results will be
124 :     returned. If the search parameters are invalid, a result count of C<undef> will be
125 :     returned and a result message will be stored in this object describing the problem.
126 :    
127 :     =cut
128 :    
129 :     sub Find {
130 :     # Get the parameters.
131 :     my ($self) = @_;
132 :     # Get the sprout and CGI query objects.
133 :     my $cgi = $self->Q();
134 :     my $sprout = $self->DB();
135 :     # Declare the return variable.
136 :     my $retVal;
137 :    
138 :     # TODO: find stuff
139 :    
140 :     # Return the result count.
141 :     return $retVal;
142 :     }
143 :    
144 :     =head3 Description
145 :    
146 :     C<< my $htmlText = $shelp->Description(); >>
147 :    
148 :     Return a description of this search. The description is used for the table of contents
149 :     on the main search tools page. It may contain HTML, but it should be character-level,
150 :     not block-level, since the description is going to appear in a list.
151 :    
152 :     =cut
153 :    
154 :     sub Description {
155 :     # Get the parameters.
156 :     my ($self) = @_;
157 :     # Return the result.
158 :     return "Search for features that common to a group of organisms or that discriminate between two groups of organisms.";
159 :     }
160 :    
161 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3