Commit 9d7bece9 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

testing stable id mapping code changes where biotype changes are penalised...

testing stable id mapping code changes where biotype changes are penalised when first calculating the transcript score
parent 823ba489
......@@ -1037,6 +1037,18 @@ sub get_DBAdaptor {
} ## end sub get_DBAdaptor
sub get_production_DBAdaptor() {
my ($self) = @_;
my $dba = new Bio::EnsEMBL::DBSQL::DBAdaptor(
-host => $self->conf->param("productionhost"),
-port => $self->conf->param("productionport"),
-user => $self->conf->param("productionuser"),
-pass => $self->conf->param("productionpass"),
-dbname => $self->conf->param("productiondbname"));
return $dba;
}
sub cache_file_exists {
my $self = shift;
my $type = shift;
......
......@@ -90,18 +90,18 @@ sub basic_mapping {
sort { $b->score <=> $a->score } @{ $matrix->get_all_Entries };
# debug
#my $idx = substr($mapping_name, -1);
my $idx = substr($mapping_name, -1);
while ( my $entry = shift(@sorted_entries) ) {
#$self->logger->debug("\nxxx$idx ".$entry->to_string." ");
$self->logger->debug("\nxxx$idx ".$entry->to_string." ");
# we already found a mapping for either source or target
next
if ( $sources_done->{ $entry->source }
or $targets_done->{ $entry->target } );
#$self->logger->debug('d');
$self->logger->debug('d');
# there's a better mapping for either source or target
next
......@@ -109,16 +109,17 @@ sub basic_mapping {
$entry, $matrix, $sources_done, $targets_done
) );
#$self->logger->debug('h');
$self->logger->debug('h');
# check for ambiguous mappings; they are dealt with later
# unless all the other ambiguous mappings have already been dealt with
my $other_sources = [];
my $other_targets = [];
if ( $self->ambiguous_mapping( $entry, $matrix,
$other_sources, $other_targets ) )
{
#$self->logger->debug('a');
$self->logger->debug('a');
$other_sources =
$self->filter_sources( $other_sources, $sources_done );
......@@ -128,7 +129,7 @@ sub basic_mapping {
next if ( scalar(@$other_sources) or scalar(@$other_targets) );
}
#$self->logger->debug('A');
$self->logger->debug('A');
# this is the best mapping, add it
$mappings->add_Entry($entry);
......
......@@ -317,20 +317,36 @@ sub score_matrix_from_flag_matrix {
} else {
=cut
my $source_transcript_biotype_group = $self->get_biotype_group($source_transcript->biotype());
my $target_transcript_biotype_group = $self->get_biotype_group($target_transcript->biotype());
# debug
$self->logger->info($source_transcript->id.":".$target_transcript->id.
" source score: $source_transcript_score".
" source length: $source_transcript_length".
" source biotype:" . $source_transcript->biotype() .
" source group: $source_transcript_biotype_group".
" target score: $target_transcript_score".
" target biotype:" . $target_transcript->biotype() .
" target group: $target_transcript_biotype_group".
" target length: $target_transcript_length\n");
=cut
# everything is fine, add score to matrix
my $transcript_score =
($source_transcript_score + $target_transcript_score) /
($source_transcript_length + $target_transcript_length);
## Add penalty if biotypes are different
if ($source_transcript->biotype() ne $target_transcript->biotype()) {
$transcript_score = $transcript_score * 0.9;
}
## Add penalty if biotype groups are different
if ($source_transcript_biotype_group ne $target_transcript_biotype_group) {
$transcript_score = $transcript_score * 0.8;
}
# everything is fine, add score to matrix
if ($transcript_score > $transcript_score_threshold) {
$matrix->add_score($source_transcript->id, $target_transcript->id,
$transcript_score);
......@@ -494,5 +510,22 @@ sub non_mapped_gene_rescore {
} ## end sub non_mapped_gene_rescore
sub get_biotype_group {
my ($self, $biotype) = @_;
my $dba = $self->cache->get_production_DBAdaptor();
my $helper = $self->cache->get_production_DBAdaptor()->dbc()->sql_helper();
my $sql = q{
SELECT biotype_group
FROM biotype
WHERE object_type = 'transcript'
AND is_current = 1
AND name = ?
AND db_type like '%core%' };
my $result = $helper->execute_simple(-SQL => $sql, -PARAMS => [$biotype]);
return $result->[0];
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment