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

View of /Sprout/SHDrugSearch.pm

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Wed Nov 8 23:18:54 2006 UTC (12 years, 11 months ago) by parrello
Branch: MAIN
Added to display drug target data.

#!/usr/bin/perl -w

package SHDrugSearch;

    use strict;
    use Tracer;
    use SearchHelper;
    use CGI;
    use HTML;
    use Sprout;
    use FeatureData;
    use FeatureQuery;

    our @ISA = qw(SearchHelper);

=head1 Drug Target Project Summary Feature Search Helper

=head2 Introduction

This search helper will display all the features that participated in a particular
drug target project. Each project represents a single study, generally related
to a specified organism. The study finds PDBs that are good drug target
candidates, and these are connected to the relevant B<DrugTargetProject> entity
instance in the database. From the PDB, we can get a list of the related
features, and these features are the ones we return in the search.

This search has the following extra parameters in addition to the ones
produced by the B<SpecialOptions> method of the B<FeatureQuery> object.

=over 4

=item project

ID of the drug target project to display.


=head2 Virtual Methods

=head3 Form

C<< my $html = $shelp->Include(); >>

Generate the HTML for a form to request a new search.


sub Form {
    # Get the parameters.
    my ($self) = @_;
    # Get the CGI and sprout objects.
    my $cgi = $self->Q();
    my $sprout = $self->DB();
    # Start the form.
    my $retVal = $self->FormStart("Select Drug Target Project");
    # Get a list of all the projects.
    my @projectNames = $sprout->GetFlat(['DrugProject'], "", [], 'DrugProject(id)');
    # See if there's already a project selected.
    my $defaultProject = $cgi->param('project');
    # Convert the project list into a drop-down menu.
    my $menu = $cgi->popup_menu(-name => 'project', -values => \@projectNames,
                                -default => $defaultProject);
    # Build a table from the drop-down menu, the special options, and the submit row.
    my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),
    $retVal .= $self->MakeTable(\@rows);
    # Close the form.
    $retVal .= $self->FormEnd();
    # Return the result.
    return $retVal;

=head3 Find

C<< my $resultCount = $shelp->Find(); >>

Conduct a search based on the current CGI query parameters. The search results will
be written to the session cache file and the number of results will be
returned. If the search parameters are invalid, a result count of C<undef> will be
returned and a result message will be stored in this object describing the problem.


sub Find {
    my ($self) = @_;
    # Get the CGI and Sprout objects.
    my $cgi = $self->Q();
    my $sprout = $self->DB();
    # Declare the return variable. If it remains undefined, the caller will
    # know that an error occurred.
    my $retVal;
    # Insure a project is selected.
    my $project = $cgi->param('project');
    if (! $project) {
        $self->SetMessage("No project specified.");
    } else {
        # Initialize the session file.
        # Initialize the result counter.
        $retVal = 0;
        # Get a query that will return the features for the project. 
        my $query= $sprout->Get(['ContainsTopic', 'ContainsAnalysisOf', 'PDB',
                                 'DescribesProteinForFeature', 'Feature'],
                                "ContainsTopic(from-link) = ?", [$project]);
        # Create a feature data object to manage our results.
        my $fd = FeatureData->new($self);
        # Loop through the results.
        while (my $record = $query->Fetch()) {
            # Validate the PDB ID.
            my ($pdb) = $record->Value('DescribesProteinForFeature(from-link)');
            if ($pdb =~ /^pdb([^.]+)\./i) {
                # Here we're okay, so we yank out the real PDB ID from the file title and
                # apply a link.
                my $pdbID = $1;
                my $pdbInfo = $cgi->a({href => "http://www.rcsb.org/pdb/explore.do?structureId=$pdbID",
                                      title => "display this protein's page in the Protein Data Bank",
                                      alt =>  "display this protein's page in the Protein Data Bank",
                                      target => "_blank"}, $pdbID);
                # Get the PDB title.
                my ($pdbTitle) = $record->Value('PDB(title)');
                # Store this feature in the data object.
                # Add the PDB columns.
                $fd->AddExtraColumns('Free PDB' => $pdbInfo, 'Title' => $pdbTitle);
                # Put it in the results list.
            } else {
                # Here the PDB didn't have the format we expected.
                Confess("Invalid PDB ID \"$pdb\" found in database.")
        # Close the session file.
    # Return the result count.
    return $retVal;

=head3 DefaultFeatureColumns

C<< my @cols = $shelp->DefaultFeatureColumns(); >>

This method returns a list of the descriptors for the columns to be
displayed by this search, overriding the standard column set.


sub DefaultFeatureColumns {
    # Get the parameters.
    my ($self) = @_;
    # Return the result.
    return qw(orgName function protlink);

=head3 Description

C<< my $htmlText = $shelp->Description(); >>

Return a description of this search. The description is used for the table of contents
on the main search tools page. It may contain HTML, but it should be character-level,
not block-level, since the description is going to appear in a list.


sub Description {
    # Get the parameters.
    my ($self) = @_;
    # Return the result.
    return "Show the PDB and feature relationships for a specified drug target analysis project.";


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3