<commit_before># See end of file for docs
package Bio::EnsEMBL::GlyphSet::scalebar;

use strict;

use POSIX qw(floor);

use base qw(Bio::EnsEMBL::GlyphSet);
  
# Least number of pixels per written number. Feel free to tweak.
my $min_pix_per_major = 80;

sub scale {
  my ($from,$to,$max) = @_; 

  my $div = 5;
  my $scale = 1;
  my $skip = 1;

  my @from_d = split(//,"".$from);
  my @to_d = split(//,"".$to);
  push @from_d,"0" for(@from_d..@to_d-1);
  push @to_d,"0" for(@to_d..@from_d-1);

  my $d; 
  my $unit = -1; 
  foreach my $i (0..@from_d-1) {
    my $a_v = join("",@from_d[0..@from_d-$i-1])+0;
    my $b_v = join("",@to_d[0..@from_d-$i-1])+0;
    $d = $b_v-$a_v;
    if($d) {
      if($d <= $max) {
        $unit = ("1".("0" x $i))+0;
        last;
      }   
    }   
  }
  return [("1".("0" x @from_d)),1,1] if $unit == -1; 
  if($d*5 <= $max) { $unit /=5; $div = 2; }
  elsif($d*4 <= $max) { $unit /=4; $skip = 2; }
  elsif($d*2 <= $max) { $unit /=2; $skip = 2; }
  $skip = 1 unless $d > 2;
  return [$unit,$div,$unit*$skip];
}

sub fmt_number {
  my ($self,$num,$step) = @_;

  $step =~ /0+$/;
  my $strip = length $&;
  my @lhs = split(//,"".$num);
  if($strip>=3) {
    my $mul = int((@lhs-1)/3);
    my @rhs = splice(@lhs,@lhs-$mul*3);
    pop @rhs for(1..$strip);
    unshift @rhs,"." if @rhs;
    return join("",@lhs,@rhs,['','k','M','G']->[$mul],"b");
  } else {
    return $self->commify($num);
  }
}

sub render {
  my ($self, $y) = @_;
  my $container     = $self->{'container'};
  my $length        = $container->length;
  my $contig_strand = $container->can('strand') ? $container->strand : 1;<commit_msg>Tweaks following feedback.<commit_after># See end of file for docs
package Bio::EnsEMBL::GlyphSet::scalebar;

use strict;

use POSIX qw(floor);

use base qw(Bio::EnsEMBL::GlyphSet);
  
# Least number of pixels per written number. Feel free to tweak.
my $min_pix_per_major = 100;

sub scale {
  my ($from,$to,$max) = @_; 

  my $div = 5;
  my $scale = 1;
  my $skip = 1;

  my @from_d = split(//,"".$from);
  my @to_d = split(//,"".$to);
  push @from_d,"0" for(@from_d..@to_d-1);
  push @to_d,"0" for(@to_d..@from_d-1);

  my $d; 
  my $unit = -1; 
  foreach my $i (0..@from_d-1) {
    my $a_v = join("",@from_d[0..@from_d-$i-1])+0;
    my $b_v = join("",@to_d[0..@from_d-$i-1])+0;
    $d = $b_v-$a_v;
    if($d) {
      if($d <= $max) {
        $unit = ("1".("0" x $i))+0;
        last;
      }   
    }   
  }
  return [("1".("0" x @from_d)),1,1] if $unit == -1; 
  if($d*5 <= $max) { $unit /=5; $div = 2; }
  elsif($d*4 <= $max) { $unit /=4; $skip = 2; $div = 1; }
  elsif($d*2 <= $max) { $unit /=2; $skip = 2; }
  $skip = 1 unless $d > 2;
  return [$unit,$div,$unit*$skip];
}

sub fmt_number {
  my ($self,$num,$step) = @_;

  $step =~ /0+$/;
  my $strip = length $&;
  my @lhs = split(//,"".$num);
  if($strip>=3) {
    my $mul = int((@lhs-1)/3);
    my @rhs = splice(@lhs,@lhs-$mul*3);
    pop @rhs for(1..$strip);
    unshift @rhs,"." if @rhs;
    return join("",@lhs,@rhs,['','k','M','G']->[$mul],"b");
  } else {
    return $self->commify($num);
  }
}

sub render {
  my ($self, $y) = @_;
  my $container     = $self->{'container'};
  my $length        = $container->length;
  my $contig_strand = $container->can('strand') ? $container->strand : 1;
{'fraction_non_alphanumeric': 0.25851581508515814, 'fraction_numerical': 0.02737226277372263, 'mean_word_length': 2.7674684994272623, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '3386763', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1496, 'n_words': 323}