Bio::EnsEMBL::ExternalData::Haplotype Haplotype
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
HaplotypeAdaptor - DESCRIPTION of Object
  This object represents a database of haplotypes.
Package variables
No package variables defined.
Included modules
Bio::Root::Object
Inherit
Bio::Root::Object
Synopsis
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::ExternalData::Haplotype::HaplotypeAdaptor;
use Bio::EnsEMBL::ExternalData::Haplotype::Haplotype;
$hapdb = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-user => 'ensro',
-dbname => 'haplotype_5_28',
-host => 'ecs3d',
-driver => 'mysql',
);
my $hap_adtor = Bio::EnsEMBL::ExternalData::Haplotype::HaplotypeAdaptor->new($hapdb);
$hap = $hap_adtor->get_Haplotype_by_id('B10045'); # Haplotype id
### You can add the HaplotypeAdaptor as an 'external adaptor' to the 'main'
### Ensembl database object, then use it as:
$ensdb = Bio::EnsEMBL::DBSQL::DBAdaptor->new( ... );
$ensdb->add_ExternalAdaptor('haplotype', $hap_adtor);
# then later on, elsewhere:
$hap_adtor = $ensdb->get_ExternalAdaptor('haplotype');
# also available:
$ensdb->list_ExternalAdaptors();
$ensdb->remove_ExternalAdaptor('haplotype');
Description
This module is an entry point into a database of haplotypes,
The objects can only be read from the database, not written. (They are
loaded ussing a separate perl script).
For more info, see Haplotype.pm
Methods
adaptorDescriptionCode
chr_nameDescriptionCode
contig_idDescriptionCode
endDescriptionCode
fetchSNPs
No description
Code
idDescriptionCode
local_endDescriptionCode
local_startDescriptionCode
newDescriptionCode
patternsDescriptionCode
samples_countDescriptionCode
snp_infoDescriptionCode
snp_reqDescriptionCode
snpsDescriptionCode
startDescriptionCode
total_samplesDescriptionCode
unclassified_samples_countDescriptionCode
Methods description
adaptorcode    nextTop
 Title   : _adaptor
Usage : $adaptor = $hap->adaptor
Function: find this objects\'s adaptor object (set by HaplotypeAdaptor)
Example :
Returns :
Args :
chr_namecodeprevnextTop
 Title   : chr_name
Usage :
Function: get/set the chr_name of the Haplotype
Example :
Returns :
Args :
contig_idcodeprevnextTop
 Title   : contig_id
Usage :
Function: get/set the contig id of the Haplotype
Example :
Returns :
Args :
endcodeprevnextTop
 Title   : end
Usage :
Function: get/set the global (chromosomal) end of the Haplotype
Example :
Returns :
Args :
idcodeprevnextTop
 Title   : id
Usage :
Function: get/set the display id of the Haplotype
Example :
Returns :
Args :
local_endcodeprevnextTop
 Title   : local_end
Usage :
Function: get/set the local (contig) end of the Haplotype
Example :
Returns :
Args :
local_startcodeprevnextTop
 Title   : local_start
Usage :
Function: get/set the local (contig) start of the Haplotype
Example :
Returns :
Args :
newcodeprevnextTop
 Title   : new
Usage : not intended for general use.
Function:
Example :
Returns : a haplotype - caller has to fill using methods
Args :
patternscodeprevnextTop
 Title   : pattern
Usage :
Function: get/set the sorted list of patterns for this Haplotype consensus
Example :
Returns :
Args :ref to a list of pattern objects (they will be sorted on order of size)
samples_countcodeprevnextTop
 Title   : samples_count
Usage :
Function: store number of classified samples
Example :
Returns :
Args :
snp_infocodeprevnextTop
 Title   : snp_info
Usage :
Function: get snp_info for names SNP of the Haplotype
Example :
Returns : ref to hash of snp info
Args : read only
snp_reqcodeprevnextTop
 Title   : snp_req
Usage :
Function: get/set the number of SNPs required to unambiguously this Haplotype pattern
Example :
Returns :
Args :
snpscodeprevnextTop
 Title   : snps
Usage :
Function: get/set the IDs of SNPs in this Haplotype pattern
Example :
Returns : ref to list of SNP IDs
Args : ref to list of SNP IDs
startcodeprevnextTop
 Title   : start
Usage :
Function: get/set the global (chromosomal) start of the Haplotype
Example :
Returns :
Args :
total_samplescodeprevnextTop
 Title   : total_samples
Usage :
Function: store total_samples
Example :
Returns :
Args :
unclassified_samples_countcodeprevnextTop
 Title   : unclassified_samples_count
Usage :
Function: store number of unclassified samples
Example :
Returns :
Args : ref to a hash of sample=>patterns
Methods code
adaptordescriptionprevnextTop
sub adaptor {
  my ($self)= shift;
  return $self->{'_adaptor'};
}
chr_namedescriptionprevnextTop
sub chr_name {
    my ($self,$value) = @_;
    if( defined $value) {
		$self->{'chr_name'} = $value;
    }
    return $self->{'chr_name'};
}
contig_iddescriptionprevnextTop
sub contig_id {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'contig_id'} = $value;
    }
    return $self->{'contig_id'};
}
enddescriptionprevnextTop
sub end {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'end'} = $value;
    }
    return $self->{'end'};
}
fetchSNPsdescriptionprevnextTop
sub fetchSNPs {
    my ($self) = @_;
    return $self->adaptor->fetchSNPs( $self->id );    
}
1;
}
iddescriptionprevnextTop
sub id {
    my ($self,$value) = @_;
    if( defined $value) {
		$self->{'id'} = $value;
    }
    return $self->{'id'};
}
local_enddescriptionprevnextTop
sub local_end {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'local_end'} = $value;
    }
    unless ($self->{'local_end'}){
        my $id = $self->id();
        my $q = qq(
        	select last_reference_position from block 
        	where block_id = "$id"
		);
        my $sth = $self->adaptor->prepare($q);
        $sth->execute();
        ($self->{'local_end'}) = $sth->fetchrow_array()
    }
    return $self->{'local_end'};
}
local_startdescriptionprevnextTop
sub local_start {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'local_start'} = $value;
    }
    unless ($self->{'local_start'}){
        my $id = $self->id();
        my $q = qq(
        	select first_reference_position from block 
        	where block_id = "$id"
		);
        my $sth = $self->adaptor->prepare($q);
        $sth->execute();
        ($self->{'local_start'}) = $sth->fetchrow_array()
    }
    return $self->{'local_start'};
}
newdescriptionprevnextTop
sub new {
   my ($class, $adaptor) = @_;
   my $self = {'_adaptor' => $adaptor};
   bless $self,$class;
   $self;
}
patternsdescriptionprevnextTop
sub patterns {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'patterns'} = $value;
    }
    my @pats = reverse sort { $a->count <=> $b->count } @{$self->{'patterns'}};
    return(\@pats);
}
samples_countdescriptionprevnextTop
sub samples_count {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'samples_count'} = $value;
    }
    return $self->{'samples_count'} ||= 0;
}
snp_infodescriptionprevnextTop
sub snp_info {
    my ($self,$value) = @_;
    unless ($self->{'snp_info'}->{$value}){
        my $q = qq(
            select 
                 position,ref_base,alt_base,ref_calls,mut_calls
            from 
                polymorphism
            where 
                polymorphism_id = "$value"
            );
        my $sth = $self->adaptor->prepare($q);
        $sth->execute();
        $self->{'snp_info'}->{$value} = $sth->fetchrow_hashref()
    }
    return $self->{'snp_info'}->{$value};
}
snp_reqdescriptionprevnextTop
sub snp_req {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'snp_req'} = $value;
    }
    return $self->{'snp_req'};
}
snpsdescriptionprevnextTop
sub snps {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'snps'} = $value;
    }
    return $self->{'snps'};
}
startdescriptionprevnextTop
sub start {
    my ($self,$value) = @_;
    if( defined $value) {
	    $self->{'start'} = $value;
    }
    return $self->{'start'};
}
total_samplesdescriptionprevnextTop
sub total_samples {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'total_samples'} = $value;
    }
    return $self->{'total_samples'} ||= 0;
}
unclassified_samples_countdescriptionprevnextTop
sub unclassified_samples_count {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'unclassified_samples_count'} = $value;
    }
    return $self->{'unclassified_samples_count'} ||= 0;
}
General documentation
CONTACTTop
 Tony Cox <Lavc@sanger.ac.uk>
APPENDIXTop
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _