<commit_before>package Bio::EnsEMBL::GlyphSet::tilepath;
use strict;
use Bump;
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 SiteDefs;

sub init_label {
    my ($self) = @_;
    return if( defined $self->{'config'}->{'_no_label'} );
    my $label = new Bio::EnsEMBL::Glyph::Text({
	'text'      => 'Tile Path',
	'font'      => 'Small',
	'absolutey' => 1,
    });
    $self->label($label);
}

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

    return unless ($self->strand() == -1);
    
	my $vc              = $self->{'container'};
    my $length   		= $vc->length();
    my $Config 			= $self->{'config'};
    my @bitmap         		= undef;
    my $pix_per_bp  		= $Config->transform->{'scalex'};
    my $bitmap_length 		= int($length * $pix_per_bp);

    my $ystart   		= 0;
    my $im_width 		= $Config->image_width();
    my ($w,$h)   		= $Config->texthelper()->px2bp('Tiny');
    my ($col, $lab) 	        = ();
    my $i 			= 1;
    my $dep                     = $Config->get('tilepath', 'dep');
    my $col1                    = $Config->get('tilepath', 'col1');
    my $col2                    = $Config->get('tilepath', 'col2');
    my $lab1                    = $Config->get('tilepath', 'lab1');
    my $lab2                    = $Config->get('tilepath', 'lab2');
    my $include_fish            = $Config->get('tilepath', 'fish' );
    my $threshold_navigation    = ($Config->get('tilepath', 'threshold_navigation') || 2e6)*1001;
	my $show_navigation = $length < $threshold_navigation;
	my $blue = $Config->colourmap->id_by_name('contigblue1');
	my $green = $Config->colourmap->id_by_name('black');
    my @asm_clones = $vc->get_all_FPCClones( $include_fish );
	my $vc_start   = $vc->_global_start();
    if (@asm_clones){

    my @fish_clones;
	foreach my $clone ( @asm_clones ) {

	    my $id    	= $clone->name();		
	    my $start	= $clone->start();
	    my $end	    = $clone->end();
        my $cl_len  = $end-$start+1;

		($col,$lab) = $i ? ($col1,$lab1) : ($col2,$lab2);
        my $MAX_WIDTH = 300000;
        my($box_start,$box_end);
        
        my $fish_clone = undef;
	    my $Composite = new Bio::EnsEMBL::Glyph::Composite({
			'y'            => 0,
			'x'            => $start,
			'absolutey'    => 1
		});
		
	    if($cl_len > $MAX_WIDTH) {
            $box_start = $start;
            $box_end   = $box_start + 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
        	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
            		'x'         => $box_start,
        	    	'y'         => $ystart+2,
            		'width'     => $box_end-$box_start+1,
            		'height'    => 7,
            		'colour'    => $col,
            		'absolutey' => 1,
        	    });
        	    $Composite->push($glyph);
            }
            $box_end   = $end;
            $box_start = $box_end - 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
        	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
            		'x'         => $box_start,
        	    	'y'         => $ystart+2,
            		'width'     => $box_end-$box_start+1,
            		'height'    => 7,
            		'colour'    => $col,
            		'absolutey' => 1,
        	    });
        	    $Composite->push($glyph);
            }
            $box_start = $start + 20/2;
            $box_end   = $end  - 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
                foreach (2,9) {
            	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
                		'x'         => $box_start,
            	    	'y'         => $ystart+$_,
                		'width'     => $box_end-$box_start+1,
                		'height'    => 0,
                		'colour'    => $col,
                		'absolutey' => 1,
            	    });
                    $Composite->push($glyph);
                }
            }
    	    $start      = 0 if ($start < 0);
	        $end        = $length if ($end > $length);
        } else {
    	    $start      = 0 if ($start < 0);
	        $end        = $length if ($end > $length);
    	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
        		'x'         => $start,
    	    	'y'         => $ystart+2,
        		'width'     => $end - $start,
        		'height'    => 7,
        		'colour'    => $col,
        		'absolutey' => 1,
    	    });
    	    $Composite->push($glyph);
        }

        if($show_navigation) {
            
    		$Composite->{'zmenu'} = {
				'caption' => $id || $clone->embl_acc,
				'02:EMBL id: '.$clone->embl_acc => '',
				"03:loc: ".($clone->start()+$vc_start-1).'-'.($clone->end()+$vc_start-1) => '',
				"04:length: ".($clone->length()) => '',
            };
            $Composite->{'zmenu'}->{'06:Jump to Contigview'} = "/$ENV{'ENSEMBL_SPECIES'}/contigview?clone=".$clone->embl_acc
                if $ENV{'ENSEMBL_SCRIPT'} ne 'contigview' ;
	    } <commit_msg>Added extra info to Zmenu - Organisation<commit_after>package Bio::EnsEMBL::GlyphSet::tilepath;
use strict;
use Bump;
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 SiteDefs;

sub init_label {
    my ($self) = @_;
    return if( defined $self->{'config'}->{'_no_label'} );
    my $label = new Bio::EnsEMBL::Glyph::Text({
	'text'      => 'Tile Path',
	'font'      => 'Small',
	'absolutey' => 1,
    });
    $self->label($label);
}

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

    return unless ($self->strand() == -1);
    
	my $vc              = $self->{'container'};
    my $length   		= $vc->length();
    my $Config 			= $self->{'config'};
    my @bitmap         		= undef;
    my $pix_per_bp  		= $Config->transform->{'scalex'};
    my $bitmap_length 		= int($length * $pix_per_bp);

    my $ystart   		= 0;
    my $im_width 		= $Config->image_width();
    my ($w,$h)   		= $Config->texthelper()->px2bp('Tiny');
    my ($col, $lab) 	        = ();
    my $i 			= 1;
    my $dep                     = $Config->get('tilepath', 'dep');
    my $col1                    = $Config->get('tilepath', 'col1');
    my $col2                    = $Config->get('tilepath', 'col2');
    my $lab1                    = $Config->get('tilepath', 'lab1');
    my $lab2                    = $Config->get('tilepath', 'lab2');
    my $include_fish            = $Config->get('tilepath', 'fish' );
    my $threshold_navigation    = ($Config->get('tilepath', 'threshold_navigation') || 2e6)*1001;
	my $show_navigation = $length < $threshold_navigation;
	my $blue = $Config->colourmap->id_by_name('contigblue1');
	my $green = $Config->colourmap->id_by_name('black');
    my @asm_clones = $vc->get_all_FPCClones( $include_fish );
	my $vc_start   = $vc->_global_start();
    if (@asm_clones){

    my @fish_clones;
	foreach my $clone ( @asm_clones ) {

	    my $id    	= $clone->name();		
	    my $start	= $clone->start();
	    my $end	    = $clone->end();
        my $cl_len  = $end-$start+1;

		($col,$lab) = $i ? ($col1,$lab1) : ($col2,$lab2);
        my $MAX_WIDTH = 300000;
        my($box_start,$box_end);
        
        my $fish_clone = undef;
	    my $Composite = new Bio::EnsEMBL::Glyph::Composite({
			'y'            => 0,
			'x'            => $start,
			'absolutey'    => 1
		});
		
	    if($cl_len > $MAX_WIDTH) {
            $box_start = $start;
            $box_end   = $box_start + 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
        	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
            		'x'         => $box_start,
        	    	'y'         => $ystart+2,
            		'width'     => $box_end-$box_start+1,
            		'height'    => 7,
            		'colour'    => $col,
            		'absolutey' => 1,
        	    });
        	    $Composite->push($glyph);
            }
            $box_end   = $end;
            $box_start = $box_end - 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
        	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
            		'x'         => $box_start,
        	    	'y'         => $ystart+2,
            		'width'     => $box_end-$box_start+1,
            		'height'    => 7,
            		'colour'    => $col,
            		'absolutey' => 1,
        	    });
        	    $Composite->push($glyph);
            }
            $box_start = $start + 20/2;
            $box_end   = $end  - 20/2;
            if($box_end=>1 && $box_start<=$length) { ## We can draw this
                $box_start = 1       if $box_start < 1;
                $box_end   = $length if $box_end   >  $length;
                foreach (2,9) {
            	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
                		'x'         => $box_start,
            	    	'y'         => $ystart+$_,
                		'width'     => $box_end-$box_start+1,
                		'height'    => 0,
                		'colour'    => $col,
                		'absolutey' => 1,
            	    });
                    $Composite->push($glyph);
                }
            }
    	    $start      = 0 if ($start < 0);
	        $end        = $length if ($end > $length);
        } else {
    	    $start      = 0 if ($start < 0);
	        $end        = $length if ($end > $length);
    	    my $glyph = new Bio::EnsEMBL::Glyph::Rect({
        		'x'         => $start,
    	    	'y'         => $ystart+2,
        		'width'     => $end - $start,
        		'height'    => 7,
        		'colour'    => $col,
        		'absolutey' => 1,
    	    });
    	    $Composite->push($glyph);
        }

        if($show_navigation) {
            
    		$Composite->{'zmenu'} = {
				'caption' => $id || $clone->embl_acc,
				'02:EMBL id: '.$clone->embl_acc => '',
				"03:loc: ".($clone->start()+$vc_start-1).'-'.($clone->end()+$vc_start-1) => '',
				"04:length: ".($clone->length()) => '',
            };
            $Composite->{'zmenu'}->{"05:Centre: ".$clone->organisation} = ''
                if $clone->organisation;
            $Composite->{'zmenu'}->{'06:Jump to Contigview'} = "/$ENV{'ENSEMBL_SPECIES'}/contigview?clone=".$clone->embl_acc
                if $ENV{'ENSEMBL_SCRIPT'} ne 'contigview' ;
	    } 
{'fraction_non_alphanumeric': 0.18426121251031827, 'fraction_numerical': 0.015592038888379345, 'mean_word_length': 1.6017656883798617, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 175, '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': '1997913', 'n_tokens_mistral': 4161, 'n_tokens_neox': 3869, 'n_words': 705}