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

Annotation of /Sprout/RHLigands.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 RHLigands;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :     use ERDBObject;
8 :     use POSIX;
9 :     use base 'ResultHelper';
10 :    
11 :     =head1 Ligand Result Helper
12 :    
13 :     =head2 Introduction
14 :    
15 :     This result helper allows a search to display data about ligands. Currently,
16 :     there is very little data about a ligand in the database. The only
17 :     column we support is the ligand ID formatted with the name as a tooltip.
18 :    
19 :    
20 :     =head2 Public Methods
21 :    
22 :     =head3 new
23 :    
24 :     C<< my $rhelp = RHLigands->new($shelp); >>
25 :    
26 :     Construct a new RHLigands object.
27 :    
28 :     =over 4
29 :    
30 :     =item shelp
31 :    
32 :     Parent search helper object for this result helper.
33 :    
34 :     =back
35 :    
36 :     =cut
37 :    
38 :     sub new {
39 :     # Get the parameters.
40 :     my ($class, $shelp) = @_;
41 :     # Create and bless the helper object.
42 :     my $retVal = ResultHelper::new($class, $shelp);
43 :     # Return it.
44 :     return $retVal;
45 :     }
46 :    
47 :     =head3 DefaultResultColumns
48 :    
49 :     C<< my @colNames = $rhelp->DefaultResultColumns(); >>
50 :    
51 :     Return a list of the default columns to be used by searches with this
52 :     type of result. Note that the actual default columns are computed by
53 :     the search helper. This method is only needed if the search helper doesn't
54 :     care.
55 :    
56 :     The columns returned should be in the form of column names, all of which
57 :     must be defined by the result helper class.
58 :    
59 :     =cut
60 :    
61 :     sub DefaultResultColumns {
62 :     return qw(zincId);
63 :     }
64 :    
65 :     =head2 Column Methods
66 :    
67 :     =head3 zincId
68 :    
69 :     C<< my $colDatum = RHLigands::zincId($type => $rhelp, $key); >>
70 :    
71 :     This method computes the various things we need to know into order to process
72 :     the zincId column.
73 :    
74 :     =over 4
75 :    
76 :     =item type
77 :    
78 :     Type of data about the column that is required: C<title> for the column title,
79 :     C<download> for the download flag (TRUE if the field should be included in
80 :     a standard tab-delimited download file and FALSE otherwise), and so forth.
81 :    
82 :     =item rhelp
83 :    
84 :     Result helper being used to format the search output.
85 :    
86 :     =item key (optional)
87 :    
88 :     The key to be used to compute a run-time value.
89 :    
90 :     =item RETURN
91 :    
92 :     Returns the desired information about the zincId column.
93 :    
94 :     =back
95 :    
96 :     =cut
97 :    
98 :     sub zincId {
99 :     # Get the parameters.
100 :     my ($type, $rhelp, $key) = @_;
101 :     # Declare the return variable.
102 :     my $retVal;
103 :     # Process according to the information requested.
104 :     if ($type eq 'title') {
105 :     # Return the title for this column.
106 :     $retVal = 'ZINC ID';
107 :     } elsif ($type eq 'download') {
108 :     # This field should be included in a download.
109 :     $retVal = 'text';
110 :     } elsif ($type eq 'style') {
111 :     # Here the caller wants the style class used to format this column.
112 :     $retVal = 'leftAlign';
113 :     } elsif ($type eq 'value') {
114 :     # Get the ligand record.
115 :     my $record = $rhelp->Record();
116 :     # Extract the ID and name.
117 :     my ($id, $name) = $record->Values(['Ligand(id)', 'Ligand(name)']);
118 :     # Get the CGI object.
119 :     my $cgi = $rhelp->Q();
120 :     # Create a tooltip for the ligand name.
121 :     $retVal = $cgi->a({ href => "http://blaster.docking.org/zinc/srchdbk.pl?zinc=$id;go=Query",
122 :     title => $name }, $id);
123 :     } elsif ($type eq 'runTimeValue') {
124 :     # Runtime support is not needed for this column.
125 :     }
126 :     return $retVal;
127 :     }
128 :    
129 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3