<commit_before>package Bio::EnsEMBL::GlyphSet::Videogram;
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::GlyphSet;
@ISA = qw(Bio::EnsEMBL::GlyphSet);

use Bio::EnsEMBL::Glyph::Rect;
use Bio::EnsEMBL::Glyph::Poly;
use Bio::EnsEMBL::Glyph::Text;
use Bio::EnsEMBL::Glyph::Line;
use Bio::EnsEMBL::Glyph::Space;
use SiteDefs;

sub init_label {
    my ($self) = @_;
    return if( $self->{'config'}->{'_label'} eq 'none'  );
    my $chr = $self->{'container'}->{'chr'} || $self->{'extras'}->{'chr'};
    $chr = uc($chr);
    $chr = "Chromosome $chr" if( $self->{'config'}->{'_label'} eq 'above' );
    my $label = new Bio::EnsEMBL::Glyph::Text({
        'text'      => $chr,
        'font'      => 'Small',
        'absolutey' => 1,
    });
    $self->label($label);
}

sub _init {
    my ($self) = @_;

    my $Config = $self->{'config'};
    return unless $Config->container_width()>0; # The container has zero width !!EXIT!!
    
    my $col    = undef;
    my $cmap   = $Config->colourmap();
    my $white  = $cmap->id_by_name('white');
    my $black  = $cmap->id_by_name('black');
    my $bg     = $Config->get('_settings','bgcolor');
    my $red    = $cmap->id_by_name('red');
 
    my %COL = ();
    $COL{'gpos100'} = $cmap->id_by_name('black'); #add_rgb([200,200,200]);
    $COL{'gpos75'}  = $cmap->id_by_name('grey3'); #add_rgb([210,210,210]);
    $COL{'gpos50'}  = $cmap->id_by_name('grey2'); #add_rgb([230,230,230]);
    $COL{'gpos25'}  = $cmap->id_by_name('grey1'); #add_rgb([240,240,240]);
    $COL{'gpos'}    = $black; #add_rgb([240,240,240]);
    $COL{'gvar'}    = $cmap->add_rgb([222,220,220]);
    $COL{'gneg'}    = $white;
    $COL{'acen'}    = $cmap->id_by_name('slategrey');
    $COL{'stalk'}   = $cmap->id_by_name('slategrey');

    my $im_width    = $Config->image_width();
    my $top_margin  = $Config->{'_top_margin'};
    my ($w,$h)      = $Config->texthelper->Vpx2bp('Tiny');
    my $chr         = $self->{'container'}->{'chr'} || $self->{'extras'}->{'chr'};

    # fetch the chromosome bands that cover this VC.
    my $kba         = $self->{'container'}->{'ka'};
    my @bands       = $kba->fetch_all_by_chromosome($chr);
    my $chr_length  = $kba->fetch_chromosome_length($chr) || 1;
    my $v_offset    = $Config->container_width() - $chr_length; # bottom align each chromosome!
    my $bpperpx     = $Config->container_width()/$Config->{'_image_height'};
    # over come a bottom border/margin problem....

    my $done_1_acen = 0;        # flag for tracking place in chromsome
    my $wid         = $Config->get('Videogram','width');
    my $h_wid       = int($wid/2);
    my $padding     = $Config->get('Videogram','padding');
        
    # max width of band label is 6 characters
    my $h_offset    = int(
        $self->{'config'}->get('Videogram','totalwidth')
            - $wid
            - ($self->{'config'}->{'_band_labels'} eq 'on' ? ($w * 6 + 4) : 0 )
    )/2;

    my @decorations;
    if($padding) {
    # make sure that there is a blank image behind the chromosome so that the
    # glyhset doesn't get "horizontally" squashed.
        my $gpadding = new Bio::EnsEMBL::Glyph::Space({
            'x'         => 0,
            'y'         => $h_offset - $padding,
            'width'     => 10000,
            'height'    => $padding * 2 + $wid,
            'absolutey' => 1,
        });
        $self->push($gpadding);        
    }
    foreach my $band (@bands){
        my $bandname       = $band->name();
        my $vc_band_start  = $band->start() + $v_offset;
        my $vc_band_end    = $band->end() + $v_offset;
        my $stain          = $band->stain();

        my $HREF;
        if($self->{'config'}->{'_band_links'}) {
            $HREF = "/$ENV{'ENSEMBL_SPECIES'}/contigview?chr=$chr&vc_start=$vc_band_start&vc_end=$vc_band_end";
        }
        if ($stain eq "acen"){
            my $gband;
            if ($done_1_acen){
                $gband = new Bio::EnsEMBL::Glyph::Poly({
                    'points'       => [ 
                                        $vc_band_start,$h_offset + $h_wid, 
                                        $vc_band_end,$h_offset,
                                        $vc_band_end,$h_offset + $wid,
                                      ],
                    'colour'       => $COL{$stain},
                    'absolutey'    => 1,
                    'href'         => $HREF
                });
            } else {
                $gband = new Bio::EnsEMBL::Glyph::Poly({
                    'points'       => [ 
                                        $vc_band_start,$h_offset, 
                                        $vc_band_end,$h_offset + $h_wid,
                                        $vc_band_start,$h_offset + $wid,
                                      ],
                    'colour'       => $COL{$stain},
                    'absolutey'    => 1,
                    'href'         => $HREF
                });
                $done_1_acen = 1;
            }
            push @decorations, $gband;
        } elsif ($stain eq "stalk"){
            my $gband = new Bio::EnsEMBL::Glyph::Poly({
                'points'           => [
                                        $vc_band_start,$h_offset, 
                                        $vc_band_end,$h_offset + $wid,
                                        $vc_band_end,$h_offset,
                                        $vc_band_start,$h_offset + $wid, 
                                      ],
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            push @decorations, $gband;
            $gband = new Bio::EnsEMBL::Glyph::Rect({
                'x'                => $vc_band_start,
                'y'                => $h_offset+ int($wid/4),
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => $h_wid,
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            push @decorations, $gband;
        } else {
            my $gband = new Bio::EnsEMBL::Glyph::Rect({
                'x'                => $vc_band_start,
                'y'                => $h_offset,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => $wid,
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            $self->push($gband);
            $gband = new Bio::EnsEMBL::Glyph::Line({
                'x'                => $vc_band_start,
                'y'                => $h_offset,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => 0,
                'colour'           => $black,
                'absolutey'        => 1,
            });
            $self->push($gband);
            $gband = new Bio::EnsEMBL::Glyph::Line({
                'x'                => $vc_band_start,
                'y'                => $h_offset+$wid,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => 0,
                'colour'           => $black,
                'absolutey'        => 1,
            });
            $self->push($gband);
        }
        my $fontcolour;
<commit_msg>Added band hiding switch to config which will allow "white" chromosomes"<commit_after>package Bio::EnsEMBL::GlyphSet::Videogram;
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::GlyphSet;
@ISA = qw(Bio::EnsEMBL::GlyphSet);

use Bio::EnsEMBL::Glyph::Rect;
use Bio::EnsEMBL::Glyph::Poly;
use Bio::EnsEMBL::Glyph::Text;
use Bio::EnsEMBL::Glyph::Line;
use Bio::EnsEMBL::Glyph::Space;
use SiteDefs;

sub init_label {
    my ($self) = @_;
    return if( $self->{'config'}->{'_label'} eq 'none'  );
    my $chr = $self->{'container'}->{'chr'} || $self->{'extras'}->{'chr'};
    $chr = uc($chr);
    $chr = "Chromosome $chr" if( $self->{'config'}->{'_label'} eq 'above' );
    my $label = new Bio::EnsEMBL::Glyph::Text({
        'text'      => $chr,
        'font'      => 'Small',
        'absolutey' => 1,
    });
    $self->label($label);
}

sub _init {
    my ($self) = @_;

    my $Config = $self->{'config'};
    return unless $Config->container_width()>0; # The container has zero width !!EXIT!!
    
    my $col    = undef;
    my $cmap   = $Config->colourmap();
    my $white  = $cmap->id_by_name('white');
    my $black  = $cmap->id_by_name('black');
    my $bg     = $Config->get('_settings','bgcolor');
    my $red    = $cmap->id_by_name('red');
 
    my %COL = ();
    $COL{'gpos100'} = $cmap->id_by_name('black'); #add_rgb([200,200,200]);
    $COL{'gpos75'}  = $cmap->id_by_name('grey3'); #add_rgb([210,210,210]);
    $COL{'gpos50'}  = $cmap->id_by_name('grey2'); #add_rgb([230,230,230]);
    $COL{'gpos25'}  = $cmap->id_by_name('grey1'); #add_rgb([240,240,240]);
    $COL{'gpos'}    = $black; #add_rgb([240,240,240]);
    $COL{'gvar'}    = $cmap->add_rgb([222,220,220]);
    $COL{'gneg'}    = $white;
    $COL{'acen'}    = $cmap->id_by_name('slategrey');
    $COL{'stalk'}   = $cmap->id_by_name('slategrey');

    my $im_width    = $Config->image_width();
    my $top_margin  = $Config->{'_top_margin'};
    my ($w,$h)      = $Config->texthelper->Vpx2bp('Tiny');
    my $chr         = $self->{'container'}->{'chr'} || $self->{'extras'}->{'chr'};

    # fetch the chromosome bands that cover this VC.
    my $kba         = $self->{'container'}->{'ka'};
    my @bands       = $kba->fetch_all_by_chromosome($chr);
    my $chr_length  = $kba->fetch_chromosome_length($chr) || 1;
    my $v_offset    = $Config->container_width() - $chr_length; # bottom align each chromosome!
    my $bpperpx     = $Config->container_width()/$Config->{'_image_height'};
    # over come a bottom border/margin problem....

    my $done_1_acen = 0;        # flag for tracking place in chromsome
    my $wid         = $Config->get('Videogram','width');
    my $h_wid       = int($wid/2);
    my $padding     = $Config->get('Videogram','padding');
        
    # max width of band label is 6 characters
    my $h_offset    = int(
        $self->{'config'}->get('Videogram','totalwidth')
            - $wid
            - ($self->{'config'}->{'_band_labels'} eq 'on' ? ($w * 6 + 4) : 0 )
    )/2;

    my @decorations;
    if($padding) {
    # make sure that there is a blank image behind the chromosome so that the
    # glyhset doesn't get "horizontally" squashed.
        my $gpadding = new Bio::EnsEMBL::Glyph::Space({
            'x'         => 0,
            'y'         => $h_offset - $padding,
            'width'     => 10000,
            'height'    => $padding * 2 + $wid,
            'absolutey' => 1,
        });
        $self->push($gpadding);        
    }
    foreach my $band (@bands){
        my $bandname       = $band->name();
        my $vc_band_start  = $band->start() + $v_offset;
        my $vc_band_end    = $band->end() + $v_offset;
        my $stain          = $band->stain();

        my $HREF;
        if($self->{'config'}->{'_band_links'}) {
            $HREF = "/$ENV{'ENSEMBL_SPECIES'}/contigview?chr=$chr&vc_start=$vc_band_start&vc_end=$vc_band_end";
        }
        if ($stain eq "acen"){
            my $gband;
            if ($done_1_acen){
                $gband = new Bio::EnsEMBL::Glyph::Poly({
                    'points'       => [ 
                                        $vc_band_start,$h_offset + $h_wid, 
                                        $vc_band_end,$h_offset,
                                        $vc_band_end,$h_offset + $wid,
                                      ],
                    'colour'       => $COL{$stain},
                    'absolutey'    => 1,
                    'href'         => $HREF
                });
            } else {
                $gband = new Bio::EnsEMBL::Glyph::Poly({
                    'points'       => [ 
                                        $vc_band_start,$h_offset, 
                                        $vc_band_end,$h_offset + $h_wid,
                                        $vc_band_start,$h_offset + $wid,
                                      ],
                    'colour'       => $COL{$stain},
                    'absolutey'    => 1,
                    'href'         => $HREF
                });
                $done_1_acen = 1;
            }
            push @decorations, $gband;
        } elsif ($stain eq "stalk"){
            my $gband = new Bio::EnsEMBL::Glyph::Poly({
                'points'           => [
                                        $vc_band_start,$h_offset, 
                                        $vc_band_end,$h_offset + $wid,
                                        $vc_band_end,$h_offset,
                                        $vc_band_start,$h_offset + $wid, 
                                      ],
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            push @decorations, $gband;
            $gband = new Bio::EnsEMBL::Glyph::Rect({
                'x'                => $vc_band_start,
                'y'                => $h_offset+ int($wid/4),
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => $h_wid,
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            push @decorations, $gband;
        } else {
            $stain = 'gneg' if($self->{'config'}->{'_hide_bands'} eq 'yes' );
            my $gband = new Bio::EnsEMBL::Glyph::Rect({
                'x'                => $vc_band_start,
                'y'                => $h_offset,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => $wid,
                'colour'           => $COL{$stain},
                'absolutey'        => 1,
                'href'             => $HREF
            });
            $self->push($gband);
            $gband = new Bio::EnsEMBL::Glyph::Line({
                'x'                => $vc_band_start,
                'y'                => $h_offset,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => 0,
                'colour'           => $black,
                'absolutey'        => 1,
            });
            $self->push($gband);
            $gband = new Bio::EnsEMBL::Glyph::Line({
                'x'                => $vc_band_start,
                'y'                => $h_offset+$wid,
                'width'            => $vc_band_end - $vc_band_start,
                'height'           => 0,
                'colour'           => $black,
                'absolutey'        => 1,
            });
            $self->push($gband);
        }
        my $fontcolour;

{'fraction_non_alphanumeric': 0.16851544337429425, 'fraction_numerical': 0.01315177681833278, 'mean_word_length': 1.377763739734681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 207, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2637760', 'n_tokens_mistral': 5075, 'n_tokens_neox': 4680, 'n_words': 839}