#!/usr/bin/env perl 
use strict;
#use warnings;
use SVG;
use Bio::SeqIO;
use Getopt::Long;
use Pod::Usage;

#drawstyle
my $man=0;
my $help=0;
my $genomenumber=0;#2
my $aligntype=1;
my $heatmap2_type=0;
my $GC_content=1;
my $curveto=1;
my $highlightinversion=1;
my $inversion_iconaa=0;
my $highlighttranslocation=1;
my $translocation_iconaa=0;
my $synteny_iconaa=0;
my $chromosomenumber=0;
my $chromosomenumber2=0;
my $chromosomenumber3=0;
my $chromosomename=0;
my $illustration=0;
my $icon=1;
my $SNP_threshold_value=2000;
my $GD_Win_bp=100000;
my $GC_Win_bp=1;#10000;#
my $TE_Win_bp=1;#100000;#
my $SNP_Win_bp=1;#100000;#
my $pro_snpa=1;
my $pro_TEa=1;
my $pro_GCa=1;
my $synteny_limit=10000;
my $Inversion_limit=10000;
my $PAV_limit=10000;
my $NLR_limit=10000;				
my $coverage_limit=90;
my $proportion =25000;
my $proportionX='';
my $proportion_m2;#100000
my $proportion_m2aa=0;
my $TE_tem3min=1000000000;
###PWD
my $pwd='';
my $pwd_test='';
my $pwd_prefix='';
my $GenomeSyn_aa='/bin/GenomeSyn';
my $GenomeSyn_bb='\bin\GenomeSyn';
my $pwd_a;
my $pwd_do_mummer='';
#my $pwd_do_variation='';
my $pwd_python='';
my $pwd_svg_pdf='';
my $linux_commands=0;
$pwd_test=eval{`which GenomeSyn 2>&1`} // 'NaN';
if( $pwd_test ne 'NaN')
{
     chomp($pwd=$pwd_test);
	 $pwd_a=index($pwd,$GenomeSyn_aa);
	 $pwd_prefix=substr($pwd,0,$pwd_a);
	 $pwd_do_mummer="$pwd_prefix".'/bin/do_mummer.sh';
	 #$pwd_do_variation="$pwd_prefix".'/bin/do_variation.sh';
	 #$pwd_python="$pwd_prefix".'/Python-3.9.4/python';
         $pwd_python='python';
	 $pwd_svg_pdf="$pwd_prefix".'/bin/svg_pdf.py';
	 $linux_commands=1;
}
$pwd_test=eval{`where GenomeSyn 2>&1`} // 'NaN';
if( $pwd_test ne 'NaN')
{
     chomp($pwd=$pwd_test);
	 $pwd_a=index($pwd,$GenomeSyn_bb);
	 $pwd_prefix=substr($pwd,0,$pwd_a);
	 $pwd_do_mummer="$pwd_prefix".'\bin\do_mummer.sh';
	 #$pwd_do_variation="$pwd_prefix".'\bin\do_variation.sh';
	 #$pwd_python="$pwd_prefix".'\Python-3.9.4\python';
	 $pwd_python='python';
	 $pwd_svg_pdf="$pwd_prefix".'\bin\svg_pdf.py';	 
}
#print"\$pwd:$pwd\n";
#print"\$pwd_prefix:$pwd_prefix\n";
#print"\$pwd_do_mummer:$pwd_do_mummer\n";
#print"\$pwd_do_variation:$pwd_do_variation\n";
#print"\$pwd_python:$pwd_python\n";
#print"\$pwd_svg_pdf:$pwd_svg_pdf\n";

###genome
#reference genome
my $genomeSeq1='';
#query1 genome
my $genomeSeq2='';
#query2 genome
my $genomeSeq3='';

###color
my $reference_color="#3979BC";#rgb(57,121,188)
my $query1_color="#499272";#rgb(73,146,114)
my $query2_color="#447784";#rgb(68,119,132)
my $synteny_color="#DFDFE1";#rgb(223,223,225)
my $inversion_color="#E56C1A";#rgb(229,108,26)
my $centromere_color="#E4993F";#rgb(228,153,63)
my $telomere_color="#441680";#rgb(68,22,128)
my $PAV_color="#F9F067";#rgb(249,240,103)
my $NLR_color="#00FFFF";#rgb(0,255,255)
my $SNP_color="#1E90FF";#rgb(30,144,255)
my $TE_color="#1E90FF";#rgb(30,144,255)
my $genedensity_color="#368F5C";#rgb(54,143,92)
my $translocation_color="#EFCF48";#rgb(239,207,72)
my $targetgene_color="#DC143C";#rgb(220,20,60)
my $targetgene_name="Target Gene";

###Comparison
#Comparison_File1
my $inputFile='';
#Comparison_File2
my $inputFile2='';                                   
#Comparison_File3
my $inputFile3='';

my $mailbox='';
my $POSTFIX1=".coords";
my $POSTFIX2=".delta.filter.coords";
my $PREFIX1="ReferencevsQuery1";
my $PREFIX2="ReferencevsQuery2";
my $PREFIX3="Query1vsQuery2";

###centromere
#query1 centromere
my $inputFile6='';#'zs_centromere.txt';
#reference centromere
my $inputFile7='';#'mh_centromere.txt';
#query2 centromere  
my $inputFile66='';##zs_centromere.txt;

###telomere
#query1 telomere
my $inputFile8='';#'zs_telomere.txt';
#reference telomere
my $inputFile9='';#'mh_telomere.txt';
#query2 telomere
my $inputFile88='';##zs_telomere.txt;


#targetgene 
#query1 targetgene
my $inputFile12='';#'example_local_human.gff3';
#reference targetgene
my $inputFile13='';#'example_local_human.gff3';
#query2 targetgene
my $inputFile14='';#'example_local_human.gff3';
#snp
my $inputFile15='';#'MH63RS3vsZS97RS3.delta.filter.SNP';
my $inputFile16='';#'MH63RS3vsZS97RS3.delta.filter.SNP';
my $inputFile166='';
my $inputFile17='';#'mh-TE.txt';
my $inputFile18='';#'zs-TE.txt';
my $inputFile19='';#'mh-TE.txt';
my $inputFile20='';
my $inputFile21='';
my $inputFile22='';
my $inputFile23='';
my $inputFile24='';
my $inputFile25='';
my $inputFile26='';
my $inputFile27='';
my $inputFile28='';
my $inputFile29='';
my $inputFile30='';
my $inputFile31='';

#outfilename
my $output1='GenomeSyn-main-1.svg';
my $output2='GenomeSyn-main-2.svg';
my $output3='GenomeSyn-heatmap.svg';
my $output4='GenomeSyn-identity.svg';
my $output5='GenomeSyn-coverage.svg';
my $output6='GenomeSyn-heatmap2.svg';
#SVG_text
my $headline_identity='GenomeSyn identity';
my $headline_coverage='GenomeSyn coverage';
my $headline_heatmap='GenomeSyn heatmap';
my $refname='reference';
my $queryname='query';
my $queryname2='query2';
#my $pre='Chr';
my $svg_pdf=1;
my $chromosome_sort='';
my $SyngtInv=10;
my $structural_variation=0;
#parameter transfer
GetOptions( 'genomenumber|gn|n=i'=>\$genomenumber,
            'aligntype|at|t=i'=>\$aligntype,
			'genomeSeq1|g1=s'=>\$genomeSeq1,
            'genomeSeq2|g2=s'=>\$genomeSeq2,
            'genomeSeq3|g3=s'=>\$genomeSeq3,
		    'comparison_file|comparison_file1|cf|cf1=s'=>\$inputFile,
            'comparison_file2|cf2=s'=>\$inputFile2,
			'comparison_file3|cf3=s'=>\$inputFile3,
		    'chromosomenumber|n1=i'=>\$chromosomenumber,
			'chromosomenumber2|n2=i'=>\$chromosomenumber2,
			'chromosomenumber3|n3=i'=>\$chromosomenumber3,
			'SVG_PDF|pdf=i'=>\$svg_pdf,
			'sort=s'=>\$chromosome_sort,
			'SyntenygtInversion|SyngtInv=i'=>\$SyngtInv,
			'chromosomename|cn=i'=>\$chromosomename,
			'referencename|reference|ref|r=s'=>\$refname,
			'queryname|queryname1|query1|query|q|q1=s'=>\$queryname,
			'queryname2|query2|q2=s'=>\$queryname2,
			'centromere_genome1|centromere1|cen1=s'=>\$inputFile7,
			'centromere_genome2|centromere2|cen2=s'=>\$inputFile6,
			'centromere_genome3|centromere3|cen3=s'=>\$inputFile66,
            'telomere_genome1|telomere1|tel1=s'=>\$inputFile9,
			'telomere_genome2|telomere2|tel2=s'=>\$inputFile8,
			'telomere_genome3|telomere3|tel3=s'=>\$inputFile88,
			'targetgene_genome1|targetgene1|gene1=s'=>\$inputFile13,
			'targetgene_genome2|targetgene2|gene2=s'=>\$inputFile12,
			'targetgene_genome3|targetgene3|gene3=s'=>\$inputFile14,
		    'snp_genome1|snp1=s'=>\$inputFile15,
		    'snp_genome2|snp2=s'=>\$inputFile16,
			'snp_genome3|snp3=s'=>\$inputFile166,
			'snp_thresholds|snp_max=i'=>\$SNP_threshold_value,
		    'TE_genome1|TE1=s'=>\$inputFile17,
		    'TE_genome2|TE2=s'=>\$inputFile18,
		    'TE_genome3|TE3=s'=>\$inputFile19,
			'TE_thresholds|TE_min=i'=>\$TE_tem3min,
		    'GC_genome1|GC_content1|GC1=s'=>\$inputFile29,
		    'GC_genome2|GC_content2|GC2=s'=>\$inputFile30,
		    'GC_genome3|GC_content3|GC3=s'=>\$inputFile31,
			'PAV_genome1|PAV1=s'=>\$inputFile20,
			'PAV_genome2|PAV2=s'=>\$inputFile21,
			'PAV_genome3|PAV3=s'=>\$inputFile22,
			'NLR_genome1|NLR1=s'=>\$inputFile23,
            'NLR_genome2|NLR2=s'=>\$inputFile24,
            'NLR_genome3|NLR3=s'=>\$inputFile25,
			'genedensity_genome1|GD1=s'=>\$inputFile26,
			'genedensity_genome2|GD2=s'=>\$inputFile27,
			'genedensity_genome3|GD3=s'=>\$inputFile28,
			'GeneDensity_Window|GD_win=i'=>\$GD_Win_bp,
			'GC_Content_Window|GC_win=i'=>\$GC_Win_bp,
			'TE_Window|TE_win=i'=>\$TE_Win_bp,
			'SNP_Window|SNP_win=i'=>\$SNP_Win_bp,
			'synteny_length_min|synteny_min|syn_min=i'=>\$synteny_limit,
			'inversion_length_min|inversion_min|inv_min=i'=>\$Inversion_limit,
			'PAV_length_min|PAV_min=i'=>\$PAV_limit,
			'NLR_length_min|NLR_min=i'=>\$NLR_limit,
			'coverage_rate_min|coverage_min|cov_min=i'=>\$coverage_limit,
			'icon=i'=>\$icon,
			'proportion1|p1=i'=>\$proportionX,
			'proportion2|p2=i'=>\$proportion_m2aa,	
			'output1|o1=s'=>\$output1,
			'output2|o2=s'=>\$output2,
			'output3|o3=s'=>\$output3,
			'output4|o4=s'=>\$output4,
			'output5|o5=s'=>\$output5,
			'output6|o6=s'=>\$output6,
			'headline_identity|headline1=s'=>\$headline_identity,
			'headline_coverage|headline2=s'=>\$headline_coverage,
			'headline_heatmap|headline3=s'=>\$headline_heatmap,
			'genome1_color|color1|c1=s'=>\$reference_color,
			'genome2_color|color2|c2=s'=>\$query1_color,
			'genome3_color|color3|c3=s'=>\$query2_color,
			'synteny_color|color4|c4=s'=>\$synteny_color,
			'inversion_color|color5|c5=s'=>\$inversion_color,
			'translocation_color|color6|c6=s'=>\$translocation_color,
			'centromere_color|color7|c7=s'=>\$centromere_color,
			'telomere_color|color8|c8=s'=>\$telomere_color,			
			'PAV_color|color9|c9=s'=>\$PAV_color,
			'NLR_color|color10|c10=s'=>\$NLR_color,
			'SNP_color|color11|c11=s'=>\$SNP_color,
			'TE_color|color12|c12=s'=>\$TE_color,
			'genedensity_color|GD_color|color13|c13=s'=>\$genedensity_color,
			'targetgene_color|color14|c14=s'=>\$targetgene_color,
                        'curveto|curve=i'=>\$curveto,
	                'highlightinversion|highlight=i'=>\$highlightinversion,
			'targetgene_name|targetgene=s'=>\$targetgene_name,
			'structural_variation|SV=s'=>\$structural_variation,
			'mailbox=s'=>\$mailbox,
			'heatmap2=s'=>\$heatmap2_type,
            'help|h|?'   =>\$help,
             man        =>\$man ) or pod2usage(2);
pod2usage(1) if ($help);
pod2usage(-exitval=> 0,-verbose => 2) if ($man);
pod2usage("$0: No files given.") if ( ( length("$genomeSeq1")==0 ) or ( length("$genomeSeq2")==0 ) );
pod2usage("$0: Invalid format for comparison file!") if ( (length($inputFile)!=0) and ((substr($inputFile,-7,7)) ne $POSTFIX1 and (substr($inputFile,-7,7)) ne ".COORDS") );
pod2usage("$0: Invalid format for comparison file2!") if ( (length($inputFile2)!=0) and ((substr($inputFile2,-7,7)) ne $POSTFIX1 and (substr($inputFile2,-7,7)) ne ".COORDS") );
pod2usage("$0: Invalid format for comparison file3!") if ( (length($inputFile3)!=0) and ((substr($inputFile3,-7,7)) ne $POSTFIX1 and (substr($inputFile3,-7,7)) ne ".COORDS") );
pod2usage("$0: No given for comparison file!") if ( (length($inputFile)==0) and ($linux_commands==0) );
pod2usage("$0: No given for comparison file2!") if ( (length($inputFile2)==0) and ($linux_commands==0) );
pod2usage("$0: No given for comparison file3!") if ( (length($inputFile3)==0) and ($linux_commands==0) and ($heatmap2_type==1) );
if( ($genomenumber==0) and (length("$genomeSeq1")!=0) and (length("$genomeSeq2")!=0) and (length("$genomeSeq3")==0) ){$genomenumber=2;}
elsif( ($genomenumber==0) and (length("$genomeSeq1")!=0) and (length("$genomeSeq2")!=0) and (length("$genomeSeq3")!=0) ){$genomenumber=3;}
#pod2usage("$0: No  chromosome number given.") if ( ($chromosomenumber==0) or ($chromosomenumber2==0) );
if($genomenumber==3 and $queryname eq 'query'){$queryname='query1';}
if(length($mailbox)!=0)
{
     $output1="$mailbox".'_'."$output1";
	 $output2="$mailbox".'_'."$output2";
	 $output3="$mailbox".'_'."$output3";
	 $output4="$mailbox".'_'."$output4";
	 $output5="$mailbox".'_'."$output5";
	 $output6="$mailbox".'_'."$output6";
	 $PREFIX1="$mailbox".'_'."$PREFIX1";
	 $PREFIX2="$mailbox".'_'."$PREFIX2";
	 $PREFIX3="$mailbox".'_'."$PREFIX3";
}

#print"Test1:\n";
my $SVs_name1;
my $SVs_name2;
my $SVs_name3;
my $SVs_name4;
my $SVs_name5;
my $SVs_name6;
#if(length($inputFile)==0)
{
	 #if(length($inputFile)!=0){print"Invalid format!\n";print"comparison file\npostfix:$postfix\n";}	
	 my $mummer_commands=length($inputFile);
	 if($linux_commands==1)
	 {
	     if($mummer_commands==0){print"Please wait a minute while sequence alignment is underway\n...\n";}
		 system("$pwd_do_mummer $genomeSeq1 $genomeSeq2 $PREFIX1 $mummer_commands $structural_variation");		 
		 if($mummer_commands==0)
		 {
		     $inputFile=$PREFIX1.$POSTFIX2;
		     print"comparison file1: $inputFile\n";
		 }
		 if($structural_variation==1)
		 {
			 $SVs_name1=$PREFIX1.'.delta.filter.snps';
			 $SVs_name2=$PREFIX1.'.delta.filter.qdiff';
			 print"reference vs query1 of snps file: $SVs_name1\n";
			 print"reference vs query1 of PAV file: $SVs_name2\n";
		 }
	 }

}


#print"Test2:\n";
#if( (length($inputFile2)==0) and ($genomenumber==3) )
if( $genomenumber==3 )
{
     #if(length($inputFile2)!=0){print"Invalid format!\n";print"comparison file2\npostfix:$postfix\n";}
	 my $mummer_commands=length($inputFile2);
	 if($linux_commands==1)
	 {
		 if($mummer_commands==0){print"Please wait a minute while sequence alignment is underway\n...\n";}
		 system("$pwd_do_mummer $genomeSeq1 $genomeSeq3 $PREFIX2 $mummer_commands $structural_variation");
		 if($mummer_commands==0)
		 {
		     $inputFile2=$PREFIX2.$POSTFIX2;
			 print"comparison file2: $inputFile2\n";
		 }
		 if($structural_variation==1)
		 {
			 $SVs_name3=$PREFIX2.'.delta.filter.snps';
			 $SVs_name4=$PREFIX2.'.delta.filter.qdiff';
			 print"reference vs query2 of snps file: $SVs_name3\n";
			 print"reference vs query2 of PAV file: $SVs_name4\n";
		 }
	 }
}
#print"Test3:\n";

#if( (length($inputFile3)==0) and ($heatmap2_type==1) and ($genomenumber==3) )
if( ($heatmap2_type==1) and ($genomenumber==3) )
{
	 my $mummer_commands=length($inputFile3);
	 if($linux_commands==1)
	 {
		 if($mummer_commands==0){print"Please wait a minute while sequence alignment is underway\n...\n";}
		 system("$pwd_do_mummer $genomeSeq2 $genomeSeq3 $PREFIX3 $mummer_commands $structural_variation");
		 if($mummer_commands==0)
		 {
		     $inputFile3=$PREFIX3.$POSTFIX2;
			 print"comparison file3: $inputFile3\n";
		 }
		 if($structural_variation==1)
		 {
			 $SVs_name5=$PREFIX3.'.delta.filter.snps';
			 $SVs_name6=$PREFIX3.'.delta.filter.qdiff';
			 print"query1 vs query2 of snps file: $SVs_name5\n";
			 print"query1 vs query2 of PAV file: $SVs_name6\n";
		 }
	 }
}

#main
our $maxChrnum;
our $maxChrlong;
our $margin ;
my $chrin= Bio::SeqIO->new(-file=>"$genomeSeq1");
my $chrin2= Bio::SeqIO->new(-file=>"$genomeSeq2");
my %chr_length;
my %chr_length2;
my %chr_length3;
my @Chrname1;
my @Chrname2;
my @Chrname3;
my @outChrname1;
my @outChrname2;
my @outChrname3;
my @ChrLength;
my @ChrLength2;
my @ChrLength3;
my $ChrLengthMAX;
my @ChrLength_genome_max;
my @ChrLength_genome_max_proportion;
my $margin_m2x=400;
my $margin_m2y=400;
my $margin_m2x_interval=100/2;
my $margin_m2y_comparison=500;
my $main2x=0;

while(my $seq = $chrin->next_seq())
{
	 my $Chrname=$seq->id();
	 push(@Chrname1,$Chrname);
	 my $Chrlength=$seq->length();
	 push(@ChrLength,$Chrlength);
     $chr_length{$seq->id()} = $seq->length();
}
while(my $seq = $chrin2->next_seq())
{
   	  my $Chrname=$seq->id();
	 push(@Chrname2,$Chrname);
	 my $Chrlength=$seq->length();
	 push(@ChrLength2,$Chrlength);
	 $chr_length2{$seq->id()} = $seq->length();
}
if($genomenumber==3)
{
	 my $chrin3= Bio::SeqIO->new(-file=>"$genomeSeq3");
	 while(my $seq = $chrin3->next_seq())
	 {
		  my $Chrname=$seq->id();
		 push(@Chrname3,$Chrname);
		 my $Chrlength=$seq->length();
		 push(@ChrLength3,$Chrlength);		 
		 $chr_length3{$seq->id()} = $seq->length();
	}
}


$proportion=$ChrLength[0]/1800;
if(length("$proportionX")!=0)
{
     $proportion=$proportionX;
}
$proportion_m2=$proportion*4;
if($proportion_m2aa!=0){$proportion_m2=$proportion_m2aa;}

if($chromosomenumber==0){$chromosomenumber=scalar(@Chrname1);}
if($chromosomenumber2==0){$chromosomenumber2=scalar(@Chrname2);}
if($genomenumber==3){if($chromosomenumber3==0){$chromosomenumber3=scalar(@Chrname3);}}
my @ChrnumMAX1=($chromosomenumber,$chromosomenumber2);  
   @ChrnumMAX1=sort{$a<=>$b}(@ChrnumMAX1);   
my $chromosomenumberMAX1=$ChrnumMAX1[-1];
my $chromosomenumberMIN1=$ChrnumMAX1[0];
my @ChrnumMAX2=($chromosomenumber,$chromosomenumber3);
   @ChrnumMAX2=sort{$a<=>$b}(@ChrnumMAX2);
my $chromosomenumberMAX2=$ChrnumMAX2[-1];
my $chromosomenumberMIN2=$ChrnumMAX2[0];
my @ChrnumMAX3=($chromosomenumber,$chromosomenumber2,$chromosomenumber3);
   @ChrnumMAX3=sort{$a<=>$b}(@ChrnumMAX3);
my $chromosomenumberMAX3=$ChrnumMAX3[-1];
my $chromosomenumberMIN3=$ChrnumMAX3[0];


{
	 my @new1_ChrLength;
	 my @new1_ChrLength2;
	 my @new1_ChrLength3;
	 for(my $addd=0;$addd<$chromosomenumber;$addd++)
	 {
		 push(@new1_ChrLength,$ChrLength[$addd]);
	 }
	 @new1_ChrLength=sort{$a<=>$b}(@new1_ChrLength);
	 for(my $addd=0;$addd<$chromosomenumber2;$addd++)
	 {
		 push(@new1_ChrLength2,$ChrLength2[$addd]);
	 }
	 @new1_ChrLength2=sort{$a<=>$b}(@new1_ChrLength2);
	 my @arr=($new1_ChrLength[-1],$new1_ChrLength2[-1]);
 
	 if(($genomenumber==3))
	 {
		 for(my $addd=0;$addd<$chromosomenumber3;$addd++)
		 {
			 push(@new1_ChrLength3,$ChrLength3[$addd]);
		 }
		 @new1_ChrLength3=sort{$a<=>$b}(@new1_ChrLength3);
		 @arr=($new1_ChrLength[-1],$new1_ChrLength2[-1],$new1_ChrLength3[-1]);
	 }
	 @arr=sort{$a<=>$b}(@arr);	
	 $ChrLengthMAX=$arr[-1];
}
#@ChrLength=sort{$a<=>$b}(@ChrLength);
#$ChrLengthMAX=$ChrLength[-1];
if($genomenumber==2)
{
     my @arr=( length("$Chrname1[$chromosomenumber-1]"),length("$Chrname2[$chromosomenumber2-1]") );
	 @arr=sort{$a<=>$b}(@arr);
	 $maxChrnum=$arr[-1];
	 my @arrChrlong=( length("$refname"),length("$queryname") );
	 @arrChrlong=sort{$a<=>$b}(@arrChrlong);
	 $maxChrlong=$arrChrlong[-1];
}
elsif($genomenumber==3)
{
     my @arr=( length("$Chrname1[$chromosomenumber-1]"),length("$Chrname2[$chromosomenumber2-1]"),length("$Chrname3[$chromosomenumber3-1]") );
	 @arr=sort{$a<=>$b}(@arr);
	 $maxChrnum=$arr[-1];
	 my @arrChrlong=( length("$refname"),length("$queryname"),length("$queryname2") );
	 @arrChrlong=sort{$a<=>$b}(@arrChrlong);
	 $maxChrlong=$arrChrlong[-1];
}

my $snp_pro=50;
my $GC_pro=30;#40;#50;
my $TE_pro=50;
my $snp_heatmap_max=length("$SNP_threshold_value")*13.7;
############illustration parameters
#identity parameters
my $margin_identity=100;
my $proportion_identity=100;
my $smallinterval_identity=25;
my $width_identity=25;
my $biginterval_identity=$width_identity*2+$smallinterval_identity*3;
my $xlength=$margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN1;
my $ylength=$margin_identity+$proportion_identity*5;

my $angle=45;
my $conversion=3.14159265358979/180;
my $radians=$angle*$conversion;
my $rotate_sine=$biginterval_identity*sin($radians);
my $rotate_cosine=$biginterval_identity*cos($radians);
my $rotate="rotate($angle)";

#coverage parameters
my $marginX_coverage=100;
my $marginY_coverage=100;
my $proportion_coverage=100;
my $smallinterval_coverage=25;
my $width_coverage=25; 
my $biginterval_coverage1=$width_coverage+$smallinterval_coverage*2;
my $biginterval_coverage2=$width_coverage*2+$smallinterval_coverage*3;
my $xlength1=$marginX_coverage+$smallinterval_coverage+$width_coverage+$biginterval_coverage1*$chromosomenumberMIN1;
my $ylength1=$marginY_coverage+$proportion_coverage*5;
my $xlength2=$marginX_coverage+$smallinterval_coverage+$width_coverage+$biginterval_coverage2*$chromosomenumberMIN3;
my $ylength2=$marginY_coverage+$proportion_coverage*5;

#related coords/bed/prop
my $margin_snp=50;
my $margin_TE=$margin_snp;
my $margin_gene_density=$margin_snp;
my $gene_density_pro=25;
my $te_pro=25*2;
my $margin2 =100;
my $valueSpan= 5000000; 
our $AlignmentHight = 50;
my $ChrHight=$AlignmentHight*2+5;




#print"\nmaxChrnum: $maxChrnum\n";
$margin =15+$maxChrnum*27+10+$maxChrlong*27+20;###+10+10+10;##$maxChrlong*16+4
if( ($margin_m2x-$maxChrlong*48-50-50)<0 ){$margin_m2x=50+$maxChrlong*48+50};
my $margin_X=180;
my $margin_Y=180;
#heatmap parameters
my $marginx1_heatmap=200;
my $marginy1_heatmap=200;
my $marginx2_heatmap=200;
my $marginy2_heatmap=35;
my $width_heatmap=80;
my $high_heatmap=40;
my $widthtable_heatmap=$width_heatmap*$chromosomenumber;
my $hightable_heatmap=$high_heatmap*$chromosomenumber2;
my $hightable_heatmap2=$high_heatmap*$chromosomenumber3;
my $fontsize=12;
if( ($marginx1_heatmap-length("$refname")*14-15-5)<0 ){$marginx1_heatmap=length("$refname")*14+25+5;}
my $x1_heatmap=$marginx1_heatmap;
my $x2_heatmap=$marginx1_heatmap+$widthtable_heatmap;
my $y1_heatmap=$marginy1_heatmap;
my $y2_heatmap=$marginy1_heatmap+$hightable_heatmap;
my $marginx1_heatmap_three=600;
my $marginy1_heatmap_three=600;
#=cut

my %sort_ref_query;
my %sort_query_pm;
my %sort_ref_query2;
my %sort_query_pm_3geonme;
###sort_chromosome
{
	my $rock;
	for(my $asort=0;$asort<$chromosomenumber2;$asort++)
	{
		 $sort_query_pm{$Chrname2[$asort]}='+';
	}
	if($chromosome_sort eq "reference_length_match")
	{
		 my @new1_Chrname1;
		 my @new2_Chrname1;
		 foreach my $keyss (sort{$chr_length{$b} <=> $chr_length{$a}} keys %chr_length)
		 {
			 push(@new1_Chrname1,$keyss);
		 }
		 my $new1_Chrname1_num=scalar(@new1_Chrname1);
		 for(my $addd=0;$addd<$new1_Chrname1_num;$addd++)
		 {
			 for(my $asort=0;$asort<$chromosomenumber;$asort++)
			 {
				 if( $new1_Chrname1[$addd] eq $Chrname1[$asort] )
				 {
					 push(@new2_Chrname1,$new1_Chrname1[$addd]);
				 }
			 }
		 }
		 @Chrname1=@new2_Chrname1;
		 
		 my @new1_Chrname2;
		 my @new2_Chrname2;
		 foreach my $keyss (sort{$chr_length2{$b} <=> $chr_length2{$a}} keys %chr_length2)
		 {
			 push(@new1_Chrname2,$keyss);
		 }
		 my $new1_Chrname2_num=scalar(@new1_Chrname2);
		 for(my $addd=0;$addd<$new1_Chrname2_num;$addd++)
		 {
			 for(my $asort=0;$asort<$chromosomenumber2;$asort++)
			 {
				 if( $new1_Chrname2[$addd] eq $Chrname2[$asort] )
				 {
					 push(@new2_Chrname2,$new1_Chrname2[$addd]);
				 }
			 }
		 }
		 @Chrname2=@new2_Chrname2;
		if($genomenumber==3)
		{
			 my @new1_Chrname3;
			 my @new2_Chrname3;
			 foreach my $keyss (sort{$chr_length3{$b} <=> $chr_length3{$a}} keys %chr_length3)
			 {
				 push(@new1_Chrname3,$keyss);
			 }
			 my $new1_Chrname3_num=scalar(@new1_Chrname3);
			 for(my $addd=0;$addd<$new1_Chrname3_num;$addd++)
			 {
				 for(my $asort=0;$asort<$chromosomenumber3;$asort++)
				 {
					 if( $new1_Chrname3[$addd] eq $Chrname3[$asort] )
					 {
						 push(@new2_Chrname3,$new1_Chrname3[$addd]);
					 }
				 }
			 }
			 @Chrname3=@new2_Chrname3;
		 }
	}

	if(($chromosome_sort eq "match") or ($chromosome_sort eq "reference_length_match"))
	{
		 if($SyngtInv==10){$SyngtInv=1;}#######
		 my @combination_sort_name;
		 my %sort_name_count;
		 my %sort_name_count_syn;
		 my %sort_name_count_inv;
		 my %sort_syntenygtinversion;
		 for(my $a=0;$a<$chromosomenumber;$a++)
		 {
			 $sort_ref_query{$Chrname1[$a]}='';
			 for(my $asort=0;$asort<$chromosomenumber2;$asort++)
			 {
				 my $aa_sort_name="$Chrname1[$a]"."&"."$Chrname2[$asort]";
				 push(@combination_sort_name,$aa_sort_name);
			 }
		 }
		 foreach $rock (@combination_sort_name)
		 {
			 $sort_name_count{$rock}=0;
			 $sort_name_count_syn{$rock}=0;
			 $sort_name_count_inv{$rock}=0;
		 }
		 for(my $a=0;$a<$chromosomenumber;$a++)
		 {
			 open FL,"$inputFile";
			 while(<FL>)
			 {
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
				 {				  
					 if($tem[11] eq $Chrname1[$a])
					 {
						 for(my $asort=0;$asort<$chromosomenumber2;$asort++)
						 {
							 if($tem[12] eq $Chrname2[$asort])
							 {
								 my $aa_sort_name="$Chrname1[$a]"."&"."$Chrname2[$asort]";
								 $sort_name_count{$aa_sort_name}+=$tem[4];
								 if($tem[2]<=$tem[3]){$sort_name_count_syn{$aa_sort_name}+=$tem[4];}
								 if($tem[2]>$tem[3]){$sort_name_count_inv{$aa_sort_name}+=$tem[4];}
							 }
						 }
					}
				}
			}
			close FL;
		 }
		 print"\nreferenceVSquery:\n";
		 print"reference&query=>match length for reference\n";
	     foreach $rock (sort keys %sort_name_count)
		 {
		     #if($chromosomenumber>=25)
			 {
			     if($sort_name_count{$rock}!=0){print "$rock=>$sort_name_count{$rock}\n";}
			 }
			 #else{print "$rock=>$sort_name_count{$rock}\n";}
		 }
		 print"\n";
		 my @arr_chrname;
		 my %arr_chrname_diff;
		 my $refnamexxx;
		 for(my $addd=0;$addd<$chromosomenumber;$addd++)
		 {
			 my @cbt_sort_name;
			 my @cbt_sort_name_syn;
			 my @cbt_sort_name_inv;
			 #my $arrchrname1=0;
			 
			 for(my $asort=0;$asort<$chromosomenumber2;$asort++)
			 {
				 my $aa_sort_name="$Chrname1[$addd]"."&"."$Chrname2[$asort]";
				 push(@cbt_sort_name,$aa_sort_name);
			 }
			 my @sort_query_percent;
			 foreach $rock (@cbt_sort_name)
			 {
				 push(@sort_query_percent,$sort_name_count{$rock});
			 }
			 @sort_query_percent=sort{$b<=>$a}(@sort_query_percent);
			 my $count_chr2=0;
			 foreach my $rock2 (@sort_query_percent)
			 {
				 if($rock2==0){next;}
				 if($count_chr2>=$chromosomenumber2){last;}
				 $count_chr2++;
				 my $arrchrname2=0;
				 foreach $rock (@cbt_sort_name)
				 {
					 if($sort_name_count{$rock}==$rock2)
					 {
						 $rock=~/&/;
						 $refnamexxx="$'";
						 foreach my $arrchrname3 (keys %arr_chrname_diff)
						 {
							 if($refnamexxx eq $arrchrname3){$arrchrname2=1;last;}
						 }
						 if($arrchrname2==0)
						 {
							 $arr_chrname_diff{$refnamexxx}=0;
							 $sort_ref_query{$Chrname1[$addd]}=$refnamexxx;
							 last;
						 }
					 }
				 }
				 if($arrchrname2==0)
				 {
					 last;
				 }
			 }		 
		 }
		 my @Chrname2_local=@Chrname2;
		 my @Chrname2_XX;
		 @Chrname2='NA';
		 pop(@Chrname2);
		 for(my $addd=0;$addd<$chromosomenumber;$addd++)
		 #foreach $rock (@Chrname1)
		 {
			 if($sort_ref_query{$Chrname1[$addd]} ne '')
			 {push(@Chrname2,$sort_ref_query{$Chrname1[$addd]});}
		 }
		 foreach my $rock4 (@Chrname2_local)
		 {
			 my $chrname_a=0;
			 foreach my $rock3 (@Chrname2)
			 {
			     if($rock4 eq $rock3){$chrname_a=1;last;}
			 }
			 if($chrname_a==0){push(@Chrname2,$rock4);}
		 }
		 for(my $addd=0;$addd<$chromosomenumberMIN1;$addd++)
		 {
			 if($Chrname1[$addd] ne $Chrname2[$addd])
			 {
				 $chromosomename=1;
			 }
			 if($SyngtInv==1)
			 {
				 my $aa_sort_name="$Chrname1[$addd]"."&"."$Chrname2[$addd]";
				#print"$sort_name_count_syn{$aa_sort_name} < $sort_name_count_inv{$aa_sort_name}\n";			 
				 if($sort_name_count_syn{$aa_sort_name} >= $sort_name_count_inv{$aa_sort_name})
				 {
					 $sort_query_pm{$Chrname2[$addd]}='+';
				 }
				 else
				 {
					 $sort_query_pm{$Chrname2[$addd]}='-';
				 }
			 }
		 }
	}

	if($genomenumber==3)
	{
		for(my $asort=0;$asort<$chromosomenumber3;$asort++)
		{
			 $sort_query_pm_3geonme{$Chrname3[$asort]}='+';
		}
		if(($chromosome_sort eq "match") or ($chromosome_sort eq "reference_length_match"))
		{
			 my @combination_sort_name;
			 my %sort_name_count;
			 my %sort_name_count_syn;
			 my %sort_name_count_inv;
			 my %sort_syntenygtinversion;
			 for(my $a=0;$a<$chromosomenumber;$a++)
			 {
				 $sort_ref_query2{$Chrname1[$a]}='';
				 for(my $asort=0;$asort<$chromosomenumber3;$asort++)
				 {
					 my $aa_sort_name="$Chrname1[$a]"."&"."$Chrname3[$asort]";
					 push(@combination_sort_name,$aa_sort_name);
				 }
			 }
			 foreach $rock (@combination_sort_name)
			 {
				 $sort_name_count{$rock}=0;
				 $sort_name_count_syn{$rock}=0;
				 $sort_name_count_inv{$rock}=0;
			 }
			 for(my $a=0;$a<$chromosomenumber;$a++)
			 {
				 open FL2,"$inputFile2";
				 while(<FL2>)
				 {
					 chomp;
					 my @tem = split /\t/;
					 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
					 {				  
						 if($tem[11] eq $Chrname1[$a])
						 {
							 for(my $asort=0;$asort<$chromosomenumber3;$asort++)
							 {
								 if($tem[12] eq $Chrname3[$asort])
								 {
									 my $aa_sort_name="$Chrname1[$a]"."&"."$Chrname3[$asort]";
									 $sort_name_count{$aa_sort_name}+=$tem[4];
									 if($tem[2]<=$tem[3]){$sort_name_count_syn{$aa_sort_name}+=$tem[4];}
									 if($tem[2]>$tem[3]){$sort_name_count_inv{$aa_sort_name}+=$tem[4];}
								 }
							 }
						}
					}
				}
				close FL2;
			 }
			 print"referenceVSquery2:\n";
			 print"reference&query2=>match length for reference\n";
			 foreach $rock (sort keys %sort_name_count)
			 {
			     #if($chromosomenumber>=25)
				 {
				     if($sort_name_count{$rock}!=0){print "$rock=>$sort_name_count{$rock}\n";}
				 }
				 #else{print "$rock=>$sort_name_count{$rock}\n";}
			 }
			 my @arr_chrname;
			 my @arr_chrname_diff;
			 my $refnamexxx;
			 for(my $addd=0;$addd<$chromosomenumber;$addd++)
			 {
				 my @cbt_sort_name;
				 my @cbt_sort_name_syn;
				 my @cbt_sort_name_inv;
				 for(my $asort=0;$asort<$chromosomenumber3;$asort++)
				 {
					 my $aa_sort_name="$Chrname1[$addd]"."&"."$Chrname3[$asort]";
					 push(@cbt_sort_name,$aa_sort_name);
				 }
				 my @sort_query_percent;
				 foreach $rock (@cbt_sort_name)
				 {
					 push(@sort_query_percent,$sort_name_count{$rock});
				 }
				 @sort_query_percent=sort{$b<=>$a}(@sort_query_percent);
				 my $count_chr3=0;
				 foreach my $rock2 (@sort_query_percent)
				 {
					 if($rock2==0){last;}
					 if($count_chr3>=$chromosomenumber3){last;}
					 $count_chr3++;
					 my $arrchrname2=0;
					 foreach $rock (@cbt_sort_name)
					 {
						 if($sort_name_count{$rock}==$rock2)
						 {
							 $rock=~/&/;
							 $refnamexxx="$'";
							 foreach my $arrchrname3 (@arr_chrname_diff)
							 {
								 if($refnamexxx eq $arrchrname3){$arrchrname2=1;last;}
							 }
							 if($arrchrname2==0)
							 {
								 push(@arr_chrname_diff,$refnamexxx);
								 $sort_ref_query2{$Chrname1[$addd]}=$refnamexxx;
								 last;
							 }
						 }
					 }
					 if($arrchrname2==0)
					 {
						 last;
					 }
				 }
			 }
			 my @Chrname3_local=@Chrname3;
			 @Chrname3='NA';
			 pop(@Chrname3);
			 for(my $addd=0;$addd<$chromosomenumber;$addd++)
			 #foreach $rock (@Chrname1)
			 {
				 if($sort_ref_query2{$Chrname1[$addd]} ne '')
				 {push(@Chrname3,$sort_ref_query2{$Chrname1[$addd]});}
			 }
			 foreach my $rock4 (@Chrname3_local)
			 {
				 my $chrname_a=0;
				 foreach my $rock3 (@Chrname3)
				 {
					 if($rock4 eq $rock3){$chrname_a=1;last;}
				 }
				 if($chrname_a==0){push(@Chrname3,$rock4);}
			 }
			 for(my $addd=0;$addd<$chromosomenumberMIN1;$addd++)
			 {
				 if($Chrname1[$addd] ne $Chrname3[$addd])
				 {
					 $chromosomename=1;
				 }
				 if($SyngtInv==1)
				 {
					 my $aa_sort_name="$Chrname1[$addd]"."&"."$Chrname3[$addd]";
					#print"$sort_name_count_syn{$aa_sort_name} < $sort_name_count_inv{$aa_sort_name}\n";			 
					 if($sort_name_count_syn{$aa_sort_name} >= $sort_name_count_inv{$aa_sort_name})
					 {
						 $sort_query_pm_3geonme{$Chrname3[$addd]}='+';
					 }
					 else
					 {
						 $sort_query_pm_3geonme{$Chrname3[$addd]}='-';
					 }
				 }
			 }
		}
	}
}
if($chromosomenumber==$chromosomenumber2)
{
	 for(my $chrl_a=0;$chrl_a<$chromosomenumberMAX1;$chrl_a++)
	 {
		 my @arr=($chr_length{$Chrname1[$chrl_a]},$chr_length2{$Chrname2[$chrl_a]});
		 @arr=sort{$a<=>$b}(@arr);
		 my $chra_max=$arr[-1];
		 push(@ChrLength_genome_max,$chra_max);
		 $ChrLength_genome_max_proportion[$chrl_a]=$chra_max/$proportion_m2;
	 }
}
else
{
	 for(my $chrl_a=0;$chrl_a<$chromosomenumberMIN1;$chrl_a++)
	 {
		 my @arr=($chr_length{$Chrname1[$chrl_a]},$chr_length2{$Chrname2[$chrl_a]});
		 @arr=sort{$a<=>$b}(@arr);
		 my $chra_max=$arr[-1];
		 push(@ChrLength_genome_max,$chra_max);
		 $ChrLength_genome_max_proportion[$chrl_a]=$chra_max/$proportion_m2;
	 }
	 if($chromosomenumber>$chromosomenumber2)
	 {
		 for(my $chrl_a=$chromosomenumberMIN1;$chrl_a<$chromosomenumberMAX1;$chrl_a++)
		 {
			 push(@ChrLength_genome_max,$chr_length{$Chrname1[$chrl_a]});
			 $ChrLength_genome_max_proportion[$chrl_a]=$chr_length{$Chrname1[$chrl_a]}/$proportion_m2;
		 }
	 }
	 if($chromosomenumber<$chromosomenumber2)
	 {
		 for(my $chrl_a=$chromosomenumberMIN1;$chrl_a<$chromosomenumberMAX1;$chrl_a++)
		 {
			 push(@ChrLength_genome_max,$chr_length2{$Chrname2[$chrl_a]});
			 $ChrLength_genome_max_proportion[$chrl_a]=$chr_length2{$Chrname2[$chrl_a]}/$proportion_m2;
		 }
	 }
}

if($genomenumber==3)
{
	 if($chromosomenumberMAX1==$chromosomenumber3)
	 {
		 for(my $chrl_a=0;$chrl_a<$chromosomenumberMAX3;$chrl_a++)
		 {
			 my @arr=($ChrLength_genome_max[$chrl_a],$chr_length3{$Chrname3[$chrl_a]});
			 @arr=sort{$a<=>$b}(@arr);
			 my $chra_max=$arr[-1];
			 $ChrLength_genome_max[$chrl_a]=$chra_max;
			 $ChrLength_genome_max_proportion[$chrl_a]=$chra_max/$proportion_m2;
		 }
	 }
	 else
	 {
		 if($chromosomenumberMAX1>$chromosomenumber3)
		 {
			 for(my $chrl_a=0;$chrl_a<$chromosomenumber3;$chrl_a++)
			 {
				 my @arr=($ChrLength_genome_max[$chrl_a],$chr_length3{$Chrname3[$chrl_a]});
				 @arr=sort{$a<=>$b}(@arr);
				 my $chra_max=$arr[-1];
				 $ChrLength_genome_max[$chrl_a]=$chra_max;
				 $ChrLength_genome_max_proportion[$chrl_a]=$chra_max/$proportion_m2;
			 }
		 }
		 if($chromosomenumberMAX1<$chromosomenumber3)
		 {
			 for(my $chrl_a=0;$chrl_a<$chromosomenumberMAX1;$chrl_a++)
			 {
				 my @arr=($ChrLength_genome_max[$chrl_a],$chr_length3{$Chrname3[$chrl_a]});
				 @arr=sort{$a<=>$b}(@arr);
				 my $chra_max=$arr[-1];
				 $ChrLength_genome_max[$chrl_a]=$chra_max;
				 $ChrLength_genome_max_proportion[$chrl_a]=$chra_max/$proportion_m2;
			 }
			 for(my $chrl_a=$chromosomenumberMAX1;$chrl_a<$chromosomenumberMAX3;$chrl_a++)
			 {
				 $ChrLength_genome_max[$chrl_a]=$chr_length3{$Chrname3[$chrl_a]};
				 $ChrLength_genome_max_proportion[$chrl_a]=$chr_length3{$Chrname3[$chrl_a]}/$proportion_m2;
			 }
		 }
	 }
}
#if($chromosomename==1)
{
     push(@outChrname1,@Chrname1);
	 push(@outChrname2,@Chrname2);
	 if($genomenumber==3)
	 {
		 push(@outChrname3,@Chrname3);
	}
}
print"\ngenomeSeq1 -> $genomeSeq1\n";
for(my $a=0;$a<$chromosomenumber;$a++)
{
     my $item=$Chrname1[$a];
     print"$item\n";
}

print"\ngenomeSeq2 -> $genomeSeq2\n";
for(my $a=0;$a<$chromosomenumber2;$a++)
{
     my $item=$Chrname2[$a];
     print"$item\n";
}

if($genomenumber==3)
{
     print"\ngenomeSeq3 -> $genomeSeq3\n";
	 for(my $a=0;$a<$chromosomenumber3;$a++)
	{
		 my $item=$Chrname3[$a];
		 print"$item\n";
	}
}
#=cut
print"\ncomparison_file1 -> $inputFile\n";
if($genomenumber==3)
{
     print"\ncomparison_file2 -> $inputFile2\n";	 
	 if($heatmap2_type==1){print"\ncomparison_file3 -> $inputFile3\n";}
}
print"\nchromosomenumber -> $chromosomenumber\n";
print"\nchromosomenumber2 -> $chromosomenumber2\n";
if($genomenumber==3){print"\nchromosomenumber3 -> $chromosomenumber3\n";}
print"\ngenomenumber -> $genomenumber\n";
print"\naligntype -> $aligntype\n";
if($aligntype==4){$aligntype=3;$illustration=1;}


#Determine if the comment file exists
my $refcentromere=1;
my $query1centromere=1;
my $query2centromere=1;
if( length("$inputFile7")==0 ){ $refcentromere=0;}
if( length("$inputFile6")==0 ){ $query1centromere=0;}
if( length("$inputFile66")==0 ){ $query2centromere=0;}
my $reftelomere=1;
my $query1telomere=1;
my $query2telomere=1;
if( length("$inputFile9")==0 ){ $reftelomere=0;}
if( length("$inputFile8")==0 ){ $query1telomere=0;}
if( length("$inputFile88")==0 ){ $query2telomere=0;}
my $reftargetgene=1;
my $query1targetgene=1;
my $query2targetgene=1;
if( length("$inputFile13")==0 ){ $reftargetgene=0;}
if( length("$inputFile12")==0 ){ $query1targetgene=0;}
if( length("$inputFile14")==0 ){ $query2targetgene=0;}
my $snp_REF=1;
my $snp_QUERY1=1;
my $snp_QUERY2=1;
if( length("$inputFile15")==0 ){ $snp_REF=0;}
if( length("$inputFile16")==0 ){ $snp_QUERY1=0;}
if( length("$inputFile166")==0 ){ $snp_QUERY2=0;}
#if(( length("$inputFile15")!=0 )or( length("$inputFile16")!=0 )or( length("$inputFile166")!=0 )){$GC_content=0;}
my $TE_REF=1;
my $TE_QUERY1=1;
my $TE_QUERY2=1;
if( length("$inputFile17")==0 ){ $TE_REF=0;}
if( length("$inputFile18")==0 ){ $TE_QUERY1=0;}
if( length("$inputFile19")==0 ){ $TE_QUERY2=0;}
my $snp_TE=1;###
if(( length("$inputFile15")!=0 )or( length("$inputFile16")!=0 )or( length("$inputFile166")!=0 )){$snp_TE=0;}
if( ((length("$inputFile15")!=0)or(length("$inputFile16")!=0)or(length("$inputFile166")!=0)) and ((length("$inputFile17")!=0)or(length("$inputFile18")!=0)or(length("$inputFile19")!=0)) ){$GC_content=0;}
my $GC_REF=1;
my $GC_QUERY1=1;
my $GC_QUERY2=1;
if( length("$inputFile29")==0 ){ $GC_REF=0;}
if( length("$inputFile30")==0 ){ $GC_QUERY1=0;}
if( length("$inputFile31")==0 ){ $GC_QUERY2=0;}
my $PAV_REF=1;
my $PAV_QUERY1=1;
my $PAV_QUERY2=1;
if( length("$inputFile20")==0 ){ $PAV_REF=0;}
if( length("$inputFile21")==0 ){ $PAV_QUERY1=0;}
if( length("$inputFile22")==0 ){ $PAV_QUERY2=0;}
my $NLR_REF=1;
my $NLR_QUERY1=1;
my $NLR_QUERY2=1;
if( length("$inputFile23")==0 ){ $NLR_REF=0;}
if( length("$inputFile24")==0 ){ $NLR_QUERY1=0;}
if( length("$inputFile25")==0 ){ $NLR_QUERY2=0;}
my $gene_density_REF=1;
my $gene_density_QUERY1=1;
my $gene_density_QUERY2=1;
if( length("$inputFile26")==0 ){ $gene_density_REF=0;}
if( length("$inputFile27")==0 ){ $gene_density_QUERY1=0;}
if( length("$inputFile28")==0 ){ $gene_density_QUERY2=0;}
if($genomenumber==2){if( ($gene_density_REF!=1) and ($gene_density_QUERY1!=1) ){$margin=$maxChrnum*27+15+20;}}
elsif($genomenumber==3){if( ($gene_density_REF!=1) and ($gene_density_QUERY1!=1) and ($gene_density_QUERY2!=1) ){$margin=$maxChrnum*27+15+20;}}
my $margin_icon=0.3*$margin;#$maxChrnum#5*30+10+5
my $icon_centromere=1;  
if($genomenumber==2){if( (length("$inputFile26")!=0) and (length("$inputFile27")!=0) ){$icon_centromere=0;}} 
elsif($genomenumber==3){if( (length("$inputFile26")!=0) and (length("$inputFile27")!=0) and (length("$inputFile28")!=0) ){$icon_centromere=0;}}

my $m2_Xoverlength=0;
if($genomenumber==2)
{
	 for(my $a=0;$a<$chromosomenumberMAX1;$a++)
	 {
	     $m2_Xoverlength+=$ChrLength_genome_max[$a]/$proportion_m2+$margin_m2x_interval;
	 }
}
elsif($genomenumber==3)
{
	 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
	 {
	     $m2_Xoverlength+=$ChrLength_genome_max[$a]/$proportion_m2+$margin_m2x_interval;
	 }
}
$marginx2_heatmap=$maxChrnum*13+$width_heatmap/2+90;

##Legend area
 my $icon_x;
 my $icon_y;
 my $icon_move=1;
 my $icon_length_max;
 my $icon_chrnum;
 my $GDheatmap_wide=70;
 my $GD_wide_text=80;
 my $GDheatmap_high=50;
 my $GD_high_move=20;
 my $GDtext_move_y=8+3;
 my $chrLength;
 my $chrLength2;
 my $chrLength3;
 if($genomenumber==2)
 {
	 for(my $a=0;$a<$chromosomenumberMIN1;$a++)
	 {
		 open FL,"$inputFile";
		 while(<FL>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 if(($tem[11] eq $Chrname1[$a]) and ($tem[12] eq $Chrname2[$a]))
				 {
					 if($highlightinversion and ($tem[2]>$tem[3]) and (abs($tem[2]-$tem[3])>=$Inversion_limit))
					 {
						 $inversion_iconaa=1;
					}
					 else
					 {
					     $synteny_iconaa=1;
					}
				}
			}
		}
		close FL;
	}
	 for(my $a=0;$a<$chromosomenumber;$a++)
	 {
		 open FL,"$inputFile";
		 while(<FL>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 for(my $b=0;$b<$chromosomenumber2;$b++)
				 {
					 if( ($tem[11] eq $Chrname1[$a]) and ($a!=$b) and ($tem[12] eq $Chrname2[$b]) )
					 {
						$translocation_iconaa=1;
					}
				}
			}
		}
		close FL;
	}
 }
 elsif($genomenumber==3)
 {
	 for(my $a=0;$a<$chromosomenumberMIN1;$a++)
	 {
		 open FL,"$inputFile";
		 while(<FL>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 if(($tem[11] eq $Chrname1[$a]) and ($tem[12] eq $Chrname2[$a]))
				 {
					 if($highlightinversion and ($tem[2]>$tem[3]) and (abs($tem[2]-$tem[3])>=$Inversion_limit))
					 {
						 $inversion_iconaa=1;
					}
					 else
					 {
					     $synteny_iconaa=1;
					}
				}
			}
		}
		close FL;
	}
	 for(my $a=0;$a<$chromosomenumber;$a++)
	 {
		 open FL,"$inputFile";
		 while(<FL>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 for(my $b=0;$b<$chromosomenumber2;$b++)
				 {
					 if( ($tem[11] eq $Chrname1[$a]) and ($a!=$b) and ($tem[12] eq $Chrname2[$b]) )
					 {
						$translocation_iconaa=1;
					}
				}
			}
		}
		close FL;
	}
	 for(my $a=0;$a<$chromosomenumberMIN2;$a++)
	 {
		 open FL2,"$inputFile2";
		 while(<FL2>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 if(($tem[11] eq $Chrname1[$a]) and ($tem[12] eq $Chrname3[$a]))
				 {
					 if($highlightinversion and ($tem[2]>$tem[3]) and (abs($tem[2]-$tem[3])>=$Inversion_limit))
					 {
						 $inversion_iconaa=1;
					}
					 else
					 {
					     $synteny_iconaa=1;
					}
				}
				 if(($tem[11] eq $Chrname1[$a]) and ($tem[12] ne $Chrname3[$a]))
				 {
					$translocation_iconaa=1;
				}
			}
		}
		close FL2;
	}
	 for(my $a=0;$a<$chromosomenumber;$a++)
	 {
		 open FL2,"$inputFile2";
		 while(<FL2>)
		 {
			 chomp;
			 my @tem = split /\t/;
			 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
			 {				  
				 for(my $b=0;$b<$chromosomenumber3;$b++)
				 {
					 if(($tem[11] eq $Chrname1[$a]) and ($a!=$b) and ($tem[12] eq $Chrname3[$b]))
					 {
						$translocation_iconaa=1;
					}
				}
			}
		}
		close FL2;
	}
 }
if($TE_tem3min==1000000000)
{ 
	 if($genomenumber==2)
	 {
		 for(my $a=0;$a<$chromosomenumberMAX1;$a++)
		 {
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
			 {
				 if($TE_REF)
				{
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_ref,"$inputFile17";
						 while(<FL_TE_ref>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname1[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
								 my $TE_tem3minaa=$tem[3];
								 if($TE_tem3minaa<$TE_tem3min){$TE_tem3min=$TE_tem3minaa;}
							}
						}
						 close FL_TE_ref;
					}
				}
				 if($TE_QUERY1)
				{			 
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query,"$inputFile18";
						 while(<FL_TE_query>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname2[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
								 my $TE_tem3minaa=$tem[3];
								 if($TE_tem3minaa<$TE_tem3min){$TE_tem3min=$TE_tem3minaa;}
							}
						}
						 close FL_TE_query;
					}
				}
			}
		}
	}
	 elsif($genomenumber==3)
	 {
		 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
		 {
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
			 {
				if($TE_QUERY1)
				{			 
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query1,"$inputFile18";
						 while(<FL_TE_query1>)
						 {
							 chomp;	
							 my @tem = split /\t/;
							 if( ($tem[0] eq $Chrname2[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
								 my $TE_tem3minaa=$tem[3];
								 if($TE_tem3minaa<$TE_tem3min){$TE_tem3min=$TE_tem3minaa;}
							}
						}
						 close FL_TE_query1;
					}
				}
			}
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
			 {
				if($TE_QUERY2)
				{
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query2,"$inputFile19";
						 while(<FL_TE_query2>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname3[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
								 my $TE_tem3minaa=$tem[3];
								 if($TE_tem3minaa<$TE_tem3min){$TE_tem3min=$TE_tem3minaa;}
							}
						}
						 close FL_TE_query2;
					}
				}
			}
		}	
	}
	 $TE_tem3min=int(10*$TE_tem3min/$TE_Win_bp)/10;
}
else
{
	 if($genomenumber==2)
	 {
		 for(my $a=0;$a<$chromosomenumberMAX1;$a++)
		 {
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
			 {
				 if($TE_REF)
				{
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_ref,"$inputFile17";
						 while(<FL_TE_ref>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname1[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
							}
						}
						 close FL_TE_ref;
					}
				}
				 if($TE_QUERY1)
				{			 
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query,"$inputFile18";
						 while(<FL_TE_query>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname2[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
							}
						}
						 close FL_TE_query;
					}
				}
			}
		}
	 }
	 elsif($genomenumber==3)
	 {
		 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
		 {
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
			 {
				if($TE_QUERY1)
				{			 
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query1,"$inputFile18";
						 while(<FL_TE_query1>)
						 {
							 chomp;	
							 my @tem = split /\t/;
							 if( ($tem[0] eq $Chrname2[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
							}
						}
						 close FL_TE_query1;
					}
				}
			}
			 if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
			 {
				if($TE_QUERY2)
				{
					 if($TE_Win_bp==1)
					 {
						 open FL_TE_query2,"$inputFile19";
						 while(<FL_TE_query2>)
						 {
							 chomp;	
							 my @tem = split /\t/;				
							 if( ($tem[0] eq $Chrname3[$a]) )
							 { 
								 if($pro_TEa==1){$TE_Win_bp=abs($tem[2]-$tem[1]);$pro_TEa++;}
							}
						}
						 close FL_TE_query2;
					}
				}
			}
		}	
	}
	 $TE_tem3min=$TE_tem3min/100;
}
 
if($genomenumber==2)
 {
	 if($synteny_iconaa){$icon_move+=1;}#2
	 if($inversion_iconaa){$icon_move+=1;}#3
	 if($reftargetgene or $query1targetgene){$icon_move+=1;}#4
	 if($refcentromere or $query1centromere){$icon_move+=1;}#5
	 if($PAV_REF or $PAV_QUERY1){$icon_move+=1;}#6
	 if($NLR_REF or $NLR_QUERY1){$icon_move+=1;}#7
	 if($snp_REF or $snp_QUERY1){$icon_move+=1;}#8
	 if($GC_content){$icon_move+=1;}#8,It doesn't exist at the same time as SNP
	 if($reftelomere or $query1telomere){$icon_move+=1;}#9
	 if($TE_REF or $TE_QUERY1){$icon_move+=1;}#10
	 if($gene_density_REF or $gene_density_QUERY1){$icon_move+=6;}#16
	 else{$icon_move+=2;}#12
	 if(int($icon_move/2.5)==($icon_move/2.5)){$icon_chrnum=$icon_move/2.5;}
	 else{$icon_chrnum=int($icon_move/2.5)+1;}
 }
 else
 {
	 if($synteny_iconaa){$icon_move+=1;}#2
	 if($inversion_iconaa){$icon_move+=1;}#3
	 if($reftargetgene or $query1targetgene or $query2targetgene){$icon_move+=1;}#4
	 if($refcentromere or $query1centromere or $query2centromere){$icon_move+=1;}#5
	 if($PAV_REF or $PAV_QUERY1 or $PAV_QUERY2){$icon_move+=1;}#6
	 if($NLR_REF or $NLR_QUERY1 or $NLR_QUERY2){$icon_move+=1;}#7
	 if($snp_REF or $snp_QUERY1 or $snp_QUERY2){$icon_move+=1;}#8
	  if($GC_content){$icon_move+=1;}#8,It doesn't exist at the same time as SNP
	 if($reftelomere or $query1telomere or $query2telomere){$icon_move+=1;}#9
	 if($TE_REF or $TE_QUERY1 or $TE_QUERY2){$icon_move+=1;}#10
	 if($gene_density_REF or $gene_density_QUERY1 or $gene_density_QUERY2){$icon_move+=6;}#16
	 else{$icon_move+=3;}#13
	 if(int($icon_move/3)==($icon_move/3)){$icon_chrnum=$icon_move/3;}
	 else{$icon_chrnum=int($icon_move/3)+1;}
 }
my $icon_move2aa=$icon_move;
my $m2_iconaa=1;
my $m2_wideaa=$m2_Xoverlength+$margin_m2x*2;
#Canvas size
my $svg= SVG->new();
my $svg2= SVG->new();
my $svg3= SVG->new();
my $svg4= SVG->new();
my $svg5= SVG->new();
my $SVG_canvas_w;
my $SVG_canvas_h;

 my $t_postfix="Mb";
 my $scaleXX;
 my $scaleYY;			
 if(($chr_length{$Chrname1[0]})>=1000000000){$t_postfix="Gb";}
 elsif(($chr_length{$Chrname1[0]})>=1000000){$t_postfix="Mb";}
 elsif(($chr_length{$Chrname1[0]})>=1000){$t_postfix="Kb";}
 elsif(($chr_length{$Chrname1[0]})>=1){$t_postfix="bp";}
 
 if(($chr_length{$Chrname1[0]})>=1000000000){$valueSpan=1000000000;$scaleYY=1;$scaleXX=$valueSpan/100;}
 elsif(($chr_length{$Chrname1[0]})>=100000000){$valueSpan=50000000;$scaleYY=50;$scaleXX=$valueSpan/20;}
 elsif(($chr_length{$Chrname1[0]})>=10000000){$valueSpan=5000000;$scaleYY=5;$scaleXX=$valueSpan/20;}
 elsif(($chr_length{$Chrname1[0]})>=1000000){$valueSpan=1000000;$scaleYY=1;$scaleXX=$valueSpan/10;}
 elsif(($chr_length{$Chrname1[0]})>=100000){$valueSpan=50000;$scaleYY=50;$scaleXX=$valueSpan/20;}
 elsif(($chr_length{$Chrname1[0]})>=10000){$valueSpan=5000;$scaleYY=5;$scaleXX=$valueSpan/20;}
 elsif(($chr_length{$Chrname1[0]})>=1000){$valueSpan=1000;$scaleYY=1;$scaleXX=$valueSpan/10;}
 elsif(($chr_length{$Chrname1[0]})>=100){$valueSpan=50;$scaleYY=50;$scaleXX=$valueSpan/20;}
 elsif(($chr_length{$Chrname1[0]})>=10){$valueSpan=5;$scaleYY=5;$scaleXX=1;}			 
 elsif(($chr_length{$Chrname1[0]})>=1){$valueSpan=1;$scaleYY=1;$scaleXX=1;}
 my $more_SIMO=int((($chr_length{$Chrname1[0]}/$valueSpan)-int(($chr_length{$Chrname1[0]}/$valueSpan)))*$valueSpan)+1;
 #print"$more_SIMO\n";
 my $more_chrXX=$chr_length{$Chrname1[0]};
 if($more_SIMO>$scaleXX){$more_chrXX=(int(($chr_length{$Chrname1[0]}/$valueSpan))+1)*$valueSpan;}
 my $scale_morexx=($more_chrXX-$chr_length{$Chrname1[0]})/$proportion;
 
if($genomenumber==2)
{
     $SVG_canvas_w=$ChrLengthMAX/$proportion+1.7*$margin;
	 $SVG_canvas_h=$margin_Y*2+($margin_snp+$ChrHight+12*2)*$chromosomenumberMAX1;
	 if($icon==1)
	 {
		 if( ($chromosomenumberMIN1-$icon_chrnum)>=0 )
		 {
			 for(my $a_icon=($chromosomenumberMIN1-$icon_chrnum);$a_icon<$chromosomenumberMIN1;$a_icon++)
			 {
				 if($a_icon==($chromosomenumberMIN1-$icon_chrnum)){$icon_length_max=$chr_length{$Chrname1[$a_icon]};}
				 if($icon_length_max<$chr_length{$Chrname1[$a_icon]}){$icon_length_max=$chr_length{$Chrname1[$a_icon]};}	
				 if($icon_length_max<$chr_length2{$Chrname2[$a_icon]}){$icon_length_max=$chr_length2{$Chrname2[$a_icon]};}				 
			 }		 
			 my $max_aa=$ChrLengthMAX;
			 if( ($max_aa-$icon_length_max)/$proportion>=400)

			 {$icon_x=$ChrLengthMAX/$proportion+$margin+$margin_icon-350;}
			 else
			 {
				 $icon_x=$icon_length_max/$proportion+$margin+$margin_icon;
				 $SVG_canvas_w=$SVG_canvas_w+400-($max_aa-$icon_length_max)/$proportion+20;
			 }
			 $icon_y=$margin_Y*(11/6)+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1);
		} 
		else
		 {
		     my $icon_chrnum2;			 
			 if($gene_density_REF or $gene_density_QUERY1){$icon_move2aa=$icon_move2aa-2;}
			 else{$icon_move2aa=$icon_move2aa-1;}
			 if(int($icon_move2aa/5)==($icon_move2aa/5)){$icon_chrnum2=$icon_move2aa/5;}
	         else{$icon_chrnum2=int($icon_move2aa/5)+1;}
			 $icon_x=$ChrLengthMAX/$proportion+$margin+$margin_icon;
			 $SVG_canvas_w=$ChrLengthMAX/$proportion+$margin+$margin_icon+300*$icon_chrnum2+20;
			 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1);
			 if($SVG_canvas_h<=($margin_Y*2+450))
			 {
			     $SVG_canvas_h=$margin_Y*2+450;
				 $icon_y=$margin_Y*1.5+450;
			 }
		}
    }
	 if($m2_wideaa<3050){$m2_wideaa=$m2_wideaa+1130;$m2_iconaa=0;}
	 if( ($aligntype==1)or($aligntype==3) ) 
	 {$svg= SVG->new( width=>$SVG_canvas_w+$scale_morexx,height=>$SVG_canvas_h );}
	 if( ($aligntype==2)or($aligntype==3) )
	 {$svg2= SVG->new( width=>$m2_wideaa ,height=>$margin_m2y*2+$margin_m2y_comparison+40);}
	 $svg3= SVG->new( width=>$marginx1_heatmap+$widthtable_heatmap+$marginx2_heatmap,height=>$marginy1_heatmap+$hightable_heatmap+$marginy1_heatmap );
     $svg4= SVG->new( width=>$xlength + $biginterval_identity,height=>$ylength + $proportion_identity*2 );
	 $svg5= SVG->new( width=>$marginX_coverage+$smallinterval_coverage*($chromosomenumberMIN1+1)*2+$width_coverage*$chromosomenumberMIN1+$marginX_coverage*2.5,height=>$ylength2+$marginY_coverage );
}
elsif($genomenumber==3)
{    
     $SVG_canvas_w=$ChrLengthMAX/$proportion+1.7*$margin;
	 $SVG_canvas_h=$margin_Y*(11/6)+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*$chromosomenumberMAX3;
	 if($icon==1)
	 {
		 if( ($chromosomenumberMAX3-$icon_chrnum)>=0 )
		 {
			 for(my $a_icon=($chromosomenumberMAX3-$icon_chrnum);$a_icon<$chromosomenumberMAX3;$a_icon++)
			 {
				 if($a_icon==($chromosomenumberMAX3-$icon_chrnum)){$icon_length_max=$chr_length{$Chrname1[$a_icon]};}
				 if($a_icon<$chromosomenumber){if($icon_length_max<$chr_length{$Chrname1[$a_icon]}){$icon_length_max=$chr_length{$Chrname1[$a_icon]};}}
				 if($a_icon<$chromosomenumber2){if($icon_length_max<$chr_length2{$Chrname2[$a_icon]}){$icon_length_max=$chr_length2{$Chrname2[$a_icon]};}}
				 if($a_icon<$chromosomenumber3){if($icon_length_max<$chr_length3{$Chrname3[$a_icon]}){$icon_length_max=$chr_length3{$Chrname3[$a_icon]};}}			 
			}

			 my $max_aa=$ChrLengthMAX;
			 if( ($max_aa-$icon_length_max)/$proportion>=400)
			 {$icon_x=$ChrLengthMAX/$proportion+$margin+$margin_icon-350;}
			 else
			 {
				 $icon_x=$icon_length_max/$proportion+$margin+$margin_icon;
				 $SVG_canvas_w=$ChrLengthMAX/$proportion+1.7*$margin+400-($max_aa-$icon_length_max)/$proportion+20;
			}
			 $icon_y=$margin_Y+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1);
		}
		else
		 {
		     my $icon_chrnum2;
			 if($gene_density_REF or $gene_density_QUERY1 or $gene_density_QUERY2){$icon_move2aa=$icon_move2aa-2;}
			 else{$icon_move2aa=$icon_move2aa-1;}
			 if(int($icon_move2aa/5)==($icon_move2aa/5)){$icon_chrnum2=int($icon_move2aa/5);}
	         else{$icon_chrnum2=int($icon_move2aa/5)+1;}
			 $icon_x=$ChrLengthMAX/$proportion+$margin+$margin_icon;
			 $SVG_canvas_w=$ChrLengthMAX/$proportion+$margin+$margin_icon+300*$icon_chrnum2+20;
			 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1);
			 if($SVG_canvas_h<=($margin_Y*2+450))
			 {
			     $SVG_canvas_h=$margin_Y*2+450;
				 $icon_y=$margin_Y*1.5+450;
			 }
		}		
	}
	 if($m2_wideaa<3050){$m2_wideaa=$m2_wideaa+1130;$m2_iconaa=0;}
	 if( ($aligntype==1)or($aligntype==3) ) 
	 {$svg= SVG->new( width=>$SVG_canvas_w+$scale_morexx ,height=>$SVG_canvas_h );}
	 if( ($aligntype==2)or($aligntype==3) ) 
	 {$svg2= SVG->new( width=>$m2_wideaa ,height=>$margin_m2y*2+$margin_m2y_comparison*2+40);}
	 $svg3= SVG->new( width=>$marginx1_heatmap+$widthtable_heatmap+$marginx2_heatmap,height=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$hightable_heatmap2+$marginy1_heatmap );
	 $xlength=$margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN3;
     $svg4= SVG->new( width=>$xlength + $biginterval_identity,height=>$ylength*2 + $proportion_identity*4 );
	 $svg5= SVG->new( width=>$marginX_coverage+$smallinterval_coverage*($chromosomenumberMIN3+1)*3+$width_coverage*$chromosomenumberMIN3*2+$marginX_coverage*2,height=>$ylength2+$marginY_coverage );
}


##Comparisontype
#two
if( ($genomenumber==2) and (($aligntype==1)or($aligntype==3)) )
{
	 
	 for(my $a=0;$a<$chromosomenumberMAX1;$a++)
	 {     
         if($a<$chromosomenumber)
		 {
		     $chrLength =$chr_length{$Chrname1[$a]}/$proportion;
		 }
		 if($a<$chromosomenumber2)
		 {
	         $chrLength2 =$chr_length2{$Chrname2[$a]}/$proportion;
		 }
		 if($a == 0){
			 my $t = 0;
			 for (my $i=0;$i<=$more_chrXX;$i+=$scaleXX)
			 {
				 my $i_pXX=$i/$proportion;
				 if(($i)%($valueSpan) ==0){
					 my $xbar = "$t"."$t_postfix";
					 $svg->text(
						 x=>$margin +$i_pXX, y=>$margin_Y -2,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'22',
						}
					)->cdata($xbar);
					 $t+=$scaleYY;
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y -5,
						 x2=>$i_pXX+$margin , y2=>$margin_Y,
						 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
						}
					);
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y,
						 x2=>$i_pXX+$margin , y2=>$margin_Y+$AlignmentHight+$margin_snp+11,
						 style=>{
							 'stroke' => 'black',
							 'stroke-dasharray'=>'5,5',
							 'stroke-dasharray-width'=>'1',
						}
					);
				}
				 else
				 {
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y -3,
						 x2=>$i_pXX+$margin , y2=>$margin_Y,
						 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
							}
					);	
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y,
						 x2=>$i_pXX+$margin , y2=>$margin_Y+$AlignmentHight+$margin_snp+11,
						 style=>{
							 'stroke' => '#cccccc',
							 'stroke-dasharray'=>'5,5',
							 'stroke-dasharray-width'=>'1',
						}
					);
				}
			}
			 my $chrLengthXX_aa=$more_chrXX/$proportion;
			 $svg->line(
				 x1=>$margin , y1=>$margin_Y,
				 x2=>$chrLengthXX_aa+$margin , y2=>$margin_Y,
				 style=>{
					 'stroke'=>'black',
					 'stroke-width'=>'1',
				}
			);	
		}

         ##Synteny Block
		 #reference vs query
		 if($a<$chromosomenumber and $a<$chromosomenumber2)
		 {
			 open FL,"$inputFile";
			 while(<FL>){
						 chomp;
						 my @tem = split /\t/;
						 if($sort_query_pm{$Chrname2[$a]} eq '-'){$tem[2]=$chr_length2{$Chrname2[$a]}-$tem[2]+1;$tem[3]=$chr_length2{$Chrname2[$a]}-$tem[3]+1;}
						 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname2[$a] ){
							 my $x1 = $tem[2]/$proportion + $margin ;
							 my $y1 = $margin_Y + 10 + 12 + 1+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x2 = $tem[3]/$proportion + $margin ;
							 my $y2 = $margin_Y + 10 + 12 + 1+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x3 = $margin + $tem[0]/$proportion ;
							 my $y3 = $margin_Y + $AlignmentHight - 1+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x4 = $margin + $tem[1]/$proportion;
							 my $y4 = $margin_Y + $AlignmentHight - 1+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x24=$x2;
							 my $y24=($y2+$y4)/2;
							 my $x42=$x4;
							 my $y42=$y24;
							 my $x31=$x3;
							 my $y31=($y1+$y3)/2;
							 my $x13=$x1;
							 my $y13=($y1+$y3)/2;
							 if(!$curveto)
							 {
								 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
								 {
									 $svg->polygon(
										 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
										 style=>{
											 'fill'=>"$inversion_color",
											 'stroke'=>"$inversion_color",
											 'stroke-width'=>'0.1',
										}
									);
								}
								 else	
								 {
									 $svg->polygon(
										 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
										 style=>{
											 'fill'=>"$synteny_color",
											 'stroke'=>"$synteny_color",
											 'stroke-width'=>'0.1',
										}
									);						     
								 }
							}
							 else
							 {
								 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
								 {
									 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
									 $svg->path(
										 d => $path,
										 fill=> "$inversion_color",
										 stroke=>"$inversion_color",
										 'stroke-width'=>'0.5',
									);
								}
								 else
								 {
									 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
									 $svg->path(
										 d => $path,
										 fill=> "$synteny_color",
										 stroke=>"$synteny_color",
										 'stroke-width'=>'0.5',
									);						     
								}						 
							}
						}
			}
			close FL;
        }

		##ref_snp
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			if($snp_REF)
			{
				 my $counta_snpa;
				 my @count_SNP;
				 if($SNP_Win_bp==1)
				 {
					 open FL_snp_ref,"$inputFile15";
					 while(<FL_snp_ref>)
					 {
						 chomp;	
						 my @tem = split /\t/; 
						 if( ($tem[0] eq $Chrname1[$a]) )
						 { 
							 if($pro_snpa==1){$SNP_Win_bp=abs($tem[2]-$tem[1]);$pro_snpa++;}
						}	
					}
					 close FL_snp_ref;
				}
				 if(int($chr_length{$Chrname1[$a]}/$SNP_Win_bp)==($chr_length{$Chrname1[$a]}/$SNP_Win_bp))
				 {$counta_snpa=int($chr_length{$Chrname1[$a]}/$SNP_Win_bp);}
				 else{$counta_snpa=int($chr_length{$Chrname1[$a]}/$SNP_Win_bp)+1;}			 			 		 
				 for(my $a_aasnp=0;$a_aasnp<$counta_snpa;$a_aasnp++)
				 {
					 push(@count_SNP,0);
				}
				 open FL_snp_ref,"$inputFile15";
				 while(<FL_snp_ref>){
					 chomp;	
					 my @tem = split /\t/; 
					 if( ($tem[0] eq $Chrname1[$a]) )
					 { 
						 my $row_snps=int($tem[1]/$SNP_Win_bp);
						 $count_SNP[$row_snps]+=$tem[3];
					}	
				}
				 close FL_snp_ref;
				 for(my $a_snp=0;$a_snp<$counta_snpa;$a_snp++)
				 {
					 if($count_SNP[$a_snp]!=0)
					 {
						 if($count_SNP[$a_snp]>$SNP_threshold_value){$count_SNP[$a_snp]=$SNP_threshold_value;}
						 if($a_snp!=($counta_snpa-1))
						 {
							 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
							 $svg->rect(
								 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
								 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
								 width=>$SNP_Win_bp/$proportion, 
								 height=>$count_SNP[$a_snp]*$snp_pro,
								 style=>{
									 'fill'=>"$SNP_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
						 else
						 {
							 if(int($chr_length{$Chrname1[$a]}/$SNP_Win_bp)==($chr_length{$Chrname1[$a]}/$SNP_Win_bp))
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
									 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
									 width=>$SNP_Win_bp/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);						 
							}
							 else
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/($SNP_threshold_value*($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$SNP_Win_bp);
								 if($count_SNP[$a_snp]>1){$count_SNP[$a_snp]=1;}
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
									 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
									 width=>($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);						     
							}
						}					 
					}
				}
			}
		}
		##query_snp
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			if($snp_QUERY1)
			{
				 my $counta_snpa;
				 my @count_SNP;
				 if($SNP_Win_bp==1)
				 {
					 open FL_snp_query,"$inputFile16";
					 while(<FL_snp_query>)
					 {
						 chomp;	
						 my @tem = split /\t/;
						 if( ($tem[0] eq $Chrname2[$a]) )
						 { 
							 if($pro_snpa==1){$SNP_Win_bp=abs($tem[2]-$tem[1]);$pro_snpa++;}
						}	
					}
					 close FL_snp_query;
				}
				 if(int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)==($chr_length2{$Chrname2[$a]}/$SNP_Win_bp))
				 {$counta_snpa=int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp);}
				 else{$counta_snpa=int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)+1;}			 
				 for(my $a_aasnp=0;$a_aasnp<$counta_snpa;$a_aasnp++)
				 {
					 push(@count_SNP,0);
				}
				 open FL_snp_query,"$inputFile16";
				 while(<FL_snp_query>){
					 chomp;	
					 my @tem = split /\t/;
					 if( ($tem[0] eq $Chrname2[$a]) )
					 { 
						 my $row_snps=int($tem[1]/$SNP_Win_bp);
						 $count_SNP[$row_snps]+=$tem[3];
					}	
				}
				 close FL_snp_query;
				 for(my $a_snp=0;$a_snp<$counta_snpa;$a_snp++)
				 {
					 if($count_SNP[$a_snp]!=0)
					 {
						 if($count_SNP[$a_snp]>$SNP_threshold_value){$count_SNP[$a_snp]=$SNP_threshold_value;}
						 if($a_snp!=($counta_snpa-1))
						 {					 
							 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
							 $svg->rect(
								 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
								 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*2*$a,
								 width=>$SNP_Win_bp/$proportion, 
								 height=>$count_SNP[$a_snp]*$snp_pro,
								 style=>{
									 'fill'=>"$SNP_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
						 else
						 {
							 if(int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)==($chr_length2{$Chrname2[$a]}/$SNP_Win_bp))
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
									 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*2*$a,
									 width=>$SNP_Win_bp/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);							 
							}
							 else
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/($SNP_threshold_value*($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$SNP_Win_bp);
								 if($count_SNP[$a_snp]>1){$count_SNP[$a_snp]=1;}
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
									 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*2*$a,
									 width=>($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);							 
							}
						}					 
					}								
				}	
			}
        }
		##ref_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			if( $TE_REF and ($snp_TE==1) )
			{
				 my $counta_TEa;
				 my @count_TE;
				 if(int($chr_length{$Chrname1[$a]}/$TE_Win_bp)==($chr_length{$Chrname1[$a]}/$TE_Win_bp))
				 {$counta_TEa=int($chr_length{$Chrname1[$a]}/$TE_Win_bp);}
				 else{$counta_TEa=int($chr_length{$Chrname1[$a]}/$TE_Win_bp)+1;}			 			 		 
				 for(my $a_aaTE=0;$a_aaTE<$counta_TEa;$a_aaTE++)
				 {
					 push(@count_TE,0);
				}
				 open FL_TE_ref,"$inputFile17";
				 while(<FL_TE_ref>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname1[$a]) )
					 { 
						 my $row_TEs=int($tem[1]/$TE_Win_bp);
						 $count_TE[$row_TEs]+=$tem[3]; 
					}	
				}
				 close FL_TE_ref;
				 for(my $a_TE=0;$a_TE<$counta_TEa;$a_TE++)
				 {
					 if($a_TE!=($counta_TEa-1))
					 {
						 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
						 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
						 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
						 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
						 if($count_TE[$a_TE]!=0)
						 {
							 $svg->rect(
								 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
								 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
								 width=>$TE_Win_bp/$proportion, 
								 height=>$count_TE[$a_TE]*$TE_pro,
								 style=>{
									 'fill'=>"$TE_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
					 else
					 {
						 if(int($chr_length{$Chrname1[$a]}/$TE_Win_bp)==($chr_length{$Chrname1[$a]}/$TE_Win_bp))
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
									 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
									 width=>$TE_Win_bp/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
						 else
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
									 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.7,
									 width=>($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$TE_Win_bp)*$TE_Win_bp)/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
					}
				}
			}
		}
		##query_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			if( $TE_QUERY1 and ($snp_TE==1) )
			{			 
				 my $counta_TEa;
				 my @count_TE;
				 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp))
				 {$counta_TEa=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp);}
				 else{$counta_TEa=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)+1;}				 		 
				 for(my $a_aaTE=0;$a_aaTE<$counta_TEa;$a_aaTE++)
				 {
					 push(@count_TE,0);
				}
				 open FL_TE_query,"$inputFile18";
				 while(<FL_TE_query>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname2[$a]) )
					 { 
						 my $row_TEs=int($tem[1]/$TE_Win_bp);
						 $count_TE[$row_TEs]+=$tem[3];
					}	
				}
				 close FL_TE_query;
				 for(my $a_TE=0;$a_TE<$counta_TEa;$a_TE++)
				 {
					 if($count_TE[$a_TE]!=0)
					 {				 
						 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
						 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
						 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
						 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
						 if($count_TE[$a_TE]!=0)
						 {
							 $svg->rect(
								 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
								 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*2*$a,
								 width=>$TE_Win_bp/$proportion, 
								 height=>$count_TE[$a_TE]*$TE_pro,
								 style=>{
									 'fill'=>"$TE_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp))
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
									 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*2*$a,
									 width=>$TE_Win_bp/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);	
							}
						}
						 else
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 { 
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
									 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*2*$a,
									 width=>($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp)/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
                            }							
						}
					}			 								
				}	
			}
		}		
		
		 #Chromosome Name
		 ####draw genome		 
		 if($gene_density_REF or $gene_density_QUERY1)
		 {
			 #query1 name
			if($a<$chromosomenumber2)
			 {
				 if($chromosomename==0)
				 {
					 $svg->text(
						 x=>15+$maxChrnum*27+10, 
						 y=>$margin_Y +20+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$queryname");						
				 }
				 else
				 {
					 $svg->text(
						 x=>15,
						 y=>$margin_Y +20+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$queryname");			      
					 $svg->text(
						 x=>15+$maxChrlong*27+10, 
						 y=>$margin_Y +20+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$outChrname2[$a]");	
				}
            }
			 #reference name
			 if($a<$chromosomenumber)
			 {
				  if($chromosomename==0)
				 {
					 $svg->text(
						 x=>15+$maxChrnum*27+10, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$refname");					
				 }
				else
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$refname");
					 $svg->text(
						 x=>15+$maxChrlong*27+10, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$outChrname1[$a]");
				}
			}
			 if($a<$chromosomenumber)
			 {
				 if($chromosomename==0)
				 {				 
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-5-5,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$outChrname1[$a]");
				}
             }			
		}
		 else
		 {
             if($a<$chromosomenumberMIN1)
			 {
				 if($chromosomename==0)
				 {			 
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-5-5,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$outChrname1[$a]");
				}
				 elsif($chromosomename==1)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y +20+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$outChrname2[$a]");
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45'
						}
					)->cdata("$outChrname1[$a]");				
				}
             }				
		}		
		 ##QUERY1_gene_density
		 if($a<$chromosomenumber2)
		 {
			 if($gene_density_QUERY1)
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 width=>$chrLength2, height=>24,
					 style=>{
						 'fill'=>'white',
						 'stroke'=>'white',
						 'stroke-width'=>'1',
					}
				);				 
				 my $GD_count=0;			 
				 my @gene_density_count1;
				 my @gene_density_count2;
				 my @gene_density_count3;
				 my $gene_density_count_y=$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
				 my $gene_density_num;
				 if( int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)==($chr_length2{$Chrname2[$a]}/$GD_Win_bp) ){$gene_density_num=int($chr_length2{$Chrname2[$a]}/$GD_Win_bp);}
				 else{$gene_density_num=int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)+1;}
				 for(my $a_agene_density=0;$a_agene_density<$gene_density_num;$a_agene_density++)
				 {
					 push(@gene_density_count3,0);
				}				 
				 open FL_query1_gene_density,"$inputFile27";
				 while(<FL_query1_gene_density>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if(length("@tem") != 0)
					 {
						 if( ( $tem[0] eq $Chrname2[$a] ) and ($tem[2] eq 'gene') )
						 {
							 push(@gene_density_count1,$tem[3]);
							 push(@gene_density_count2,$tem[4]);
							 $GD_count++;
						}
					}	
				}
				 close FL_query1_gene_density;

				 for(my $a_agene_density=0;$a_agene_density<$GD_count;$a_agene_density++)
				 {
					 my $count_gene1=int($gene_density_count1[$a_agene_density]/$GD_Win_bp);
					 if( ($gene_density_count2[$a_agene_density]<(($count_gene1+1)*$GD_Win_bp)) )
					 {
						 $gene_density_count3[$count_gene1]+=($gene_density_count2[$a_agene_density]-$gene_density_count1[$a_agene_density]+1);
					}
					 else
					 {
						 my $count_gene2=int($gene_density_count2[$a_agene_density]/$GD_Win_bp);
						 my $gene_length_num=$count_gene2-$count_gene1;
						 $gene_density_count3[$count_gene1]+=(($count_gene1+1)*$GD_Win_bp-$gene_density_count1[$a_agene_density]+1);
						 $gene_density_count3[$count_gene2]+=($gene_density_count2[$a_agene_density]-$count_gene2*$GD_Win_bp+1);
						 if($gene_length_num>1)
						 {
							 for(my $a_GDa=1;$a_GDa<$gene_length_num;$a_GDa++)
							 {
								 $gene_density_count3[$count_gene1+$a_GDa]+=$GD_Win_bp;
							}
						}	
					}
				} 		
				 for(my $a_gene_density=0;$a_gene_density<$gene_density_num;$a_gene_density++)
				 {
					 my $gene_density_count_x=$margin+$GD_Win_bp/$proportion*$a_gene_density;
					 if($a_gene_density!=($gene_density_num-1))
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/$GD_Win_bp;
					}
					else
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)*$GD_Win_bp);
					}
					 my $gene_opacity;					 				
					 if($gene_density_count3[$a_gene_density]<0.25){$gene_opacity=(0.1+0.1*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.5){$gene_opacity=(0.1+0.1+0.2*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.75){$gene_opacity=(0.1+0.3+0.3*$gene_density_count3[$a_gene_density]);}
					 else{$gene_opacity=(0.1+0.6+0.4*$gene_density_count3[$a_gene_density]);}		
					 if( $a_gene_density!=($gene_density_num-1) )
					 {					     
			             my $stroke_gene_w=$GD_Win_bp/$proportion;	
						 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
						 {						 
							 $svg->line(
								 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
								 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>"24",
									 'stroke-opacity'=>"$gene_opacity",   
								}
							);
                        }						 						 						
                    }
                     else
                     {
						 if( ($chr_length2{$Chrname2[$a]}/$GD_Win_bp)==int($chr_length2{$Chrname2[$a]}/$GD_Win_bp) )
						 {
							 my $stroke_gene_w=$GD_Win_bp/$proportion;	
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}					     
						 }
						 else
						 {
							 my $stroke_gene_w=($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)*$GD_Win_bp)/$proportion;
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}
						}	
					}					 
				}		 
				 #frame
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,
					 y2=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+24,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,
					 y2=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 x2=>$margin,
					 y2=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,
					 y1=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,
					 y2=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);					
			}			
			 else
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
					 width=>$chrLength2, height=>24,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'10',
						 'ry'=>'10',
						 'stroke-width'=>'1',
					}
				);			 
			}	
        }	
		 if($a<$chromosomenumber)
		 {
		     ##reference_gene_density
			 if($gene_density_REF)
			 {				 
				 my $GD_count=0;			 
				 my @gene_density_count1;
				 my @gene_density_count2;
				 my @gene_density_count3;
				 my $gene_density_count_y=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
				 my $gene_density_num;
				 if( int($chr_length{$Chrname1[$a]}/$GD_Win_bp)==($chr_length{$Chrname1[$a]}/$GD_Win_bp) ){$gene_density_num=int($chr_length{$Chrname1[$a]}/$GD_Win_bp);}
				 else{$gene_density_num=int($chr_length{$Chrname1[$a]}/$GD_Win_bp)+1;}
				 for(my $a_agene_density=0;$a_agene_density<$gene_density_num;$a_agene_density++)
				 {
					 push(@gene_density_count3,0);
				}				 
				 open FL_ref_gene_density,"$inputFile26";
				 while(<FL_ref_gene_density>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if(length("@tem") != 0)
					 {
						 if( ( $tem[0] eq $Chrname1[$a] ) and ($tem[2] eq 'gene') )
						 {
							 push(@gene_density_count1,$tem[3]);
							 push(@gene_density_count2,$tem[4]);
							 $GD_count++;
						}
					}	
				}
				 close FL_ref_gene_density;

				 for(my $a_agene_density=0;$a_agene_density<$GD_count;$a_agene_density++)
				 {
					 my $count_gene1=int($gene_density_count1[$a_agene_density]/$GD_Win_bp);
					 if( ($gene_density_count2[$a_agene_density]<(($count_gene1+1)*$GD_Win_bp)) )
					 {
						 $gene_density_count3[$count_gene1]+=($gene_density_count2[$a_agene_density]-$gene_density_count1[$a_agene_density]+1);
					}
					 else
					 {
						 my $count_gene2=int($gene_density_count2[$a_agene_density]/$GD_Win_bp);
						 my $gene_length_num=$count_gene2-$count_gene1;
						 $gene_density_count3[$count_gene1]+=(($count_gene1+1)*$GD_Win_bp-$gene_density_count1[$a_agene_density]+1);
						 $gene_density_count3[$count_gene2]+=($gene_density_count2[$a_agene_density]-$count_gene2*$GD_Win_bp+1);
						 if($gene_length_num>1)
						 {
							 for(my $a_GDa=1;$a_GDa<$gene_length_num;$a_GDa++)
							 {
								 $gene_density_count3[$count_gene1+$a_GDa]+=$GD_Win_bp;
							}
						}	
					}
				} 		
				 for(my $a_gene_density=0;$a_gene_density<$gene_density_num;$a_gene_density++)
				 {
					 my $gene_density_count_x=$margin+$GD_Win_bp/$proportion*$a_gene_density;
					 if($a_gene_density!=($gene_density_num-1))
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/$GD_Win_bp;
					}
					else
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GD_Win_bp)*$GD_Win_bp);
					}
					 my $gene_opacity;					 				
					 if($gene_density_count3[$a_gene_density]<0.25){$gene_opacity=(0.1+0.1*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.5){$gene_opacity=(0.1+0.1+0.2*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.75){$gene_opacity=(0.1+0.3+0.3*$gene_density_count3[$a_gene_density]);}
					 else{$gene_opacity=(0.1+0.6+0.4*$gene_density_count3[$a_gene_density]);}		
					 if( $a_gene_density!=($gene_density_num-1) )
					 {					     
			             my $stroke_gene_w=$GD_Win_bp/$proportion;	
						 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
						 {						 
							 $svg->line(
								 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
								 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>"24",
									 'stroke-opacity'=>"$gene_opacity",   
								}
							);
                        }						 						 						
                    }
                     else
                     {
						 if( ($chr_length{$Chrname1[$a]}/$GD_Win_bp)==int($chr_length{$Chrname1[$a]}/$GD_Win_bp) )
						 {
							 my $stroke_gene_w=$GD_Win_bp/$proportion;	
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}					     
						 }
						 else
						 {
							 my $stroke_gene_w=($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GD_Win_bp)*$GD_Win_bp)/$proportion;
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}
						}	
					}				 
				}			 
				 #frame
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,
					 y2=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+24,
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,
					 y2=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,
					 y1=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
					 x2=>$margin,
					 y2=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin+$chr_length{$Chrname1[$a]}/$proportion,
					 y1=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,
					 y2=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);							
			}
			 else
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
					 width=>$chrLength, height=>24,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'10',
						 'ry'=>'10',
						 'stroke-width'=>'1',
					}
				);					 
			}	
        }		
		
		 #Annotation information
		 #Draw Comment Area
		 ##centromere ˿
		if($a<$chromosomenumber)
		 {
			 if($refcentromere)
			 {
				 if($gene_density_REF)
				 {
					 open REF_centromere,"$inputFile7";
					 while(<REF_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname1[$a] ){						
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = 12+$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x2 = $tem[1]/$proportion + $margin;
							 my $y2 = 24+0.6+$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x3 = $tem[2]/$proportion + $margin;
							 my $y3 = 24+0.6+$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $y4 = $margin_Y-0.6+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'stroke'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'stroke'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,
								 y1=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-0.05,
								 x2=>$margin+$tem[2]/$proportion,
								 y2=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-0.05+24,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,
								 y1=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-0.05+24,
								 x2=>$margin+$tem[2]/$proportion,
								 y2=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1)-0.05,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
						}	
					}
					 close REF_centromere;				
				}
				 else
				 {	 
					 #reference centromere ˿
					 open REF_centromere,"$inputFile7";
					 while(<REF_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname1[$a] ){
							 $svg->rect(
								 x=>$margin+$tem[1]/$proportion,
								 y=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
								 width=>($tem[2]-$tem[1])/$proportion, height=>24,
								 style=>{
									 'fill'=>"$centromere_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x2 = $midx/$proportion + $margin-6;
							 my $y2 = $margin_Y+24+0.6+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $x3 = $midx/$proportion + $margin+6;
							 my $y3 = $margin_Y+24+0.6+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 my $y4 = $margin_Y-0.6+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
						}
					}
					 close REF_centromere;
				}	 
			}
		}
		if($a<$chromosomenumber2)
		 {
			 if($query1centromere)
			 {
				 if($gene_density_QUERY1)
				 {
					 open QUERY1_centromere,"$inputFile6";
					 while(<QUERY1_centromere>){
						 chomp;
						 my @tem = split /\t/;  
						 if( $tem[0] eq $Chrname2[$a] ){						
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $x2 = $tem[1]/$proportion + $margin;
							 my $y2 = $margin_Y+24+0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $x3 = $tem[2]/$proportion + $margin;
							 my $y3 = $margin_Y+24+0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $y4 = $margin_Y-0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,
								 y1=>$margin_Y  + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.05,
								 x2=>$margin+$tem[2]/$proportion,
								 y2=>$margin_Y  + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.05+24,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,
								 y1=>$margin_Y  + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.05+24,
								 x2=>$margin+$tem[2]/$proportion,
								 y2=>$margin_Y  + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.05,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
						}
					}
					 close QUERY1_centromere;
				}
				 else
				 {
					 #query1 centromere ˿
					 open QUERY1_centromere,"$inputFile6";
					 while(<QUERY1_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname2[$a] ){
							 $svg->rect(
								 x=>$margin+$tem[1]/$proportion,
								 y=>$margin_Y+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
								 width=>($tem[2]-$tem[1])/$proportion, height=>24,
								 style=>{
									 'fill'=>"$centromere_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $x2 = $midx/$proportion+$margin-6;
							 my $y2 = $margin_Y+24+0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $x3 = $midx/$proportion +$margin+6;
							 my $y3 = $margin_Y+24+0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 my $y4 = $margin_Y-0.6+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
						}
					}
					 close QUERY1_centromere;
				}	 
			}					 			
		}
		 ##reference telomere 
		if($a<$chromosomenumber)
		 {
			 if($reftelomere)
			 {
				 #reference telomere 
				 open REF_telomere,"$inputFile9";
				 while(<REF_telomere>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] )
					 {
						 my $x1;
						 my $y1;
						 my $x2;
						 my $y2;
						 my $x3;
						 my $y3;
						 if($tem[1]==1)
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
							 $x2 = ($tem[1])/$proportion + $margin-12;
							 $y2 = $margin_Y-12+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
							 $x3 = $tem[1]/$proportion + $margin-12;
							 $y3 = $margin_Y+12+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
						}
						 else
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
							 $x2 = ($tem[1])/$proportion + $margin+12;
							 $y2 = $margin_Y-12+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
							 $x3 = $tem[1]/$proportion + $margin+12;
							 $y3 = $margin_Y+12+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2);
						}					 
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
					}
				 }
				 close REF_telomere;
			}
		}	
		if($a<$chromosomenumber2)
		 {
			 if($query1telomere)
			 {
				 #query1 telomere
				 open QUERY1_telomere,"$inputFile8";
				 while(<QUERY1_telomere>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] )
					 {
						 my $x1;
						 my $y1;
						 my $x2;
						 my $y2;
						 my $x3;
						 my $y3;				     
						 if($tem[1]==1)
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+12+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $x2 = ($tem[1])/$proportion + $margin-12;
							 $y2 = $margin_Y+12+10-12+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $x3 = $tem[1]/$proportion + $margin-12;
							 $y3 = $margin_Y+12+10+12+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
						}
						 else
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+12+10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $x2 = ($tem[1])/$proportion + $margin+12;
							 $y2 = $margin_Y+12+10-12+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;
							 $x3 = $tem[1]/$proportion + $margin+12;
							 $y3 = $margin_Y+12+10+12+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a;					     
						}
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
					}
				}
				 close QUERY1_telomere;
			}
		}
          ##query_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if( $TE_QUERY1 and ($snp_TE==0) )
			 {
				 my @TE_count;
				 my @TE_count_x;
				 my @TE_count_y;
				 my $TE_num;
				 if( int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp) ){$TE_num=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp);}
				 else{$TE_num=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)+1;}			 
				 for(my $a_aTE=0;$a_aTE<$TE_num;$a_aTE++)
				 {
					 push(@TE_count_x,0);
					 push(@TE_count_y,0);
					 push(@TE_count,0);				 
				}
				 open FL_query_TE,"$inputFile18";
				 while(<FL_query_TE>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname2[$a])
					 {
					 my $row_TE=int($tem[1]/$TE_Win_bp);
					 $TE_count[$row_TE]+=$tem[3];
					}
				}
				 close FL_query_TE;
				 for(my $a_TE=0;$a_TE<$TE_num;$a_TE++)
				 {
					 if($a_TE!=($TE_num-1))
					 {
						 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
						 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}
						 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp/(2*$proportion);
						 $TE_count_y[$a_TE]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$TE_count[$a_TE]*$te_pro;
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp))
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp/(2*$proportion);
							 $TE_count_y[$a_TE]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$TE_count[$a_TE]*$te_pro;				     
						}
						 else
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp)/($proportion*2);
							 $TE_count_y[$a_TE]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$TE_count[$a_TE]*$te_pro;						 
						}
					} 
					if($a_TE!=0)
					 {	
						 $svg->polygon(
							 points=>"$TE_count_x[$a_TE-1],$TE_count_y[$a_TE-1] $TE_count_x[$a_TE],$TE_count_y[$a_TE]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
          ##ref_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if( $TE_REF and ($snp_TE==0) )
			 {
				 my @TE_count;
				 my @TE_count_x;
				 my @TE_count_y;
				 my $TE_num;
				 if( int($chr_length{$Chrname1[$a]}/$TE_Win_bp)==($chr_length{$Chrname1[$a]}/$TE_Win_bp) ){$TE_num=int($chr_length{$Chrname1[$a]}/$TE_Win_bp);}
				 else{$TE_num=int($chr_length{$Chrname1[$a]}/$TE_Win_bp)+1;}			 
				 for(my $a_aTE=0;$a_aTE<$TE_num;$a_aTE++)
				 {
					 push(@TE_count_x,0);
					 push(@TE_count_y,0);
					 push(@TE_count,0);				 
				}
				 open FL_ref_TE,"$inputFile17";
				 while(<FL_ref_TE>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname1[$a])
					 {
					 my $row_TE=int($tem[1]/$TE_Win_bp);
					 $TE_count[$row_TE]+=$tem[3];
					}
				}
				 close FL_ref_TE;
				 for(my $a_TE=0;$a_TE<$TE_num;$a_TE++)
				 {
					 if($a_TE!=($TE_num-1))
					 {
						 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
						 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}					 
						 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
						 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$TE_count[$a_TE]*$te_pro;
					}
					 else
					 {
						 if(int($chr_length{$Chrname1[$a]}/$TE_Win_bp)==($chr_length{$Chrname1[$a]}/$TE_Win_bp))
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
							 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$TE_count[$a_TE]*$te_pro;
						}
						 else
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$TE_Win_bp)*$GD_Win_bp)/($proportion*2);
							 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$TE_count[$a_TE]*$te_pro;
						}
					} 
					if($a_TE!=0)
					 {	
						 $svg->polygon(
							 points=>"$TE_count_x[$a_TE-1],$TE_count_y[$a_TE-1] $TE_count_x[$a_TE],$TE_count_y[$a_TE]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
         ##query_GC
		if($a<$chromosomenumber2)
		 {
			 if( $GC_QUERY1 and ($GC_content==1) )
			 {
				 my @GC_count;
				 my @GC_count_x;
				 my @GC_count_y;
				 my $GC_num;
				 if($GC_Win_bp==1)
				 {
					 open FL_query_GC,"$inputFile30";
					 while(<FL_query_GC>)
					 {
						 chomp;	
						 my @tem = split /\t/;
						 if($tem[0] eq $Chrname2[$a])
						 {
							 if($pro_GCa==1){$GC_Win_bp=abs($tem[2]-$tem[1]);$pro_GCa++;}	
						}
					}
					 close FL_query_GC;	
				}	 
				 if( int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)==($chr_length2{$Chrname2[$a]}/$GC_Win_bp) ){$GC_num=int($chr_length2{$Chrname2[$a]}/$GC_Win_bp);}
				 else{$GC_num=int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)+1;}			 
				 for(my $a_aGC=0;$a_aGC<$GC_num;$a_aGC++)
				 {
					 push(@GC_count_x,0);
					 push(@GC_count_y,0);
					 push(@GC_count,0);				 
				}
				 open FL_query_GC,"$inputFile30";
				 while(<FL_query_GC>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname2[$a])
					 {
					 my $row_GC=int($tem[1]/$GC_Win_bp);
					 $GC_count[$row_GC]+=$tem[3];
					}
				}
				 close FL_query_GC;
				 for(my $a_GC=0;$a_GC<$GC_num;$a_GC++)
				 {
					 if($a_GC!=($GC_num-1))
					 {
						 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
						 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
						 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
						 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;					 
						 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
						 $GC_count_y[$a_GC]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)==($chr_length2{$Chrname2[$a]}/$GC_Win_bp))
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;						 
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
							 $GC_count_y[$a_GC]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;			     
						}
						 else
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)*$GC_Win_bp);
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)*$GC_Win_bp)/($proportion*2);
							 $GC_count_y[$a_GC]=$margin_Y+ 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;						 
						}
					} 
					if($a_GC!=0)
					 {	
						 $svg->polygon(
							 points=>"$GC_count_x[$a_GC-1],$GC_count_y[$a_GC-1] $GC_count_x[$a_GC],$GC_count_y[$a_GC]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
          ##ref_GC
		if($a<$chromosomenumber)
		 {
			 if( $GC_REF and ($GC_content==1) )
			 {
				 my @GC_count;
				 my @GC_count_x;
				 my @GC_count_y;
				 my $GC_num;
				 if($GC_Win_bp==1)
				 {
					 open FL_ref_GC,"$inputFile29";
					 while(<FL_ref_GC>)
					 {
						 chomp;	
						 my @tem = split /\t/;
						 if($tem[0] eq $Chrname1[$a])
						 {
							 if($pro_GCa==1){$GC_Win_bp=abs($tem[2]-$tem[1]);$pro_GCa++;}
						}
					}
					 close FL_ref_GC;
				}
				 if( int($chr_length{$Chrname1[$a]}/$GC_Win_bp)==($chr_length{$Chrname1[$a]}/$GC_Win_bp) ){$GC_num=int($chr_length{$Chrname1[$a]}/$GC_Win_bp);}
				 else{$GC_num=int($chr_length{$Chrname1[$a]}/$GC_Win_bp)+1;}			 
				 for(my $a_aGC=0;$a_aGC<$GC_num;$a_aGC++)
				 {
					 push(@GC_count_x,0);
					 push(@GC_count_y,0);
					 push(@GC_count,0);				 
				}
				 open FL_ref_GC,"$inputFile29";
				 while(<FL_ref_GC>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname1[$a])
					 {
					 my $row_GC=int($tem[1]/$GC_Win_bp);
					 $GC_count[$row_GC]+=$tem[3];
					}
				}
				 close FL_ref_GC;
				 for(my $a_GC=0;$a_GC<$GC_num;$a_GC++)
				 {
					 if($a_GC!=($GC_num-1))
					 {
						 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
						 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
						 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
						 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
						 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
						 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$GC_count[$a_GC]*$GC_pro+20;
					}
					 else
					 {
						 if(int($chr_length{$Chrname1[$a]}/$GC_Win_bp)==($chr_length{$Chrname1[$a]}/$GC_Win_bp))
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
							 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$GC_count[$a_GC]*$GC_pro+20;
						}
						 else
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GC_Win_bp)*$GC_Win_bp);
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GC_Win_bp)*$GC_Win_bp)/($proportion*2);
							 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+2)+12+0.6+$GC_count[$a_GC]*$GC_pro+20;
						}
					} 
					if($a_GC!=0)
					 {	
						 $svg->polygon(
							 points=>"$GC_count_x[$a_GC-1],$GC_count_y[$a_GC-1] $GC_count_x[$a_GC],$GC_count_y[$a_GC]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
		}
		 ##PAV
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if($PAV_REF)
			 {
				 #reference PAV
				 open REF_PAV,"$inputFile20";
				 while(<REF_PAV>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] and abs($tem[2]-$tem[1])>$PAV_limit ){
						 my $PAV_start=$tem[1];
						 if($tem[1]>$tem[2]){$PAV_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {
							 $svg->rect(
								 x=>$margin+$PAV_start/$proportion,
								 y=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$PAV_color",
									 'stroke'=>'black',
									 #'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_PAV;
			}
		}	
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if($PAV_QUERY1)
			 {
				 #query1 PAV
				 open QUERY1_PAV,"$inputFile21";
				 while(<QUERY1_PAV>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] and abs($tem[2]-$tem[1])>$PAV_limit ){
						 my $PAV_start=$tem[1];
						 if($tem[1]>$tem[2]){$PAV_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$PAV_start/$proportion,
								 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$PAV_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close QUERY1_PAV;
			}
        }
		 ##NLR
		if($a<$chromosomenumber)
		 {
			 if($NLR_REF)
			 {
				 #reference NLR
				 open REF_NLR,"$inputFile23";
				 while(<REF_NLR>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] and abs($tem[2]-$tem[1])>$NLR_limit ){
						 my $NLR_start=$tem[1];
						 if($tem[1]>$tem[2]){$NLR_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$NLR_start/$proportion,
								 y=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$NLR_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_NLR;
			}
		}
		if($a<$chromosomenumber2)
		 {		
			 if($NLR_QUERY1)
			 {
				 #query1 NLR
				 open QUERY1_NLR,"$inputFile24";
				 while(<QUERY1_NLR>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] and abs($tem[2]-$tem[1])>$NLR_limit ){
						 my $NLR_start=$tem[1];
						 if($tem[1]>$tem[2]){$NLR_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$NLR_start/$proportion,
								 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$NLR_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close QUERY1_NLR;
			}
        }
		 ##targetgene
		if($a<$chromosomenumber)
		 {
			 if($reftargetgene)
			 {
				 #reference targetgene
				 open REF_targetgene,"$inputFile13";
				 while(<REF_targetgene>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] ){
						 my $targetgene_start=$tem[1];
						 if($tem[1]>$tem[2]){$targetgene_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$targetgene_start/$proportion, 
								 y=>$margin_Y +$AlignmentHight+$ChrHight*$a+$margin_snp*($a+1)+12*(2*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$targetgene_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_targetgene;
			}
		}
		if($a<$chromosomenumber2)
		 {
			if($query1targetgene)
			 {
				 #query1 targetgene
				 open QUERY1_targetgene,"$inputFile12";
				 while(<QUERY1_targetgene>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] ){
						 my $targetgene_start=$tem[1];
						 if($tem[1]>$tem[2]){$targetgene_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$targetgene_start/$proportion, 
								 y=>$margin_Y + 10+$ChrHight*$a+$margin_snp*($a+1)+12*2*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$targetgene_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				 close QUERY1_targetgene;
			}
		}	
         if($a == 0)
		 {
			 if($icon==1)
             {			 
				 if( ($chromosomenumberMAX1-$icon_chrnum)>=0 )
				 {				 
					 if($gene_density_REF or $gene_density_QUERY1)
					 {	
						 #heat map legend
						 my $icon_high_h=$AlignmentHight*5+$margin_snp+60;
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+($k/($icon_high_h/4))*0.1),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.1+($k/($icon_high_h/4))*0.2),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/2)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/2)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.3+($k/($icon_high_h/4))*0.3),   
								}
							);
						}
						 for(my $k=0;$k<=($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h*3/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h*3/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.6+($k/($icon_high_h/4))*0.4),   
								}
							);
						}				
						##white line
						 for(my $k=0;$k<=$icon_high_h;$k++)
						 {

							 if( $k==int($icon_high_h/2) ) 
							 {
								 my $icon_line="black";

								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$k,
									 x2=>$icon_x+int($GDheatmap_wide/4),y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide-int($GDheatmap_wide/4),y1=>$icon_y-$k,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",  
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
							}	
							 if( ($k==0) or ($k==int($icon_high_h/2)) or ($k==$icon_high_h) ) 
							 {
								 my $iconheatmap_num;
								 if($k==0){$iconheatmap_num="0";}
								 elsif($k==int($icon_high_h/2)){$iconheatmap_num="50%";}
								 elsif($k==$icon_high_h){$iconheatmap_num="100%";}
								 $svg->text(
									 x=>$icon_x+$GDheatmap_wide+4, 
									 y=>$icon_y-$k+10,
									 style=>{
									     'font-family'=>"Courier",#
										 'stroke'=>'none',
										 'font-size'=>'25',
									}
								)->cdata("$iconheatmap_num"); 
							}						
						}
						 {
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$icon_high_h,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);						
						}
						 my $GD_bp_S=$GD_Win_bp/1000;
						 my $GD_bp_name="("."$GD_bp_S"."Kb)";
						 my $ca_wide=($GDheatmap_wide-length($GD_bp_name)*15)/2;
						 $svg->text(
							 x=>$icon_x+$ca_wide,#-8
							 y=>$icon_y+37,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25',
							}
						)->cdata($GD_bp_name);
						$icon_y=$icon_y-$icon_high_h-$GD_high_move/2;
						 my $tujie_name='Gene Density';
						 $svg->text(
							 x=>$icon_x-15, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
						
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move*1.5;
					}

					 if( ($TE_REF or $TE_QUERY1) and ($snp_TE==0) )
					 {   
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+9, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("100%");
						 $svg->text(
							 x=>$TE_X3-18, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("0");	
						 {	
							my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $GD_bp_S=$GD_Win_bp/1000;
							 my $GD_bp_name="("."$GD_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x-8, 
								 y=>$icon_y+37,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($GD_bp_name);							
						}
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;				
					}
					 if( ($GC_REF or $GC_QUERY1) and ($GC_content==1) )
					 {   
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15-8;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro+20;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+8+8+2,#+28-14*$TE_bp_n, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("50%");
						$svg->text(
							 x=>$TE_X3-75+8+8+2, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("40%");	
						
						 {	
 						     my $tujie_name="GC Content";
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $GC_bp_S=$GC_Win_bp/1000;
							 my $GC_bp_name="("."$GC_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+190+25, 
								 y=>$icon_y-$GDtext_move_y-3+3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($GC_bp_name);	
						}
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;				
					}

					if($snp_REF or $snp_QUERY1)
					 {
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;#100000
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$SNP_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$SNP_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-$snp_heatmap_max-4, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("$SNP_threshold_value");									
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-13-4, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("0");							
							 my $tujie_name='SNP';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $SNP_bp_S=$SNP_Win_bp/1000;
							 my $SNP_bp_name="("."$SNP_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50+25, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($SNP_bp_name);							
						}	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;
					}
					
					if( ($TE_REF or $TE_QUERY1) and ($snp_TE==1) )
					 {
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$TE_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$TE_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-$snp_heatmap_max-4-17+9, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("100%");
							 my $TE_xiaaa=$TE_tem3min*100;
							 my $TE_xiabb="$TE_xiaaa".'%';
							 if($TE_tem3min==0){$TE_xiabb='0';}
							 my $TE_xialeng=(length($TE_xiabb)-1)*18;
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-13-4-$TE_xialeng, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("$TE_xiabb");
							 my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);							 
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;
					}
					
					 if($reftelomere or $query1telomere)
					 {
						 #reference legend 
						 my $x1 = $icon_x+24;
						 my $y1 = $icon_y-24;
						 my $x2 = $x1-24;
						 my $y2 = $y1-24;
						 my $x3 = $x1-24;
						 my $y3 = $y1+24;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='Telomere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if( $NLR_REF or $NLR_QUERY1 )
					 {
						 #NLR_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$NLR_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='NLR';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if($PAV_REF or $PAV_QUERY1)
					 {
						 #PAV_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$PAV_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='PAV';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
					 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if($icon_centromere and ($refcentromere or $query1centromere))
					 {
						 #centromere legend ˿
						 
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$centromere_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 my $x1 = $icon_x+$GDheatmap_wide/2;
						 my $y1 = $icon_y-$GDheatmap_high/2;
						 my $x2 = $x1-12;
						 my $y2 = $y1-$GDheatmap_high/2-1;
						 my $x3 = $x1+12;
						 my $y3 = $y1-$GDheatmap_high/2-1;
						 my $y4 = $y1+$GDheatmap_high/2+1;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2 $x3,$y3",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'0.1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y4 $x3,$y4",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 my $tujie_name='Centromere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if($reftargetgene or $query1targetgene)
					 {
						 #targetgene_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$targetgene_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($targetgene_name);				 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}
					 
					 {
						##synteny bolck legend 
						 if($inversion_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Inversion';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
						}
						if($synteny_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Synteny';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
						}
					}			
					 if($gene_density_REF!=1)
					 {
						 #icon_reference
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$reference_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$refname");	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;			 
					}
					 if($gene_density_QUERY1!=1)
					 {
						 #icon_query1
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query1_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname");	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;			 
					}				
					 {
						 my $tujie_name='Type';
						 $svg->text(
							 x=>$icon_x-5, 
							 y=>$icon_y-$GDtext_move_y+$GD_high_move/2-10,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);	 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;	
					}
				}
				 else
				 {				 
					 my $aa_x=0;
					 my $aa_y=0;
					 my $icon_high_h=$AlignmentHight*5+$margin_snp+60;
					 if($gene_density_REF or $gene_density_QUERY1)
					 {	
						 #heat map legend
						 
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+($k/($icon_high_h/4))*0.1),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.1+($k/($icon_high_h/4))*0.2),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/2)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/2)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.3+($k/($icon_high_h/4))*0.3),   
								}
							);
						}
						 for(my $k=0;$k<=($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h*3/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h*3/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.6+($k/($icon_high_h/4))*0.4),   
								}
							);
						}				
						##white line
						 for(my $k=0;$k<=$icon_high_h;$k++)
						 {

							 if( $k==int($icon_high_h/2) ) 
							 {
								 my $icon_line="black";

								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$k,
									 x2=>$icon_x+int($GDheatmap_wide/4),y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide-int($GDheatmap_wide/4),y1=>$icon_y-$k,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",  
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
							}	
							 if( ($k==0) or ($k==int($icon_high_h/2)) or ($k==$icon_high_h) ) 
							 {
								 my $iconheatmap_num;
								 if($k==0){$iconheatmap_num="0";}
								 elsif($k==int($icon_high_h/2)){$iconheatmap_num="50%";}
								 elsif($k==$icon_high_h){$iconheatmap_num="100%";}
								 $svg->text(
									 x=>$icon_x+$GDheatmap_wide+4, 
									 y=>$icon_y-$k+10,
									 style=>{
									     'font-family'=>"Courier",#
										 'stroke'=>'none',
										 'font-size'=>'25',
									}
								)->cdata("$iconheatmap_num"); 
							}						
						}
						 {
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$icon_high_h,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);						
						}
						 my $tujie_name='Gene Density';
						 $svg->text(
							 x=>$icon_x-15, 
							 y=>$icon_y-$GDtext_move_y-$icon_high_h-$GD_high_move/2,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
						 my $GD_bp_S=$GD_Win_bp/1000;
						 my $GD_bp_name="("."$GD_bp_S"."Kb)";
						 my $ca_wide=($GDheatmap_wide-length($GD_bp_name)*15)/2;
						 $svg->text(
							 x=>$icon_x+$ca_wide,#-8
							 y=>$icon_y+37,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25',
							}
						)->cdata($GD_bp_name);							
						 $aa_y+=5;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 {
					     $icon_y = $margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h;#-$GDheatmap_high-$GD_high_move
						 if($SVG_canvas_h==($margin_Y*2+450))
						 {
							 $icon_y = $margin_Y*1.5+450-$icon_high_h;#-$GDheatmap_high-$GD_high_move;
						}						 
						 my $tujie_name='Type';
						 $svg->text(
							 x=>$icon_x-5, 
							 y=>$icon_y-$GDtext_move_y-$GD_high_move/2,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;						
					}
					 if($gene_density_REF!=1)
					 {
						 #icon_reference
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$reference_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$refname");	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }						 
					}
					 if($gene_density_QUERY1!=1)
					 {
						 #icon_query1
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query1_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname");	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }						 
					}					
					 {
						##synteny bolck legend 
						 if($synteny_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Synteny';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
							 $aa_y+=1;
							 if($aa_y==5)
							 {
								 $aa_x+=1;
								 $aa_y=0;
								 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
								 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
								 if($SVG_canvas_h==($margin_Y*2+450))
								 {
									 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
								}							 
							}
						}						
						 if($inversion_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Inversion';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
							 $aa_y+=1;
							 if($aa_y==5)
							 {
								 $aa_x+=1;
								 $aa_y=0;
								 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
								 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
								 if($SVG_canvas_h==($margin_Y*2+450))
								 {
									 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
								}							 
							}
						}
					}
					 if($reftargetgene or $query1targetgene)
					 {
						 #targetgene_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$targetgene_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($targetgene_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if($icon_centromere and ($refcentromere or $query1centromere))
					 {
						 #centromere legend ˿
						 
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$centromere_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 my $x1 = $icon_x+$GDheatmap_wide/2;
						 my $y1 = $icon_y-$GDheatmap_high/2;
						 my $x2 = $x1-12;
						 my $y2 = $y1-$GDheatmap_high/2-1;
						 my $x3 = $x1+12;
						 my $y3 = $y1-$GDheatmap_high/2-1;
						 my $y4 = $y1+$GDheatmap_high/2+1;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2 $x3,$y3",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'0.1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y4 $x3,$y4",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 my $tujie_name='Centromere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if($PAV_REF or $PAV_QUERY1)
					 {
						 #PAV_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$PAV_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='PAV';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if( $NLR_REF or $NLR_QUERY1 )
					 {
						 #NLR_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$NLR_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='NLR';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if($reftelomere or $query1telomere)
					 {
						 #reference legend 
						 my $x1 = $icon_x+24;
						 my $y1 = $icon_y-24;
						 my $x2 = $x1-24;
						 my $y2 = $y1-24;
						 my $x3 = $x1-24;
						 my $y3 = $y1+24;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='Telomere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if($snp_REF or $snp_QUERY1)
					 {
						 $icon_y=$icon_y+10;
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$SNP_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$SNP_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-$snp_heatmap_max-4, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("$SNP_threshold_value");									
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-13-4, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("0");							
							 my $tujie_name='SNP';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $SNP_bp_S=$SNP_Win_bp/1000;
							 my $SNP_bp_name="("."$SNP_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50+25, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($SNP_bp_name);								
						}	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}

					if( ($TE_REF or $TE_QUERY1) and ($snp_TE==1) )
					 {
						 $icon_y=$icon_y+10;
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$TE_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$TE_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-$snp_heatmap_max-4-17+9, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("100%");
							 my $TE_xiaaa=$TE_tem3min*100;
							 my $TE_xiabb="$TE_xiaaa".'%';
							 if($TE_tem3min==0){$TE_xiabb='0';}
							 my $TE_xialeng=(length($TE_xiabb)-1)*18;
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-13-4-$TE_xialeng, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("$TE_xiabb");						
							 my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if( ($TE_REF or $TE_QUERY1) and ($snp_TE==0) )
					 {   
						 $icon_y=$icon_y+10;
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+9, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("100%");									
						$svg->text(
							 x=>$TE_X3-18, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("0");	
						
						 {	
							 my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }				
					}
					 if( ($GC_REF or $GC_QUERY1) and ($GC_content==1) )
					 {   
						 $icon_y=$icon_y+10;
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15-8;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro+20;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+8+8+2,#+28-14*$TE_bp_n, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("50%");									
						$svg->text(
							 x=>$TE_X3-75+8+8+2, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("40%");							
						 {	
							my $tujie_name='GC Content';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $GC_bp_S=$GC_Win_bp/1000;
							 my $GC_bp_name="("."$GC_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+48+25, 
								 y=>$icon_y-$GDtext_move_y+30+3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($GC_bp_name);
						}
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+($margin_snp+$ChrHight+12*2)*($chromosomenumberMAX1-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }				
					}					
				}
            }
		}		
	}

	 #Illustrations drawn  
	 #two genomes 
	 if( $illustration==1 )
	 {  
	     my $different=1;
		 #Determine if the names are consistent
		 if($chromosomenumber != $chromosomenumber2)
		 {
			 $different=0;
		}
		 else
		 {
			 for( my $q=0;$q<$chromosomenumberMAX1;$q++ )
			 {
				 if($outChrname1[$q] ne $outChrname2[$q])
				 {
					 $different=0;
				}
			}
		}	

		 #Illustration.2: synGenome identity   ###two genomes
		 for( my $q=0;$q<$chromosomenumberMIN1;$q++)
		 {
			 # chromosome name
		     if( $different and ($chromosomenumber == $chromosomenumber2) )
			 {
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+($width_identity+$smallinterval_identity)/2+$biginterval_identity*$q-7,
					 y=>$margin_identity+$proportion_identity*5+20,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$q]");
			}
			else
			 {
			     if($q<$chromosomenumber)
				 {
					 my $goal_x=$margin_identity+$smallinterval_identity;
					 my $goal_y=$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$rotate_cosine*$q,
						 y=>$rotate_y-$rotate_sine*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname1[$q]");		
				}
				if($q<$chromosomenumber2)
				 {
                     my $goal_x=$margin_identity+$smallinterval_identity*2+$width_identity;
					 my $goal_y=$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$rotate_cosine*$q,
						 y=>$rotate_y-$rotate_sine*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname2[$q]");	
				}
					
			}
			
			 #Draw coordinate axes of Illustration.2
			 if($q==0){
				 #The title 
				 $svg4->text(
					 x=>($xlength+$proportion_identity)/2.4,y=>$margin_identity-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_identity);
				 #The Y axis
				 $svg4->line(
					 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5,
					 x2=>$margin_identity,y2=>$margin_identity,
					 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
					}
				);
				 #The X axis
				 $svg4->line(
					 x1=>$margin_identity,y1=>$margin_identity +$proportion_identity*5,
					 x2=>$xlength+$proportion_identity,y2=>$margin_identity+$proportion_identity*5,
					 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
					}
				);
			 
				 for(my $i=0; $i<$proportion_identity*5; $i+=10){
					 if ($i%$proportion_identity==0){
						 my $z=$i/4;
						 my $t="$z"."%";
						 $svg4->text(
							 x=>$margin_identity-30,y=>$margin_identity+$proportion_identity*5-$i+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'10',
							}
						)->cdata($t);
						 $svg4->line(
							 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+5,y2=>$margin_identity+$proportion_identity*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
					 else
					 {
						 $svg4->line(
							 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+2,y2=>$margin_identity+$proportion_identity*5-$i,
							 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
							}
						);
					}
				}
				 my $x1=$margin_identity-3;
				 my $x2=$margin_identity+3;
				 my $y1=$margin_identity;
				 my $y2=$margin_identity-3;
				 my $x3=$xlength+$proportion_identity;
				 my $x4=$x3+5;
				 my $y3=$ylength-3;
				 my $y4=$ylength+3;
				 #The Y axis direction
				 $svg4->polygon(
					 points=>"$x1,$y1 $x2,$y1 $margin_identity,$y2",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 #The X axis direction
				 $svg4->polygon(
					 points=>"$x3,$y3 $x3,$y4 $x4,$ylength",
					 style=>{
							  'fill'=>'#000000',
							 'stroke'=>'black',
							 'stroke-width'=>'0.1',
							 'stroke'=>'#000000',
					}
				);
				 #reference color
				 if($q<$chromosomenumber)
				 {
					 $svg4->rect(
						 x=>$x3-170, y=>$y1,
						 width=>$width_identity, height=>$width_identity,
						 style=>{
							 'fill'=>"$reference_color",
							 'stroke'=>"$reference_color",
							 'rx'=>'5',
							 'ry'=>'5',
							 'stroke-width'=>'1',
						}
					);
					 #reference name
					 $svg4->text(
						 x=>$x3+$width_identity-160,y=>$y1+15,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$refname");
				}
				 if($q<$chromosomenumber2)
				 {
					 #query color
					 $svg4->rect(
						 x=>$x3-170, y=>$y1+$width_identity+10,
						 width=>$width_identity, height=>$width_identity,
						 style=>{
							 'fill'=>"$query1_color",
							 'stroke'=>"$query1_color",
							 'rx'=>'5',
							 'ry'=>'5',
							 'stroke-width'=>'1',
						}
					);	
					 #query name
					 $svg4->text(
						 x=>$x3+$width_identity-160,y=>$y1+$width_identity+25,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$queryname");
				}
			}
			
			 open RefvsQuery,"$inputFile";
			 my $refpro=0;
			 my $querypro=0;
			 while(<RefvsQuery>){
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname2[$q] ){
					 $refpro+=$tem[4]/$tem[7];
					 $querypro+=$tem[5]/$tem[8];	
				} 
			}
			 close RefvsQuery; 
			 $refpro=$refpro*100;
			 $querypro=$querypro*100;
			 my $zrefpro=sprintf("%.2f",$refpro);
			 my $zquerypro=sprintf("%.2f",$querypro);
			 my $refheight=$refpro/100*$proportion_identity*4;
			 my $queryheight=$querypro/100*$proportion_identity*4;
			 ####print"$refheight  $queryheight\n\n";
			 if($zrefpro>100)
			 {
				 $zrefpro=100;
			}
			 if($zquerypro>100)
			 {
				 $zquerypro=100;
			}	
			
			if($q<$chromosomenumber)
			 {
			     #reference
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*$q, y=>$ylength-$refheight,
					 width=>$width_identity, height=>$refheight,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*$q-3, y=>$ylength-$refheight-5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'10',
					}
				)->cdata("$zrefpro"."%");
			}	
			if($q<$chromosomenumber2)
			 {
				 #query
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*$q, y=>$ylength-$queryheight,
					 width=>$width_identity, height=>$queryheight,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*$q-2, y=>$ylength-$queryheight-5,
					 style=>{
							 'stroke'=>'none',
							 'font-size'=>'10',
					}
				)->cdata("$zquerypro"."%");
			}	
		}
		 
		 #Illustration.1: synGenome heatmap   ###two genomes
		 for( my $num=0;$num<$chromosomenumber;$num++)
		 {				 
             #chromosome number 
			 #reference  chromosome number 
			 if( (length($outChrname1[-1])*9) < $width_heatmap )
			 {
				 $svg3->text(
					 x=>$marginx1_heatmap+$width_heatmap*$num+$width_heatmap/2-$fontsize*2,
					 y=>$marginy1_heatmap +$hightable_heatmap+$fontsize*2,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$num]");
                 if($num==0)
				 {
					 #reference chromosome name
					 $svg3->text(
						 x=>$marginx1_heatmap-length("$refname")*14-10,y=>$marginy1_heatmap+$hightable_heatmap+$fontsize*2,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>' 20',
						}
					)->cdata($refname);
				}
			}
			 else
			 {
				 my $goal_x=$marginx1_heatmap+$width_heatmap/2-$fontsize*2;
				 my $goal_y=$marginy1_heatmap +$hightable_heatmap+ $fontsize*2;
				 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
				 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
				 $svg3->text(
					 x=>$rotate_x+$width_heatmap*cos($radians)*$num,
					 y=>$rotate_y-$width_heatmap*sin($radians)*$num,
					 transform=>$rotate,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$num]");
                 if($num==0)
				 {
				     $marginy2_heatmap=(length($outChrname1[-1])*13)*sin($radians);
					 #reference chromosome name
					 $svg3->text(
						 x=>$marginx1_heatmap-length("$refname")*14-10,y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap/2,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>' 20',
						}
					)->cdata($refname);
				}			
			}
					
			 for(my $b=0;$b<$chromosomenumber2;$b++)
			 {
				 if($num==0)
				 {
					 #query number
					 $svg3->text(
						 x=>$marginx1_heatmap+$widthtable_heatmap+ $fontsize,y=>$marginy1_heatmap+$high_heatmap*$b+$high_heatmap/2+5,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname2[$b]");
	            }
				 my $numquerypro=0;
				 my $numrefpro=0;
				 open RefvsQuery,"$inputFile";						
				 while(<RefvsQuery>){
					 chomp;
					 my @tem = split /\t/;
					 
					 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$num] and $tem[12] eq $Chrname2[$b] )
					 {	
						 $numquerypro+=$tem[5]/$tem[8];
						 $numrefpro+=$tem[4]/$tem[7];
					} 							 
				}
				 close RefvsQuery; 
                 if($numrefpro<$numquerypro)
				 {
				     $numquerypro=$numrefpro;
				}
				 
				 $numquerypro=$numquerypro*100;
				 my $zquery2pro=sprintf("%.2f",$numquerypro);
				 if($zquery2pro==0)
				 {
				     for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							  x1=>$marginx1_heatmap+$width_heatmap*$num+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  x2=>$marginx1_heatmap+$width_heatmap*($num+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8,  
							}
						);
					}
					 $zquery2pro=0;
					 $svg3->text(
						 x=>$marginx1_heatmap+$width_heatmap/2-5+$width_heatmap*$num, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'12',
						}
					)->cdata("$zquery2pro");
							 
				}
				 else{
					 if($zquery2pro>100)
					 {
						 $zquery2pro=100;
					}
				     for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$width_heatmap*$num+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 x2=>$marginx1_heatmap+$width_heatmap*($num+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 style=>{
								 'stroke'=>'rgb(255,0,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*($zquery2pro*0.01),
							}
						);
						 $svg3->line(
							  x1=>$marginx1_heatmap+$width_heatmap*$num+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  x2=>$marginx1_heatmap+$width_heatmap*($num+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*(1-$zquery2pro*0.01),
							}
						);
						
					}
                     if(length("$zquery2pro"."%")==5)
                     {					 
						 $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$num+4, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery2pro"."%");   
					}
                     else
					 {
                         $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$num, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery2pro"."%");  					     
					}					
				}
			}
			 #Form to draw
			 if($num==0){
				 #The title 
				 $svg3->text(
					 x=>$marginx1_heatmap+$widthtable_heatmap/2.5,y=>$marginy1_heatmap-$fontsize-10-30,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_heatmap);
				 #query name
				 $svg3->text(
					 x=>$marginx1_heatmap+$widthtable_heatmap+$fontsize/2,y=>$marginy1_heatmap-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'20',
					}
				)->cdata($queryname);

				 for(my $i=0;$i<=$chromosomenumber;$i++)
				 {		
					 #Vertical line of Form
					 $svg3->line(
						 x1=>($marginx1_heatmap+$width_heatmap*$i),
						 y1=>$marginy1_heatmap-1,
						 x2=>($marginx1_heatmap+$width_heatmap*$i),
						 y2=>($marginy1_heatmap+$high_heatmap*$chromosomenumber2+1),
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'3',
							 'stroke-opacity'=>1,
						}
					);
				}
				 for(my $i=0;$i<=$chromosomenumber2;$i++)
				 {	
					 #Horizontal line of Form
					 $svg3->line(
						 x1=>$marginx1_heatmap-1,
						 y1=>($marginy1_heatmap+$high_heatmap*$i)-0.5,
						 x2=>($marginx1_heatmap+$width_heatmap*$chromosomenumber+1),
						 y2=>($marginy1_heatmap+$high_heatmap*$i)-0.5,
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'3',
							  'stroke-opacity'=>1,
						}
					);
				}	
			
				 #Heat map legend 
				 for(my $k=0;$k<=$hightable_heatmap;$k++)
				 {
					 $svg3->line(
						 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13,y1=>$marginy1_heatmap+$k,
						 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap/2,y2=>$marginy1_heatmap+$k,
						 style=>{
							 'stroke'=>'rgb(255,0,0)',   
							 'stroke-width'=>'2',
							 'stroke-opacity'=>(1-$k/$hightable_heatmap)*0.8,   
						}
					);
					 $svg3->line(
						 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13,y1=>$marginy1_heatmap+$k,
						 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap/2,y2=>$marginy1_heatmap+$k,
						 style=>{
							 'stroke'=>'rgb(255,255,0)',  
							 'stroke-width'=>'2',
							 'stroke-opacity'=>($k/$hightable_heatmap)*0.8,   
						}
					);
				}
				 #white line 
				 for(my $k=0;$k<=$hightable_heatmap;$k++)
				 {
					if(($k==4)or ($k==$hightable_heatmap/2)or($k==($hightable_heatmap-4))) 
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13-1,y1=>$marginy1_heatmap+$k,
							 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap/8,y2=>$marginy1_heatmap+$k,
							 style=>{
								 'stroke'=>'white',   
								 'stroke-width'=>'2.5',
								 'stroke-opacity'=>1,   
							}
						);
						 $svg3->line(
							 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap*3/8,y1=>$marginy1_heatmap+$k,
							 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap/2+1,y2=>$marginy1_heatmap+$k,
							 style=>{
								 'stroke'=>'white',   
								 'stroke-width'=>'2.5',
								 'stroke-opacity'=>1,   
							}
						);
						 my $heatmap_num;
						 if($k==4){$heatmap_num="100%";}
						 elsif($k==$hightable_heatmap/2){$heatmap_num="50%";}
						 elsif($k==($hightable_heatmap-4)){$heatmap_num="0";}
                         $svg3->text(
							 x=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*13+$width_heatmap/2+4, 
							 y=>$marginy1_heatmap+$k+7,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'20',
							}
						)->cdata("$heatmap_num");  						
					}	
				}				
			}
		}
		 #Illustration.3: synGenome coverage   ###two genomes
		 for( my $q=0;$q<$chromosomenumberMIN1;$q++)
		 {
             # chromosome name
			 if( (length($outChrname2[-1])*13) < $biginterval_coverage1 )
			 {
				 $svg5->text(
					 x=>$marginX_coverage+$smallinterval_coverage+$width_coverage+$biginterval_coverage1*$q-5,
					 y=>$marginY_coverage+$proportion_coverage*5+20,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname2[$q]");       
			}
			 else
			 {
				 my $goal_x=$marginX_coverage+$smallinterval_coverage+$width_coverage;
				 my $goal_y=$marginY_coverage+$proportion_coverage*5+20;
				 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
				 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
				 $svg5->text(
					 x=>$rotate_x+$biginterval_coverage1*cos($radians)*$q,
					 y=>$rotate_y-$biginterval_coverage1*sin($radians)*$q,
					 transform=>$rotate,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname2[$q]");	
			}
			
			 #Draw coordinate axes
			 if($q==0){
				 #The title 
				 $svg5->text(
					 x=>($xlength1+$proportion_coverage)/2.4,y=>$marginY_coverage-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_coverage);
				#The vertical line of Form
				 $svg5->line(
					 x1=>$marginX_coverage,y1=>$ylength1,
					 x2=>$marginX_coverage,y2=>$marginY_coverage,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				#The horizontal line of Form
				 $svg5->line(
					 x1=>$marginX_coverage,y1=>$ylength1,
					 x2=>$xlength1+$proportion_coverage,y2=>$ylength1,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 my $x1=$marginX_coverage-3;
				 my $x2=$marginX_coverage+3;
				 my $y1=$marginY_coverage;
				 my $y2=$marginY_coverage-3;
				 my $x3=$xlength1+$proportion_coverage;
				 my $x4=$x3+5;
				 my $y3=$ylength1-3;
				 my $y4=$ylength1+3;
				 my $y5=$ylength1;
				 #The Y axis direction
				 $svg5->polygon(
					 points=>"$x1,$y1 $x2,$y1 $marginX_coverage,$y2",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 #The X axis direction
				 $svg5->polygon(
					 points=>"$x3,$y3 $x3,$y4 $x4,$y5",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 #query color
				 $svg5->rect(
					 x=>$xlength1+$proportion_coverage-90, y=>$marginY_coverage,
					 width=>$width_coverage, height=>$width_coverage,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>"$query1_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);	 
				 #query name
				 $svg5->text(
					 x=>$xlength1+$proportion_coverage+$width_coverage-80,
					 y=>$marginY_coverage+15,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$queryname");
				 for(my $i=0; $i<$proportion_coverage*5; $i+=10){
					 if ($i%$proportion_coverage==0){
						 my $z=$i/4;
						 my $t="$z"."%";
						 #calibration of Y axis
						 $svg5->text(
							 x=>$marginX_coverage-30,y=>$ylength1-$i+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'10',
							}
						)->cdata($t);
						 #long calibration of Y axis
						 $svg5->line(
							 x1=>$marginX_coverage,y1=>$ylength1-$i,
							 x2=>$marginX_coverage+5,y2=>$ylength1-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
					 else
					 {
					     #short calibration of Y axis
						 $svg5->line(
							 x1=>$marginX_coverage,y1=>$ylength1-$i,
							 x2=>$marginX_coverage+2,y2=>$ylength1-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
				}
			}
			 open RefvsQuery,"$inputFile";
			 my $querypro=0;
			 my $count=0;
			 while(<RefvsQuery>){
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname2[$q] ){
					
					 ######$querypro+=$tem[6]*$tem[10];	
					 $querypro+=$tem[6];
					 $count++;
				} 
			}
			if($count != 0)
			 {
			     $querypro=$querypro/$count;
			}
			 close RefvsQuery; 
			 
			 my $zquerypro=sprintf("%.2f",$querypro);
			 
			 my $queryheight1=$querypro/100*$proportion_coverage*4;
			
			 ##print"$queryheight1\n";

			 #query
			 $svg5->rect(
				 x=>$marginX_coverage+$smallinterval_coverage+$width_coverage+$biginterval_coverage1*($q), y=>$ylength1-$queryheight1,
				 width=>$width_coverage, height=>$queryheight1,
				 style=>{
					 'fill'=>"$query1_color",
					 'stroke'=>'black',
					 'rx'=>'5',
					 'ry'=>'5',
					 'stroke-width'=>'1',
				}
			);
			 #query percentage
			 $svg5->text(
				 x=>$marginX_coverage+$smallinterval_coverage+$width_coverage+$biginterval_coverage1*($q)-2, y=>$ylength1-$queryheight1-5,
				 style=>{
					 'stroke'=>'none',
					 'font-size'=>'10',
				}
			)->cdata("$zquerypro"."%");

		}
		
	}

}

#three sequence alignment 
elsif( ($genomenumber==3) and (($aligntype==1)or($aligntype==3)) ) 
{

     my $marginx3_heatmap;
	 my @arr_q1q2;
	 @arr_q1q2=(length($outChrname2[$chromosomenumber2-1]),length($outChrname3[$chromosomenumber3-1]));
	 @arr_q1q2=sort{$a<=>$b}(@arr_q1q2);
	 $marginx3_heatmap=($arr_q1q2[-1])*9+9;
	 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
	 {
         if($a<$chromosomenumber){$chrLength = $chr_length{$Chrname1[$a]} / $proportion;}
         if($a<$chromosomenumber2){$chrLength2 = $chr_length2{$Chrname2[$a]} / $proportion;}
         if($a<$chromosomenumber3){$chrLength3 = $chr_length3{$Chrname3[$a]} / $proportion;} 
		 #Draw coordinate axes
		 if($a == 0){
			 my $t = 0;
			 for (my $i=0;$i<=$more_chrXX;$i+=$scaleXX)
			 {
				 my $i_pXX=$i/$proportion;
				 if(($i)%($valueSpan) ==0){
					 my $xbar = "$t"."$t_postfix";
					 $svg->text(
						 x=>$margin +$i_pXX, y=>$margin_Y -2,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'22',
						}
					)->cdata($xbar);
					 $t+=$scaleYY;
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y -5,
						 x2=>$i_pXX+$margin , y2=>$margin_Y,
						 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
						}
					);
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y,
						 x2=>$i_pXX+$margin , y2=>$margin_Y+$AlignmentHight+$margin_snp+11,###
						 style=>{
							 'stroke' => 'black',
							 'stroke-dasharray'=>'5,5',
							 'stroke-dasharray-width'=>'1',
						}
					);
				}
				 else
				 {
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y -3,
						 x2=>$i_pXX+$margin , y2=>$margin_Y,
						 style=>{
							 'stroke'=>'black',
							 'stroke-width'=>'1',
							}
					);	
					 $svg->line(
						 x1=>$i_pXX+$margin , y1=>$margin_Y,
						 x2=>$i_pXX+$margin , y2=>$margin_Y+$AlignmentHight+$margin_snp+11,###
						 style=>{
							 'stroke' => '#cccccc',
							 'stroke-dasharray'=>'5,5',
							 'stroke-dasharray-width'=>'1',
						}
					);
				}
			}
			 my $chrLengthXX_aa=$more_chrXX/$proportion;
			 $svg->line(
				 x1=>$margin , y1=>$margin_Y,
				 x2=>$chrLengthXX_aa+$margin , y2=>$margin_Y,
				 style=>{
					 'stroke'=>'black',
					 'stroke-width'=>'1',
				}
			);	
		}	

		##query1_snp
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {		
			if($snp_QUERY1)
			{
				 my $counta_snpa;
				 my @count_SNP;
				 if($SNP_Win_bp==1)
				 {
					 open FL_snp_query1,"$inputFile16";
					 while(<FL_snp_query1>)
					 {
						 chomp;	
						 my @tem = split /\t/;				
						 if( ($tem[0] eq $Chrname2[$a]) )
						 { 
							 if($pro_snpa==1){$SNP_Win_bp=abs($tem[2]-$tem[1]);$pro_snpa++;}
						}	
					}
				 close FL_snp_query1;	
				}
				 if(int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)==($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)){$counta_snpa=int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp);}
				 else{$counta_snpa=int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)+1;}			 			 		 
				 for(my $a_aasnp=0;$a_aasnp<$counta_snpa;$a_aasnp++)
				 {
					 push(@count_SNP,0);
				}
				 open FL_snp_query1,"$inputFile16";
				 while(<FL_snp_query1>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname2[$a]) )
					 { 
						 my $row_snps=int($tem[1]/$SNP_Win_bp);
						 $count_SNP[$row_snps]+=$tem[3]; 
					}	
				}
				 close FL_snp_query1;
				 for(my $a_snp=0;$a_snp<$counta_snpa;$a_snp++)
				 {
					 if($count_SNP[$a_snp]!=0)
					 {
						 if($count_SNP[$a_snp]>$SNP_threshold_value){$count_SNP[$a_snp]=$SNP_threshold_value;}
						 if($a_snp!=($counta_snpa-1))
						 {
							 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
							 $svg->rect(
								 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
								 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*3*$a,
								 width=>$SNP_Win_bp/$proportion, 
								 height=>$count_SNP[$a_snp]*$snp_pro,
								 style=>{
									 'fill'=>"$SNP_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
						 else
						 {
							 if(int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)==($chr_length2{$Chrname2[$a]}/$SNP_Win_bp))
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
									 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*3*$a,
									 width=>$SNP_Win_bp/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);						 
							}
							 else
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/($SNP_threshold_value*($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$SNP_Win_bp);
								 if($count_SNP[$a_snp]>1){$count_SNP[$a_snp]=1;}
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp ,
									 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)-0.7-$count_SNP[$a_snp]*$snp_pro+12*3*$a,
									 width=>($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);						     
							}
						}					 
					}
				}
			}
		}
		##query2_snp
		if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
		 {
			if($snp_QUERY2)
			{
				 my $counta_snpa;
				 my @count_SNP;			 
				 if($SNP_Win_bp==1)
				 {
					 open FL_snp_query2,"$inputFile166";
					 while(<FL_snp_query2>)
					 {
						 chomp;	
						 my @tem = split /\t/;				
						 if( ($tem[0] eq $Chrname3[$a]) )
						 { 
							 if($pro_snpa==1){$SNP_Win_bp=abs($tem[2]-$tem[1]);$pro_snpa++;}
						}	
					}
					 close FL_snp_query2;	
				}		 
				 if(int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)==($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)){$counta_snpa=int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp);}
				 else{$counta_snpa=int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)+1;}			 
				 for(my $a_aasnp=0;$a_aasnp<=$counta_snpa;$a_aasnp++)
				 {
					 push(@count_SNP,0);
				}
				 open FL_snp_query2,"$inputFile166";
				 while(<FL_snp_query2>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname3[$a]) )
					 { 
						 $counta_snpa=int($tem[1]/$SNP_Win_bp);
						 $count_SNP[$counta_snpa]+=$tem[3];
					}	
				}
				 close FL_snp_query2;
				 for(my $a_snp=0;$a_snp<$counta_snpa;$a_snp++)
				 {
					 if($count_SNP[$a_snp]!=0)
					 {
						 if($count_SNP[$a_snp]>$SNP_threshold_value){$count_SNP[$a_snp]=$SNP_threshold_value;}
						 if($a_snp!=($counta_snpa-1))
						 {
                                                         $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;					 
							 $svg->rect(
								 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
								 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24+0.7,
								 width=>$SNP_Win_bp/$proportion, 
								 height=>$count_SNP[$a_snp]*$snp_pro,
								 style=>{
									 'fill'=>"$SNP_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
						 else
						 {
							 if(int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)==($chr_length3{$Chrname3[$a]}/$SNP_Win_bp))
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/$SNP_threshold_value;
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
									 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24+0.7,
									 width=>$SNP_Win_bp/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);							 
							}
							 else
							 {
								 $count_SNP[$a_snp]=$count_SNP[$a_snp]/($SNP_threshold_value*($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$SNP_Win_bp);
								 if($count_SNP[$a_snp]>1){$count_SNP[$a_snp]=1;}
								 $svg->rect(
									 x=>$margin+$SNP_Win_bp/$proportion*$a_snp,
									 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24+0.7,
									 width=>($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$SNP_Win_bp)*$SNP_Win_bp)/$proportion, 
									 height=>$count_SNP[$a_snp]*$snp_pro,
									 style=>{
										 'fill'=>"$SNP_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);							 
							}
						}					 
					}							
				}	
			}
		} 

		##query1_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			if( $TE_QUERY1 and ($snp_TE==1) )
			{			 
				 my $counta_TEa;
				 my @count_TE;
				 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp)){$counta_TEa=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp);}
				 else{$counta_TEa=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)+1;}			 			 		 
				 for(my $a_aaTE=0;$a_aaTE<$counta_TEa;$a_aaTE++)
				 {
					 push(@count_TE,0);
				}
				 open FL_TE_query1,"$inputFile18";
				 while(<FL_TE_query1>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname2[$a]) )
					 { 
						 my $row_TEs=int($tem[1]/$TE_Win_bp);
						 $count_TE[$row_TEs]+=$tem[3]; 
					}	
				}
				 close FL_TE_query1;
				 for(my $a_TE=0;$a_TE<$counta_TEa;$a_TE++)
				 {
					 #if($count_TE[$a_TE]>$SNP_threshold_value){$count_TE[$a_TE]=$SNP_threshold_value;}
					 if($a_TE!=($counta_TEa-1))
					 {
						 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
						 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
						 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
						 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
						 if($count_TE[$a_TE]!=0)
						 {
							 $svg->rect(
								 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
								 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*3*$a,
								 width=>$TE_Win_bp/$proportion, 
								 height=>$count_TE[$a_TE]*$TE_pro,
								 style=>{
									 'fill'=>"$TE_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp))
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
									 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*3*$a,
									 width=>$TE_Win_bp/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
						 else
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE ,
									 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)-0.7-$count_TE[$a_TE]*$TE_pro+12*3*$a,
									 width=>($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp)/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
					}
				}
			}
		}
		##query2_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
		 {
			if( $TE_QUERY2 and ($snp_TE==1) )
			{
				 my $counta_TEa;
				 my @count_TE;
				 if(int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)==($chr_length3{$Chrname3[$a]}/$TE_Win_bp)){$counta_TEa=int($chr_length3{$Chrname3[$a]}/$TE_Win_bp);}
				 else{$counta_TEa=int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)+1;}				 		 
				 for(my $a_aaTE=0;$a_aaTE<=$counta_TEa;$a_aaTE++)
				 {
					 push(@count_TE,0);
				}
				 open FL_TE_query2,"$inputFile19";
				 while(<FL_TE_query2>){
					 chomp;	
					 my @tem = split /\t/;				
					 if( ($tem[0] eq $Chrname3[$a]) )
					 { 
						 $counta_TEa=int($tem[1]/$TE_Win_bp);
						 $count_TE[$counta_TEa]+=$tem[3];
					}	
				}
				 close FL_TE_query2;
				 for(my $a_TE=0;$a_TE<$counta_TEa;$a_TE++)
				 {
					 if($a_TE!=($counta_TEa-1))
					 {					 
						 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
						 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
						 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
						 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
						 if($count_TE[$a_TE]!=0)
						 {
							 $svg->rect(
								 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
								 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)+12*(3*$a+2)+24+0.7,
								 width=>$TE_Win_bp/$proportion, 
								 height=>$count_TE[$a_TE]*$TE_pro,
								 style=>{
									 'fill'=>"$TE_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
					 else
					 {
						 if(int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)==($chr_length3{$Chrname3[$a]}/$TE_Win_bp))
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/$TE_Win_bp;
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
									 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)+12*(3*$a+2)+24+0.7,
									 width=>$TE_Win_bp/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
						 else
						 {
							 $count_TE[$a_TE]=$count_TE[$a_TE]/($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($count_TE[$a_TE]>1){$count_TE[$a_TE]=1;}
							 $count_TE[$a_TE]=($count_TE[$a_TE]-$TE_tem3min)/(1-$TE_tem3min);
							 if($count_TE[$a_TE]<0){$count_TE[$a_TE]=0;}
							 if($count_TE[$a_TE]!=0)
							 {
								 $svg->rect(
									 x=>$margin+$TE_Win_bp/$proportion*$a_TE,
									 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_TE*($a+1)+12*(3*$a+2)+24+0.7,
									 width=>($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)*$TE_Win_bp)/$proportion, 
									 height=>$count_TE[$a_TE]*$TE_pro,
									 style=>{
										 'fill'=>"$TE_color",
										 'stroke'=>'black',
										 'stroke-width'=>'0',
									}
								);
							}
						}
					}			 								
				}	
			}		 
		}

         #draw synteny block
		 #reference vs query1
		 if($a<$chromosomenumber and $a<$chromosomenumber2)
		 {
			 open RefvsQuery1,"$inputFile";
			 while(<RefvsQuery1>){
				 chomp;
				 my @tem = split /\t/;
				 if($sort_query_pm{$Chrname2[$a]} eq '-'){$tem[2]=$chr_length2{$Chrname2[$a]}-$tem[2]+1;$tem[3]=$chr_length2{$Chrname2[$a]}-$tem[3]+1;}
				 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname2[$a] ){##$tem[4] >= 10000 and $tem[6] >= 90
					 my $x1 = $tem[2]/$proportion + $margin;
					 my $y1 = $margin_Y + 10 + 12 + 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
					 my $x2 = $tem[3]/$proportion + $margin;
					 my $y2 = $margin_Y + 10 + 12 + 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
					 my $x3 = $margin + $tem[0]/$proportion ;
					 my $y3 = $margin_Y + $AlignmentHight - 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
					 my $x4 = $margin + $tem[1]/$proportion;
					 my $y4 = $margin_Y + $AlignmentHight - 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
					 my $x24=$x2;
					 my $y24=($y2+$y4)/2;
					 my $x42=$x4;
					 my $y42=$y24;
					 my $x31=$x3;
					 my $y31=($y1+$y3)/2;
					 my $x13=$x1;
					 my $y13=($y1+$y3)/2;
					 if(!$curveto)
					 {
						 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
						 {
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>"$inversion_color",
									 'stroke-width'=>'0.1',
								}
							);
						}
                         else	
  						 {
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>"$synteny_color",
									 'stroke-width'=>'0.1',
								}
							);						     
						 }
					}
					 else
					 {
						 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
						 {
							 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
							 $svg->path(
								 d => $path,
								 fill=> "$inversion_color",
								 stroke=>"$inversion_color",
								 'stroke-width'=>'0.5',
							);
						}
                         else
                         {
							 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
							 $svg->path(
								 d => $path,
								 fill=> "$synteny_color",
								 stroke=>"$synteny_color",
								 'stroke-width'=>'0.5',
							);						     
						}						 
					}
				}
			}
			 close RefvsQuery1;
        }

		 #reference vs query2
		 if($a<$chromosomenumber and $a<$chromosomenumber3)
		 {
			 open RefvsQuery2,"$inputFile2";
			 while(<RefvsQuery2>){
				 chomp;
				 my @tem = split /\t/;
				 if($sort_query_pm_3geonme{$Chrname3[$a]} eq '-'){$tem[2]=$chr_length3{$Chrname3[$a]}-$tem[2]+1;$tem[3]=$chr_length3{$Chrname3[$a]}-$tem[3]+1;}
				 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname3[$a] ){
					 my $x1 = $tem[0]/$proportion + $margin;
					 my $y1 = $margin_Y + $AlignmentHight + 12 + 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
					 my $x2 = $tem[1]/$proportion + $margin;
					 my $y2 = $margin_Y + $AlignmentHight + 12 + 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
					 my $x3 = $margin + $tem[2]/$proportion ;
					 my $y3 = $margin_Y + $AlignmentHight*2-10 - 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
					 my $x4 = $margin + $tem[3]/$proportion;
					 my $y4 = $margin_Y + $AlignmentHight*2-10 - 1+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
					 my $x24=$x2;
					 my $y24=($y2+$y4)/2;
					 my $x42=$x4;
					 my $y42=$y24;
					 my $x31=$x3;
					 my $y31=($y1+$y3)/2;
					 my $x13=$x1;
					 my $y13=($y1+$y3)/2;					 
					 if(!$curveto)
					 {
						 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
						 {
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>"$inversion_color",
									 'stroke-width'=>'0.1',
								}
							);
						}
                         else	
  						 {
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>"$synteny_color",
									 'stroke-width'=>'0.1',
								}
							);						     
						 }
					}
					 else
					 {
						 if($highlightinversion and $tem[2]>$tem[3] and abs($tem[2]-$tem[3])>=$Inversion_limit)
						 {
							 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
							 $svg->path(
								 d => $path,
								 fill=> "$inversion_color",
								 stroke=>"$inversion_color",
								 'stroke-width'=>'0.5',
							);
						}
                         else
                         {
							 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
							 $svg->path(
								 d => $path,
								 fill=> "$synteny_color",
								 stroke=>"$synteny_color",
								 'stroke-width'=>'0.5',
							);						     
						}						 
					} 
				}
			}
			 close RefvsQuery2;
        }		

		 #Chromosome Name
		 ####draw genome		 
		 if($gene_density_REF or $gene_density_QUERY1 or $gene_density_QUERY2)
		 {
			 #query1 name
			if($a<$chromosomenumber2)
			 {
				 if($chromosomename==0)
				 {
					 $svg->text(
						 x=>15+$maxChrnum*27+10, 
						 y=>$margin_Y+20+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$queryname");				 
				 }
				 elsif($chromosomename==1)
				 {
					 $svg->text(
						 x=>15,
						 y=>$margin_Y+20+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$queryname");			      
					 $svg->text(
						 x=>15+$maxChrlong*27+10, 
						 y=>$margin_Y+20+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$outChrname2[$a]");	
				}
            }
			 #reference name
			 if($a<$chromosomenumber)
			 {
				  if($chromosomename==0)
				 {
					 $svg->text(
						 x=>15+$maxChrnum*27+10, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$refname");
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname1[$a]");
				 }
				 elsif($chromosomename==1)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$refname");
					 $svg->text(
						 x=>15+$maxChrlong*27+10, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname1[$a]");
				}
			}
		     #query2 name
			 if($a<$chromosomenumber3)
			 {
				 if($chromosomename==0)
				 {
					$svg->text(
						 x=>15+$maxChrnum*27+10, 
						 y=>$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$queryname2");			 
				 }
				 elsif($chromosomename==1)
				 {	
					$svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$queryname2");			     
					 $svg->text(
						 x=>15+$maxChrlong*27+10, 
						 y=>$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+18-3,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname3[$a]");
				}			 
			}
		}
		 else
		 {
			 if($chromosomename==0)
			 {
				 if($a<$chromosomenumber)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname1[$a]");
				 }
			}
			 elsif($chromosomename==1)
			 {
				 if($a<$chromosomenumber2)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+20+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}    
					)->cdata("$outChrname2[$a]");
				}
				if($a<$chromosomenumber)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname1[$a]");
				}
				 if($a<$chromosomenumber3)
				 {
					 $svg->text(
						 x=>15, 
						 y=>$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+18-3,
						 style=>{
							 'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'45',
						}
					)->cdata("$outChrname3[$a]");
				}
			}
		}

		 ##QUERY1_gene_density		
		 if($a<$chromosomenumber2)
		 {
			 if($gene_density_QUERY1)
			 {
				 if($a==0)
				 {
					 $svg->rect(
						 x=>$margin, 
						 y=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
						 width=>$chrLength2, height=>24,
						 style=>{
							 'fill'=>'white',
							 'stroke'=>'white',
							 'stroke-width'=>'1',
						}
					);
				}	
				 my $GD_count=0;			 
				 my @gene_density_count1;
				 my @gene_density_count2;
				 my @gene_density_count3;
				 my $gene_density_count_y=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
				 my $gene_density_num;
				 if( int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)==($chr_length2{$Chrname2[$a]}/$GD_Win_bp) ){$gene_density_num=int($chr_length2{$Chrname2[$a]}/$GD_Win_bp);}
				 else{$gene_density_num=int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)+1;}
				 for(my $a_agene_density=0;$a_agene_density<$gene_density_num;$a_agene_density++)
				 {
					 push(@gene_density_count3,0);
				}				 
				 open FL_query1_gene_density,"$inputFile27";
				 while(<FL_query1_gene_density>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if(length("@tem") != 0)
					 {
						 if( ( $tem[0] eq $Chrname2[$a] ) and ($tem[2] eq 'gene') )
						 {
							 push(@gene_density_count1,$tem[3]);
							 push(@gene_density_count2,$tem[4]);
							 $GD_count++;
						}
					}	
				}
				 close FL_query1_gene_density;

				 for(my $a_agene_density=0;$a_agene_density<$GD_count;$a_agene_density++)
				 {
					 my $count_gene1=int($gene_density_count1[$a_agene_density]/$GD_Win_bp);
					 if( ($gene_density_count2[$a_agene_density]<(($count_gene1+1)*$GD_Win_bp)) )
					 {
						 $gene_density_count3[$count_gene1]+=($gene_density_count2[$a_agene_density]-$gene_density_count1[$a_agene_density]+1);
					}
					 else
					 {
						 my $count_gene2=int($gene_density_count2[$a_agene_density]/$GD_Win_bp);
						 my $gene_length_num=$count_gene2-$count_gene1;
						 $gene_density_count3[$count_gene1]+=(($count_gene1+1)*$GD_Win_bp-$gene_density_count1[$a_agene_density]+1);
						 $gene_density_count3[$count_gene2]+=($gene_density_count2[$a_agene_density]-$count_gene2*$GD_Win_bp+1);
						 if($gene_length_num>1)
						 {
							 for(my $a_GDa=1;$a_GDa<$gene_length_num;$a_GDa++)
							 {
								 $gene_density_count3[$count_gene1+$a_GDa]+=$GD_Win_bp;
							}
						}	
					}
				} 		
				 for(my $a_gene_density=0;$a_gene_density<$gene_density_num;$a_gene_density++)
				 {
					 my $gene_density_count_x=$margin+$GD_Win_bp/$proportion*$a_gene_density;
					 if($a_gene_density!=($gene_density_num-1))
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/$GD_Win_bp;
					}
					else
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)*$GD_Win_bp);
					}
					 my $gene_opacity;					 				
					 if($gene_density_count3[$a_gene_density]<0.25){$gene_opacity=(0.1+0.1*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.5){$gene_opacity=(0.1+0.1+0.2*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.75){$gene_opacity=(0.1+0.3+0.3*$gene_density_count3[$a_gene_density]);}
					 else{$gene_opacity=(0.1+0.6+0.4*$gene_density_count3[$a_gene_density]);}		
					 if( $a_gene_density!=($gene_density_num-1) )
					 {					     
			             my $stroke_gene_w=$GD_Win_bp/$proportion;	
						 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
						 {						 
							 $svg->line(
								 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
								 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>"24",
									 'stroke-opacity'=>"$gene_opacity",   
								}
							);
                        }						 						 						
                    }
                     else
                     {
						 if( ($chr_length2{$Chrname2[$a]}/$GD_Win_bp)==int($chr_length2{$Chrname2[$a]}/$GD_Win_bp) )
						 {
							 my $stroke_gene_w=$GD_Win_bp/$proportion;	
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}					     
						 }
						 else
						 {
							 my $stroke_gene_w=($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GD_Win_bp)*$GD_Win_bp)/$proportion;
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}
						}	
					}				 
				}		 
				 #frame
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,y2=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+24,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,y2=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
					 x2=>$margin,y2=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,y1=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
					 x2=>$margin+$chr_length2{$Chrname2[$a]}/$proportion,y2=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);					
			}			
			 else
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
					 width=>$chrLength2, height=>24,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'10',
						 'ry'=>'10',
						 'stroke-width'=>'1',
					}
				);			 
			}	
        }	
		 ##reference_gene_density
		 if($a<$chromosomenumber)
		 {
			 if($gene_density_REF)
			 {				 
				 my $GD_count=0;			 
				 my @gene_density_count1;
				 my @gene_density_count2;
				 my @gene_density_count3;
				 my $gene_density_count_y=$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
				 my $gene_density_num;
				 if( int($chr_length{$Chrname1[$a]}/$GD_Win_bp)==($chr_length{$Chrname1[$a]}/$GD_Win_bp) ){$gene_density_num=int($chr_length{$Chrname1[$a]}/$GD_Win_bp);}
				 else{$gene_density_num=int($chr_length{$Chrname1[$a]}/$GD_Win_bp)+1;}
				 for(my $a_agene_density=0;$a_agene_density<$gene_density_num;$a_agene_density++)
				 {
					 push(@gene_density_count3,0);
				}				 
				 open FL_ref_gene_density,"$inputFile26";
				 while(<FL_ref_gene_density>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if(length("@tem") != 0)
					 {
						 if( ( $tem[0] eq $Chrname1[$a] ) and ($tem[2] eq 'gene') )
						 {
							 push(@gene_density_count1,$tem[3]);
							 push(@gene_density_count2,$tem[4]);
							 $GD_count++;
						}
					}	
				}
				 close FL_ref_gene_density;

				 for(my $a_agene_density=0;$a_agene_density<$GD_count;$a_agene_density++)
				 {
					 my $count_gene1=int($gene_density_count1[$a_agene_density]/$GD_Win_bp);
					 if( ($gene_density_count2[$a_agene_density]<(($count_gene1+1)*$GD_Win_bp)) )
					 {
						 $gene_density_count3[$count_gene1]+=($gene_density_count2[$a_agene_density]-$gene_density_count1[$a_agene_density]+1);
					}
					 else
					 {
						 my $count_gene2=int($gene_density_count2[$a_agene_density]/$GD_Win_bp);
						 my $gene_length_num=$count_gene2-$count_gene1;
						 $gene_density_count3[$count_gene1]+=(($count_gene1+1)*$GD_Win_bp-$gene_density_count1[$a_agene_density]+1);
						 $gene_density_count3[$count_gene2]+=($gene_density_count2[$a_agene_density]-$count_gene2*$GD_Win_bp+1);
						 if($gene_length_num>1)
						 {
							 for(my $a_GDa=1;$a_GDa<$gene_length_num;$a_GDa++)
							 {
								 $gene_density_count3[$count_gene1+$a_GDa]+=$GD_Win_bp;
							}
						}	
					}
				} 		
				 for(my $a_gene_density=0;$a_gene_density<$gene_density_num;$a_gene_density++)
				 {
					 my $gene_density_count_x=$margin+$GD_Win_bp/$proportion*$a_gene_density;
					 if($a_gene_density!=($gene_density_num-1))
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/$GD_Win_bp;
					}
					else
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GD_Win_bp)*$GD_Win_bp);
					}
					 my $gene_opacity;					 				
					 if($gene_density_count3[$a_gene_density]<0.25){$gene_opacity=(0.1+0.1*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.5){$gene_opacity=(0.1+0.1+0.2*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.75){$gene_opacity=(0.1+0.3+0.3*$gene_density_count3[$a_gene_density]);}
					 else{$gene_opacity=(0.1+0.6+0.4*$gene_density_count3[$a_gene_density]);}		
					 if( $a_gene_density!=($gene_density_num-1) )
					 {					     
			             my $stroke_gene_w=$GD_Win_bp/$proportion;	
						 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
						 {						 
							 $svg->line(
								 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
								 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>"24",
									 'stroke-opacity'=>"$gene_opacity",   
								}
							);
                        }						 						 						
                    }
                     else
                     {
						 if( ($chr_length{$Chrname1[$a]}/$GD_Win_bp)==int($chr_length{$Chrname1[$a]}/$GD_Win_bp) )
						 {
							 my $stroke_gene_w=$GD_Win_bp/$proportion;	
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}					     
						 }
						 else
						 {
							 my $stroke_gene_w=($chr_length{$Chrname1[$a]}-int($chr_length{$Chrname1[$a]}/$GD_Win_bp)*$GD_Win_bp)/$proportion;
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}
						}	
					}				 
				}				 
				 #frame
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+24,
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
					 x2=>$margin,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin+$chr_length{$Chrname1[$a]}/$proportion,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
					 x2=>$margin+$chr_length{$Chrname1[$a]}/$proportion,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);							
			}
			 else
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
					 width=>$chrLength, height=>24,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'10',
						 'ry'=>'10',
						 'stroke-width'=>'1',
					}
				);					 
			}	
        }			
		 
		 ##query2_gene_density
		 if($a<$chromosomenumber3)
		 {
			 if($gene_density_QUERY2)
			 {				 
				 my $GD_count=0;			 
				 my @gene_density_count1;
				 my @gene_density_count2;
				 my @gene_density_count3;
				 my $gene_density_count_y=$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
				 my $gene_density_num;
				 if( int($chr_length3{$Chrname3[$a]}/$GD_Win_bp)==($chr_length3{$Chrname3[$a]}/$GD_Win_bp) ){$gene_density_num=int($chr_length3{$Chrname3[$a]}/$GD_Win_bp);}
				 else{$gene_density_num=int($chr_length3{$Chrname3[$a]}/$GD_Win_bp)+1;}
				 for(my $a_agene_density=0;$a_agene_density<$gene_density_num;$a_agene_density++)
				 {
					 push(@gene_density_count3,0);
				}				 
				 open FL_query2_gene_density,"$inputFile28";
				 while(<FL_query2_gene_density>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if(length("@tem") != 0)
					 {
						 if( ( $tem[0] eq $Chrname3[$a] ) and ($tem[2] eq 'gene') )
						 {
							 push(@gene_density_count1,$tem[3]);
							 push(@gene_density_count2,$tem[4]);
							 $GD_count++;
						}
					}	
				}
				 close FL_query2_gene_density;

				 for(my $a_agene_density=0;$a_agene_density<$GD_count;$a_agene_density++)
				 {
					 my $count_gene1=int($gene_density_count1[$a_agene_density]/$GD_Win_bp);
					 if( ($gene_density_count2[$a_agene_density]<(($count_gene1+1)*$GD_Win_bp)) )
					 {
						 $gene_density_count3[$count_gene1]+=($gene_density_count2[$a_agene_density]-$gene_density_count1[$a_agene_density]+1);
					}
					 else
					 {
						 my $count_gene2=int($gene_density_count2[$a_agene_density]/$GD_Win_bp);
						 my $gene_length_num=$count_gene2-$count_gene1;
						 $gene_density_count3[$count_gene1]+=(($count_gene1+1)*$GD_Win_bp-$gene_density_count1[$a_agene_density]+1);
						 $gene_density_count3[$count_gene2]+=($gene_density_count2[$a_agene_density]-$count_gene2*$GD_Win_bp+1);
						 if($gene_length_num>1)
						 {
							 for(my $a_GDa=1;$a_GDa<$gene_length_num;$a_GDa++)
							 {
								 $gene_density_count3[$count_gene1+$a_GDa]+=$GD_Win_bp;
							}
						}	
					}
				} 		
				 for(my $a_gene_density=0;$a_gene_density<$gene_density_num;$a_gene_density++)
				 {
					 my $gene_density_count_x=$margin+$GD_Win_bp/$proportion*$a_gene_density;
					 if($a_gene_density!=($gene_density_num-1))
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/$GD_Win_bp;
					}
					else
					 {
					     $gene_density_count3[$a_gene_density]=$gene_density_count3[$a_gene_density]/($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$GD_Win_bp)*$GD_Win_bp);
					}
					 my $gene_opacity;					 				
					 if($gene_density_count3[$a_gene_density]<0.25){$gene_opacity=(0.1+0.1*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.5){$gene_opacity=(0.1+0.1+0.2*$gene_density_count3[$a_gene_density]);}
					 elsif($gene_density_count3[$a_gene_density]<0.75){$gene_opacity=(0.1+0.3+0.3*$gene_density_count3[$a_gene_density]);}
					 else{$gene_opacity=(0.1+0.6+0.4*$gene_density_count3[$a_gene_density]);}		
					 if( $a_gene_density!=($gene_density_num-1) )
					 {					     
			             my $stroke_gene_w=$GD_Win_bp/$proportion;	
						 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
						 {						 
							 $svg->line(
								 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
								 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>"24",
									 'stroke-opacity'=>"$gene_opacity",   
								}
							);
                        }						 						 						
                    }
                     else
                     {
						 if( ($chr_length3{$Chrname3[$a]}/$GD_Win_bp)==int($chr_length3{$Chrname3[$a]}/$GD_Win_bp) )
						 {
							 my $stroke_gene_w=$GD_Win_bp/$proportion;	
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}					     
						 }
						 else
						 {
							 my $stroke_gene_w=($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$GD_Win_bp)*$GD_Win_bp)/$proportion;
							 for(my $a_gene_a=0;$a_gene_a<2;$a_gene_a++)
							 {							 
								 $svg->line(
									 x1=>$gene_density_count_x,y1=>$gene_density_count_y+12,
									 x2=>$gene_density_count_x+$stroke_gene_w,y2=>$gene_density_count_y+12,
									 style=>{
										 'stroke'=>"$genedensity_color",
										 'stroke-width'=>"24",
										 'stroke-opacity'=>"$gene_opacity",   
									}
								);
							}
						}	
					}				 
				}				 
				 #frame
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
					 x2=>$margin+$chr_length3{$Chrname3[$a]}/$proportion,y2=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24,
					 x2=>$margin+$chr_length3{$Chrname3[$a]}/$proportion,y2=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin,y1=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
					 x2=>$margin,y2=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 $svg->line(
					 x1=>$margin+$chr_length3{$Chrname3[$a]}/$proportion,y1=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
					 x2=>$margin+$chr_length3{$Chrname3[$a]}/$proportion,y2=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)+24,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);		
			}
			 else
			 {
				 $svg->rect(
					 x=>$margin, 
					 y=>$margin_Y + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
					 width=>$chrLength3, height=>24,
					 style=>{
						 'fill'=>"$query2_color",
						 'stroke'=>'black',
						 'rx'=>'10',
						 'ry'=>'10',
						 'stroke-width'=>'1',
					}
				);			 
			}	
        }

		 #Draw Comment Area
		 ##centromere ˿
		if($a<$chromosomenumber)
		 {
			 if($refcentromere)
			 {
				 if($gene_density_REF)
				 {
					 open REF_centromere,"$inputFile7";
					 while(<REF_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname1[$a] ){						
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = 12+$margin_Y+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $x2 = $tem[1]/$proportion + $margin;
							 my $y2 = 24+0.6+$margin_Y+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $x3 = $tem[2]/$proportion + $margin;
							 my $y3 = 24+0.6+$margin_Y+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $y4 = $margin_Y-0.6+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'stroke'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'stroke'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)-0.05,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)-0.05+24,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)-0.05+24,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1)-0.05,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
						}	
					}
					 close REF_centromere;				
				}
				 else
				 {	 
					 #reference centromere ˿
					 open REF_centromere,"$inputFile7";
					 while(<REF_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname1[$a] ){
							 $svg->rect(
								 x=>$margin+$tem[1]/$proportion,
								 y=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
								 width=>($tem[2]-$tem[1])/$proportion, height=>24,
								 style=>{
									 'fill'=>"$centromere_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $x2 = $midx/$proportion + $margin-6;
							 my $y2 = $margin_Y+24+0.6+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $x3 = $midx/$proportion + $margin+6;
							 my $y3 = $margin_Y+24+0.6+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 my $y4 = $margin_Y-0.6+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
						}
					}
					 close REF_centromere;
				}	 
			}
		}
		if($a<$chromosomenumber2)
		 {
			 if($query1centromere)
			 {
				 if($gene_density_QUERY1)
				 {
					 open QUERY1_centromere,"$inputFile6";
					 while(<QUERY1_centromere>){
						 chomp;
						 my @tem = split /\t/;  
						 if( $tem[0] eq $Chrname2[$a] ){						
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $x2 = $tem[1]/$proportion + $margin;
							 my $y2 = $margin_Y+24+0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $x3 = $tem[2]/$proportion + $margin;
							 my $y3 = $margin_Y+24+0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $y4 = $margin_Y-0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y  + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.05,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y  + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.05+24,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y  + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.05+24,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y  + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.05,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
						}
					}
					 close QUERY1_centromere;
				}
				 else
				 {
					 #query1 centromere ˿
					 open QUERY1_centromere,"$inputFile6";
					 while(<QUERY1_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname2[$a] ){
							 $svg->rect(
								 x=>$margin+$tem[1]/$proportion,
								 y=>$margin_Y+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
								 width=>($tem[2]-$tem[1])/$proportion, height=>24,
								 style=>{
									 'fill'=>"$centromere_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $x2 = $midx/$proportion+$margin-6;
							 my $y2 = $margin_Y+24+0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $x3 = $midx/$proportion +$margin+6;
							 my $y3 = $margin_Y+24+0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 my $y4 = $margin_Y-0.6+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
						}
					}
					 close QUERY1_centromere;
				}	 
			}
		}
		if($a<$chromosomenumber3)
		 {
			if($query2centromere)
			 {
				 if($gene_density_QUERY2)
				 {
					 open QUERY2_centromere,"$inputFile66";
					 while(<QUERY2_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname3[$a] ){						
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y+12+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $x2 = $tem[1]/$proportion + $margin;
							 my $y2 = $margin_Y+24+0.6+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $x3 = $tem[2]/$proportion + $margin;
							 my $y3 = $margin_Y+24+0.6+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $y4 = $margin_Y-0.6+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)-0.05,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)-0.05+24,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
							 $svg->line(
								 x1=>$margin+$tem[1]/$proportion,y1=>$margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)-0.05+24,
								 x2=>$margin+$tem[2]/$proportion,y2=>$margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2)-0.05,
								 style=>{
									 'stroke'=>'black',
									 'stroke-width'=>'1',
								}
							);
						}
					}
					 close QUERY2_centromere;				
				 }
				 else
				 {			 
					 #query2 centromere ˿
					 open QUERY2_centromere,"$inputFile66";
					 while(<QUERY2_centromere>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[0] eq $Chrname3[$a] ){
							 $svg->rect(
								 x=>$margin+$tem[1]/$proportion, 
								 y=>$margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
								 width=>($tem[2]-$tem[1])/$proportion, height=>24,
								 style=>{
									 'fill'=>"$centromere_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
							 my $midx=($tem[1]+$tem[2])/2;
							 my $x1 = $midx/$proportion + $margin;
							 my $y1 = $margin_Y +12+ $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $x2 = $midx/$proportion + $margin-6;
							 my $y2 = $margin_Y  +24+0.6 +$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $x3 = $midx/$proportion + $margin+6;
							 my $y3 = $margin_Y  +24+0.6 + $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 my $y4 = $margin_Y  -0.6+ $AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
							 $svg->polygon(
								 points=>"$x1,$y1 $x2,$y4  $x3,$y4",
								 style=>{
									 'fill'=>'#FFFFFF',
									 'opacity'=>'1',
									 'stroke-width'=>'0.1',
									 'stroke'=>'#FFFFFF'
								}
							);
						}
					}
					 close QUERY2_centromere;
				}
			}	
        }
		 ##reference telomere 
		if($a<$chromosomenumber)
		 {
			 if($reftelomere)
			 {
				 #reference telomere 
				 open REF_telomere,"$inputFile9";
				 while(<REF_telomere>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] )
					 {
						 my $x1;
						 my $y1;
						 my $x2;
						 my $y2;
						 my $x3;
						 my $y3;
						 if($tem[1]==1)
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $x2 = ($tem[1])/$proportion + $margin-12;
							 $y2 = $margin_Y-12+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $x3 = $tem[1]/$proportion + $margin-12;
							 $y3 = $margin_Y+12+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
						}
						 else
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $x2 = ($tem[1])/$proportion + $margin+12;
							 $y2 = $margin_Y-12+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
							 $x3 = $tem[1]/$proportion + $margin+12;
							 $y3 = $margin_Y+12+$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2);
						}					 
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
					}
				 }
				 close REF_telomere;
			}
		}
		if($a<$chromosomenumber2)
		 {
			 if($query1telomere)
			 {
				 #query1 telomere
				 open QUERY1_telomere,"$inputFile8";
				 while(<QUERY1_telomere>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] )
					 {
						 my $x1;
						 my $y1;
						 my $x2;
						 my $y2;
						 my $x3;
						 my $y3;				     
						 if($tem[1]==1)
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+12+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $x2 = ($tem[1])/$proportion + $margin-12;
							 $y2 = $margin_Y+12+10-12+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $x3 = $tem[1]/$proportion + $margin-12;
							 $y3 = $margin_Y+12+10+12+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
						}
						 else
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+12+10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $x2 = ($tem[1])/$proportion + $margin+12;
							 $y2 = $margin_Y+12+10-12+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;
							 $x3 = $tem[1]/$proportion + $margin+12;
							 $y3 = $margin_Y+12+10+12+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a;					     
						}
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
					}
				}
				 close QUERY1_telomere;
			}
		}
		if($a<$chromosomenumber3)
		 {
			 if($query2telomere)
			 {
				 #query2 telomere
				 open QUERY2_telomere,"$inputFile88";
				 while(<QUERY2_telomere>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname3[$a] )
					 {
						 my $x1;
						 my $y1;
						 my $x2;
						 my $y2;
						 my $x3;
						 my $y3;
						 if($tem[1]==1)
						 {					 	 
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
							 $x2 = ($tem[1])/$proportion + $margin-12;
							 $y2 = $margin_Y -12+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
							 $x3 = $tem[1]/$proportion + $margin-12;
							 $y3 = $margin_Y +12+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
						}
						 else
						 {
							 $x1 = $tem[1]/$proportion + $margin;
							 $y1 = $margin_Y+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
							 $x2 = ($tem[1])/$proportion + $margin+12;
							 $y2 = $margin_Y -12+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
							 $x3 = $tem[1]/$proportion + $margin+12;
							 $y3 = $margin_Y +12+$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*($a+1);
												 
						} 
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
					}
				}
				close QUERY2_telomere;
			}
		}
          ##query1_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if( $TE_QUERY1 and ($snp_TE==0) )
			 {
				 my @TE_count;
				 my @TE_count_x;
				 my @TE_count_y;
				 my $TE_num;
				 if( int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp) ){$TE_num=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp);}
				 else{$TE_num=int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)+1;}			 
				 for(my $a_aTE=0;$a_aTE<$TE_num;$a_aTE++)
				 {
					 push(@TE_count_x,0);
					 push(@TE_count_y,0);
					 push(@TE_count,0);				 
				}
				 open FL_query_TE,"$inputFile18";
				 while(<FL_query_TE>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname2[$a])
					 {
					 my $row_TE=int($tem[1]/$TE_Win_bp);
					 $TE_count[$row_TE]+=$tem[3];
					}
				}
				 close FL_query_TE;
				 for(my $a_TE=0;$a_TE<$TE_num;$a_TE++)
				 {
					 if($a_TE!=($TE_num-1))
					 {
						 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
						 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}
						 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
						 $TE_count_y[$a_TE]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$TE_count[$a_TE]*$te_pro;	
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)==($chr_length2{$Chrname2[$a]}/$TE_Win_bp))
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
							 $TE_count_y[$a_TE]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$TE_count[$a_TE]*$te_pro;						     
						}
						 else
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}						 
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$TE_Win_bp)*$TE_Win_bp)/($proportion*2);
							 $TE_count_y[$a_TE]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$TE_count[$a_TE]*$te_pro;						 
						}
					} 
					if($a_TE!=0)
					 {	
						 $svg->polygon(
							 points=>"$TE_count_x[$a_TE-1],$TE_count_y[$a_TE-1] $TE_count_x[$a_TE],$TE_count_y[$a_TE]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
          ##query2_TE
		 if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
		 {
			 if( $TE_QUERY2 and ($snp_TE==0) )
			 {
				 my @TE_count;
				 my @TE_count_x;
				 my @TE_count_y;
				 my $TE_num;
				 if( int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)==($chr_length3{$Chrname3[$a]}/$TE_Win_bp) ){$TE_num=int($chr_length3{$Chrname3[$a]}/$TE_Win_bp);}
				 else{$TE_num=int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)+1;}			 
				 for(my $a_aTE=0;$a_aTE<$TE_num;$a_aTE++)
				 {
					 push(@TE_count_x,0);
					 push(@TE_count_y,0);
					 push(@TE_count,0);				 
				}
				 open FL_query2_TE,"$inputFile19";
				 while(<FL_query2_TE>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname3[$a])
					 {
					 my $row_TE=int($tem[1]/$TE_Win_bp);
					 $TE_count[$row_TE]+=$tem[3];
					}
				}
				 close FL_query2_TE;
				 for(my $a_TE=0;$a_TE<$TE_num;$a_TE++)
				 {
					 if($a_TE!=($TE_num-1))
					 {
						 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
						 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}
						 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
						 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$TE_count[$a_TE]*$te_pro;
					}
					 else
					 {
						 if(int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)==($chr_length3{$Chrname3[$a]}/$TE_Win_bp))
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/$TE_Win_bp;
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+$TE_Win_bp*0.5/$proportion;
							 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$TE_count[$a_TE]*$te_pro;
						}
						 else
						 {
							 $TE_count[$a_TE]=$TE_count[$a_TE]/($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)*$TE_Win_bp);
							 if($TE_count[$a_TE]>1){$TE_count[$a_TE]=1;}
							 $TE_count_x[$a_TE]=$margin+$TE_Win_bp/$proportion*$a_TE+($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$TE_Win_bp)*$TE_Win_bp)/($proportion*2);
							 $TE_count_y[$a_TE]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$TE_count[$a_TE]*$te_pro;
						}
					} 
					if($a_TE!=0)
					 {	
						 $svg->polygon(
							 points=>"$TE_count_x[$a_TE-1],$TE_count_y[$a_TE-1] $TE_count_x[$a_TE],$TE_count_y[$a_TE]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
         ##query1_GC
		if($a<$chromosomenumber2)
		 {
			 if( $GC_QUERY1 and ($GC_content==1) )
			 {
				 my @GC_count;
				 my @GC_count_x;
				 my @GC_count_y;
				 my $GC_num;
				 if($GC_Win_bp==1)
				 {
					 open FL_query1_GC,"$inputFile30";
					 while(<FL_query1_GC>)
					 {
						 chomp;	
						 my @tem = split /\t/;
						 if($tem[0] eq $Chrname2[$a])
						 {
							 if($pro_GCa==1){$GC_Win_bp=abs($tem[2]-$tem[1]);$pro_GCa++;}	
						}
					}
					 close FL_query1_GC;
				}
				 if( int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)==($chr_length2{$Chrname2[$a]}/$GC_Win_bp) ){$GC_num=int($chr_length2{$Chrname2[$a]}/$GC_Win_bp);}
				 else{$GC_num=int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)+1;}			 
				 for(my $a_aGC=0;$a_aGC<$GC_num;$a_aGC++)
				 {
					 push(@GC_count_x,0);
					 push(@GC_count_y,0);
					 push(@GC_count,0);				 
				}
				 open FL_query1_GC,"$inputFile30";
				 while(<FL_query1_GC>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname2[$a])
					 {
					 my $row_GC=int($tem[1]/$GC_Win_bp);
					 $GC_count[$row_GC]+=$tem[3];
					}
				}
				 close FL_query1_GC;
				 for(my $a_GC=0;$a_GC<$GC_num;$a_GC++)
				 {
					 if($a_GC!=($GC_num-1))
					 {
						 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
						 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
						 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
						 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;				 
						 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
						 $GC_count_y[$a_GC]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;	
					}
					 else
					 {
						 if(int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)==($chr_length2{$Chrname2[$a]}/$GC_Win_bp))
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
							 $GC_count_y[$a_GC]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;						     
						}
						 else
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)*$GC_Win_bp);
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+($chr_length2{$Chrname2[$a]}-int($chr_length2{$Chrname2[$a]}/$GC_Win_bp)*$GC_Win_bp)/($proportion*2);
							 $GC_count_y[$a_GC]=$margin_Y+ 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a-0.6-$GC_count[$a_GC]*$GC_pro-20;						 
						}
					} 
					if($a_GC!=0)
					 {	
						 $svg->polygon(
							 points=>"$GC_count_x[$a_GC-1],$GC_count_y[$a_GC-1] $GC_count_x[$a_GC],$GC_count_y[$a_GC]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }
          ##query2_GC
		if($a<$chromosomenumber3)
		 {
			 if( $GC_QUERY2 and ($GC_content==1) )
			 {
				 my @GC_count;
				 my @GC_count_x;
				 my @GC_count_y;
				 my $GC_num;
				 if($GC_Win_bp==1)
				 {
					 open FL_query2_GC,"$inputFile31";
					 while(<FL_query2_GC>)
					 {
						 chomp;	
						 my @tem = split /\t/;
						 if($tem[0] eq $Chrname3[$a])
						 {
							 if($pro_GCa==1){$GC_Win_bp=abs($tem[2]-$tem[1]);$pro_GCa++;}	
						}
					}
					 close FL_query2_GC;
				}
				 if( int($chr_length3{$Chrname3[$a]}/$GC_Win_bp)==($chr_length3{$Chrname3[$a]}/$GC_Win_bp) ){$GC_num=int($chr_length3{$Chrname3[$a]}/$GC_Win_bp);}
				 else{$GC_num=int($chr_length3{$Chrname3[$a]}/$GC_Win_bp)+1;}			 
				 for(my $a_aGC=0;$a_aGC<$GC_num;$a_aGC++)
				 {
					 push(@GC_count_x,0);
					 push(@GC_count_y,0);
					 push(@GC_count,0);				 
				}
				 open FL_query2_GC,"$inputFile31";
				 while(<FL_query2_GC>)
				 {
					 chomp;	
					 my @tem = split /\t/;
					 if($tem[0] eq $Chrname3[$a])
					 {
					 my $row_GC=int($tem[1]/$GC_Win_bp);
					 $GC_count[$row_GC]+=$tem[3];
					}
				}
				 close FL_query2_GC;
				 for(my $a_GC=0;$a_GC<$GC_num;$a_GC++)
				 {
					 if($a_GC!=($GC_num-1))
					 {
						 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
						 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
						 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
						 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
						 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
						 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$GC_count[$a_GC]*$GC_pro+20;
					}
					 else
					 {
						 if(int($chr_length3{$Chrname3[$a]}/$GC_Win_bp)==($chr_length3{$Chrname3[$a]}/$GC_Win_bp))
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/$GC_Win_bp;
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+$GC_Win_bp/(2*$proportion);
							 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$GC_count[$a_GC]*$GC_pro+20;
						}
						 else
						 {
							 $GC_count[$a_GC]=$GC_count[$a_GC]/($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$GC_Win_bp)*$GC_Win_bp);
							 if($GC_count[$a_GC]>0.5){$GC_count[$a_GC]=0.5;}
							 if($GC_count[$a_GC]<0.4){$GC_count[$a_GC]=0.4;}
							 $GC_count[$a_GC]=($GC_count[$a_GC]-0.4)*10;
							 $GC_count_x[$a_GC]=$margin+$GC_Win_bp/$proportion*$a_GC+($chr_length3{$Chrname3[$a]}-int($chr_length3{$Chrname3[$a]}/$GC_Win_bp)*$GC_Win_bp)/($proportion*2);
							 $GC_count_y[$a_GC]=$margin_Y+$AlignmentHight*2+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+0.6+2+12*3*($a+1)+$GC_count[$a_GC]*$GC_pro+20;
						}
					} 
					if($a_GC!=0)
					 {	
						 $svg->polygon(
							 points=>"$GC_count_x[$a_GC-1],$GC_count_y[$a_GC-1] $GC_count_x[$a_GC],$GC_count_y[$a_GC]",
							 style=>{
									'stroke'=>"black",
									'stroke-width'=>'0.5',
							}
						);				
					}	
				}	
			}
        }		
		 ##targetgene
		if($a<$chromosomenumber)
		 {
			 if($reftargetgene)
			 {
				 #reference targetgene
				 open REF_targetgene,"$inputFile13";
				 while(<REF_targetgene>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] ){
						 my $targetgene_start=$tem[1];
						 if($tem[1]>$tem[2]){$targetgene_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$targetgene_start/$proportion, 
								 y=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$targetgene_color",
									 'stroke'=>'black',
									 #'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_targetgene;
			}
		}
		if($a<$chromosomenumber2)
		 {
			if($query1targetgene)
			 {
				 #query1 targetgene
				 open QUERY1_targetgene,"$inputFile12";
				 while(<QUERY1_targetgene>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] ){
						 my $targetgene_start=$tem[1];
						 if($tem[1]>$tem[2]){$targetgene_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$targetgene_start/$proportion, 
								 y=>$margin_Y + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$targetgene_color",
									 'stroke'=>'black',
									 # 'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				 close QUERY1_targetgene;
			}
		}
		if($a<$chromosomenumber3)
		 {
			 if($query2targetgene)
			 {
				 #query2 targetgene
				 open QUERY2_targetgene,"$inputFile14";
				 while(<QUERY2_targetgene>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname3[$a] ){
						 my $targetgene_start=$tem[1];
						 if($tem[1]>$tem[2]){$targetgene_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$targetgene_start/$proportion, 
								 y=>$margin_Y +$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$targetgene_color",
									 'stroke'=>'black',
									 # 'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				close QUERY2_targetgene;
			}
		}
		
		 ##PAV
		 if($a<$chromosomenumber)
		 {
			 if($PAV_REF)
			 {
				 #reference PAV
				 open REF_PAV,"$inputFile20";
				 while(<REF_PAV>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] and abs($tem[2]-$tem[1])>$PAV_limit ){
						 my $PAV_start=$tem[1];
						 if($tem[1]>$tem[2]){$PAV_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$PAV_start/$proportion, 
								 y=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$PAV_color",
									 'stroke'=>'black',
									 #'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_PAV;
			}
		}
         if(($a<$chromosomenumber) and ($a<$chromosomenumber2))
		 {
			 if($PAV_QUERY1)
			 {
				 #query1 PAV
				 open QUERY1_PAV,"$inputFile21";
				 while(<QUERY1_PAV>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] and abs($tem[2]-$tem[1])>$PAV_limit ){
						 my $PAV_start=$tem[1];
						 if($tem[1]>$tem[2]){$PAV_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$PAV_start/$proportion, 
								 y=>$margin_Y + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$PAV_color",
									 'stroke'=>'black',
									 # 'opacity'=>'0.5',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				 close QUERY1_PAV;
			}
		}
		if(($a<$chromosomenumber) and ($a<$chromosomenumber3))
		 {
			 if($PAV_QUERY2)
			 {
				 #query2 PAV
				 open QUERY2_PAV,"$inputFile22";
				 while(<QUERY2_PAV>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname3[$a] and abs($tem[2]-$tem[1])>$PAV_limit ){
						 my $PAV_start=$tem[1];
						 if($tem[1]>$tem[2]){$PAV_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$PAV_start/$proportion,
								 y=>$margin_Y +$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$PAV_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				close QUERY2_PAV;
			}
		}
		 ##NLR
		if($a<$chromosomenumber)
		 {
			 if($NLR_REF)
			 {
				 #reference NLR
				 open REF_NLR,"$inputFile23";
				 while(<REF_NLR>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname1[$a] and abs($tem[2]-$tem[1])>$NLR_limit ){
						 my $NLR_start=$tem[1];
						 if($tem[1]>$tem[2]){$NLR_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$NLR_start/$proportion,
								 y=>$margin_Y +$AlignmentHight+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+1),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
			  
									 'fill'=>"$NLR_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}
					}
				}
				 close REF_NLR;
			}
		}
		if($a<$chromosomenumber2)
		 {
			 if($NLR_QUERY1)
			 {
				 #query1 NLR
				 open QUERY1_NLR,"$inputFile24";
				 while(<QUERY1_NLR>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname2[$a] and abs($tem[2]-$tem[1])>$NLR_limit ){
						 my $NLR_start=$tem[1];
						 if($tem[1]>$tem[2]){$NLR_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$NLR_start/$proportion,
								 y=>$margin_Y + 10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*3*$a,
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$NLR_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				 close QUERY1_NLR;
			}
		}
		if($a<$chromosomenumber3)
		 {
			 if($NLR_QUERY2)
			 {
				 #query2 NLR
				 open QUERY2_NLR,"$inputFile25";
				 while(<QUERY2_NLR>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[0] eq $Chrname3[$a] and abs($tem[2]-$tem[1])>$NLR_limit ){
						 my $NLR_start=$tem[1];
						 if($tem[1]>$tem[2]){$NLR_start=$tem[2];}
						 if((abs($tem[2]-$tem[1])/$proportion)>0)
						 {					 
							 $svg->rect(
								 x=>$margin+$NLR_start/$proportion,
								 y=>$margin_Y +$AlignmentHight*2-10+($ChrHight+$AlignmentHight-10)*$a+$margin_snp*($a+1)+12*(3*$a+2),
								 width=>abs($tem[2]-$tem[1])/$proportion, height=>20,
								 style=>{
							  
									 'fill'=>"$NLR_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);
						}	
					}
				}
				close QUERY2_NLR;
			}
		}
         if($a == 0)
		 {    
			 if($icon==1)
			 {
				 if( ($chromosomenumberMAX3-$icon_chrnum)>=0 )
				 {					 
					 if($gene_density_REF or $gene_density_QUERY1 or $gene_density_QUERY2)
					 {	
						 #heat map legend
						 my $icon_high_h=$AlignmentHight*5+$margin_snp+60;
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 						 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+($k/($icon_high_h/4))*0.1),   
								}
							);											
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 						
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.1+($k/($icon_high_h/4))*0.2),   
								}
							);												
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 						 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/2)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/2)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.3+($k/($icon_high_h/4))*0.3),   
								}
							);	
						}
						 for(my $k=0;$k<=($icon_high_h/4);$k++)
						 {					 						 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h*3/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h*3/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.6+($k/($icon_high_h/4))*0.4),   
								}
							);
						}				
						##white line
						 for(my $k=0;$k<=$icon_high_h;$k++)
						 {

							 if( $k==int($icon_high_h/2) ) 
							 {
								 my $icon_line="black";
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$k,
									 x2=>$icon_x+int($GDheatmap_wide/4),y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide-int($GDheatmap_wide/4),y1=>$icon_y-$k,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",  
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
							}	
							 if( ($k==0) or ($k==int($icon_high_h/2)) or ($k==$icon_high_h) ) 
							 {
								 my $iconheatmap_num;
								 if($k==0){$iconheatmap_num="0";}
								 elsif($k==int($icon_high_h/2)){$iconheatmap_num="50%";}
								 elsif($k==$icon_high_h){$iconheatmap_num="100%";}
								 $svg->text(
									 x=>$icon_x+$GDheatmap_wide+4, 
									 y=>$icon_y-$k+10,
									 style=>{
									     'font-family'=>"Courier",#
										 'stroke'=>'none',
										 'font-size'=>'25',
									}
								)->cdata("$iconheatmap_num"); 
							}						
						}
						 {
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$icon_high_h,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);						
						}
						 my $GD_bp_S=$GD_Win_bp/1000;
						 my $GD_bp_name="("."$GD_bp_S"."Kb)";
						 my $ca_wide=($GDheatmap_wide-length($GD_bp_name)*15)/2;
						 $svg->text(
							 x=>$icon_x+$ca_wide, #-8
							 y=>$icon_y+37,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25',
							}
						)->cdata($GD_bp_name);							 
						$icon_y=$icon_y-$icon_high_h-$GD_high_move/2;
						 my $tujie_name='Gene Density';
						 $svg->text(
							 x=>$icon_x-15, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
					
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move*1.5;
					}
					 if( ($GC_QUERY1 or $GC_QUERY2) and ($GC_content==1) )
					 {   
						 #GC_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15-8;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro+20;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+8+8+2,
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("50%");									
						$svg->text(
							 x=>$TE_X3-75+8+8+2, #-18
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("40%");	
						
						 {	
							 my $tujie_name='GC Content';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $GC_bp_S=$GC_Win_bp/1000;
							 my $GC_bp_name="("."$GC_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+190+25, 
								 y=>$icon_y-$GDtext_move_y-3+3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($GC_bp_name);								
						}
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;				
					}
					
					 if( ($TE_QUERY1 or $TE_QUERY2) and ($snp_TE==0) )
					 {   
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+9, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("100%");								
						$svg->text(
							 x=>$TE_X3-18, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("0");	
						
						 {	
							my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;				
					}

					if($snp_QUERY1 or $snp_QUERY2)
					 {
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$SNP_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$SNP_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-$snp_heatmap_max-4, #-5
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("$SNP_threshold_value");									
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-13-4, #-2-2
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("0");							
							 my $tujie_name='SNP';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $SNP_bp_S=$SNP_Win_bp/1000;
							 my $SNP_bp_name="("."$SNP_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50+25, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($SNP_bp_name);								
						}	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;
					}
					if( ($TE_REF or $TE_QUERY1 or $TE_QUERY2) and ($snp_TE==1) )
					 {
						 my $snp_x1=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$TE_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$TE_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-$snp_heatmap_max-4-17+9, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("100%");
							 my $TE_xiaaa=$TE_tem3min*100;
							 my $TE_xiabb="$TE_xiaaa".'%';
							 if($TE_tem3min==0){$TE_xiabb='0';}
							 my $TE_xialeng=(length($TE_xiabb)-1)*18;
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-13-4-$TE_xialeng, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("$TE_xiabb");						
							 my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);
						}	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move-10;
					}					
					
					 if($reftelomere or $query1telomere or $query2telomere)
					 {
						 #reference legend 
						 my $x1 = $icon_x+24;
						 my $y1 = $icon_y-24;
						 my $x2 = $x1-24;
						 my $y2 = $y1-24;
						 my $x3 = $x1-24;
						 my $y3 = $y1+24;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='Telomere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}
					
					 if( $NLR_REF or $NLR_QUERY1 or $NLR_QUERY2 )
					 {
						 #NLR_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$NLR_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='NLR';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if($PAV_REF or $PAV_QUERY1 or $PAV_QUERY2)
					 {
						 #PAV_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$PAV_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='PAV';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
					 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if( $icon_centromere and ($refcentromere or $query1centromere or $query2centromere ) )
					 {
						 #centromere legend ˿
						 
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$centromere_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 my $x1 = $icon_x+$GDheatmap_wide/2;
						 my $y1 = $icon_y-$GDheatmap_high/2;
						 my $x2 = $x1-12;
						 my $y2 = $y1-$GDheatmap_high/2-1;
						 my $x3 = $x1+12;
						 my $y3 = $y1-$GDheatmap_high/2-1;
						 my $y4 = $y1+$GDheatmap_high/2+1;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2 $x3,$y3",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'0.1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y4 $x3,$y4",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 my $tujie_name='Centromere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}

					 if($reftargetgene or $query1targetgene or $query2targetgene)
					 {
						 #targetgene_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$targetgene_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($targetgene_name);				 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
					}
					 
					 {
						##synteny bolck legend 
						 if($inversion_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Inversion';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
						}
						 if($synteny_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Synteny';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;
						}
					}
				
					 if($gene_density_QUERY2!=1)
					 {
						 #icon_query2
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query2_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname2");				
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;	
					}
					 if($gene_density_REF!=1)
					 {
						 #icon_reference
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$reference_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$refname");	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;			 
					}
					 if($gene_density_QUERY1!=1)
					 {
						 #icon_query1
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query1_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname");	
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;			 
					}				
					 {
						 my $tujie_name='Type';
						 $svg->text(
							 x=>$icon_x-5, 
							 y=>$icon_y-$GDtext_move_y+$GD_high_move/2-10,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);	 
						 $icon_y=$icon_y-$GDheatmap_high-$GD_high_move;	
					}
				}
				 else
				 {				 
					 my $aa_x=0;
					 my $aa_y=0;
					 my $icon_high_h=$AlignmentHight*5+$margin_snp+60;
					 if($gene_density_REF or $gene_density_QUERY1 or $gene_density_QUERY2)
					 {	
						 #heat map legend
						 
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+($k/($icon_high_h/4))*0.1),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.1+($k/($icon_high_h/4))*0.2),   
								}
							);
						}
						 for(my $k=0;$k<($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h/2)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h/2)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.3+($k/($icon_high_h/4))*0.3),   
								}
							);
						}
						 for(my $k=0;$k<=($icon_high_h/4);$k++)
						 {					 
							 $svg->line(
								 x1=>$icon_x,y1=>$icon_y-($icon_high_h*3/4)-$k,
								 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-($icon_high_h*3/4)-$k,
								 style=>{
									 'stroke'=>"$genedensity_color",
									 'stroke-width'=>'2',
									 'stroke-opacity'=>(0.1+0.6+($k/($icon_high_h/4))*0.4),   
								}
							);
						}				
						##white line
						 for(my $k=0;$k<=$icon_high_h;$k++)
						 {

							 if( $k==int($icon_high_h/2) ) 
							 {
								 my $icon_line="black";

								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$k,
									 x2=>$icon_x+int($GDheatmap_wide/4),y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide-int($GDheatmap_wide/4),y1=>$icon_y-$k,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$k,
									 style=>{
										 'stroke'=>"$icon_line",  
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
							}	
							 if( ($k==0) or ($k==int($icon_high_h/2)) or ($k==$icon_high_h) ) 
							 {
								 my $iconheatmap_num;
								 if($k==0){$iconheatmap_num="0";}
								 elsif($k==int($icon_high_h/2)){$iconheatmap_num="50%";}
								 elsif($k==$icon_high_h){$iconheatmap_num="100%";}
								 $svg->text(
									 x=>$icon_x+$GDheatmap_wide+4, 
									 y=>$icon_y-$k+10,
									 style=>{
									     'font-family'=>"Courier",#
										 'stroke'=>'none',
										 'font-size'=>'25',
									}
								)->cdata("$iconheatmap_num"); 
							}						
						}
						 {
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y-$icon_high_h,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x,y1=>$icon_y,
									 x2=>$icon_x,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);
								 $svg->line(
									 x1=>$icon_x+$GDheatmap_wide,y1=>$icon_y,
									 x2=>$icon_x+$GDheatmap_wide,y2=>$icon_y-$icon_high_h,
									 style=>{
										 'stroke'=>"black",
										 'stroke-width'=>'2.5',
										 'stroke-opacity'=>1,   
									}
								);						
						}
						 my $tujie_name='Gene Density';
						 $svg->text(
							 x=>$icon_x-15, 
							 y=>$icon_y-$GDtext_move_y-$icon_high_h-$GD_high_move/2,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
						 my $GD_bp_S=$GD_Win_bp/1000;
						 my $GD_bp_name="("."$GD_bp_S"."Kb)";
						 my $ca_wide=($GDheatmap_wide-length($GD_bp_name)*15)/2;
						 $svg->text(
							 x=>$icon_x+$ca_wide, #-8
							 y=>$icon_y+37,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25',
							}
						)->cdata($GD_bp_name);
						 $aa_y+=5;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;							 
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 {
					     $icon_y = $margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h;#-$GDheatmap_high-$GD_high_move
						 if($SVG_canvas_h==($margin_Y*2+450))
						 {
							 $icon_y = $margin_Y*1.5+450-$icon_high_h;#-$GDheatmap_high-$GD_high_move;
						}						 
						 my $tujie_name='Type';
						 $svg->text(
							 x=>$icon_x-5, 
							 y=>$icon_y-$GDtext_move_y-$GD_high_move/2,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'45',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;						
					}
					 if($gene_density_REF!=1)
					 {
						 #icon_reference
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$reference_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$refname");	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }						 
					}
					 if($gene_density_QUERY1!=1)
					 {
						 #icon_query1
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query1_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);	
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname");	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }						 
					}
					 if($gene_density_QUERY2!=1)
					 {
						 #icon_query2
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$query2_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata("$queryname2");				
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 {
						##synteny bolck legend 
						 if($synteny_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$synteny_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Synteny';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
							 $aa_y+=1;
							 if($aa_y==5)
							 {
								 $aa_x+=1;
								 $aa_y=0;
								 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
								 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
								 if($SVG_canvas_h==($margin_Y*2+450))
								 {
									 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
								}							 
							}
						}						
						 if($inversion_iconaa)
						 {
							 $svg->rect(
								 x=>$icon_x,
								 y=>$icon_y-$GDheatmap_high,
								 width=>$GDheatmap_wide, height=>$GDheatmap_high,
								 style=>{
									 'fill'=>"$inversion_color",
									 'stroke'=>'black',
									 'stroke-width'=>'0',
								}
							);						
							 my $tujie_name='Inversion';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
							 $aa_y+=1;
							 if($aa_y==5)
							 {
								 $aa_x+=1;
								 $aa_y=0;
								 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
								 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
								 if($SVG_canvas_h==($margin_Y*2+450))
								 {
									 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
								}							 
							}
						}
					}
					 if($reftargetgene or $query1targetgene or $query2targetgene)
					 {
						 #targetgene_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$targetgene_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($targetgene_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if( $icon_centromere and ($refcentromere or $query1centromere or $query2centromere ) )
					 {
						 #centromere legend ˿
						 
						 $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$centromere_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 
						 my $x1 = $icon_x+$GDheatmap_wide/2;
						 my $y1 = $icon_y-$GDheatmap_high/2;
						 my $x2 = $x1-12;
						 my $y2 = $y1-$GDheatmap_high/2-1;
						 my $x3 = $x1+12;
						 my $y3 = $y1-$GDheatmap_high/2-1;
						 my $y4 = $y1+$GDheatmap_high/2+1;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2 $x3,$y3",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'0.1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y4 $x3,$y4",
							 style=>{
								 'fill'=>'#FFFFFF',
								 'opacity'=>'1',
								 'stroke-width'=>'1',
								 'stroke'=>'#FFFFFF'
							}
						);
						 my $tujie_name='Centromere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if($PAV_REF or $PAV_QUERY1 or $PAV_QUERY2)
					 {
						 #PAV_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$PAV_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='PAV';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if( $NLR_REF or $NLR_QUERY1 or $NLR_QUERY2 )
					 {
						 #NLR_legend
						  $svg->rect(
							 x=>$icon_x,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$GDheatmap_wide, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$NLR_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='NLR';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);				 
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if($reftelomere or $query1telomere or $query2telomere)
					 {
						 #reference legend 
						 my $x1 = $icon_x+24;
						 my $y1 = $icon_y-24;
						 my $x2 = $x1-24;
						 my $y2 = $y1-24;
						 my $x3 = $x1-24;
						 my $y3 = $y1+24;
						 $svg->polygon(
							 points=>"$x1,$y1 $x2,$y2  $x3,$y3",
							 style=>{
								 'fill'=>"$telomere_color",
								 'stroke'=>'black',
								 'opacity'=>'1',
								 'stroke-width'=>'0',
							}
						);
						 my $tujie_name='Telomere';
						 $svg->text(
							 x=>$icon_x+$GD_wide_text, 
							 y=>$icon_y-$GDtext_move_y,
							 style=>{
							     'font-family'=>"Courier",
								 'stroke'=>'none',
								 'font-size'=>'35',
							}
						)->cdata($tujie_name);
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					 if($snp_QUERY1 or $snp_QUERY2)
					 {
						 $icon_y=$icon_y+10;
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$SNP_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$SNP_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$SNP_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-$snp_heatmap_max-4, 
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("$SNP_threshold_value");									
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$SNP_Win_bp/$proportion-5-13-4, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$SNP_color",
									 'font-size'=>'25'
								}
							)->cdata("0");							
							 my $tujie_name='SNP';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $SNP_bp_S=$SNP_Win_bp/1000;
							 my $SNP_bp_name="("."$SNP_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50+25, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($SNP_bp_name);								
						}	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}
					if(($TE_QUERY1 or $TE_QUERY2) and ($snp_TE==1))
					 {
						 $icon_y=$icon_y+10;
						 #snp_transition legend
						 my $snp_x1=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y1=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x2=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y2=$icon_y-$GDheatmap_high+0.25;
						 my $snp_x3=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion;
						 my $snp_y3=$icon_y-0.25;
						 my $snp_x4=$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5;	 
						 my $snp_y4=$icon_y-0.25;					 
						 $svg->polygon(
							 points=>"$snp_x1,$snp_y1 $snp_x2,$snp_y2",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$snp_x3,$snp_y3 $snp_x4,$snp_y4",
							 style=>{
								 'stroke'=>"$TE_color",
								 'stroke-width'=>'0.5',
							}
						);					 
						 $svg->rect(
							 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion,
							 y=>$icon_y-$GDheatmap_high,
							 width=>$TE_Win_bp/$proportion, height=>$GDheatmap_high,
							 style=>{
								 'fill'=>"$TE_color",
								 'stroke'=>'black',
								 'stroke-width'=>'0',
							}
						);					
						{
							 $svg->text(
								 x=>$icon_x+$GDheatmap_wide-80-17+9,
								 y=>$icon_y-$GDheatmap_high+10,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("100%");									
							 my $TE_xiaaa=$TE_tem3min*100;
							 my $TE_xiabb="$TE_xiaaa".'%';
							 if($TE_tem3min==0){$TE_xiabb='0';}
							 my $TE_xialeng=(length($TE_xiabb)-1)*18;
							$svg->text(
								 x=>$icon_x+$GDheatmap_wide-$TE_Win_bp/$proportion-5-13-4-$TE_xialeng, 
								 y=>$icon_y+9,
								 style=>{
								     'font-family'=>"Courier",#
									 'fill'=>"$TE_color",
									 'font-size'=>'25'
								}
							)->cdata("$TE_xiabb");							
							 my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}	
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }
					}					
					 if( ($TE_QUERY1 or $TE_QUERY2) and ($snp_TE==0) )
					 {   
						 $icon_y=$icon_y+10;
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("100Kb");									
						$svg->text(
							 x=>$TE_X3-18, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("0");	
						
						 {	
							my $tujie_name='TE';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $TE_bp_S=$TE_Win_bp/1000;
							 my $TE_bp_name="("."$TE_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+50, 
								 y=>$icon_y-$GDtext_move_y-3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($TE_bp_name);							
						}
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }				
					}
					 if( ($GC_QUERY1 or $GC_QUERY2) and ($GC_content==1) )
					 {   
						 $icon_y=$icon_y+10;
						 #TE_legend
						 my $TE_X1=$icon_x+$GDheatmap_wide;
						 my $TE_Y1=$icon_y-12+15-8;
						 my $TE_X2=$TE_X1;
						 my $TE_Y2=$TE_Y1-$te_pro+20;
						 my $TE_X3=$TE_X1-5;
						 my $TE_Y3=$TE_Y1;
						 my $TE_X4=$TE_X2-5;
						 my $TE_Y4=$TE_Y2;
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X2,$TE_Y2",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->polygon(
							 points=>"$TE_X1,$TE_Y1 $TE_X3,$TE_Y3",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);
						 $svg->polygon(
							 points=>"$TE_X2,$TE_Y2 $TE_X4,$TE_Y4",
							 style=>{
								 'stroke'=>"black",
								 'stroke-width'=>'0.5',
							}
						);	
						 $svg->text(
							 x=>$TE_X4-75+8+8+2, 
							 y=>$TE_Y4+8,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("50%");									
						$svg->text(
							 x=>$TE_X3-75+8+8+2, 
							 y=>$TE_Y3+12-1,
							 style=>{
							     'font-family'=>"Courier",#
								 'stroke'=>'none',
								 'font-size'=>'25'
							}
						)->cdata("40%");	
						
						 {	
							my $tujie_name='GC Content';
							 $svg->text(
								 x=>$icon_x+$GD_wide_text, 
								 y=>$icon_y-$GDtext_move_y+3,
								 style=>{
								     'font-family'=>"Courier",
									 'stroke'=>'none',
									 'font-size'=>'35',
								}
							)->cdata($tujie_name);
							 my $GC_bp_S=$GC_Win_bp/1000;
							 my $GC_bp_name="("."$GC_bp_S"."Kb)";			
							 $svg->text(
								 x=>$icon_x+$GD_wide_text+48+25, 
								 y=>$icon_y-$GDtext_move_y+30+3,
								 style=>{
								     'font-family'=>"Courier",#
									 'stroke'=>'none',
									 'font-size'=>'25',
								}
							)->cdata($GC_bp_name);								
						}
						 $icon_y=$icon_y+$GDheatmap_high+$GD_high_move;
						 $aa_y+=1;
						 if($aa_y==5)
						 {
							 $aa_x+=1;
							 $aa_y=0;
							 $icon_x=$ChrLengthMAX/$proportion+$margin+$aa_x*300+$margin_icon;
							 $icon_y=$margin_Y*1.5+$AlignmentHight*2-10+$margin_snp+12*3*2+($ChrHight+$AlignmentHight-10+$margin_snp+12*3)*($chromosomenumberMAX3-1)-$icon_high_h+$GDheatmap_high+$GD_high_move;#-$GD_high_move/2
							 if($SVG_canvas_h==($margin_Y*2+450))
							 {
								 $icon_y = $margin_Y*1.5+450-$icon_high_h+$GDheatmap_high+$GD_high_move;
							}							 
                        }				
					}					
				}				
            }
		}		
	}
	
	 my $different1=1;
	 #Determine if the names are consistent
	 if($chromosomenumber != $chromosomenumber2)
	 {
	     $different1=0;
	}
	 else
	 {
		 for( my $q=0;$q<$chromosomenumberMAX1;$q++ )
		 {
			 if($outChrname1[$q] ne $outChrname2[$q])
			 {
				 $different1=0;
			}
		}
	}	
     #Determine if the names are consistent
	 my $different2=1;
	 if($chromosomenumber != $chromosomenumber3)
	 {
	     $different2=0;
	}
	 else
	 {
		 for( my $q=0;$q<$chromosomenumberMAX2;$q++ )
		 {
			 if($outChrname1[$q] ne$outChrname3[$q])
			 {
				 $different2=0;
			}
		}
	}	
	 #Determine if the names are consistent
	 my $different3=1;
	 if($chromosomenumber2 != $chromosomenumber3)
	 {
	      $different3=0;
	}
	 else
	 {
		 for( my $q=0; $q<$chromosomenumber2 or $q<$chromosomenumber3 ;$q++ )
		 {
			 if($outChrname2[$q] ne $outChrname3[$q])
			 {
				 $different3=0;
			}
		}
	}
	
	 #Illustrations drawn:three genomes 
	 if( $illustration==1 )
	 {  
		 ##Illustration.2: synGenome identity   ###three genomes     
		 ###Illustration.2-1
		 for( my $q=0;$q<$chromosomenumberMIN1;$q++){
			 #Coordinate axis drawing of Illustration.2-1
			 if($q==0)
			 {
				 #The title1 
				 $svg4->text(
					 x=>$margin_identity+($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN1)/2.5,
					 y=>$margin_identity-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_identity);
				 ##The Y axis
				 $svg4->line(
					 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5,
					 x2=>$margin_identity,y2=>$margin_identity,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 ##The X axis
				 $svg4->line(
					 x1=>$margin_identity,y1=>$margin_identity +$proportion_identity*5,
					 x2=>($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN1)+$proportion_identity,
					 y2=>$margin_identity+$proportion_identity*5,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 my $x1=$margin_identity-3;
				 my $x2=$margin_identity+3;
				 my $y1=$margin_identity;
				 my $y2=$margin_identity-3;
				 my $x3=($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN1)+$proportion_identity;
				 my $x4=$x3+5;
				 my $y3=$ylength-3;
				 my $y4=$ylength+3;
				 $svg4->polygon(
					 points=>"$x1,$y1 $x2,$y1 $margin_identity,$y2",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 $svg4->polygon(
					 points=>"$x3,$y3 $x3,$y4 $x4,$ylength",
					 style=>{
						  'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);				 
				 #chromosome name
				 #reference color
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN1+$proportion_identity+$width_identity*2-170, 
					 y=>$margin_identity,
					 width=>$width_identity, height=>$width_identity,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>"$reference_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 #reference name
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN1+$proportion_identity+$width_identity*3-160,
					 y=>$margin_identity+15,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$refname");
				#query1 color
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN1+$proportion_identity+$width_identity*2-170,
					 y=>$margin_identity+$width_identity+10,
					 width=>$width_identity, height=>$width_identity,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>"$query1_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 #query1 name	
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN1+$proportion_identity+$width_identity*3-160,
					 y=>$margin_identity+$width_identity+25,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$queryname");
					 
				 for(my $i=0;$i<$proportion_identity*5;$i+=10){
					 if ($i%$proportion_identity==0){
						 my $z=$i/4;
						 my $t="$z"."%";
						 $svg4->text(
							 x=>$margin_identity-30,y=>$margin_identity+$proportion_identity*5-$i+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'10',
							}
						)->cdata($t);
						##long graduation
						 $svg4->line(
							 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+5,y2=>$margin_identity+$proportion_identity*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
					else
					 {
						 ##short graduation
						 $svg4->line(
							 x1=>$margin_identity,y1=>$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+2,y2=>$margin_identity+$proportion_identity*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
				}
			}	  
			 #chromosome name
			 #ref vs query1
			 if($different1)
			{
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+($width_identity+$smallinterval_identity)/2+$biginterval_identity*$q-7,
					 y=>$margin_identity+$proportion_identity*5+20,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$q]");
			}
			 else
			 {  
				 if($q<$chromosomenumber)
				 {
					 my $goal_x=$margin_identity+$smallinterval_identity;
					 my $goal_y=$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$biginterval_identity*cos($radians)*$q,
						 y=>$rotate_y-$biginterval_identity*sin($radians)*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname1[$q]");		
				}
				if($q<$chromosomenumber2)
				 {
					 my $goal_x=$margin_identity+$smallinterval_identity*2+$width_identity;
					 my $goal_y=$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$biginterval_identity*cos($radians)*$q,
						 y=>$rotate_y-$biginterval_identity*sin($radians)*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname2[$q]");	
				}
					
			}
			
			open FL1_1,"$inputFile";
			 my $refpro=0;
			 my $querypro=0;
			 while(<FL1_1>){
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname2[$q] ){
					 $refpro+=$tem[4]/$tem[7];
					 $querypro+=$tem[5]/$tem[8];	
				} 
			}
			 close FL1_1; 		 
			 my $zrefpro=sprintf("%.2f",$refpro*100);
			 my $zquerypro=sprintf("%.2f",$querypro*100);
			 my $refheight=$refpro*$proportion_identity*4;
			 my $queryheight=$querypro*$proportion_identity*4;
			 #####print"$refheight  $queryheight\n\n";
				
			 #reference
			 if($q<$chromosomenumber)
			 {
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*($q), y=>$ylength-$refheight,
					 width=>$width_identity, height=>$refheight,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*($q)-3, y=>$ylength-$refheight-5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'10',
					}
				)->cdata("$zrefpro"."%");
			}
			 #query1
			 if($q<$chromosomenumber2)
			 {
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*($q), y=>$ylength-$queryheight,
					 width=>$width_identity, height=>$queryheight,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*($q)-2, y=>$ylength-$queryheight-5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'10',
					}
				)->cdata("$zquerypro"."%");
			}
		}	

		 ###Illustration.2-2
		 for( my $q=0;$q<$chromosomenumberMIN2;$q++){
			#Coordinate axis drawing
			 if($q==0)
			 {
				 #The title2
				 $svg4->text(
					 x=>$margin_identity+($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN2)/2.5,
					 y=>$ylength+$margin_identity*3-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_identity);
				 ##The Y axis
				 $svg4->line(
					 x1=>$margin_identity,y1=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5,
					 x2=>$margin_identity,y2=>$ylength + $proportion_identity*2+$margin_identity,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 ##The X axis
				 $svg4->line(
					 x1=>$margin_identity,
					 y1=>$ylength + $proportion_identity*2+$margin_identity +$proportion_identity*5,
					 x2=>($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN2)+$proportion_identity,
					 y2=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 my $x1=$margin_identity-3;
				 my $x2=$margin_identity+3;
				 my $y1=$ylength + $proportion_identity*2+$margin_identity;
				 my $y2=$ylength + $proportion_identity*2+$margin_identity-3;
				 my $x3=($margin_identity+$smallinterval_identity*2+$width_identity*2+$biginterval_identity*$chromosomenumberMIN2)+$proportion_identity;
				 my $x4=$x3+5;
				 my $y3=$ylength*2 + $proportion_identity*2-3;
				 my $y4=$ylength*2 + $proportion_identity*2+3;
				 my $y5=$ylength*2 + $proportion_identity*2;
				 $svg4->polygon(
					 points=>"$x1,$y1 $x2,$y1 $margin_identity,$y2",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 $svg4->polygon(
					 points=>"$x3,$y3 $x3,$y4 $x4,$y5",
					 style=>{
						  'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 #reference color
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN2+$proportion_identity+$width_identity*2-170,
					 y=>$ylength + $proportion_identity*2+$margin_identity,
					 width=>$width_identity, height=>$width_identity,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>"$reference_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 #reference name
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN2+$proportion_identity+$width_identity*3-160,
					 y=>$ylength + $proportion_identity*2+$margin_identity+15,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$refname");
				 #query2 color
				 $svg4->rect(
						 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN2+$proportion_identity+$width_identity*2-170,
						 y=>$ylength + $proportion_identity*2+$margin_identity+$width_identity+10,
						 width=>$width_identity, height=>$width_identity,
						 style=>{
							 'fill'=>"$query2_color",###8E1D78
							 'stroke'=>"$query2_color",
							 'rx'=>'5',
							 'ry'=>'5',
							 'stroke-width'=>'1',
						}
					);
				 #query2 name
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$biginterval_identity*$chromosomenumberMIN2+$proportion_identity+$width_identity*3-160,
					 y=>$ylength + $proportion_identity*2+$margin_identity+$width_identity+25,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$queryname2");
				
				 ########
				 for(my $i=0; $i<$proportion_identity*5; $i+=10){
					 if ($i%$proportion_identity==0){
						 my $z=$i/4;
						 my $t="$z"."%";
						 $svg4->text(
							 x=>$margin_identity-30,y=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5-$i+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'10',
							}
						)->cdata($t);
						##long graduation
						 $svg4->line(
							 x1=>$margin_identity,y1=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+5,y2=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
					else
					 {
						 ##short graduation
						 $svg4->line(
							 x1=>$margin_identity,y1=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5-$i,
							 x2=>$margin_identity+2,y2=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
				}
			}	
			 if($different2)
			 {
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+($width_identity+$smallinterval_identity)/2+$biginterval_identity*$q-7,
					 y=>$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5+40,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$q]");
			}
			 else
			 {
				 if($q<$chromosomenumber)
				 {
					 my $goal_x=$margin_identity+$smallinterval_identity;
					 my $goal_y=$ylength+$proportion_identity*2+$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$rotate_cosine*$q,
						 y=>$rotate_y-$rotate_sine*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname1[$q]");		
				}
				if($q<$chromosomenumber3)
				 {
					 my $goal_x=$margin_identity+$smallinterval_identity*2+$width_identity;
					 my $goal_y=$ylength + $proportion_identity*2+$margin_identity+$proportion_identity*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg4->text(
						 x=>$rotate_x+$rotate_cosine*$q,
						 y=>$rotate_y-$rotate_sine*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname3[$q]");	  
				}
			}	
			######     #######	
			 open FL2_2,"$inputFile2";
			 my $refpro2=0;
			 my $querypro2=0;
			 while(<FL2_2>){
				 chomp;
				 my @tem = split /\t/;
				 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname3[$q] ){
					 $refpro2+=$tem[4]/$tem[7];
					 $querypro2+=$tem[5]/$tem[8];	
				} 
			}
			 close FL2_2; 
			 my $zrefpro2=sprintf("%.2f",$refpro2*100);
			 my $zquerypro2=sprintf("%.2f",$querypro2*100);
			 my $refheight2=$refpro2*$proportion_identity*4;
			 my $queryheight2=$querypro2*$proportion_identity*4;
			 ####print"$refheight  $queryheight\n\n";
				
			 #reference
			 if($q<$chromosomenumber)
			 {
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*($q),
					 y=>$ylength + $proportion_identity*2+$ylength-$refheight2,
					 width=>$width_identity, height=>$refheight2,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity+$biginterval_identity*($q)-3,
					 y=>$ylength + $proportion_identity*2+$ylength-$refheight2-5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'10',
					}
				)->cdata("$zrefpro2"."%");
			}
			 #query2
			 if($q<$chromosomenumber3)
			 {
				 $svg4->rect(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*($q),
					 y=>$ylength + $proportion_identity*2+$ylength-$queryheight2,
					 width=>$width_identity, height=>$queryheight2,
					 style=>{
						 'fill'=>"$query2_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 $svg4->text(
					 x=>$margin_identity+$smallinterval_identity*2+$width_identity+$biginterval_identity*($q)-2,
					 y=>$ylength + $proportion_identity*2+$ylength-$queryheight2-5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'10',
					}
				)->cdata("$zquerypro2"."%");
			}				
		}

		 #Illustration.1: synGenome heatmap   ###three genomes
		 for( my $a=0;$a<$chromosomenumber;$a++){	
			 #chromosome name
			 #reference number
			 if( (length($outChrname1[-1])*11) < $width_heatmap )
			 {
				 $svg3->text(
					 x=>$marginx1_heatmap+$width_heatmap*$a+$width_heatmap/2-$fontsize*2,y=>$marginy1_heatmap+$hightable_heatmap+$fontsize*2,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$a]");
				 #reference name
				 if($a==0)
				 {
					 $svg3->text(
						 x=>$marginx1_heatmap-length("$refname")*14-10,
						 y=>$marginy1_heatmap+$hightable_heatmap+$fontsize*2,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>' 20',
						}
					)->cdata($refname);
				}
			}
			 else
			 {
				 my $goal_x=$marginx1_heatmap+$width_heatmap/2-$fontsize*3;
				 my $goal_y=$marginy1_heatmap +$hightable_heatmap+$fontsize*2;
				 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
				 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
				 $svg3->text(
					 x=>$rotate_x+$width_heatmap*cos($radians)*$a,
					 y=>$rotate_y-$width_heatmap*sin($radians)*$a,
					 transform=>$rotate,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname1[$a]");
				 if($a==0)
				 {
					 $marginy2_heatmap=(length($outChrname1[-1])*13)*sin($radians);
					 #refrence name
					 $svg3->text(
						 x=>$marginx1_heatmap-length("$refname")*10-10,y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap/2+$fontsize-5,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>' 20',
						}
					)->cdata($refname);
				}	
			}
			 #Form to draw
			 if($a==0){
				 #The title
				 $svg3->text(
					 x=>$marginx1_heatmap+$widthtable_heatmap/2.5,y=>$marginy1_heatmap-$fontsize-10-30,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}
				)->cdata($headline_heatmap);
				 #query1 name
				 $svg3->text(
					 x=>$marginx1_heatmap+$widthtable_heatmap+$fontsize/2,y=>$marginy1_heatmap-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'20',
					}
				)->cdata($queryname);
				 #query2 name
				 $svg3->text(
					 x=>$marginx1_heatmap+$widthtable_heatmap+$fontsize/2,y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$hightable_heatmap2+$fontsize+5,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'20',
					}
				)->cdata($queryname2);
				
				 for(my $i=0;$i<=$chromosomenumber; $i++){
					 #The vertical line of ref vs query1 Form
					 $svg3->line(
						 x1=>$x1_heatmap+$width_heatmap*$i,y1=>$y1_heatmap,
						 x2=>$x1_heatmap+$width_heatmap*$i,y2=>$marginy1_heatmap+$hightable_heatmap,
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'2',
						}
					);
					 #The horizontal line of ref vs query2 Form
					 $svg3->line(
						 x1=>$x1_heatmap+$width_heatmap*$i,y1=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap,
						 x2=>$x1_heatmap+$width_heatmap*$i,y2=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$hightable_heatmap2,
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'2',
						}
					);
				}	  
				
				 for(my $i=0; $i<=$chromosomenumber2; $i++){	 
					 #query1 number
					 if($i<$chromosomenumber2)
					 {
						 $svg3->text(
							 x=>$marginx1_heatmap+$widthtable_heatmap+$fontsize,y=>$marginy1_heatmap+$high_heatmap*$i+$high_heatmap/2,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'15',
							}
						)->cdata("$outChrname2[$i]");
					}
					 #The horizontal line of ref vs query1 Form
					 $svg3->line(
						 x1=>$x1_heatmap,y1=>$y1_heatmap+$high_heatmap*$i,
						 x2=>$x2_heatmap,y2=>$y1_heatmap+$high_heatmap*$i,
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'2',
						}
					);
				}	
				
				 for(my $i=0; $i<=$chromosomenumber3; $i++){ 
					 #query2 number
					 if($i<$chromosomenumber3)
					 {
						 $svg3->text(
							 x=>$marginx1_heatmap+$widthtable_heatmap+$fontsize,y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$i+$high_heatmap/2,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'15',
							}
						)->cdata("$outChrname3[$i]");
					}
					 #The horizontal line of ref vs query2 Form
					 $svg3->line(
						 x1=>$x1_heatmap,y1=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$i,
						 x2=>$x2_heatmap,y2=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$i,
						 style=>{
							 'stroke'=>'white',
							 'stroke-width'=>'2',
						}
					);
				}	
				 #heat map legend
				 for(my $k=0;$k<=($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap);$k+=1)
				 {					 
					 $svg3->line(
						 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10,y1=>$marginy1_heatmap+$k,
						 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap/2,y2=>$marginy1_heatmap+$k,
						 style=>{
							 'stroke'=>'rgb(255,0,0)',   
							 'stroke-width'=>'2',
							 'stroke-opacity'=>(1-$k/($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap))*0.8,   
						}
					);
					 $svg3->line(
						 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10,y1=>$marginy1_heatmap+$k,
						 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap/2,y2=>$marginy1_heatmap+$k,
						 style=>{
							 'stroke'=>'rgb(255,255,0)',  
							 'stroke-width'=>'2',
							 'stroke-opacity'=>($k/($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap))*0.8,   
						}
					);						
				}
				##white line
                 for(my $k=0;$k<=($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap);$k++)
				 {
					if( ($k==4) or ($k==int(($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap)/2)) or ($k==int($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap-4)) ) 
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10-1,y1=>$marginy1_heatmap+$k,
							 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap/8,y2=>$marginy1_heatmap+$k,
							 style=>{
								 'stroke'=>'white',   
								 'stroke-width'=>'2.5',
								 'stroke-opacity'=>1,   
							}
						);
						 $svg3->line(
							 x1=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap*3/8,y1=>$marginy1_heatmap+$k,
							 x2=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap/2+1,y2=>$marginy1_heatmap+$k,
							 style=>{
								 'stroke'=>'white',   
								 'stroke-width'=>'2.5',
								 'stroke-opacity'=>1,   
							}
						);
						 my $heatmap_num;
						 if($k==4){$heatmap_num="100%";}
						 elsif($k==int(($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap)/2)){$heatmap_num="50%";}
						 else{$heatmap_num="0";}
                         $svg3->text(
							 x=>$marginx1_heatmap+$widthtable_heatmap+$maxChrnum*12+10+$width_heatmap/2+4, 
							 y=>$marginy1_heatmap+$k+7,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'20',
							}
						)->cdata("$heatmap_num");  
						 #print"\n\$k:$k\n";
					}	
				} 				
			}				 			 

			 for(my $b=0;$b<$chromosomenumber2;$b++){
				 my $numquery1pro=0;
				 my $numref1pro=0;
				 #color bolck of ref vs query1 
				 open HEATMAP1,"$inputFile";						
				 while(<HEATMAP1>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname2[$b] ){
						 $numquery1pro+=$tem[5]/$tem[8];
						 $numref1pro+=$tem[4]/$tem[7];
					} 							 
				}
				 close HEATMAP1; 
				 if($numref1pro<$numquery1pro)
				 {
					 $numquery1pro=$numref1pro;
				}
				 my $zquery1pro=sprintf("%.2f",$numquery1pro*100);
				 if($zquery1pro==0)
				 {
				     for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8,
							}
						);	
					}					 
					 $zquery1pro=0;
					 $svg3->text(
						 x=>$marginx1_heatmap+$width_heatmap/2-5+$width_heatmap*$a, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'12',
						}
					)->cdata("$zquery1pro");
									 
				}
				else
				 {
					 if($zquery1pro>100)
					 {
						 $zquery1pro=100;
					}
				     for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							 style=>{
								 'stroke'=>'rgb(255,0,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*($zquery1pro*0.01),
							}
						);
						 $svg3->line(
							  x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$high_heatmap*$b+$m,
							  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*(1-$zquery1pro*0.01),
							}
						);	
					}
                     if(length("$zquery1pro"."%")==5)
                     {					 
						 $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$a+4, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery1pro"."%"); 
					}
                     else
					 {
                         $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$a, y=>$marginy1_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery1pro"."%"); 				     
					}						  
				}
			}
			 for(my $b=0;$b<$chromosomenumber3;$b++)
			 {
				 my $numquery2pro=0;
				 my $numref2pro=0;
				 #color bolck of ref vs query2 
				 open HEATMAP2,"$inputFile2";						
				 while(<HEATMAP2>){
					 chomp;
					 my @tem = split /\t/;
					 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname3[$b] ){
							
						 $numquery2pro+=$tem[5]/$tem[8];
						  $numref2pro+=$tem[4]/$tem[7];
					} 							 
				}
				 close HEATMAP2; 
				 if($numref2pro<$numquery2pro)
				 {
					 $numquery2pro=$numref2pro;
				}
				 my $zquery2pro=sprintf("%.2f",$numquery2pro*100);
				 if($zquery2pro==0)
				 {
					 for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							 x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							 style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8,
							}
						);	
					}						
					 $zquery2pro=0;
					 $svg3->text(
						 x=>$marginx1_heatmap+$width_heatmap/2-5+$width_heatmap*$a, y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'12',
						}
					)->cdata("$zquery2pro");				 
				}
				 else
				 {
					 if($zquery2pro>100)
					 {
						 $zquery2pro=100;
					}
					 for(my $m=2;$m<$high_heatmap-2;$m++)
					 {
						 $svg3->line(
							 x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							 x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							 style=>{
								 'stroke'=>'rgb(255,0,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*($zquery2pro*0.01),
							}
						);
						 $svg3->line(
							  x1=>$marginx1_heatmap+$width_heatmap*$a+1.5, y1=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							  x2=>$marginx1_heatmap+$width_heatmap*($a+1)-1.5, y2=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
							  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*(1-$zquery2pro*0.01),
							}
						);	
					}						
				     if(length("$zquery2pro"."%")==5)
                     {					 
						 $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$a+4, y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery2pro"."%"); 
					}
                     else
					 {
						 $svg3->text(
							 x=>$marginx1_heatmap+$width_heatmap/2-20+$width_heatmap*$a, y=>$marginy1_heatmap+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery2pro"."%"); 			     
					}						    
				}

			}

		}
		
		
		 #Illustration.3: synGenome coverage   ###three genomes
		 for( my $q=0;$q<$chromosomenumberMIN3;$q++){ 		 
			 #chromosome name
			 if($different3)
			 {
				 $svg5->text(
					 x=>$marginX_coverage+($width_coverage+$smallinterval_coverage)/2+$biginterval_coverage2*$q+20,
					 y=>$marginY_coverage+$proportion_coverage*5+20,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$outChrname2[$q]");
			}
			 else
			 {
				 if($q<$chromosomenumber2)
				 {
					 my $goal_x=$marginX_coverage+$smallinterval_coverage-5;
					 my $goal_y=$marginY_coverage+$proportion_coverage*5+20;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg5->text(
						 x=>$rotate_x+$biginterval_coverage2*cos($radians)*$q,
						 y=>$rotate_y-$biginterval_coverage2*sin($radians)*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname2[$q]");		
				}
				if($q<$chromosomenumber3)
				 {
					 my $goal_x=$marginX_coverage+$smallinterval_coverage*2+$width_coverage-5;
					 my $goal_y=$marginY_coverage+$proportion_coverage*5+18;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg5->text(
						 x=>$rotate_x+$biginterval_coverage2*cos($radians)*$q,
						 y=>$rotate_y-$biginterval_coverage2*sin($radians)*$q,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname3[$q]");	
				}	
			}
			 #Coordinate axis drawing
			 if($q==0){
				 #The title
				 $svg5->text(
					 x=>($xlength2+$proportion_coverage)/2.4,y=>$marginY_coverage-$fontsize,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>' 20',
					}	
				)->cdata($headline_coverage);
				 #Vertical line
				 $svg5->line(
					 x1=>$marginX_coverage,y1=>$marginY_coverage+$proportion_coverage*5,
					 x2=>$marginX_coverage,y2=>$marginY_coverage,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				);
				 #Horizontal line
				 $svg5->line(
					 x1=>$marginX_coverage,y1=>$marginY_coverage +$proportion_coverage*5,
					 x2=>$xlength2+$proportion_coverage,y2=>$marginY_coverage+$proportion_coverage*5,
					 style=>{
						 'stroke'=>'black',
						 'stroke-width'=>'1',
					}
				); 
				 my $x1=$marginX_coverage-3;
				 my $x2=$marginX_coverage+3;
				 my $y1=$marginY_coverage;
				 my $y2=$marginY_coverage-3;
				 my $x3=$xlength2+$proportion_coverage;
				 my $x4=$x3+5;
				 my $y3=$ylength2-3;
				 my $y4=$ylength2+3;
				 my $y5=$ylength2;
				 $svg5->polygon(
					 points=>"$x1,$y1 $x2,$y1 $marginX_coverage,$y2",
					 style=>{
						 'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 $svg5->polygon(
					 points=>"$x3,$y3 $x3,$y4 $x4,$y5",
					 style=>{
						  'fill'=>'#000000',
						 'stroke'=>'black',
						 'stroke-width'=>'0.1',
						 'stroke'=>'#000000',
					}
				);
				 #query1 color
				 $svg5->rect(
					 x=>$xlength2+$proportion_coverage-120, 
					 y=>$marginY_coverage,
					 width=>$width_coverage, height=>$width_coverage,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>"$query1_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 #query2 name
				 $svg5->text(
					 x=>$xlength2+$proportion_coverage+$width_coverage-110,
					 y=>$marginY_coverage+15,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$queryname");
				 #query2 color
				 $svg5->rect(
					 x=>$xlength2+$proportion_coverage-120, 
					 y=>$marginY_coverage+$width_coverage+10,
					 width=>$width_coverage, height=>$width_coverage,
					 style=>{
						 'fill'=>"$query2_color",
						 'stroke'=>"$query2_color",
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
				 #query2 name
				 $svg5->text(
					 x=>$xlength2+$proportion_coverage+$width_coverage-110,
					 y=>$marginY_coverage+$width_coverage+25,
					 style=>{
						 'stroke'=>'none',
						 'font-size'=>'15',
					}
				)->cdata("$queryname2");
				
				 for(my $i=0; $i<$proportion_coverage*5; $i+=10){
					 if ($i%$proportion_coverage==0){
						 my $z=$i/4;
						 my $t="$z"."%";
						 $svg5->text(
							 x=>$marginX_coverage-30,y=>$marginY_coverage+$proportion_coverage*5-$i+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'10',
							}
						)->cdata($t);
						 $svg5->line(
							 x1=>$marginX_coverage,y1=>$marginY_coverage+$proportion_coverage*5-$i,
							 x2=>$marginX_coverage+5,y2=>$marginY_coverage+$proportion_coverage*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
					 else
					 {
						 $svg5->line(
							 x1=>$marginX_coverage,y1=>$marginY_coverage+$proportion_coverage*5-$i,
							 x2=>$marginX_coverage+2,y2=>$marginY_coverage+$proportion_coverage*5-$i,
							 style=>{
								 'stroke'=>'black',
								 'stroke-width'=>'1',
							}
						);
					}
				}
			}
			 #query1		 
			 open RefvsQuery,"$inputFile";
			 my $querypro=0;
			 my $count1=0;
			 while(<RefvsQuery>){
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname2[$q] ){
					 $querypro+=$tem[6];
					 $count1++;
				} 
			}
			 close RefvsQuery; 
			 if($count1!=0)
			 {
				 $querypro=$querypro/$count1;
			 }
			 #query2		 
			 open RefvsQuery2,"$inputFile2";
			 my $querypro2=0;
			 my $count2=0;
			 while(<RefvsQuery2>){
				 chomp;
				 my @tem = split /\t/;
				 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$q] and $tem[12] eq $Chrname3[$q] ){
					 $querypro2+=$tem[6];
					 $count2++;
				} 
			}
			 close RefvsQuery2; 
			 if($count2!=0)
			 {
				 $querypro2=$querypro2/$count2;
			}
			
			 my $zquerypro=sprintf("%.2f",$querypro);
			 my $zquerypro2=sprintf("%.2f",$querypro2);
			 my $queryheight1=$querypro/100*$proportion_coverage*4;
			 my $queryheight12=$querypro2/100*$proportion_coverage*4;
			 ##print"$queryheight1  $queryheight12\n\n";
			
			 #query1
				 $svg5->rect(
					 x=>$marginX_coverage+$smallinterval_coverage+$biginterval_coverage2*($q), 
					 y=>$ylength2-$queryheight1,
					 width=>$width_coverage, height=>$queryheight1,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'5',
						 'ry'=>'5',
						 'stroke-width'=>'1',
					}
				);
			 #query2
			 $svg5->rect(
				 x=>$marginX_coverage+$smallinterval_coverage*2+$width_coverage+$biginterval_coverage2*($q), 
				 y=>$ylength2-$queryheight12,
				 width=>$width_coverage, height=>$queryheight12,
				 style=>{
					 'fill'=>"$query2_color",
					 'stroke'=>'black',
					 'rx'=>'5',
					 'ry'=>'5',
					 'stroke-width'=>'1',
				}
			);			 
			 $svg5->text(
				 x=>$marginX_coverage+$smallinterval_coverage+$biginterval_coverage2*($q)-2, 
				 y=>$ylength2-$queryheight1-5,
				 style=>{
					 'stroke'=>'none',
					 'font-size'=>'10',
				}
			)->cdata("$zquerypro"."%");
			 $svg5->text(
				 x=>$marginX_coverage+$smallinterval_coverage*2+$width_coverage+$biginterval_coverage2*($q)-2, 
				 y=>$ylength2-$queryheight12-5,
				 style=>{
					 'stroke'=>'none',
					 'font-size'=>'10',
				}
			)->cdata("$zquerypro2"."%");
		 
		}

		 #Illustration.4: synGenome heatmap2   ###three genomes 
		 if($heatmap2_type)
		 {	 
			 
			 if($chromosomenumber3>12)
			 {
				 $marginx1_heatmap_three=$high_heatmap*$chromosomenumber3+200;
				 $marginy1_heatmap_three=$high_heatmap*$chromosomenumber3+200;
			}
			 my $svg6= SVG->new( width=>$marginx1_heatmap_three+$widthtable_heatmap+$marginx2_heatmap*1.4,height=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$hightable_heatmap2+$marginy1_heatmap_three );	 
			 for( my $a=0;$a<$chromosomenumber;$a++){	
				 for(my $b=0;$b<$chromosomenumber2;$b++){
					 my $numquery1pro=0;
					 my $numref1pro=0;
					 #color block of ref vs query1
					 open HEATMAP1,"$inputFile";						
					 while(<HEATMAP1>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname2[$b] ){
							 $numquery1pro+=$tem[5]/$tem[8];
							 $numref1pro+=$tem[4]/$tem[7];
						} 							 
					}
					 close HEATMAP1; 
					 if($numref1pro<$numquery1pro)
					 {
						 $numquery1pro=$numref1pro;
					}
					 my $zquery1pro=sprintf("%.2f",$numquery1pro*100);
					 if($zquery1pro==0){
					 
						 for(my $m=0;$m<$high_heatmap;$m++)
						 {
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a, y1=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1), y2=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8,  
								}
							);
						}				
						 $zquery1pro=0;
						 $svg6->text(
							 x=>$marginx1_heatmap_three+$width_heatmap/2-5+$width_heatmap*$a, y=>$marginy1_heatmap_three+$high_heatmap/2+$high_heatmap*($chromosomenumber2-1-$b)+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery1pro");
										 
					}
					else
					 {
						 if($zquery1pro>100)
						 {
							 $zquery1pro=100;
						}
						
						 for(my $m=0;$m<$high_heatmap;$m++)
						 {
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a, y1=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1), y2=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  style=>{
									 'stroke'=>'#FF0000',
									 'stroke-width'=>'2',
									 'stroke-opacity'=>0.8*$zquery1pro*0.01,  
								}
							);
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a, y1=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1), y2=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$b)+$m,
								  style=>{
									 'stroke'=>'rgb(255,255,0)',
									 'stroke-width'=>'2',
									 'stroke-opacity'=>0.8*(1-$zquery1pro*0.01),  
								}
							);
						}	
						 if(length("$zquery1pro"."%")==5)
						 {					 
							 $svg6->text(
								 x=>$marginx1_heatmap_three+$width_heatmap/2-20+$width_heatmap*$a+4, y=>$marginy1_heatmap_three+$high_heatmap/2+$high_heatmap*($chromosomenumber2-1-$b)+5,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'12',
								}
							)->cdata("$zquery1pro"."%"); 
						}
						 else
						 {
							 $svg6->text(
								 x=>$marginx1_heatmap_three+$width_heatmap/2-20+$width_heatmap*$a, y=>$marginy1_heatmap_three+$high_heatmap/2+$high_heatmap*($chromosomenumber2-1-$b)+5,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'12',
								}
							)->cdata("$zquery1pro"."%");   				     
						}						
					}
				}						 
				 #Chromosome number
				 #reference number
				 if( (length($outChrname1[-1])*13) < $width_heatmap )
				 {
					 $svg6->text(
						 x=>$marginx1_heatmap_three+$width_heatmap*$a+$width_heatmap/2-$fontsize*2,
						 y=>$marginy1_heatmap_three+$hightable_heatmap+$fontsize*2,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname1[$a]");
					 #reference name
					 if($a==0)
					 {
						 $svg6->text(
							 x=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize,
							 y=>$marginy1_heatmap_three+$hightable_heatmap+$fontsize*2,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>' 20',
							}
						)->cdata($refname);
					}
				}
				 else
				 {
					 my $goal_x=$marginx1_heatmap_three+$width_heatmap/2-$fontsize*3;
					 my $goal_y=$marginy1_heatmap_three +$hightable_heatmap+$fontsize*2;
					 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
					 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
					 $svg6->text(
						 x=>$rotate_x+$width_heatmap*cos($radians)*$a,
						 y=>$rotate_y-$width_heatmap*sin($radians)*$a,
						 transform=>$rotate,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'15',
						}
					)->cdata("$outChrname1[$a]");
					 if($a==0)
					 {
						 $marginy2_heatmap=(length($outChrname1[-1])*13)*sin($radians);
						 #reference name
						 $svg6->text(
							 x=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize,
							 y=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap/2+$fontsize-5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>' 20',
							}
						)->cdata($refname);
						
					}	
				}
				 for(my $b=0;$b<$chromosomenumber3;$b++)
				 {
					 my $numquery2pro=0;
					 my $numref2pro=0;
					 #color block of ref vs query2
					 open HEATMAP2,"$inputFile2";						
					 while(<HEATMAP2>){
						 chomp;
						 my @tem = split /\t/;
						 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname1[$a] and $tem[12] eq $Chrname3[$b] ){
								
							 $numquery2pro+=$tem[5]/$tem[8];
							  $numref2pro+=$tem[4]/$tem[7];
						} 							 
					}
					 close HEATMAP2; 
					 if($numref2pro<$numquery2pro)
					 {
						 $numquery2pro=$numref2pro;
					}
					 my $zquery2pro=sprintf("%.2f",$numquery2pro*100);
					 if($zquery2pro==0){
						 for(my $m=0;$m<$high_heatmap;$m++)
						 {
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a-$m-$high_heatmap*$b-$width_heatmap/4,
								  y1=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1)-$m-$high_heatmap*$b-$width_heatmap/4, 
								  y2=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8,  
								}
							);
						}					
						 $zquery2pro=0;
						 $svg6->text(
							 x=>$marginx1_heatmap_three+$width_heatmap/2-5+$width_heatmap*$a-$high_heatmap*$b-$high_heatmap/2-$width_heatmap/4,
							 y=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'12',
							}
						)->cdata("$zquery2pro");
										 
					}
					 else
					 {
						 if($zquery2pro>100)
						 {
							 $zquery2pro=100;
						}
						
						 for(my $m=0;$m<$high_heatmap;$m++)
						 {
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a-$m-$high_heatmap*$b-$width_heatmap/4, 
								  y1=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1)-$m-$high_heatmap*$b-$width_heatmap/4, 
								  y2=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  style=>{
								 'stroke'=>'#FF0000',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*$zquery2pro*0.01,  
								}
							);
							 $svg6->line(
								  x1=>$marginx1_heatmap_three+$width_heatmap*$a-$m-$high_heatmap*$b-$width_heatmap/4, 
								  y1=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  x2=>$marginx1_heatmap_three+$width_heatmap*($a+1)-$m-$high_heatmap*$b-$width_heatmap/4, 
								  y2=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$b+$m,
								  style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'2',
								 'stroke-opacity'=>0.8*(1-$zquery2pro*0.01),  
								}
							);
						}
						 if(length("$zquery2pro"."%")==5)
						 {					 
							 $svg6->text(
								 x=>$marginx1_heatmap_three+$width_heatmap/2-20+$width_heatmap*$a-$high_heatmap*$b-$high_heatmap/2-$width_heatmap/4+4,
								 y=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'12',
								}
							)->cdata("$zquery2pro"."%"); 
						}
						 else
						 {
							 $svg6->text(
								 x=>$marginx1_heatmap_three+$width_heatmap/2-20+$width_heatmap*$a-$high_heatmap*$b-$high_heatmap/2-$width_heatmap/4,
								 y=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+$high_heatmap*$b+5,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'12',
								}
							)->cdata("$zquery2pro"."%");  				     
						}						  
					}

				}

				 #Form to draw
				 if($a==$chromosomenumber-1){
				 
					for( my $u=0;$u<$chromosomenumber3;$u++){	
						 for(my $b=0;$b<$chromosomenumber2;$b++){
							 my $numquery1pro=0;
							 my $numref1pro=0;
							 #color block of query1 vs query2
							 open HEATMAP3,"$inputFile3";						
							 while(<HEATMAP3>){
								 chomp;
								 my @tem = split /\t/;
								 if( $tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit and $tem[11] eq $Chrname2[$u] and $tem[12] eq $Chrname3[$b] ){
									 $numquery1pro+=$tem[5]/$tem[8];
									 $numref1pro+=$tem[4]/$tem[7];
								} 							 
							}
							 close HEATMAP1; 
							 if($numref1pro<$numquery1pro)
							 {
								 $numquery1pro=$numref1pro;
							}
							 my $zquery1pro=sprintf("%.2f",$numquery1pro*100);
							 if($zquery1pro==0){
							 
								 for(my $m=0;$m<$high_heatmap;$m++)
								 {
									 $svg6->line(
										  x1=>$marginx1_heatmap_three-$high_heatmap*($u+1)+0.3-$marginx3_heatmap-17, 
										  y1=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*($u+1)+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  x2=>$marginx1_heatmap_three-$high_heatmap*$u+0.3-$marginx3_heatmap-17,
										  y2=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  style=>{
										 'stroke'=>'rgb(255,255,0)',
										 'stroke-width'=>'2',
										 'stroke-opacity'=>0.8,  
										}
									);
								}	
								 $zquery1pro=0;
								 
								 my $goal_x=$marginx1_heatmap_three-$high_heatmap*($u+1)-$marginx3_heatmap+21.5-17;
								 my $goal_y=$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b+18-13;
								 my $rotate_x=abs($goal_y*sin(45*$conversion)-$goal_x*cos(45*$conversion));
								 my $rotate_y=abs($goal_y*cos(45*$conversion)+$goal_x*sin(45*$conversion));
								 $svg6->text(
									 x=>-$rotate_x,
									 y=>$rotate_y,
									 transform=>'rotate(315)',
									 style=>{
										 'stroke'=>'none',
										 'font-size'=>'12',
									}
								)->cdata("$zquery1pro");										 
							}
							else
							 {
								 if($zquery1pro>100)
								 {
									 $zquery1pro=100;
								}
								
								 for(my $m=0;$m<$high_heatmap;$m++)
								 {
									 $svg6->line(
										  x1=>$marginx1_heatmap_three-$high_heatmap*($u+1)+0.3-$marginx3_heatmap-17, 
										  y1=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*($u+1)+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  x2=>$marginx1_heatmap_three-$high_heatmap*$u+0.3-$marginx3_heatmap-17,
										  y2=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  style=>{
											 'stroke'=>'#FF0000',
											 'stroke-width'=>'2',
											 'stroke-opacity'=>0.8*$zquery1pro*0.01,  
										}
									);
									 $svg6->line(
										  x1=>$marginx1_heatmap_three-$high_heatmap*($u+1)+0.3-$marginx3_heatmap-17, 
										  y1=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*($u+1)+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  x2=>$marginx1_heatmap_three-$high_heatmap*$u+0.3-$marginx3_heatmap-17,
										  y2=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b-$m-1,
										  style=>{
											 'stroke'=>'rgb(255,255,0)',
											 'stroke-width'=>'2',
											 'stroke-opacity'=>0.8*(1-$zquery1pro*0.01),  
										}
									);									 
								}
								 my $goal_x=$marginx1_heatmap_three-$high_heatmap*($u+1)-$marginx3_heatmap+8.5-17;
								 my $goal_y=$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b+18;
								 if(length("$zquery1pro"."%")==5)
						         {					 
									 $goal_x=$marginx1_heatmap_three-$high_heatmap*($u+1)-$marginx3_heatmap+8.5-17+4;
									 $goal_y=$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$u+$high_heatmap/4-$high_heatmap*$b+18-4;
								}	
								 my $rotate_x=abs($goal_y*sin(45*$conversion)-$goal_x*cos(45*$conversion));
								 my $rotate_y=abs($goal_y*cos(45*$conversion)+$goal_x*sin(45*$conversion));
								 $svg6->text(
									 x=>-$rotate_x,
									 y=>$rotate_y,
									 transform=>'rotate(315)',
									 style=>{
										 'stroke'=>'none',
										 'font-size'=>'12',
									}
								)->cdata("$zquery1pro"."%");					
							}
						}
					}		 
				 
					 #The title
					 $svg6->text(
						 x=>($marginx1_heatmap_three+$widthtable_heatmap)/2.5,y=>$marginy1_heatmap_three-$fontsize-100-20,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'50',
						}
					)->cdata($headline_heatmap);
					 #query1 name
					 $svg6->text(
						 x=>$marginx1_heatmap_three-$marginx3_heatmap/2-87/2,y=>$marginy1_heatmap_three-$fontsize,
						 style=>{
							 'stroke'=>'none',
							 'font-size'=>'20',
						}
					)->cdata($queryname);
					 #query2 name			
					 {
						 my $goal_x=$marginx1_heatmap_three-$high_heatmap*$chromosomenumber3+0.3-$marginx3_heatmap-10-$high_heatmap*2.25+$marginx3_heatmap/2-87/2;
						 my $goal_y=$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$chromosomenumber3+$high_heatmap/4+0.3+$high_heatmap*0.75+$marginx3_heatmap/2-87/2;
						 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
						 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
						 $svg6->text(
							 x=>$rotate_x+$width_heatmap*cos($radians),
							 y=>$rotate_y-$width_heatmap*sin($radians),
							 transform=>$rotate,
							 style=>{
								 'stroke'=>'none',
								 'font-size'=>'20',
							}
						)->cdata($queryname2);
					}
					
					 for(my $i=0;$i<=$chromosomenumber; $i++){
						 #The vertical line of reference vs query1 Form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three+$width_heatmap*$i,y1=>$marginy1_heatmap_three-1,
							 x2=>$marginx1_heatmap_three+$width_heatmap*$i,y2=>$marginy1_heatmap_three+$hightable_heatmap+1,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
						 #The vertical line of reference vs query2 Form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three+$width_heatmap*$i-$width_heatmap/4,
							 y1=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap-0.3,
							 x2=>$marginx1_heatmap_three+$width_heatmap*$i-$high_heatmap*$chromosomenumber3-$width_heatmap/4,
							 y2=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$hightable_heatmap2+0.3,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
					}	  
			
					 for(my $i=0; $i<=$chromosomenumber2; $i++){	 
						 #query1 number
						 if($i<$chromosomenumber2)
						 {
							 $svg6->text(
								 x=>$marginx1_heatmap_three-$marginx3_heatmap,y=>$marginy1_heatmap_three+$high_heatmap*($chromosomenumber2-1-$i)+$high_heatmap/2+5,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'15',
								}
							)->cdata("$outChrname2[$i]");
						}
						  #The horizontal line of ref vs query1 Form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three-1,y1=>$marginy1_heatmap_three+$high_heatmap*$i,
							 x2=>$marginx1_heatmap_three+$widthtable_heatmap+1,y2=>$marginy1_heatmap_three+$high_heatmap*$i,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
						
						#The horizontal line of ref vs query2 Form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three-$marginx3_heatmap-17,
							 y1=>$marginy1_heatmap_three+$high_heatmap*$i+$high_heatmap/4,
							 x2=>$marginx1_heatmap_three-$marginx3_heatmap-$chromosomenumber3*$high_heatmap-17,
							 y2=>$marginy1_heatmap_three+$high_heatmap*$i+$chromosomenumber3*$high_heatmap+$high_heatmap/4,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
						
						
					}	
					
					 for(my $i=0; $i<=$chromosomenumber3; $i++){ 				
						if($i<$chromosomenumber3)
						 {
							 #chromosome number
							 #query2 number				 
							 if( (length($outChrname3[-1])*12) < $width_heatmap*1.4 )
							 {
								 $svg6->text(
									 x=>$marginx1_heatmap_three-$marginx3_heatmap-($high_heatmap+1)*$i-$high_heatmap,
									 y=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap/2+5+$high_heatmap*$i,
									 style=>{
										 'stroke'=>'none',
										 'font-size'=>'15',
									}
								)->cdata("$outChrname3[$i]");
							}
							 else
							 {						 
								 my $goal_x=$marginx1_heatmap_three-$high_heatmap*$i+0.3-$marginx3_heatmap-10-$high_heatmap*2.25;
								 my $goal_y=$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$i+$high_heatmap/4+0.3+$high_heatmap*0.75;
								 my $rotate_x=abs($goal_x*cos($radians)+$goal_y*sin($radians));
								 my $rotate_y=abs($goal_y*cos($radians)-$goal_x*sin($radians));
								 $svg6->text(
									 x=>$rotate_x+$width_heatmap*cos($radians),
									 y=>$rotate_y-$width_heatmap*sin($radians),
									 transform=>$rotate,
									 style=>{
										 'stroke'=>'none',
										 'font-size'=>'15',
									}
								)->cdata("$outChrname3[$i]");							
							}						
						}
						 #The horizontal line of ref vs query2 form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three-$high_heatmap*$i-0.3-$width_heatmap/4,
							 y1=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$i,
							 x2=>$marginx1_heatmap_three+$widthtable_heatmap-$high_heatmap*$i+0.3-$width_heatmap/4,
							 y2=>$marginy1_heatmap_three+$hightable_heatmap+$marginy2_heatmap+$high_heatmap*$i,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
						
						 #The Vertical line of query1 vs query2 form
						 $svg6->line(
							 x1=>$marginx1_heatmap_three-$high_heatmap*$i-0.3-$marginx3_heatmap-17,
							 y1=>$marginy1_heatmap_three+$high_heatmap*$i+$high_heatmap/4-0.3,
							 x2=>$marginx1_heatmap_three-$high_heatmap*$i+0.3-$marginx3_heatmap-17,
							 y2=>$marginy1_heatmap_three+$high_heatmap*$chromosomenumber2+$high_heatmap*$i+$high_heatmap/4+0.3,
							 style=>{
								 'stroke'=>'white',
								 'stroke-width'=>'2.5',
							}
						);
					}	
					 #heat map legend
					 for(my $k=0;$k<=($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap);$k+=1)
					 {				 
						 $svg6->line(
							 x1=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50,y1=>$marginy1_heatmap_three+$k,
							 x2=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap/2,y2=>$marginy1_heatmap_three+$k,
							 style=>{
								 'stroke'=>'rgb(255,0,0)',  
								 'stroke-width'=>'3',
								 'stroke-opacity'=>(1-$k/($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap))*0.8,   
							}
						);

						 $svg6->line(
							 x1=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50,y1=>$marginy1_heatmap_three+$k,
							 x2=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap/2,y2=>$marginy1_heatmap_three+$k,
							 style=>{
								 'stroke'=>'rgb(255,255,0)',
								 'stroke-width'=>'3',
								 'stroke-opacity'=>($k/($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap))*0.8,   
							}
						);
					}
					 ##white line
					 for(my $k=0;$k<=($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap);$k++)
					 {
						if( ($k==4) or ($k==int(($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap)/2)) or ($k==int($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap-4)) ) 
						 {
							 $svg6->line(
								 x1=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50-1,y1=>$marginy1_heatmap_three+$k,
								 x2=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap/8,y2=>$marginy1_heatmap_three+$k,
								 style=>{
									 'stroke'=>'white',   
									 'stroke-width'=>'2.5',
									 'stroke-opacity'=>1,   
								}
							);
							 $svg6->line(
								 x1=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap*3/8,y1=>$marginy1_heatmap_three+$k,
								 x2=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap/2+1,y2=>$marginy1_heatmap_three+$k,
								 style=>{
									 'stroke'=>'white',   
									 'stroke-width'=>'2.5',
									 'stroke-opacity'=>1,   
								}
							);
							 my $heatmap_num;
							 if($k==4){$heatmap_num="100%";}
							 elsif($k==int(($hightable_heatmap+$hightable_heatmap2+$marginy2_heatmap)/2)){$heatmap_num="50%";}
							 else{$heatmap_num="0";}
							 $svg6->text(
								 x=>$marginx1_heatmap_three+$widthtable_heatmap+$fontsize+$maxChrlong*10+50+$width_heatmap/2+4, 
								 y=>$marginy1_heatmap_three+$k+7,
								 style=>{
									 'stroke'=>'none',
									 'font-size'=>'20',
								}
							)->cdata("$heatmap_num");  						
						}	
					} 					
				}
			}
				
			
		 #outfile6
		 open illustration4,">$output6";
		 my $out6 = $svg6->xmlify();
		 print illustration4 "$out6\n";
		 close illustration4;
		 #print "Refresh chrome!\n";
		 
		}
	}	


}	

#############image-2
if(($aligntype==2)or($aligntype==3))
{
     my $genome_long1=$margin_m2x+$margin_m2x_interval*5;
	 if($genomenumber==2)
	 {
		 for(my $a=0;$a<$chromosomenumberMAX1;$a++)
		 { 
			 ##draw synteny block
			 #reference vs query
			 if($a<$chromosomenumberMIN1)
			 {
				open FL,"$inputFile";
				while(<FL>){
					 chomp;
					 my @tem = split /\t/;
					 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
					 {
						 my $translocation_X=0;
						 my $translocation_num=0;
						 my $match_XXXA=0;
						 if($tem[11] eq $Chrname1[$a])
						 {			 
							 for(my $m2a=0;$m2a<$chromosomenumber2;$m2a++)
							 {			 	
								 if($tem[12] eq $Chrname2[$m2a])
								 {
									 $translocation_num=$m2a;
									 if($sort_query_pm{$Chrname2[$m2a]} eq '-'){$tem[2]=$chr_length2{$Chrname2[$m2a]}-$tem[2]+1;$tem[3]=$chr_length2{$Chrname2[$m2a]}-$tem[3]+1;}
									 $match_XXXA=1;
								 }
							 }
							 if($translocation_num==$a)
							 {$translocation_X=0;}
							 elsif($a>$translocation_num)
							 {
								 for(my $m2b=$translocation_num;$m2b<$a;$m2b++)
								 {
									 $translocation_X-=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
								}
							}
							 else
							 {
								 for(my $m2b=$a;$m2b<$translocation_num;$m2b++)
								 {
									 $translocation_X+=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
								}
							}
							 if($match_XXXA==1)
							 {
								 my $x1 = $tem[2]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
								 my $y1 = $margin_m2y+$margin_m2y_comparison-0.5;
								 my $x2 = $tem[3]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
								 my $y2 = $margin_m2y+$margin_m2y_comparison-0.5;
								 my $x3 = $tem[0]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
								 my $y3 = $margin_m2y+80+0.5;
								 my $x4 = $tem[1]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
								 my $y4 = $margin_m2y+80+0.5;
								 my $x24=$x2;
								 my $y24=($y2+$y4)/2;
								 my $x42=$x4;
								 my $y42=$y24;
								 my $x31=$x3;
								 my $y31=($y1+$y3)/2;
								 my $x13=$x1;
								 my $y13=($y1+$y3)/2;
								 if(!$curveto)
								{
									 if(($translocation_X!=0) and $highlighttranslocation)
									 {
										 $svg2->polygon(
											 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
											 style=>{
												 'fill'=>"$translocation_color",
												 'stroke'=>"$translocation_color",
												 'stroke-width'=>'0.01',
												 'stroke-opacity'=>'0.2',
												 'fill-opacity'=>'0.2',
											}
										);
									}
									 else
									 {
										 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
										{
											 $svg2->polygon(
												 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
												 style=>{
													 'fill'=>"$inversion_color",
													 'stroke'=>"$inversion_color",
													 'stroke-width'=>'0.1',
													 'stroke-opacity'=>'0.7',
													 'fill-opacity'=>'0.7',
												}
											);
										}
										 else 
										 {
											 $svg2->polygon(
												 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
												 style=>{
													 'fill'=>"rgb(223,223,225)",
													 'stroke'=>"rgb(223,223,225)",
													 'stroke-width'=>'0.1',
													 'stroke-opacity'=>'0.7',
													 'fill-opacity'=>'0.7',
												}
											);
										}	
									}
								}
								 else
								{
									 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
									 if(($translocation_X!=0) and $highlighttranslocation)
									 {
										 $svg2->path(
											 d => $path,
											 fill=> "$translocation_color",
											 stroke=>"$translocation_color",
											 'stroke-width'=>'0.01',
											 'stroke-opacity'=>'0.2',
											 'fill-opacity'=>'0.2',
										);
									}
									else
									 {
										 
										 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
										 {
											 $svg2->path(
												 d => $path,
												 fill=> "$inversion_color",
												 stroke=>"$inversion_color",
												 'stroke-width'=>'2',
												 'stroke-opacity'=>'0.7',
												 'fill-opacity'=>'0.7',
											);
										}
										 else 
										 {
											 $svg2->path(
												 d => $path,
												 fill=> "$synteny_color",
												 stroke=>"$synteny_color",
												 'stroke-width'=>'0.1',
												 'stroke-opacity'=>'0.4',
												 'fill-opacity'=>'0.4',
											);
										}	
									}
								} 
							}	
						}

					}
				}
				close FL;
			}
			 
			 if($a<$chromosomenumber)
			 {

				 ####reference chromosome
				 my $width_ref_m2=$chr_length{$Chrname1[$a]}/$proportion_m2;
				 $svg2->rect(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, 
					 y=>$margin_m2y,
					 width=>$width_ref_m2, height=>80,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'40',
						 'ry'=>'40',
						 'stroke-width'=>'1',
					}
				);
				
				 if($a==0)
				 {
					 $svg2->text(
						 x=>50,#$margin_m2x/3-$maxChrlong*55-25, 
						 y=>$margin_m2y+35+33.5,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}	
					)->cdata("$refname");
				}
				 $svg2->text(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, 
					 y=>$margin_m2y+35+33.5,
					 style=>{
						 'fill'=>'white',
						 'font-size'=>'80'
						}
					
				)->cdata("$outChrname1[$a]");			 
			}
			 
			 if($a<$chromosomenumber2)
			 {

				####query chromosome
				 my $width_ref_m2=$chr_length2{$Chrname2[$a]}/$proportion_m2;
				 $svg2->rect(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, 
					 y=>$margin_m2y+$margin_m2y_comparison,
					 width=>$width_ref_m2, height=>80,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'40',
						 'ry'=>'40',
						 'stroke-width'=>'1',
					}
				);
				 if($a==0)
				 {
					 $svg2->text(
						 x=>50,#$margin_m2x/3-$maxChrlong*55-25, 
						 y=>$margin_m2y+$margin_m2y_comparison+35+33.5,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}	
					)->cdata("$queryname");
				}
				 $svg2->text(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, 
					 y=>$margin_m2y+$margin_m2y_comparison+35+33.5,
					 style=>{
						 'fill'=>'white',
						 'font-size'=>'80',
					}
				)->cdata("$outChrname2[$a]");		
			}	
			 $main2x+=$ChrLength_genome_max[$a]/$proportion_m2;
			 $genome_long1+=($ChrLength_genome_max[$a]/$proportion_m2+$margin_m2x_interval);
		}
		
	}
	elsif($genomenumber==3)
	{
		 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
		 { 
			 ##draw synteny block
			 #reference vs query2
			 if($a<$chromosomenumber)
			 {
				 open FL2,"$inputFile2";
				 while(<FL2>){
					 chomp;
					 my @tem = split /\t/;
					 if($tem[4] >= $synteny_limit and $tem[6] >= $coverage_limit)
					 {
						 my $translocation_X=0;
						 my $translocation_num=-1;#0;
						 my $match_XXXA=0;
						 if($tem[11] eq $Chrname1[$a])
						 {			 
							 for(my $m2a=0;$m2a<$chromosomenumber3;$m2a++)
							 {
								 if($tem[12] eq $Chrname3[$m2a])
								 {
									 $translocation_num=$m2a;
									 if($sort_query_pm_3geonme{$Chrname3[$m2a]} eq '-'){$tem[2]=$chr_length3{$Chrname3[$m2a]}-$tem[2]+1;$tem[3]=$chr_length3{$Chrname3[$m2a]}-$tem[3]+1;}
									 $match_XXXA=1;
								}
							}
							 if($translocation_num!=-1)
							 {
								 if($translocation_num==$a)
								 {$translocation_X=0;}
								 elsif($a>$translocation_num)
								 {
									 for(my $m2b=$translocation_num;$m2b<$a;$m2b++)
									 {
										 $translocation_X-=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
									}
								}
								elsif($a<$translocation_num)
								 {
									 for(my $m2b=$a;$m2b<$translocation_num;$m2b++)
									 {
										 $translocation_X+=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
									}
								}
								 if($match_XXXA==1)
								 {
									 my $x1 = $tem[2]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
									 my $y1 = $margin_m2y+$margin_m2y_comparison*2-0.5;
									 my $x2 = $tem[3]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
									 my $y2 = $margin_m2y+$margin_m2y_comparison*2-0.5;
									 my $x3 = $tem[0]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
									 my $y3 = $margin_m2y+$margin_m2y_comparison+80+0.5;
									 my $x4 = $tem[1]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
									 my $y4 = $margin_m2y+$margin_m2y_comparison+80+0.5;
									 my $x24=$x2;
									 my $y24=($y2+$y4)/2;
									 my $x42=$x4;
									 my $y42=$y24;
									 my $x31=$x3;
									 my $y31=($y1+$y3)/2;
									 my $x13=$x1;
									 my $y13=($y1+$y3)/2;
									 if(!$curveto)
									{
										 if(($translocation_X!=0) and $highlighttranslocation)
										 {
											 $svg2->polygon(
												 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
												 style=>{
													 'fill'=>"$translocation_color",
													 'stroke'=>"$translocation_color",
													 'stroke-width'=>'0.8',#0.01
													 'stroke-opacity'=>'0.2',#0.2
													 'fill-opacity'=>'0.2',#0.2
												}
											);
										}
										 else
										 {
											 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
											{
												 $svg2->polygon(
													 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
													 style=>{
														 'fill'=>"$inversion_color",
														 'stroke'=>"$inversion_color",
														 'stroke-width'=>'0.1',
														 'stroke-opacity'=>'0.7',
														 'fill-opacity'=>'0.7',
													}
												);
											}
											 else 
											 {
												 $svg2->polygon(
													 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
													 style=>{
														 'fill'=>"rgb(223,223,225)",
														 'stroke'=>"rgb(223,223,225)",
														 'stroke-width'=>'0.1',
														 'stroke-opacity'=>'0.7',
														 'fill-opacity'=>'0.7',
													}
												);
											}	
										}
									}
									 else
									{
										 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
										 if(($translocation_X!=0) and $highlighttranslocation)
										 {
											 $svg2->path(
												 d => $path,
												 fill=> "$translocation_color",
												 stroke=>"$translocation_color",
												 'stroke-width'=>'0.8',#0.01
												 'stroke-opacity'=>'0.2',#0.2
												 'fill-opacity'=>'0.2',#0.2
											);
										}
										else
										 {
											 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
											 {
												 $svg2->path(
													 d => $path,
													 fill=> "$inversion_color",
													 stroke=>"$inversion_color",
													 'stroke-width'=>'2',
													 'stroke-opacity'=>'0.7',
													 'fill-opacity'=>'0.7',
												);
											}
											 else 
											 {
												 $svg2->path(
													 d => $path,
													 fill=> "$synteny_color",
													 stroke=>"$synteny_color",
													 'stroke-width'=>'0.1',
													 'stroke-opacity'=>'0.4',
													 'fill-opacity'=>'0.4',
												);
											}	
										}
									} 
								}
							}	
						}
					}
				}
				close FL2;
			}

			 ###
			##draw synteny block
			 #reference vs query1
			 if($a<$chromosomenumber)
			 {
				 open FL,"$inputFile";
				 while(<FL>){
					 chomp;
					 my @tem = split /\t/;
					 if($tem[4] >=$synteny_limit and $tem[6] >= $coverage_limit)
					 {
						 my $translocation_X=0;
						 my $translocation_num=-1;#0;
						 if($tem[11] eq $Chrname1[$a])
						 {			 
							 for(my $m2a=0;$m2a<$chromosomenumber2;$m2a++)
							 {
								 if($tem[12] eq $Chrname2[$m2a])
								 {
									 $translocation_num=$m2a;
									 if($sort_query_pm{$Chrname2[$m2a]} eq '-'){$tem[2]=$chr_length2{$Chrname2[$m2a]}-$tem[2]+1;$tem[3]=$chr_length2{$Chrname2[$m2a]}-$tem[3]+1;}
								}
							}
							 if($translocation_num!=-1)
							 {
								 if($translocation_num==$a)
								 {$translocation_X=0;}
								 elsif($a>$translocation_num)
								 {
									 for(my $m2b=$translocation_num;$m2b<$a;$m2b++)
									 {
										 $translocation_X-=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
									}
								}
								else
								 {
									 for(my $m2b=$a;$m2b<$translocation_num;$m2b++)
									 {
										 $translocation_X+=($ChrLength_genome_max_proportion[$m2b]+$margin_m2x_interval);
									}
								}
								 my $x1 = $tem[2]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
								 my $y1 = $margin_m2y+80+0.5;
								 my $x2 = $tem[3]/$proportion_m2+$margin_m2x+$translocation_X+$main2x+$margin_m2x_interval*$a;
								 my $y2 = $margin_m2y+80+0.5;
								 my $x3 = $tem[0]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
								 my $y3 = $margin_m2y+$margin_m2y_comparison-0.5;
								 my $x4 = $tem[1]/$proportion_m2+$margin_m2x+$main2x+$margin_m2x_interval*$a;
								 my $y4 = $margin_m2y+$margin_m2y_comparison-0.5;
								 my $x24=$x2;
								 my $y24=($y2+$y4)/2;
								 my $x42=$x4;
								 my $y42=$y24;
								 my $x31=$x3;
								 my $y31=($y1+$y3)/2;
								 my $x13=$x1;
								 my $y13=($y1+$y3)/2;
								 if(!$curveto)
								{
									 if(($translocation_X!=0) and $highlighttranslocation)
									 {
										 $svg2->polygon(
											 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
											 style=>{
												 'fill'=>"$translocation_color",
												 'stroke'=>"$translocation_color",
												 'stroke-width'=>'0.8',#0.01
												 'stroke-opacity'=>'0.2',#0.2
												 'fill-opacity'=>'0.2',#0.2
											}
										);
									}
									 else
									 {
										 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
										{
											 $svg2->polygon(
												 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
												 style=>{
													 'fill'=>"$inversion_color",
													 'stroke'=>"$inversion_color",
													 'stroke-width'=>'0.1',
													 'stroke-opacity'=>'0.7',
													 'fill-opacity'=>'0.7',
												}
											);
										}
										 else 
										 {
											 $svg2->polygon(
												 points=>"$x1,$y1 $x2,$y2 $x4,$y4 $x3,$y3",
												 style=>{
													 'fill'=>"rgb(223,223,225)",
													 'stroke'=>"rgb(223,223,225)",
													 'stroke-width'=>'0.1',
													 'stroke-opacity'=>'0.7',
													 'fill-opacity'=>'0.7',
												}
											);
										}	
									}
								}
								 else
								{
									 my $path = "M$x1,$y1 L$x2,$y2 C$x24,$y24 $x42,$y42 $x4,$y4 L$x3,$y3 C$x31,$y31 $x13,$y13 $x1,$y1 Z";
									 if(($translocation_X!=0) and $highlighttranslocation)
									 {
										 $svg2->path(
											 d => $path,
											 fill=> "$translocation_color",
											 stroke=>"$translocation_color",
											 'stroke-width'=>'0.8',#0.01
											 'stroke-opacity'=>'0.2',#0.2
											 'fill-opacity'=>'0.2',#0.2
										);
									}
									else
									 {
										 if( $tem[2]>$tem[3] and ( abs($tem[2]-$tem[3])>=$Inversion_limit ) and $highlightinversion)
										 {
											 $svg2->path(
												 d => $path,
												 fill=> "$inversion_color",
												 stroke=>"$inversion_color",
												 'stroke-width'=>'2',
												 'stroke-opacity'=>'0.7',
												 'fill-opacity'=>'0.7',
											);
										}
										 else 
										 {
											 $svg2->path(
												 d => $path,
												 fill=> "$synteny_color",
												 stroke=>"$synteny_color",
												 'stroke-width'=>'0.1',
												 'stroke-opacity'=>'0.4',
												 'fill-opacity'=>'0.4',
											);
										}	
									}
								} 
							}	
						}
					}
				}
				close FL;
			}
			 $main2x+=$ChrLength_genome_max[$a]/$proportion_m2;
		}
		 $main2x=0;
		 for(my $a=0;$a<$chromosomenumberMAX3;$a++)
		 { 
			 if($a<$chromosomenumber)
			 {
				 ####reference chromosome
				 my $width_ref_m2=$chr_length{$Chrname1[$a]}/$proportion_m2;
				 $svg2->rect(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y+$margin_m2y_comparison,
					 width=>$width_ref_m2, height=>80,
					 style=>{
						 'fill'=>"$reference_color",
						 'stroke'=>'black',
						 'rx'=>'40',
						 'ry'=>'40',
						 'stroke-width'=>'1',
					}
				);
				 if($a==0)
				 {
					 $svg2->text(
						 x=>50,#$margin_m2x-$maxChrlong*55-25, 
						 y=>$margin_m2y+$margin_m2y_comparison+35+33.5,#-25
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}	
					)->cdata("$refname");
				}
				 $svg2->text(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y+$margin_m2y_comparison+35+33.5,
					 style=>{
						 'fill'=>'white',
						 'font-size'=>'80'
						}
				)->cdata("$outChrname1[$a]");			 
			}
			 
			 if($a<$chromosomenumber2)
			 {
				####query1 chromosome
				 my $width_ref_m2=$chr_length2{$Chrname2[$a]}/$proportion_m2;
				 $svg2->rect(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y,
					 width=>$width_ref_m2, height=>80,
					 style=>{
						 'fill'=>"$query1_color",
						 'stroke'=>'black',
						 'rx'=>'40',
						 'ry'=>'40',
						 'stroke-width'=>'1',
					}
				);
				 if($a==0)
				 {
					 $svg2->text(
						 x=>50,#$margin_m2x-$maxChrlong*55-25,
						 y=>$margin_m2y+35+33.5,#-25
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}	
					)->cdata("$queryname");			
				}
				 $svg2->text(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y+35+33.5,
					 style=>{
						 'fill'=>'white',					 
						 'font-size'=>'80',
					}
				)->cdata("$outChrname2[$a]");		
			}
			 if($a<$chromosomenumber3)
			 {
				 ####query2  chromosome
				 my $width_ref_m2=$chr_length3{$Chrname3[$a]}/$proportion_m2;
				 $svg2->rect(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y+$margin_m2y_comparison*2,
					 width=>$width_ref_m2, height=>80,
					 style=>{
						 'fill'=>"$query2_color",
						 'stroke'=>'black',
						 'rx'=>'40',
						 'ry'=>'40',
						 'stroke-width'=>'1',
					}
				);
				 if($a==0)
				 {
					 $svg2->text(
						 x=>50,#$margin_m2x-$maxChrlong*55-25,
						 y=>$margin_m2y+$margin_m2y_comparison*2+35+33.5,#-25
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}	
					)->cdata("$queryname2");
				}
				 $svg2->text(
					 x=>$margin_m2x+$main2x+$margin_m2x_interval*$a, y=>$margin_m2y+$margin_m2y_comparison*2+35+33.5,
					 style=>{
						 'fill'=>'white',					 
						 'font-size'=>'80',
					}
				)->cdata("$outChrname3[$a]");		
			}	
			 $main2x+=$ChrLength_genome_max[$a]/$proportion_m2;
			 $genome_long1+=($ChrLength_genome_max[$a]/$proportion_m2+$margin_m2x_interval);
		}	
	}
     if($icon==1)
	 {	    
		 my $icon2_high=80;
		 my $icon2_wide=500;
		 my $icon2_test_w=260;
		 my $icon2_test_h=50+15;
		 my $icon2_w_move=15;	
		 my $icon2_h_move=150;			 
		 my $icon2_x=$m2_wideaa-$margin_m2x_interval;#$margin_m2x+$m2_Xoverlength-$margin_m2x_interval;
		 my $icon2_y=$margin_m2y-$icon2_high-$icon2_h_move;	
		 my $icon2_y_h=$margin_m2y_comparison/2;
		##synteny bolck legend 
		if($m2_iconaa==1)
		 {
			 if($highlighttranslocation and $translocation_iconaa)
			 {
				 $svg2->rect(
					 x=>$icon2_x-$icon2_wide,
					 y=>$icon2_y,
					 width=>$icon2_wide, height=>$icon2_high,
					 style=>{
						 'fill'=>"$translocation_color",
						 'stroke'=>'black',
						 'stroke-width'=>'0',
					}
				);
				 $icon2_x=$icon2_x-$icon2_wide-$icon2_w_move;
				 my $tujie_name='Translocation';
				 $svg2->text(
					 x=>$icon2_x-length($tujie_name)*48, 
					 y=>$icon2_y+$icon2_test_h,
					 style=>{
					     'font-family'=>"Courier",
						 'stroke'=>'none',
						 'font-size'=>'80',
					}
				)->cdata($tujie_name);
				 $icon2_x=$icon2_x-length($tujie_name)*48-$icon2_w_move*2;
			}
			 if($inversion_iconaa)
			 {

				 $svg2->rect(
					 x=>$icon2_x-$icon2_wide,
					 y=>$icon2_y,
					 width=>$icon2_wide, height=>$icon2_high,
					 style=>{
						 'fill'=>"$inversion_color",
						 'stroke'=>'black',
						 'stroke-width'=>'0',
					}
				);
				 $icon2_x=$icon2_x-$icon2_wide-$icon2_w_move;
				 my $tujie_name='Inversion';
				 $svg2->text(
					 x=>$icon2_x-length($tujie_name)*48, 
					 y=>$icon2_y+$icon2_test_h,
					 style=>{
					     'font-family'=>"Courier",
						 'stroke'=>'none',
						 'font-size'=>'80',
					}
				)->cdata($tujie_name);
				 $icon2_x=$icon2_x-length($tujie_name)*48-$icon2_w_move*2;
			}
			 if($synteny_iconaa)
			 {
				 $svg2->rect(
					 x=>$icon2_x-$icon2_wide,
					 y=>$icon2_y,
					 width=>$icon2_wide, height=>$icon2_high,
					 style=>{
						 'fill'=>"$synteny_color",
						 'stroke'=>'black',
						 'stroke-width'=>'0',
					}
				);			
				 $icon2_x=$icon2_x-$icon2_wide-$icon2_w_move;			
				 my $tujie_name='Synteny';
				 $svg2->text(
					 x=>$icon2_x-length($tujie_name)*48, 
					 y=>$icon2_y+$icon2_test_h,
					 style=>{
					     'font-family'=>"Courier",
						 'stroke'=>'none',
						 'font-size'=>'80',
					}
				)->cdata($tujie_name);
				 $icon2_x=$icon2_x-length($tujie_name)*48-$icon2_w_move*2;
			}
		}
		elsif($m2_iconaa==0)
		 {
			 #$icon2_x=$m2_wideaa-$margin_m2x_interval;
			 $icon2_y=$margin_m2y;#
			 if($genomenumber==2)
			 {
				 if($synteny_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$synteny_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);					
					 my $tujie_name='Synteny';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					 $icon2_y=$icon2_y+$icon2_y_h;
				}
				 if($inversion_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$inversion_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);
					 my $tujie_name='Inversion';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					 $icon2_y=$icon2_y+$icon2_y_h;
				}
	             if($highlighttranslocation and $translocation_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$translocation_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);
					 my $tujie_name='Translocation';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					 $icon2_y=$icon2_y+$icon2_y_h;
				}
			}
			elsif($genomenumber==3)
			 {
			     $icon2_y=$margin_m2y+$margin_m2y_comparison;#
				 $icon2_y_h=$margin_m2y_comparison/2;
				 if($synteny_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$synteny_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);					
					 my $tujie_name='Synteny';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					$icon2_y=$icon2_y+$icon2_y_h;
				}
				 if($inversion_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$inversion_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);
					 my $tujie_name='Inversion';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					 $icon2_y=$icon2_y+$icon2_y_h;
				}
	             if($highlighttranslocation and $translocation_iconaa)
				 {
					 $svg2->rect(
						 x=>$genome_long1,#$icon2_x-$icon2_wide,
						 y=>$icon2_y,
						 width=>$icon2_wide, height=>$icon2_high,
						 style=>{
							 'fill'=>"$translocation_color",
							 'stroke'=>'black',
							 'stroke-width'=>'0',
						}
					);
					 my $tujie_name='Translocation';
					 $svg2->text(
						 x=>$genome_long1+$icon2_wide+$icon2_w_move,#$icon2_x-length($tujie_name)*48-$icon2_wide-$icon2_w_move, 
						 y=>$icon2_y+$icon2_test_h,
						 style=>{
						     'font-family'=>"Courier",
							 'stroke'=>'none',
							 'font-size'=>'80',
						}
					)->cdata($tujie_name);
					 $icon2_y=$icon2_y+$icon2_y_h;
				}
			}
		}
	}
}

#outfile1
if( ($aligntype==1) or ($aligntype==3) )
{
	 open main1,">$output1";
	 my $out1 = $svg->xmlify();
	 print main1 "$out1\n";
	 close main1;
	 #print "\nRefresh chrome!\n";
}

#outflie2
if( ($aligntype==2) or ($aligntype==3) )
{
	 open main2,">$output2";
	 my $out2 = $svg2->xmlify();
	 print main2 "$out2\n";
	 close main2;
	 #print "Refresh chrome!\n";
}
if($illustration==1)
{
	 #outflie3
	 open illustration1,">$output3";
	 my $out3 = $svg3->xmlify();
	 print illustration1 "$out3\n";
	 close illustration1;
	 #print "Refresh chrome!\n";

	 #outfile4
	 open illustration2,">$output4";
	 my $out4 = $svg4->xmlify();
	 print illustration2 "$out4\n";
	 close illustration2;
	 #print "Refresh chrome!\n";

	 #outflie5
	 open illustration3,">$output5";
	 my $out5 = $svg5->xmlify();
	 print illustration3 "$out5\n";
	 close illustration3;
	 #print "Refresh chrome!\n";
}	
if($svg_pdf==1)
{
	 if( ($aligntype==1) or ($aligntype==3) )
	 {	 
		 if((substr($output1,-4,4) eq ".svg") or (substr($output1,-4,4) eq ".SVG"))
		 {
			 my $name_svg_num1=length($output1)-4;
			 my $name_svg_out1=substr($output1,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
	}
     if( ($aligntype==2) or ($aligntype==3) )
     {	 
		 if((substr($output2,-4,4) eq ".svg") or (substr($output2,-4,4) eq ".SVG"))
		 {
			 my $name_svg_num1=length($output2)-4;
			 my $name_svg_out1=substr($output2,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
	}	
	 if($illustration==1)
	 {
		 if((substr($output3,-4,4) eq ".svg") or (substr($output3,-4,4) eq ".SVG"))
		 {
			 my $name_svg_num1=length($output3)-4;
			 my $name_svg_out1=substr($output3,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
		 if((substr($output4,-4,4) eq ".svg") or (substr($output4,-4,4) eq ".SVG"))
		 {
			 my $name_svg_num1=length($output4)-4;
			 my $name_svg_out1=substr($output4,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
		 if((substr($output5,-4,4) eq ".svg") or (substr($output5,-4,4) eq ".SVG"))
		 {
			 my $name_svg_num1=length($output5)-4;
			 my $name_svg_out1=substr($output5,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
		 if( ($genomenumber==3) and($heatmap2_type==1) and ((substr($output6,-4,4) eq ".svg") or (substr($output6,-4,4) eq ".SVG")) )
		 {
			 my $name_svg_num1=length($output6)-4;
			 my $name_svg_out1=substr($output6,0,$name_svg_num1);
			 system("$pwd_python $pwd_svg_pdf '$name_svg_out1'");
		}
	}
}

print"\nRefresh chrome!\n";
print"\n";


###############################################################################
# Help Documentation
###############################################################################

=head1 NAME

GenomeSyn --- Draw two/three genomes synteny blocks.

=head1 SYNOPSIS

GenomeSyn [options]

example:
    
    a) GenomeSyn -g1 ../data/rice_MH63.fa -g2 ../data/rice_ZS97.fa

    b) GenomeSyn -t 3 -g1 ../data/rice_MH63.fa -g2 ../data/rice_ZS97.fa -cf1 ../data/rice_MH63vsZS97.delta.filter.coords

    c) GenomeSyn -t 3 -g1 ../data/rice_MH63.fa -g2 ../data/rice_ZS97.fa -cf1 ../data/rice_MH63vsZS97.delta.filter.coords -cen1 ../data/rice_MH63_centromere.bed -cen2 ../data/rice_ZS97_centromere.bed -tel1 ../data/rice_MH63_telomere.bed -tel2 ../data/rice_ZS97_telomere.bed -TE1 ../data/rice_MH63_repeat.bed -TE2 ../data/rice_ZS97_repeat.bed -PAV1 ../data/rice_MH63_PAV.bed -PAV2 ../data/rice_ZS97_PAV.bed -NLR1 ../data/rice_MH63_NLR.bed -NLR2 ../data/rice_ZS97_NLR.bed -r MH63 -q ZS97 -GD1 ../data/rice_MH63_nonTEgene.gff3 -GD2 ../data/rice_ZS97_nonTEgene.gff3 -GC1 ../data/rice_MH63_GC_10000.bed -GC2 ../data/rice_ZS97_GC_10000.bed -GC_win 100000 -TE_min 40

    d) GenomeSyn -t 3 -n3 12 -g1 ../data/rice_MH63.fa -g2 ../data/rice_ZS97.fa -g3 ../data/rice_R498.fasta -cf1 ../data/rice_MH63vsZS97.delta.filter.coords -cf2 ../data/rice_MH63vsR498.delta.filter.coords -cen1 ../data/rice_MH63_centromere.bed -cen2 ../data/rice_ZS97_centromere.bed -cen3 ../data/rice_R498_centromere.bed -tel1 ../data/rice_MH63_telomere.bed -tel2 ../data/rice_ZS97_telomere.bed -tel3 ../data/rice_R498_telomere.bed -TE2 ../data/rice_ZS97_repeat.bed -PAV1 ../data/rice_MH63_PAV.bed -PAV2 ../data/rice_ZS97_PAV.bed -NLR1 ../data/rice_MH63_NLR.bed -NLR2 ../data/rice_ZS97_NLR.bed -r MH63 -q1 ZS97 -q2 R498 -GD1 ../data/rice_MH63_nonTEgene.gff3 -GD2 ../data/rice_ZS97_nonTEgene.gff3 -GD3 ../data/rice_R498_IGDBv3_coreset.gff -GC2 ../data/rice_ZS97_GC_10000.bed -GC_win 100000 -TE_min 40

=head1 OPTIONS

=over 8

=item B<-aligntype/-at/-t>

The output mode is divided into four output modes, the parameter value is 1/2/3/4, and the default value is 1; When the value is 1, only the one-to-one double/triple sequence comparison chart will be output; when the value is 2, only the multiple-to-multiple double/triple sequence comparison chart will be output; when the value is 3, it will output simultaneously in 1, 2 mode Two comparison graphs of; when the value is 4, in addition to the first two comparison graphs, some statistical sub-graphs will be generated, such as consistency heat map, consistency histogram, and coverage histogram.

=item B<-genomeSeq1/-g1>

Input the genome1 fasta file to obtain the length of each chromosome in the genome1(ie reference genome).

=item B<-genomeSeq2/-g2>

Input the genome2 fasta file to obtain the length of each chromosome in the genome2(ie query genome).

=item B<-genomeSeq3/-g3>

Input the genome3 fasta file to obtain the length of each chromosome in the genome3(ie query genome2).

=item B<-comparison_file/-comparison_file1/-cf/-cf1>

Input the coordinate file for comparing genome1 and genome2, if there is no coordinate file, call mummer to compare genome1 and genome2 to generate this coordinate file, such as ReferencevsQuery1.delta.filter.coords.

=item B<-comparison_file2/-cf2>

Input the coordinate file for comparing genome1 and genome3, if there is no coordinate file, call mummer to compare genome1 and genome3 to generate this coordinate file, such as ReferencevsQuery2.delta.filter.coords.

=item B<-comparison_file3/-cf3>

Input the coordinate file for comparing genome2 and genome3, if there is no coordinate file, call mummer to compare genome2 and genome3 to generate this coordinate file, such as Query1vsQuery2.delta.filter.coords.

=item B<-SVG_PDF/-pdf>

Format transition, generate the corresponding PDF format file with the SVG format file as the original, value is 1/0, default true(1), that is default output SVG format and PDF format files are output at the same time.

=item B<-sort>

The -sort parameter has two modes, "match" and "reference_length_match", which are not sorted by default. "match" mode function: according to the chromosome number of the reference, the chromosome number of the query is sorted for the best match; "reference_length_match" mode function: first sort the reference chromosome numbers according to the chromosome length from long to short, and then sort the query chromosome numbers according to the best match.

=item B<-chromosomename/-cn>

Chromosome numeration setting, the value is 1/0, and the default value is false (0); when the value is 0, the unified chromosome numeration(Chromosome numeration for reference genome) will be displayed on the output map, and when the value is 1, the actual chromosome numeration in the comparison file will be displayed on the output map.

=item B<-referencename/-reference/-ref/-r>

Set the name of the genome1, default output is "reference".eg. MH63

=item B<-queryname/-queryname1/-query/-query1/-q/-q1>

Set the name of the genome2, default output is "query"/"query1".eg. ZS97

=item B<-queryname2/-query2/-q2>

Set the name of the genome3, default output is "query2".eg. R498

=item B<-centromere_genome1/-centromere1/-cen1>

Input the centromere position file of genome1, the file uses the bed (Browser Extensible Data) format, and draw centromeres on each chromosome of genome1.

=item B<-centromere_genome2/-centromere2/-cen2>

Input the centromere position file of genome2, the file uses the bed (Browser Extensible Data) format, and draw centromeres on each chromosome of genome2.

=item B<-centromere_genome3/-centromere3/-cen3>

Input the centromere position file of genome3, the file uses the bed (Browser Extensible Data) format, and draw centromeres on each chromosome of genome3.

=item B<-telomere_genome1/-telomere1/-tel1>

Input the telomere position file of genome1, the file uses the bed format, and draw telomere on each chromosome of genome1.

=item B<-telomere_genome2/-telomere2/-tel2>

Input the telomere position file of genome2, the file uses the bed format, and draw telomere on each chromosome of genome2.

=item B<-telomere_genome3/-telomere3/-tel3>

Input the telomere position file of genome3, the file uses the bed format, and draw telomere on each chromosome of genome3.

=item B<-snp_genome1/-snp1>

Input the SNP file of genome1, which uses the bed format to map the SNP distribution of genome1.

=item B<-snp_genome2/-snp2>

Input the SNP file of genome2, which uses the bed format to map the SNP distribution of genome2.

=item B<-snp_genome3/-snp3>

Input the SNP file of genome3, which uses the bed format to map the SNP distribution of genome3.

=item B<-snp_thresholds/-snp_max>

SNP threshold setting, that is, setting the upper limit of SNP statistics, the default value is 2000.

=item B<-TE_genome1/-TE1>

Input the TE file of genome1, which uses the bed format to map the TE distribution of genome1.

=item B<-TE_genome2/-TE2>

Input the TE file of genome2, which uses the bed format to map the TE distribution of genome2.

=item B<-TE_genome3/-TE3>

Input the TE file of genome3, which uses the bed format to map the TE distribution of genome3.

=item B<-TE_thresholds/-TE_min>

Set the TE threshold that set the lower limit of TE statistics, default the integer value of the smallest TE proportion in the TE file used is the lower limit, for example, the minimum TE is 11%, the icon in the lower right corner shows a scale of 10%-100%, the minimum TE is 28%, and the icon in the lower right corner shows a scale of 20%-100%; if the user inputs the lower limit of TE, it will be output according to the lower limit of TE input by the user, and the value is 0-100. For example: input "-TE_min 50", then a 50%-100% TE statistical graph will be drawn, TE has two display forms, but only when TE is displayed in a histogram, the lower limit of TE can be adjusted.

=item B<-GC_genome1/-GC_content1/-GC1>

Input the bed format file of the GC content of genome1 to plot the distribution of the GC content of genome1.

=item B<-GC_genome2/-GC_content2/-GC2>

Input the bed format file of the GC content of genome2 to plot the distribution of the GC content of genome2.

=item B<-GC_genome3/-GC_content3/-GC3>

Input the bed format file of the GC content of genome2 to plot the distribution of the GC content of genome3.

=item B<-PAV_genome1/-PAV1>

Input the PAV file of genome1, which uses the bed format to map the PAV distribution of genome1.

=item B<-PAV_genome2/-PAV2>

Input the PAV file of genome2, which uses the bed format to map the PAV distribution of genome2.

=item B<-PAV_genome3/-PAV3>

Input the PAV file of genome3, which uses the bed format to map the PAV distribution of genome3.

=item B<-NLR_genome1/-NLR1>

Input the NLR file of genome1, which uses the bed format to map the NLR distribution of genome1.

=item B<-NLR_genome2/-NLR2>

Input the NLR file of genome2, which uses the bed format to map the NLR distribution of genome2.

=item B<-NLR_genome3/-NLR3>

Input the NLR file of genome3, which uses the bed format to map the NLR distribution of genome3.

=item B<-gene_density_genome1/-GD1>

Input the annotation file of genome1, which uses the gff3 format to map the gene density distribution of genome1.

=item B<-gene_density_genome2/-GD2>

Input the annotation file of genome2, which uses the gff3 format to map the gene density distribution of genome2.

=item B<-gene_density_genome3/-GD3>

Input the annotation file of genome3, which uses the gff3 format to map the gene density distribution of genome3.

=item B<-GeneDensity_Window/-GD_win>

Set the window size for statistical gene density, this parameter is a required parameter when the gene density is counted in the annotation file of the input gene, the value can be set to 100000.

=item B<-SNP_Window/-SNP_win>

Set the window size for statistical SNPs, this parameter is optional, its value is determined by default according to the window size in the bed file of the input SNP of genome1.

=item B<-TE_Window/-TE_win>

Set the window size for statistical TEs, this parameter is optional, its value is determined by default according to the window size in the bed file of the input TEs of genome1.

=item B<-GC_Content_Window/-GC_win>

Set the window size for statistical GC content, this parameter is optional, its value is determined by default according to the window size in the bed file of the input GC content of genome1.

=item B<-synteny_length_min/-synteny_min/-syn_min>

Set the minimum length for drawing synteny fragments, the default value is 10000.

=item B<-inversion_length_min/-inversion_min/-inv_min>

Set the minimum length for drawing inversion fragments, the default value is 10000.

=item B<-PAV_length_min/-PAV_min>

Set the minimum length for drawing PAV, the default value is 10000.

=item B<-NLR_length_min/-NLR_min>

Set the minimum length for drawing NLR, the default value is 10000.

=item B<-coverage_rate_min/-coverage_min/-cov_min>

Set the minimum coverage (%) for drawing synteny fragments, the default value is 90.

=item B<-icon>

Whether to output the main image icon, value is 1/0, default true(1).

=item B<-proportion1/-p1>

Set the chromosome window size of the one-to-one double/triple sequence alignment chart, the default value is chromosome_length/1800.

=item B<-proportion2/-p2>

Set the chromosome window size of the multiple-to-multiple double/triple sequence alignment chart, the default value is four times the value of -proportion1/-p1, the default value is chromosome_length/450.

=item B<-targetgene_genome1/-targetgene1/-gene1>

Input the target gene file of genome 1, the file uses the bed format, the target gene can be any gene that the user studies.

=item B<-targetgene_genome2/-targetgene2/-gene2>

Input the target gene file of genome 2, the file uses the bed format, the target gene can be any gene that the user studies.

=item B<-targetgene_genome3/-targetgene3/-gene3>

Input the target gene file of genome 3, the file uses the bed format, the target gene can be any gene that the user studies.

=item B<-targetgene_name/-targetgene>

Set the name of the target gene, default output as "Target Gene".

=item B<-genomenumber/-gn/-n>

Comparison mode, double/triple sequence comparison, this parameter is optional, the parameter value can be set to 2/3,the value is determined by the number of input genomes by default, that is, when two genomes are input, the value is 2, and when three genomes are input, the value is 3.

=item B<-chromosomenumber/-n1>

Set the number of chromosomes in genome1,this parameter is optional, and its value is determined by the number of chromosomes in the fasta file of the input genome1 by default, or it can be set by users.eg. 12

=item B<-chromosomenumber2/-n2>

Set the number of chromosomes in genome2,this parameter is optional, and its value is determined by the number of chromosomes in the fasta file of the input genome2 by default, or it can be set by users.eg. 12

=item B<-chromosomenumber3/-n3>

Set the number of chromosomes in genome3,this parameter is optional, and its value is determined by the number of chromosomes in the fasta file of the input genome3 by default, or it can be set by users.eg. 12

=item B<-output1/-o1>

Set the name of output SVG format file1, default "GenomeSyn-main-1.svg".

=item B<-output2/-o2>

Set the name of output SVG format file2, default "GenomeSyn-main-2.svg".

=item B<-output3/-o3>

Set the name of output SVG format file3, default "GenomeSyn heatmap.svg".

=item B<-output4/-o4>

Set the name of output SVG format file4, default "GenomeSyn identity.svg".

=item B<-output5/-o5>

Set the name of output SVG format file5, default "GenomeSyn coverage.svg".

=item B<-output6/-o6>

Set the name of output SVG format file6, default "GenomeSyn heatmap2.svg".

=item B<-headline_identity/-headline1>

Set the title of illustration1, default output is "GenomeSyn identity".

=item B<-headline_coverage/-headline2>

Set the title of illustration2, default output is "GenomeSyn coverage".

=item B<-headline_heatmap/-headline3>

Set the title of illustration3, default output is "GenomeSyn heatmap".

=item B<-genome1_color/-color1/-c1>

Set the drawing color of the chromosome in genome1,default color is LightBlue (#3979BC), recommended to input in hexadecimal color code or RGB code, eg. "#3979BC"/"rgb(57,121,188)".

=item B<-genome2_color/-color2/-c2>

Set the drawing color of the chromosome in genome2,default color is Green(#499272), recommended to input in hexadecimal color code or RGB code, eg. "#499272"/"rgb(73,146,114)".

=item B<-genome3_color/-color3/-c3>

Set the drawing color of the chromosome in genome3, default color is DarkBlue(#447784), recommended to input in hexadecimal color code or RGB code, eg. "#447784"/"rgb(68,119,132)".

=item B<-synteny_color/-color4/-c4>

Set the drawing color of the synteny blocks, default color is LightGray(#DFDFE1), recommended to input in hexadecimal color code or RGB code, eg. "#DFDFE1"/"rgb(223,223,225)".

=item B<-inversion_color/-color5/-c5>

Set the drawing color of the inversion blocks, default color is DarkOrange(#E56C1A), recommended to input in hexadecimal color code or RGB code, eg. "#E56C1A"/"rgb(229,108,26)".

=item B<-translocation_color/-color6/-c6>

Set the drawing color of the translocation blocks, default color is Saffron(#EFCF48), recommended to input in hexadecimal color code or RGB code, eg. "#EFCF48"/"rgb(239,207,72)".

=item B<-centromere_color/-color7/-c7>

Set the drawing color of the centromere blocks, default color is Orange(#E4993F), recommended to input in hexadecimal color code or RGB code, eg. "#E4993F"/"rgb(228,153,63)".

=item B<-telomere_color/-color8/-c8>

Set the drawing color of the telomere blocks, default color is Purple(#441680), recommended to input in hexadecimal color code or RGB code, eg. "#441680"/"rgb(68,22,128)".

=item B<-PAV_color/-color9/-c9>

Set the drawing color of PAVs, default color is LightYellow(#F9F067), recommended to input in hexadecimal color code or RGB code, eg. "#F9F067"/"rgb(249,240,103)".

=item B<-NLR_color/-color10/-c10>

Set the drawing color of the NLRs, default color is Cyan(#00FFFF), recommended to input in hexadecimal color code or RGB code, eg. "#00FFFF"/"rgb(0,255,255)".

=item B<-SNP_color/-color11/-c11>

Set the drawing color of the SNPs, default color is DoderBlue(#1E90FF), recommended to input in hexadecimal color code or RGB code, eg. "#1E90FF"/"rgb(30,144,255)".

=item B<-TE_color/-color12/-c12>

Set the drawing color of the TEs, default color is DoderBlue(#1E90FF), recommended to input in hexadecimal color code or RGB code, eg. "#1E90FF"/"rgb(30,144,255)". TE has two forms of display, when it is displayed as a histogram only, the drawing color of TE can be adjusted.

=item B<-genedensity_color/-color13/-c13>

Set the drawing color of the gene density, default color is DarkGreen(#368F5C), recommended to input in hexadecimal color code or RGB code, eg. "#368F5C"/"rgb(54,143,92)".

=item B<-targetgene_color/-color14/-c14>

Set the drawing color of the target gene, default color is Crimson(#DC143C), recommended to input in hexadecimal color code or RGB code, eg. "#DC143C"/"rgb(220,20,60)".

=item B<-curveto/-curve>

Draw synteny blocks with curve or straight line, value is 1/0, default true(1), that is default output as a curve.

=item B<-highlightinversion/-highlight>

Highlight inversion, value is 1/0, default true(1), that is default the inverted information is highlighted.

=item B<-help/-h/?>

Print a brief help message and exits.

=item B<-man>

Prints the manual page and exits.

=back

=head1 DESCRIPTION

B<GenomeSyn> Draw two/three genomes synteny blocks.

=cut
