<commit_before>
=pod

=head1 NAME

Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript




=head1 SYNOPSIS

my $runnableDB =  Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript->new(
    -db         => $refdb,
    -analysis   => $analysis_obj,
  );

$runnableDB->fetch_input();
$runnableDB->run();
$runnableDB->write_output(); #writes to DB

=head1 DESCRIPTION

Extends Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa to allow
reads to be aligned against transcript sequences and then projected
onto the genome

=head1 CONTACT

Post general queries to B<<EMAIL>>

=head1 APPENDIX

=cut

package Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript;

use strict;
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use Bio::EnsEMBL::Analysis::RunnableDB;
use Bio::EnsEMBL::Analysis::RunnableDB::ExonerateAlignFeature;
use Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa;
use Bio::EnsEMBL::Analysis::Config::GeneBuild::ExonerateSolexa;
use Bio::EnsEMBL::FeaturePair;
use vars qw(@ISA);

@ISA =  ("Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa");


sub new {
  my ( $class, @args ) = @_;
  my $self = $class->SUPER::new(@args);
  return $self;
}


sub fetch_input {
  my ($self) = @_;
  # do all the normal stuff
  $self->SUPER::fetch_input();
  # then get all the transcripts and exons
  my $trans_db = $self->get_dbadaptor($self->TRANSDB); 
  my $trans_adaptor = $trans_db->get_TranscriptAdaptor;
  my %trans_by_id;
  my $biotype = $self->BIOTYPE;
  my @trans;
  # fetch genes, transcripts
  if ( $biotype ){
    push @trans , @{$trans_adaptor->generic_fetch("biotype = \"$biotype\"")};
  } else {
    push @trans , @{$trans_adaptor->fetch_all(undef,undef,undef)};
  }
  $trans_db->disconnect_when_inactive(1);
  
  foreach my $trans ( @trans ) {
    $trans_by_id{$trans->display_id} = $trans;
  }
  $self->transcripts(\%trans_by_id);
  return ;
}


sub filter_solexa {
  my ($self,$features_ref) = @_;
  my @features = @$features_ref;
  my @filtered_features;
  #allow no more than MISSMATCH missmatches and
  foreach my $feat ( @features ) {
   # check missmatches
    if ( $self->MISSMATCH ) {
      my $aligned_length = abs($feat->hend - $feat->hstart) +1;
      #print $feat->hseqname ." ";
      #print $feat->percent_id . " " ;
      #print " aligned length = $aligned_length ";
      my $matches = $aligned_length *  $feat->percent_id / 100;
      #print " matches $matches  ";
      my $missmatches = ( $aligned_length - $matches) / $aligned_length * 100;
      #print " missmatches $missmatches \n";
      next if $missmatches > $self->MISSMATCH;<commit_msg>BIOTYPE changed to TRANSCRIPT_BIOTYPE<commit_after>
=pod

=head1 NAME

Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript




=head1 SYNOPSIS

my $runnableDB =  Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript->new(
    -db         => $refdb,
    -analysis   => $analysis_obj,
  );

$runnableDB->fetch_input();
$runnableDB->run();
$runnableDB->write_output(); #writes to DB

=head1 DESCRIPTION

Extends Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa to allow
reads to be aligned against transcript sequences and then projected
onto the genome

=head1 CONTACT

Post general queries to B<<EMAIL>>

=head1 APPENDIX

=cut

package Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexaTranscript;

use strict;
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use Bio::EnsEMBL::Analysis::RunnableDB;
use Bio::EnsEMBL::Analysis::RunnableDB::ExonerateAlignFeature;
use Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa;
use Bio::EnsEMBL::Analysis::Config::GeneBuild::ExonerateSolexa;
use Bio::EnsEMBL::FeaturePair;
use vars qw(@ISA);

@ISA =  ("Bio::EnsEMBL::Analysis::RunnableDB::ExonerateSolexa");


sub new {
  my ( $class, @args ) = @_;
  my $self = $class->SUPER::new(@args);
  return $self;
}


sub fetch_input {
  my ($self) = @_;
  # do all the normal stuff
  $self->SUPER::fetch_input();
  # then get all the transcripts and exons
  my $trans_db = $self->get_dbadaptor($self->TRANSDB); 
  $trans_db->disconnect_when_inactive(1);
  my $trans_adaptor = $trans_db->get_TranscriptAdaptor;
  my %trans_by_id;
  my $biotype = $self->TRANSCRIPT_BIOTYPE;
  my @trans;
  # fetch genes, transcripts 
  if ( $biotype ){ 
    print "MSG: fetching transcripts of biotype $biotype !\n"; 
    push @trans , @{$trans_adaptor->generic_fetch("biotype = \"$biotype\"")};
  } else {
    push @trans , @{$trans_adaptor->fetch_all(undef,undef,undef)};
  }
  $self->db->dnadb()->disconnect_when_inactive(1); 
 
  print scalar(@trans) . " transcripts fetched \n";   

  foreach my $trans ( @trans ) {
    $trans_by_id{$trans->display_id} = $trans;
  }
  $self->transcripts(\%trans_by_id);
  return ;
}


sub filter_solexa {
  my ($self,$features_ref) = @_;
  my @features = @$features_ref;
  my @filtered_features;
  #allow no more than MISSMATCH missmatches and
  foreach my $feat ( @features ) {
   # check missmatches
    if ( $self->MISSMATCH ) {
      my $aligned_length = abs($feat->hend - $feat->hstart) +1;
      #print $feat->hseqname ." ";
      #print $feat->percent_id . " " ;
      #print " aligned length = $aligned_length ";
      my $matches = $aligned_length *  $feat->percent_id / 100;
      #print " matches $matches  ";
      my $missmatches = ( $aligned_length - $matches) / $aligned_length * 100;
      #print " missmatches $missmatches \n";
      next if $missmatches > $self->MISSMATCH;
{'fraction_non_alphanumeric': 0.14961354435038646, 'fraction_numerical': 0.0049687154950312845, 'mean_word_length': 4.517766497461929, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3110112', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1941, 'n_words': 402}