Read.pm

- NAME
- SYNOPSIS
- DESCRIPTION
- LICENSE
- FEEDBACK
- AUTHOR - Steve Mathias
- DETAILS
- Imported Packages
- Inheritance
- Public Methods

- getCluster
- getMiniCluster
- getSubject
- getMiniSubject
- getKindred
- getMiniKindred
- getMarker
- getMiniMarker
- getMiniMarkerByName
- getSNP
- getMiniSNP
- getGenotype
- getMiniGenotype
- getStudyVariable
- getMiniStudyVariable
- getPhenotype
- getMiniPhenotype
- getFrequencySource
- getMiniFrequencySource
- getHtMarkerCollection
- getHaplotype
- getMiniHaplotype
- getDNASample
- getTissueSample
- getMap
- getMiniMap

- Private methods

- _getObjAssocData

# NAME

Genetics::API::DB::Read

# SYNOPSIS

      use Genetics::API ;

      $api = new Genetics::API(DSN => {driver => "mysql",
                                       host => $Host,
                                       database => $Database},
                               user => $UserName,
                               password => $Password) ;

      $id = 123456 ;
      $subject = $api->getSubject($id) ;

# DESCRIPTION

The Genetics::API::DB packages provide an interface for the manipulation of Genperl objects in a relationa; database. This package contains the methods for retrieving objects from a database by id. To retrieve objects using more complex criteria, see Genetics::API::DB::Query.

Two versions of get methods are provided for most object types. One returns ``full'' objects containing all the data in the database associated with an object id; the other returns ``mini'' objects containing only a subset of the data associated with an object. Generally, the getMini methods do not return any of the general object annotation fields (ie. things like Keywords, DBXReferences, etc. are not returned with ``mini'' objects). In some cases, certain class-specific data is also left out of ``mini'' objects. See the individual getMini method descriptions for details on this.

# LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# FEEDBACK

Currently, all feedback should be sent directly to the author.

# AUTHOR - Steve Mathias

Email: mathias@genomica.com

Phone: (720) 565-4029

Address: Genomica Corporation 1745 38th Street Boulder, CO 80301

# DETAILS

The rest of the documentation describes each of the object variables and methods. The names of internal variables and methods are preceded with an underscore (_).

# Imported Packages

     strict             Just to be anal
     vars               Global variables
     Carp               Error reporting

# Inheritance

     Exporter           Make methods available to importing packages

# Public Methods

## getCluster

      Function  : Get (read) a Genetics::Object::Cluster object from the database.
      Argument  : The Object ID of the Cluster to be returned.
      Returns   : A Genetics::Object::Cluster object.
      Scope     : Public

## getMiniCluster

      Function  : Get a "light" version of a Genetics::Object::Cluster object
                  from the database.
      Argument  : The Object ID of the Cluster to be returned.
      Returns   : A Genetics::Object::Cluster object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.

## getSubject

      Function  : Get (read) a Genetics::Object::Subject object from the database.
      Argument  : The Object ID of the Subject to be returned.
      Returns   : A Genetics::Object::Subject object.
      Scope     : Public

## getMiniSubject

      Function  : Get a "light" version of a Genetics::Object::Subject object from
                  the database, by id.
      Argument  : The Object ID of the Subject to be returned.
      Returns   : A Genetics::Object::Subject object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  Subject-specific fields.

## getKindred

      Function  : Get (read) a Genetics::Object::Kindred object from the database.
      Argument  : The Object ID of the Kindred to be returned.
      Returns   : A Genetics::Object::Kindred object.
      Scope     : Public

## getMiniKindred

      Function  : Get a "light" version of a Genetics::Object::Kindred object from
                  the database.
      Argument  : The Object ID of the Kindred to be returned.
      Returns   : A Genetics::Object::Kindred object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.

## getMarker

      Function  : Get (read) a Genetics::Object::Marker object from the database.
      Argument  : The Object ID of the Marker to be returned.
      Returns   : A Genetics::Object::Marker object.
      Scope     : Public

## getMiniMarker

      Function  : Get a "light" version of a Genetics::Object::Marker object from the
                  database.
      Argument  : The Object ID of the Marker to be returned.
      Returns   : A Genetics::Object::Marker object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  Marker-specific fields.

## getMiniMarkerByName

      Function  : Get a "light" version of a Genetics::Object::Marker object from the
                  database, by name.
      Argument  : The name of the Marker to be returned.
      Returns   : A Genetics::Object::Marker object.
      Scope     : Public
      Comments  : If there is more than one Marker object with the same name, this
                  will only return ONE of them.  Which one?  Good question.  Caveat
                  Programmor!
                  "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.

## getSNP

      Function  : Get (read) a Genetics::Object::SNP object from the database.
      Argument  : The Object ID of the SNP to be returned.
      Returns   : A Genetics::Object::SNP object.
      Scope     : Public

## getMiniSNP

      Function  : Get a "light" version of a Genetics::Object::SNP object from the
                  database.
      Argument  : The Object ID of the SNP to be returned.
      Returns   : A Genetics::Object::SNP object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  SNP-specific fields.

## getGenotype

      Function  : Get (read) a Genetics::Object::Genotype object from the database.
      Argument  : The Object ID of the Genotype to be returned.
      Returns   : A Genetics::Object::Genotype object.
      Scope     : Public

## getMiniGenotype

      Function  : Get a "light" version of a Genetics::Object::Genotype object from
                  the database.
      Argument  : The Object ID of the Genotype to be returned.
      Returns   : A Genetics::Object::Genotype object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  Genotype-specific fields.

## getStudyVariable

      Function  : Get (read) a Genetics::Object::StudyVariable object from the database.
      Argument  : The Object ID of the StudyVariable to be returned.
      Returns   : A Genetics::Object::StudyVariable object.
      Scope     : Public

## getMiniStudyVariable

      Function  : Get a "light" version of a Genetics::Object::StudyVariable object
                  from the database.
      Argument  : The Object ID of the StudyVariable to be returned.
      Returns   : A Genetics::Object::StudyVariable object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  StudyVariable-specific fields.
    =cut

sub getMiniStudyVariable { my($self, $id) = @_ ; my($sv, %param, $sth, $sth1, $arrRef, $arrRef1, %init, %init1, $category, $format, @codesList, @aseList, @lcList, $p11, $p12, $p22, $mp1, $mp2) ; my $dbh = $self->{dbh} ;

      $DEBUG and carp " ->[getMiniStudyVariable] $id" ;

      # StudyVariable data
      $sth = $dbh->prepare("select name, id, dateCreated, dateModified, comment,
                                   category, format, isXLinked, description
                            from Object, StudyVariable
                            where id = $id
                            and id = studyVariableID") ;
      $sth->execute() ;
      $arrRef = $sth->fetchrow_arrayref() ;
      $sth->finish() ;
      defined $arrRef or return(undef) ;

      $param{name} = $$arrRef[0] ;
      $param{id} = $$arrRef[1] ;
      $param{dateCreated} = $$arrRef[2] ;
      $param{dateModified} = $$arrRef[3] ;
      $param{comment} = $$arrRef[4] ;
      $category = $param{category} = $$arrRef[5] ;
      $format = $param{format} = $$arrRef[6] ;
      $param{isXLinked} = $$arrRef[7] ;
      defined $$arrRef[8] and $param{description} = $$arrRef[8] ;
      # CodeDerivation data
      if ($format eq "Code") {
        if ($category eq "StaticLiabilityClass") {
          $sth = $dbh->prepare("select codeDerivationID, code, description, formula
                              from CodeDerivation
                              where studyVariableID = $id") ;
          $sth->execute() ;
          $sth1 = $dbh->prepare("select pen11, pen12, pen22, malePen1, malePen2
                                 from StaticLCPenetrance
                                 where cdID = ?") ;
          while ($arrRef = $sth->fetchrow_arrayref()) {
            %init = () ;
            $sth1->execute($$arrRef[0]) ;
            ($p11, $p12, $p22, $mp1, $mp2) = $sth1->fetchrow_array() ;
            $init{code} = $$arrRef[1] ;
            $init{pen11} = $p11 ;
            $init{pen12} = $p12 ;
            $init{pen22} = $p22 ;
            defined $mp1 and $init{malePen1} = $mp1 ;
            defined $mp2 and $init{malePen2} = $mp2 ;
            defined $$arrRef[2] and $init{description} = $$arrRef[2] ;
            defined $$arrRef[3] and $init{formula} = $$arrRef[3] ;
            push(@codesList, { %init }) ;
          }
        } else {
          $sth = $dbh->prepare("select code, description, formula
                                from CodeDerivation
                                where studyVariableID = $id") ;
          $sth->execute() ;
          while ($arrRef = $sth->fetchrow_arrayref()) {
            %init = () ;
            $init{code} = $$arrRef[0] ;
            defined $$arrRef[1] and $init{description} = $$arrRef[1] ;
            defined $$arrRef[2] and $init{formula} = $$arrRef[2] ;
            push(@codesList, { %init }) ;
          }
        }
      }
      defined $codesList[0] and $param{Codes} = \@codesList ;

      if ($category =~ /AffectionStatus$/) {
        # AffectionStatus data
        $sth = $dbh->prepare("select name, diseaseAlleleFreq, pen11, pen12,
                                     pen22, malePen1, malePen2, asDefID
                              from AffectionStatusDefinition
                              where studyVariableID = $id") ;
        $sth->execute() ;
        if ( defined ($arrRef = $sth->fetchrow_arrayref()) ) {
          %init = () ;
          $init{name} = $$arrRef[0] ;
          $init{diseaseAlleleFreq} = $$arrRef[1] ;
          $init{pen11} = $$arrRef[2] ;
          $init{pen12} = $$arrRef[3] ;
          $init{pen22} = $$arrRef[4] ;
          defined $$arrRef[5] and $init{malePen1} = $$arrRef[5] ;
          defined $$arrRef[6] and $init{malePen2} = $$arrRef[6] ;
          # Elements
          $sth1 = $dbh->prepare("select code, type, formula
                                 from AffectionStatusElement
                                 where asDefID = $$arrRef[7]") ;
          $sth1->execute() ;
          while ($arrRef1 = $sth1->fetchrow_arrayref()) {
            push(@aseList, {code => $$arrRef1[0],
                            type => $$arrRef1[1],
                            formula => $$arrRef1[2]}) ;
          }
          $init{AffStatElements} = \@aseList ;
          $param{AffStatDef} = { %init } ;
        }
      }

      $sv = new Genetics::StudyVariable(%param) ;

      $DEBUG and carp " ->[getMiniStudyVariable] $sv" ;

      return($sv) ;
    }

## getPhenotype

      Function  : Get (read) a Genetics::Object::Phenotype object from the database.
      Argument  : The Object ID of the Phenotype to be returned.
      Returns   : A Genetics::Object::Phenotype object.
      Scope     : Public

## getMiniPhenotype

      Function  : Get a "light" version of a Genetics::Object::Phenotype object from
                  the database.
      Argument  : The Object ID of the Phenotype to be returned.
      Returns   : A Genetics::Object::Phenotype object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  Phenotype-specific fields.

## getFrequencySource

      Function  : Get (read) a Genetics::Object::FrequencySource object from the database.
      Argument  : The Object ID of the FrequencySource to be returned.
      Returns   : A Genetics::Object::FrequencySource object.
      Scope     : Public

## getMiniFrequencySource

      Function  : Get (read) a Genetics::Object::FrequencySource object from the database.
      Argument  : The Object ID of the FrequencySource to be returned.
      Returns   : A Genetics::Object::FrequencySource object.
      Scope     : Public

## getHtMarkerCollection

      Function  : Get (read) a Genetics::Object::HtMarkerCollection object from the database.
      Argument  : The Object ID of the HtMarkerCollection to be returned.
      Returns   : A Genetics::Object::HtMarkerCollection object.
      Scope     : Public

## getHaplotype

      Function  : Get (read) a Genetics::Object::Haplotype object from the database.
      Argument  : The Object ID of the Haplotype to be returned.
      Returns   : A Genetics::Object::Haplotype object.
      Scope     : Public

## getMiniHaplotype

      Function  : Get a "light" version of a Genetics::Object::Haplotype object
                  from the database.
      Argument  : The Object ID of the Haplotype to be returned.
      Returns   : A Genetics::Object::Haplotype object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.

## getDNASample

      Function  : Get (read) a Genetics::Object::DNASample object from the database.
      Argument  : The Object ID of the DNASample to be returned.
      Returns   : A Genetics::Object::DNASample object.
      Scope     : Public

## getTissueSample

      Function  : Get (read) a Genetics::Object::TissueSample object from the database.
      Argument  : The Object ID of the TissueSample to be returned.
      Returns   : A Genetics::Object::TissueSample object.
      Scope     : Public

## getMap

      Function  : Get (read) a Genetics::Object::Map object from the database.
      Argument  : The Object ID of the Map to be returned.
      Returns   : A Genetics::Object::Map object.
      Scope     : Public

## getMiniMap

      Function  : Get "light" version of a Genetics::Object::Map object from
                  the database.
      Argument  : The Object ID of the Map to be returned.
      Returns   : A Genetics::Object::Map object.
      Scope     : Public
      Comments  : "Light" version means that the object has only the name and id
                  fields from Object, and it does not contain any associated NameAlias,
                  Contact, DBXReference or Keyword data.  It also has a sub-set of
                  Map-specific fields.

# Private methods

## _getObjAssocData

      Function  : get (read) data from and associated with the Object table/object.
      Arguments : Scalar containing an Object.id and a reference to a hash which
                  will be populated with the data.
      Returns   : N/A
      Scope     : Private
      Called by : The various getObjectSubClass methods.
      Comments  : The format of the data structure created by this method is
                  identical to that passed to Object::new().