<commit_before>#########
# Author: <EMAIL>
# Maintainer: <EMAIL>
# Created: 2001
#
package Sanger::Graphics::GlyphSet;
use strict;
use Exporter;
use Sanger::Graphics::Glyph::Diagnostic;
use Sanger::Graphics::Glyph::Text;
use Sanger::Graphics::Root;
use Sanger::Graphics::Glyph::Space;

use vars qw(@ISA);
@ISA = qw( Sanger::Graphics::Root );

#########
# constructor
#
sub new {
    my ($class, $Container, $Config, $highlights, $strand, $extra_config) = @_;
    my $self = {
	'glyphs'     => [],
	'x'          => undef,
	'y'          => undef,
	'width'      => undef,
	'highlights' => $highlights,
	'strand'     => $strand,
	'minx'       => undef,
	'miny'       => undef,
	'maxx'       => undef,
	'maxy'       => undef,
	'label'      => undef,
        'bumped'     => undef,
        'bumpbutton' => undef,
	'label2'     => undef,	
	'container'  => $Container,
	'config'     => $Config,
	'extras'     => $extra_config,
    };

    bless($self, $class);
    $self->init_label() if($self->can('init_label'));
    return $self;
}

#########
# _init creates masses of Glyphs from a data source.
# It should executes bumping and globbing on the fly and also
# keep track of x,y,width,height as it goes.
#
sub __init {
  my $self = shift;
  $self->_init(@_);
}
sub _init {
    my ($self) = @_;
    print STDERR qq($self unimplemented\n);
}

# Gets the number of Base Pairs per pixel
sub basepairs_per_pixel {
    my ($self) = @_;
    my $pixels = $self->{'config'}->get( '_settings' ,'width' );
    return (defined $pixels && $pixels) ? $self->{'container'}->length() / $pixels : undef; 
}    

sub glob_bp {
    my ($self) = @_;
    return int( $self->basepairs_per_pixel()*2 );
}


# join_tag joins between glyphsets in different tracks
#$self->join_tag(
#  $tglyph,         # A glyph you've drawn...
#  $key,            # Key for glyph
#  $T,              # X position in glyph (0-1)
#  0,               # Y position in glyph (0-1) 0 nearest contigs
#  $colour,         # colour to draw shape
#  'fill',          # whether to fill or draw line
#  -99              # z-index 
#);

sub join_tag {
    my( $self, $glyph, $tag, $x_pos, $y_pos, $col, $style, $zindex ) = @_;
    CORE::push @{$self->{'tags'}{$tag}}, { 'glyph' => $glyph, 'x' => $x_pos, 'y' => $y_pos, 'col' => $col, 'style' => $style, 'z' => $zindex };
}

#########
# return our list of glyphs
#
sub glyphs {
    my ($self) = @_;
    return @{$self->{'glyphs'}};
}

#########
# push either a Glyph or a GlyphSet on to our list
#
sub push {
    my $self = CORE::shift;
    my ($gx, $gx1, $gy, $gy1);
    
    foreach my $Glyph (@_) {
    	CORE::push @{$self->{'glyphs'}}, $Glyph;<commit_msg>made easier to read and has options for hashref parameter<commit_after>#########
# Author: <EMAIL>
# Maintainer: <EMAIL>
# Created: 2001
#
package Sanger::Graphics::GlyphSet;
use strict;
use Exporter;
use Sanger::Graphics::Glyph::Diagnostic;
use Sanger::Graphics::Glyph::Text;
use Sanger::Graphics::Root;
use Sanger::Graphics::Glyph::Space;

use vars qw(@ISA);
@ISA = qw( Sanger::Graphics::Root );

#########
# constructor
#
sub new {
    my ($class, $Container, $Config, $highlights, $strand, $extra_config) = @_;
    my $self = {
	'glyphs'     => [],
	'x'          => undef,
	'y'          => undef,
	'width'      => undef,
	'highlights' => $highlights,
	'strand'     => $strand,
	'minx'       => undef,
	'miny'       => undef,
	'maxx'       => undef,
	'maxy'       => undef,
	'label'      => undef,
        'bumped'     => undef,
        'bumpbutton' => undef,
	'label2'     => undef,	
	'container'  => $Container,
	'config'     => $Config,
	'extras'     => $extra_config,
    };

    bless($self, $class);
    $self->init_label() if($self->can('init_label'));
    return $self;
}

#########
# _init creates masses of Glyphs from a data source.
# It should executes bumping and globbing on the fly and also
# keep track of x,y,width,height as it goes.
#
sub __init {
  my $self = shift;
  $self->_init(@_);
}
sub _init {
    my ($self) = @_;
    print STDERR qq($self unimplemented\n);
}

# Gets the number of Base Pairs per pixel
sub basepairs_per_pixel {
    my ($self) = @_;
    my $pixels = $self->{'config'}->get( '_settings' ,'width' );
    return (defined $pixels && $pixels) ? $self->{'container'}->length() / $pixels : undef; 
}    

sub glob_bp {
    my ($self) = @_;
    return int( $self->basepairs_per_pixel()*2 );
}


# join_tag joins between glyphsets in different tracks
#$self->join_tag(
#  $tglyph,         # A glyph you've drawn...
#  $key,            # Key for glyph
#  $T,              # X position in glyph (0-1)
#  0,               # Y position in glyph (0-1) 0 nearest contigs
#  $colour,         # colour to draw shape
#  'fill',          # whether to fill or draw line
#  -99              # z-index 
#);

sub join_tag {
  my( $self, $glyph, $tag, $x_pos, $y_pos, $col, $style, $zindex, $href, $alt ) = @_;
  if( ref($x_pos) eq 'HASH' ) {
    CORE::push @{$self->{'tags'}{$tag}}, {
      %$x_pos,
      'glyph' => $glyph
    };
  } else {
    CORE::push @{$self->{'tags'}{$tag}}, {
      'glyph' => $glyph,
      'x'     => $x_pos,
      'y'     => $y_pos,
      'col'   => $col, 
      'style' => $style,
      'z'     => $zindex,
      'href'  => $href,
      'alt'   => $alt
    };
  }
}

#########
# return our list of glyphs
#
sub glyphs {
    my ($self) = @_;
    return @{$self->{'glyphs'}};
}

#########
# push either a Glyph or a GlyphSet on to our list
#
sub push {
    my $self = CORE::shift;
    my ($gx, $gx1, $gy, $gy1);
    
    foreach my $Glyph (@_) {
    	CORE::push @{$self->{'glyphs'}}, $Glyph;
{'fraction_non_alphanumeric': 0.19860440150295222, 'fraction_numerical': 0.0057255322955806045, 'mean_word_length': 2.704440026507621, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 81, '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': '2997289', 'n_tokens_mistral': 2162, 'n_tokens_neox': 2064, 'n_words': 542}