<commit_before>=head1 LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2020] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=head1 CONTACT

Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.

=head1 NAME

TranscriptCluster

=head1 SYNOPSIS


=head1 DESCRIPTION

This object holds one or more transcripts which have been clustered according to 
comparison criteria external to this class (for instance, in the 
method _compare_Transcripts of the class GeneComparison).
Each TranscriptCluster object holds the IDs of the transcripts clustered and the beginning and end coordinates
of each one (taken from the start and end coordinates of the first and last exon in the correspondig
get_all_Exons array)

It inherits from Bio::EnsEMBL::Root and Bio::RangeI. A TranscriptCluster is a range in the sense that it convers
a defined extent of genomic sequence. It is also possible to check whether two clusters overlap (in range),
is included into another cluster, etc...

=head1 METHODS

=cut

# Let the code begin ...

package Bio::EnsEMBL::Analysis::Tools::Algorithms::TranscriptCluster;

use warnings ;
use Bio::EnsEMBL::Transcript;
use Bio::EnsEMBL::Analysis::Tools::Algorithms::ExonCluster;
use Bio::EnsEMBL::Analysis::Tools::Algorithms::IntronCluster;
use strict;

use Bio::EnsEMBL::Gene;
use Bio::RangeI;
use Bio::EnsEMBL::Utils::Exception qw (throw warning ) ; 
use vars qw(@ISA);
@ISA = qw(Bio::RangeI);


#########################################################################


=head2 new

new() initializes the attributes:
_transcript_array
_transcriptID_array
_start
_end

=cut

sub new {
  my ($class, $ignore_strand, $whatever) = @_ ;

  if (ref($class)){
    $class = ref($class);
  }
  my $self = {};
  bless($self,$class);

  $self->{_ignore_strand} = $ignore_strand;
  
  if ($whatever) {
    throw( "Can't pass an object to new() method. Use put_Transcript() to include Bio::EnsEMBL::Transcript in cluster") ;
  }

  $self->{_start}  = undef;
  $self->{_end}    = undef;
  $self->{_strand} = undef;

  $self->{v} = 0 ; # verbosity
  return $self;
}
#########################################################################

=head1 Range-like methods

Methods start and end are typical for a range. We also implement the boolean
and geometrical methods for a range.

=head2 start

  Title   : start
  Usage   : $start = $transcript_cluster->end();
  Function: get/set the start of the range covered by the cluster. This is re-calculated and set everytime
            a new transcript is added to the cluster
  Returns : a number
  Args    : optionaly allows the start to be set

=cut

sub start {
  my ($self,$start) = @_ ;

  if ($start) {
    throw( "$start is not an integer") unless $start =~/^[-+]?\d+$/;
    $self->{_start} = $start;
  }

  if (!defined($self->{_start})) {
    my $start;

    foreach my $transcript (@{$self->get_Transcripts}) {
      my $this_start = $transcript->start;
      unless ( $start ){
        $start = $this_start;
      }
      if ( $this_start < $start ){
        $start = $this_start;
      }
    }
    $self->{_start} = $start;
  }
  return $self->{_start};
}

############################################################

=head2 end

  Title   : end
  Usage   : $end = $transcript_cluster->end();
  Function: get/set the end of the range covered by the cluster. This is re-calculated and set everytime
            a new transcript is added to the cluster
  Returns : the end of this range
  Args    : optionaly allows the end to be set
          : using $range->end($end
=cut

sub end {
  my ($self, $end) = @_ ;

  if ($end) {
    throw( "$end is not an integer") unless $end =~/^[-+]?\d+$/;
    $self->{_end} = $end;
  }

  if (!defined($self->{_end})) {
    my $end;

    foreach my $transcript (@{$self->get_Transcripts}) {
      my $this_end = $transcript->end;
      unless ( $end ){
        $end = $this_end;
      }
      if ( $this_end > $end ){
        $end = $this_end;
      }
    }
    $self->{_end} = $end;
  }

  return $self->{_end};
}<commit_msg>Use defined instead or true/false in if statement<commit_after>=head1 LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2020] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=head1 CONTACT

Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.

=head1 NAME

TranscriptCluster

=head1 SYNOPSIS


=head1 DESCRIPTION

This object holds one or more transcripts which have been clustered according to 
comparison criteria external to this class (for instance, in the 
method _compare_Transcripts of the class GeneComparison).
Each TranscriptCluster object holds the IDs of the transcripts clustered and the beginning and end coordinates
of each one (taken from the start and end coordinates of the first and last exon in the correspondig
get_all_Exons array)

It inherits from Bio::EnsEMBL::Root and Bio::RangeI. A TranscriptCluster is a range in the sense that it convers
a defined extent of genomic sequence. It is also possible to check whether two clusters overlap (in range),
is included into another cluster, etc...

=head1 METHODS

=cut

# Let the code begin ...

package Bio::EnsEMBL::Analysis::Tools::Algorithms::TranscriptCluster;

use warnings ;
use Bio::EnsEMBL::Transcript;
use Bio::EnsEMBL::Analysis::Tools::Algorithms::ExonCluster;
use Bio::EnsEMBL::Analysis::Tools::Algorithms::IntronCluster;
use strict;

use Bio::EnsEMBL::Gene;
use Bio::RangeI;
use Bio::EnsEMBL::Utils::Exception qw (throw warning ) ; 
use vars qw(@ISA);
@ISA = qw(Bio::RangeI);


#########################################################################


=head2 new

new() initializes the attributes:
_transcript_array
_transcriptID_array
_start
_end

=cut

sub new {
  my ($class, $ignore_strand, $whatever) = @_ ;

  if (ref($class)){
    $class = ref($class);
  }
  my $self = {};
  bless($self,$class);

  $self->{_ignore_strand} = $ignore_strand;
  
  if ($whatever) {
    throw( "Can't pass an object to new() method. Use put_Transcript() to include Bio::EnsEMBL::Transcript in cluster") ;
  }

  $self->{_start}  = undef;
  $self->{_end}    = undef;
  $self->{_strand} = undef;

  $self->{v} = 0 ; # verbosity
  return $self;
}
#########################################################################

=head1 Range-like methods

Methods start and end are typical for a range. We also implement the boolean
and geometrical methods for a range.

=head2 start

  Title   : start
  Usage   : $start = $transcript_cluster->end();
  Function: get/set the start of the range covered by the cluster. This is re-calculated and set everytime
            a new transcript is added to the cluster
  Returns : a number
  Args    : optionaly allows the start to be set

=cut

sub start {
  my ($self,$start) = @_ ;

  if (defined $start) {
    throw( "$start is not an integer") unless $start =~/^[-+]?\d+$/;
    $self->{_start} = $start;
  }

  if (!defined($self->{_start})) {
    my $start;

    foreach my $transcript (@{$self->get_Transcripts}) {
      my $this_start = $transcript->start;
      unless ( $start ){
        $start = $this_start;
      }
      if ( $this_start < $start ){
        $start = $this_start;
      }
    }
    $self->{_start} = $start;
  }
  return $self->{_start};
}

############################################################

=head2 end

  Title   : end
  Usage   : $end = $transcript_cluster->end();
  Function: get/set the end of the range covered by the cluster. This is re-calculated and set everytime
            a new transcript is added to the cluster
  Returns : the end of this range
  Args    : optionaly allows the end to be set
          : using $range->end($end
=cut

sub end {
  my ($self, $end) = @_ ;

  if (defined $end) {
    throw( "$end is not an integer") unless $end =~/^[-+]?\d+$/;
    $self->{_end} = $end;
  }

  if (!defined($self->{_end})) {
    my $end;

    foreach my $transcript (@{$self->get_Transcripts}) {
      my $this_end = $transcript->end;
      unless ( $end ){
        $end = $this_end;
      }
      if ( $this_end > $end ){
        $end = $this_end;
      }
    }
    $self->{_end} = $end;
  }

  return $self->{_end};
}
{'fraction_non_alphanumeric': 0.15065502183406113, 'fraction_numerical': 0.00644624662091911, 'mean_word_length': 3.717508582638548, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1372964', 'n_tokens_mistral': 3088, 'n_tokens_neox': 2862, 'n_words': 1055}