<commit_before>#!/usr/bin/perl -w

use strict;
use GD;
use Getopt::Long;
use CoGeX;
use DBI;
use Data::Dumper;
use DBI;
use POSIX;

use vars qw($dagfile $alignfile $width $link $min_chr_size $dsgid1 $dsgid2 $help $coge $graphics_context $CHR1 $CHR2 $basename $link_type $flip $grid $ks_db $ks_type $log $MAX $MIN $assemble $axis_metric $color_type $box_diags $fid1 $fid2 $selfself);


GetOptions(
	   "dagfile|d=s"=>\$dagfile, #all dots
	   "alignfile|a=s"=>\$alignfile, #syntenic dots
	   "width|w=i"=>\$width,
	   "link|l=s"=>\$link,
	   "link_type|lt=i"=>\$link_type,
	   "min_chr_size|mcs=i"=>\$min_chr_size,
	   "dsgid1|dsg1=i"=>\$dsgid1,
	   "dsgid2|dsg2=i"=>\$dsgid2,
	   "help|h" =>\$help,
	   "chr1|c1=s"=>\$CHR1,
	   "chr2|c2=s"=>\$CHR2,
	   "basename|b=s"=>\$basename,
	   "flip|f=i"=>\$flip,
	   "grid|g=i"=>\$grid,
	   "ksdb|ks_db=s"=>\$ks_db,
	   "ks_type|kst=s"=>\$ks_type, 
	   "color_diags_type|cdt=s"=>\$color_type, #how to color diagonals
	                                         #NOTE this is trumped by ksdb and the diag dots will be colored according to ks_type
	   "max=s"=>\$MAX,
	   "min=s"=>\$MIN,
	   "log=s"=>\$log,
	   "assemble=s"=>\$assemble,
	   "axis_metrix|am=s"=>\$axis_metric,
	   "box_diags|bd=i"=>\$box_diags,
	   "fid1|f1=i"=>\$fid1,
	   "fid2|f2=i"=>\$fid2,
	   "selfself" => \$selfself, #draw diag for self self comparison
	   );
$selfself = 1 unless defined $selfself;


usage() if $help;
usage() unless -r $dagfile;

#set a default for this, make sure it is uppercase
$ks_type = "kS" unless $ks_type;
$ks_type = uc($ks_type) if $ks_type;

my $ks_hist = "/opt/apache/CoGe/bin/ks_histogram.pl";

$basename = "test" unless $basename;
$width = 1024 unless $width;

$coge = CoGeX->dbconnect();



my ($org1_order, $org2_order) = parse_syn_blocks(file=>$alignfile) if $assemble;

my $skip_non_ordered = $assemble && $assemble == 2 ? 1 : 0;
my $org1info = get_dsg_info(dsgid=>$dsgid1, chr=>$CHR1, minsize=>$min_chr_size, order=>$org1_order, metric=>$axis_metric, skip_non_ordered=>$skip_non_ordered);
my $org1length =0;
map {$org1length+=$_->{length}} values %$org1info;
my $org2info = get_dsg_info(dsgid=>$dsgid2, chr=>$CHR2, minsize=>$min_chr_size, order=>$org2_order, metric=>$axis_metric, skip_non_ordered=>$skip_non_ordered);
my $org2length =0;
map {$org2length+=$_->{length}} values %$org2info;
($org1info, $org1length, $dsgid1, $org2info, $org2length, $dsgid2) = ($org2info, $org2length, $dsgid2, $org1info, $org1length, $dsgid1) if $flip;
($CHR1, $CHR2) = ($CHR2, $CHR1) if $flip && ($CHR1 || $CHR2);
my $height = sprintf("%.0f", $width*$org2length/$org1length);
$height = $width if ($height > 20*$width) || ($height <  $width/20);
my $x_bp_per_pix = $org1length/$width; #sprintf("%.0f", $org1length/$width);
#$x_bp_per_pix = 1 if $x_bp_per_pix < 1;
my $x_pix_per_bp = 1/$x_bp_per_pix;
my $y_bp_per_pix = $org2length/$height;#sprintf("%.0f", $org2length/$height);
#$y_bp_per_pix = 1 if $y_bp_per_pix < 1;<commit_msg>no change<commit_after>#!/usr/bin/perl -w

use strict;
use GD;
use Getopt::Long;
use CoGeX;
use DBI;
use Data::Dumper;
use DBI;
use POSIX;

use vars qw($dagfile $alignfile $width $link $min_chr_size $dsgid1 $dsgid2 $help $coge $graphics_context $CHR1 $CHR2 $basename $link_type $flip $grid $ks_db $ks_type $log $MAX $MIN $assemble $axis_metric $color_type $box_diags $fid1 $fid2 $selfself);


GetOptions(
	   "dagfile|d=s"=>\$dagfile, #all dots
	   "alignfile|a=s"=>\$alignfile, #syntenic dots
	   "width|w=i"=>\$width,
	   "link|l=s"=>\$link,
	   "link_type|lt=i"=>\$link_type,
	   "min_chr_size|mcs=i"=>\$min_chr_size,
	   "dsgid1|dsg1=i"=>\$dsgid1,
	   "dsgid2|dsg2=i"=>\$dsgid2,
	   "help|h" =>\$help,
	   "chr1|c1=s"=>\$CHR1,
	   "chr2|c2=s"=>\$CHR2,
	   "basename|b=s"=>\$basename,
	   "flip|f=i"=>\$flip,
	   "grid|g=i"=>\$grid,
	   "ksdb|ks_db=s"=>\$ks_db,
	   "ks_type|kst=s"=>\$ks_type, 
	   "color_diags_type|cdt=s"=>\$color_type, #how to color diagonals
	                                         #NOTE this is trumped by ksdb and the diag dots will be colored according to ks_type
	   "max=s"=>\$MAX,
	   "min=s"=>\$MIN,
	   "log=s"=>\$log,
	   "assemble=s"=>\$assemble,
	   "axis_metrix|am=s"=>\$axis_metric,
	   "box_diags|bd=i"=>\$box_diags,
	   "fid1|f1=i"=>\$fid1,
	   "fid2|f2=i"=>\$fid2,
	   "selfself" => \$selfself, #draw diag for self self comparison
	   );
$selfself = 1 unless defined $selfself;


usage() if $help;
usage() unless -r $dagfile;

#set a default for this, make sure it is uppercase
$ks_type = "kS" unless $ks_type;
$ks_type = uc($ks_type) if $ks_type;

my $ks_hist = "/opt/apache/CoGe/bin/ks_histogram.pl";

$basename = "test" unless $basename;
$width = 1024 unless $width;

$coge = CoGeX->dbconnect();



my ($org1_order, $org2_order) = parse_syn_blocks(file=>$alignfile) if $assemble;

my $skip_non_ordered = $assemble && $assemble == 2 ? 1 : 0;
my $org1info = get_dsg_info(dsgid=>$dsgid1, chr=>$CHR1, minsize=>$min_chr_size, order=>$org1_order, metric=>$axis_metric, skip_non_ordered=>$skip_non_ordered);
my $org1length =0;
map {$org1length+=$_->{length}} values %$org1info;
my $org2info = get_dsg_info(dsgid=>$dsgid2, chr=>$CHR2, minsize=>$min_chr_size, order=>$org2_order, metric=>$axis_metric, skip_non_ordered=>$skip_non_ordered);
my $org2length =0;
map {$org2length+=$_->{length}} values %$org2info;

($org1info, $org1length, $dsgid1, $org2info, $org2length, $dsgid2) = ($org2info, $org2length, $dsgid2, $org1info, $org1length, $dsgid1) if $flip;
($CHR1, $CHR2) = ($CHR2, $CHR1) if $flip && ($CHR1 || $CHR2);
my $height = sprintf("%.0f", $width*$org2length/$org1length);
$height = $width if ($height > 20*$width) || ($height <  $width/20);
my $x_bp_per_pix = $org1length/$width; #sprintf("%.0f", $org1length/$width);
#$x_bp_per_pix = 1 if $x_bp_per_pix < 1;
my $x_pix_per_bp = 1/$x_bp_per_pix;
my $y_bp_per_pix = $org2length/$height;#sprintf("%.0f", $org2length/$height);
#$y_bp_per_pix = 1 if $y_bp_per_pix < 1;
{'fraction_non_alphanumeric': 0.19969589457678663, 'fraction_numerical': 0.029058962662611928, 'mean_word_length': 4.949748743718593, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6300339', 'n_tokens_mistral': 2797, 'n_tokens_neox': 2637, 'n_words': 496}