Bio::EnsEMBL::Compara::Production::EPOanchors RemoveAnchorOverlaps
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::EnsEMBL::Compara::Production::EPOanchors::RemoveAnchorOverlaps
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Compara::MethodLinkSpeciesSet
Bio::EnsEMBL::Compara::Production::DBSQL::DBAdaptor
Bio::EnsEMBL::Compara::Production::EPOanchors::AnchorAlign
Bio::EnsEMBL::Hive::Process
Bio::EnsEMBL::Utils::Exception qw ( throw warning )
Data::Dumper
Inherit
Bio::EnsEMBL::Hive::Process
Synopsis
parameters
{input_analysis_id=> ?,method_link_species_set_id=> ?,test_method_link_species_set_id=> ?, genome_db_ids => [?],}
Description
Removes the minimum number of overlappping anchors.
Methods
configure_defaults
No description
Code
fetch_input
No description
Code
genome_db_ids
No description
Code
get_params
No description
Code
input_analysis_id
No description
Code
method_link_species_set_id
No description
Code
overlapping_ancs_to_remove
No description
Code
run
No description
Code
test_method_link_species_set_id
No description
Code
write_output
No description
Code
Methods description
None available.
Methods code
configure_defaultsdescriptionprevnextTop
sub configure_defaults {
 	my $self = shift;
  	return 1;
}
fetch_inputdescriptionprevnextTop
sub fetch_input {
	my ($self) = @_;
	$self->configure_defaults();

	$self->{'comparaDBA'} = Bio::EnsEMBL::Compara::Production::DBSQL::DBAdaptor->new(-DBCONN=>$self->db->dbc);
	$self->{'comparaDBA'}->dbc->disconnect_when_inactive(0);
	$self->get_params($self->parameters);
	return 1;
}
genome_db_idsdescriptionprevnextTop
sub genome_db_ids {
	my $self = shift;
	if (@_) {
		$self->{genome_db_ids} = shift;
	}
	return $self->{genome_db_ids};
}
get_paramsdescriptionprevnextTop
sub get_params {
  my $self         = shift;
  my $param_string = shift;

  return unless($param_string);
  print("parsing parameter string : ",$param_string,"\n");

  my $params = eval($param_string);
  return unless($params);

  if(defined($params->{'genome_db_ids'})) {
    $self->genome_db_ids($params->{'genome_db_ids'});
  }
  if(defined($params->{'test_method_link_species_set_id'})) {
	$self->test_method_link_species_set_id($params->{'test_method_link_species_set_id'});
  }
  if(defined($params->{'method_link_species_set_id'})) {
	$self->method_link_species_set_id($params->{'method_link_species_set_id'});
  }
  if(defined($params->{'input_analysis_id'})) {
    $self->input_analysis_id($params->{'input_analysis_id'});
  }
  return 1;
}

#sub store_input {
# my $self = shift;
#
# if (@_) {
# $self->{_store_input} = shift;
# }
#
# return $self->{_store_input};
#}
#
#sub store_output {
# my $self = shift;
#
# if (@_) {
# $self->{_store_output} = shift;
# }
#
# return $self->{_store_output};
#}
1;
}
input_analysis_iddescriptionprevnextTop
sub input_analysis_id {
	my $self = shift;
	if (@_) {
		$self->{input_analysis_id} = shift;
	}
	return $self->{input_analysis_id};
}
method_link_species_set_iddescriptionprevnextTop
sub method_link_species_set_id {
	my $self = shift;
	if (@_) {
		$self->{method_link_species_set_id} = shift;
	}
	return $self->{method_link_species_set_id};
}
overlapping_ancs_to_removedescriptionprevnextTop
sub overlapping_ancs_to_remove {
	my $self = shift;
	if (@_) {
		$self->{overlapping_ancs_to_remove} = shift;
	}
	return $self->{overlapping_ancs_to_remove};
}
rundescriptionprevnextTop
sub run {
	my ($self) = @_;
	my $anchor_align_adaptor = $self->{'comparaDBA'}->get_AnchorAlignAdaptor();
	my $dnafrag_ids = $anchor_align_adaptor->fetch_all_dnafrag_ids($self->test_method_link_species_set_id);
	my (%Overlappping_anchors, %Anchors_2_remove, %Scores);
	my $test_mlssid = $self->test_method_link_species_set_id;
	foreach my $genome_db_id(sort keys %{$dnafrag_ids}) {
		my %genome_db_dnafrags;
		foreach my $genome_db_anchors(@{ $anchor_align_adaptor->fetch_all_anchors_by_genome_db_id_and_mlssid(
						$genome_db_id, $test_mlssid) }) {
			push(@{ $genome_db_dnafrags{ $genome_db_anchors->[0] } }, [ @{ $genome_db_anchors }[1..4] ]);	
		}
		foreach my $dnafrag_id(sort keys %genome_db_dnafrags) {
			my @Dnafrag_anchors = @{ $genome_db_dnafrags{$dnafrag_id} };
			for(my$i=0;$i<@Dnafrag_anchors-1;$i++) { #count number of overlaps an anchor has at every position to which it maps
for(my$j=$i+1;$j<@Dnafrag_anchors;$j++) { if($Dnafrag_anchors[$i]->[3] >= $Dnafrag_anchors[$j]->[2]) { $Overlappping_anchors{$Dnafrag_anchors[$i]->[1]}{$Dnafrag_anchors[$j]->[1]}++; $Overlappping_anchors{$Dnafrag_anchors[$j]->[1]}{$Dnafrag_anchors[$i]->[1]}++; } else { splice(@Dnafrag_anchors, $i, 1); $i--; last; } } } } } foreach my$anchor(sort keys %Overlappping_anchors) { foreach my $overlapping_anchor(sort keys %{$Overlappping_anchors{$anchor}}) { $Scores{$anchor} += ($Overlappping_anchors{$anchor}{$overlapping_anchor})**2; #score the anchors according to the number of overlaps
} } print STDERR "scores: ", scalar(keys %Scores), "\n"; my$flag = 1; while($flag) { $flag = 0; foreach my $anchor(sort {$Scores{$b} <=> $Scores{$a}} keys %Scores) { #get highest scoring anchor
next unless(exists($Scores{$anchor})); #don't add it to "remove list" if it's already gone from the score hash
foreach my $anc_with_overlap_2_anchor(sort keys %{$Overlappping_anchors{$anchor}}) { #find all the anchors which overlap this anchor
$Scores{$anc_with_overlap_2_anchor} -= ($Overlappping_anchors{$anc_with_overlap_2_anchor}{$anchor})**2; #decrement the score
delete $Scores{$anc_with_overlap_2_anchor} unless($Scores{$anc_with_overlap_2_anchor}); #if score is zero remove this anchor from the overlapping list,
delete($Overlappping_anchors{$anc_with_overlap_2_anchor}{$anchor}); #remove high scoring anchor from hash of overlaps
} delete($Overlappping_anchors{$anchor}); #remove high scoring anchor from hash
delete($Scores{$anchor}); #also remove it from scoring hash
$Anchors_2_remove{$anchor}++; #add it to list of ancs to remove
} $flag = 1 if (scalar(keys %Scores)); } print STDERR "anchors to remove: ", scalar(keys %Anchors_2_remove), "\n"; $self->overlapping_ancs_to_remove(\%Anchors_2_remove); return 1;
}
test_method_link_species_set_iddescriptionprevnextTop
sub test_method_link_species_set_id {
	my $self = shift;
	if (@_) {
		$self->{test_method_link_species_set_id} = shift;
	}
	return $self->{test_method_link_species_set_id};
}
write_outputdescriptionprevnextTop
sub write_output {
	my ($self) = @_;
	my $anchor_align_adaptor = $self->{'comparaDBA'}->get_AnchorAlignAdaptor();
	my $current_analysis_id = $self->input_analysis_id();
	my $Anchors_2_remove = $self->overlapping_ancs_to_remove(); 
	my $test_mlssid = $self->test_method_link_species_set_id();
	$anchor_align_adaptor->update_failed_anchor($Anchors_2_remove, $current_analysis_id, $test_mlssid);	
	return 1;
}
General documentation
CONTACTTop
ensembl-compara@ebi.ac.uk
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _