Bio::EnsEMBL::ExternalData::Haplotype
Tag
Toolbar
Summary
Bio::EnsEMBL::ExternalData::Haplotype::Tag.pm - Haplotype tag object.
Package variables
No package variables defined.
Included modules
Data::Dumper
Storable qw ( dclone )
Synopsis
use Bio::PopGen::Haplotype::Tag;
my $obj = Tag -> new($hap);
Description
This module take as input a haplotype and try toe get the minimal
set of SNP that define the haplotype. This module can be use alone.
But due to the tagging haplotype process is exponential one. My
suggestion is that before to use this module you pass your data under
Select.mp module also on this folder. In any case if, you provide an
haplotype the module will try to find the answer to your question.
Methods
Methods description
Title : _gen_comb Usage : internal Function: we supply the length of the haplotype and the length of the word we need to find and the functions returns the possible list of combinations. Returns : scalar Args : none Status : private |
Title : _generateCombinations Usage : internal Function: Recursive function that produce all combinations for a set
i.e.:
1, 2, 3, 4
and word of 3 will produce:
1, 2, 3
1, 2, 4
1, 3, 4
2, 3, 4
Returns :
Args : none
Status : private |
Title : _scan_combinations Usage : internal Function: take the haplotype and a list of possible combination for that length. Generate a subset and scan it to find if the information is enought to define the haplotype set. Returns : Args : none Status : private |
Title : _scan_snp Usage : internal Function: scan sets increasing the length until find a non degenerated pattern. Returns : scalar Args : none Status : private |
Title : input_block Usage : $obj->input_block() Function: constructor of the class. Returns : reference to array of array with the haplotype input value Args : none Status : public |
Title : new Function: constructor of the class. Returns : self hash Args : input haplotype (array of array) Status : public |
Title : tag_length Usage : $obj->tag_length() Function: returns the length of the tag. Returns : scalar Args : none Status : public |
Title : tag_list Usage : $obj->tag_list() Function: returns the list of SNPs combination that identify the haplotype. All combinations are displayed as arrays Returns : reference to array of array. Args : none Status : public |
Methods code
sub _deg_test
{
my ($hap)= @_;
for my $c1(0..$#$hap){
for my $c2($c1+1..$#$hap){
my $degeneration = compare_arrays($hap->[$c1], $hap->[$c2]);
if ($degeneration){
return 1;
}
}
}
}
} |
sub _gen_comb
{
my ($hap_length,$n) = @_;
my @array = ();
for(0..$hap_length-1){ push @array, $_ };
my $m = -1;
my $value = []; my $list = [];
_generateCombinations (\@ array,\$ m, \$n, $value, $list);
return $list; } |
sub _generateCombinations
{ my ($rarr, $rm, $rn, $rvalue,$rlist)=@_;
for (my $i = ($$rm+1); $i<scalar @$rarr; $i++){
push (my @value2,@$rvalue,$rarr->[$i]);
if (scalar @value2<$$rn){
_generateCombinations($rarr,\$i, $rn,\@ value2, $rlist);
}
if (scalar @value2==$$rn){
push @$rlist, [@value2];
}
if(scalar @value2>$$rn){
last;
}
}
}
} |
sub _get_subArray
{ my($hap, $combination) =@_;
my $out = [];
for my $i (0..$#$hap){
foreach(@$combination){
push @{$out->[$i]}, $hap->[$i][$_];
}
}
return $out;
}
} |
sub _scan_combinations
{
my($hap,$list) = @_;
my $valid_combination = undef;
for my $i (0..$#$list){
my $subArray = _get_subArray ($hap, $list->[$i]);
my $degeneration = _deg_test($subArray);
if(!$degeneration){
push @$valid_combination, [@{$list->[$i]}];
}
}
return $valid_combination;
}
} |
sub _scan_snp
{ my ($hap)=@_;
my $hap_length = scalar @{$hap->[0]};
for my $i(1..$hap_length){
my $list = _gen_comb($hap_length, $i);
my $snp_collection = _scan_combinations($hap, $list);
if($#$snp_collection>-1){
return $snp_collection;
}
} } |
sub compare_arrays
{ my ($first, $second) = @_;
return 0 unless @$first == @$second;
for (my $i = 0; $i < @$first; $i++) {
return 0 if $first->[$i] ne $second->[$i];
}
return 1;
}
1; } |
sub input_block
{ my $self = shift;
return $self->{input_block}; } |
sub new
{ my $class = shift;
my $self ={};
$self->{'input_block'} = shift;
$self->{'tag_list'} = _scan_snp( $self->{'input_block'} );
if ( $self->{'tag_list'}){
$self->{'tag_length'} = scalar @{ $self->{'tag_list'}->[0] };
}
else {
$self->{'tag_length'} = "NO TAGS FOUND!";
}
bless $self, $class;
return $self; } |
sub tag_length
{ my $self =shift;
return $self->{tag_length}; } |
sub tag_list
{ my $self = shift;
return $self->{tag_list}; } |
General documentation
my $obj = Tag -> new($hap);
were $hap is the reference to an array of array with the haplotype.
$hap= [[0, 0, 0],
[1, 0, 0],
[0, 1, 1]
];
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
http://bugzilla.bioperl.org/
AUTHOR - Pedro M. Gomez-Fabre | Top |
Email pedro.fabre-at-gen.gu.se