#!/usr/bin/perl -w
# 
require $ENV{'CYCLIZE_HOME'}."lib/cyclize_lib.pl";

# Build the cyclize parameters hash
%cyclize_parameters = (
	"whole_chains"     => 1e8,
	"nrad_stats"       => 1e7,
	"icalcs"           => 100,
	"radial_cutoff"    => 60,
	"axial_cutoff"     => 40,
	"torsional_cutoff" => 36,
	"nkeepers"         => 10,
);

# Set the default values for generating the DNA
$Temp       = 300;
$nnuc       = 156;

# Build the parameter hashes defined below
&build_parameter_hashes; 

# The positions of the A-tracts
@atract_positions = ( 25..30, 36..41, 46..51, 57..62, 67..72, 78..82 );

# Create the generic sequence, with nts named "B"
# and fill the sequence with standard Bform parameters
%seq = &create_sequence( B, $nnuc );
%seq = &fill_params( \%seq, \%BDNA );

# Change the name of the nts in the A-tract sites to "A"
# and fill these regions with A-tract parameters
%seq = &fill_name( \%seq, "A", @atract_positions );
%seq = &fill_Atract_params( \%seq, \%Atract, \%Atract_3, \%Atract_5 );

for $repeat ( 1 ) {
	&Cyclize( \%seq, \%cyclize_parameters, "atract_example_$repeat" );
}

exit;

############################################################
# build_parameters_hashes
# 
# USAGE: 
# &build_parameter_hashes;
#
# -This subroutine initialize the defaults for the "parameter hashes" used
#  to construct the "sequence hash".  
# -A single parameter hash contains six keys: tilt, tilt_flex, roll,
#  roll_flex, twist and twist_flex.
############################################################
sub build_parameter_hashes {

	#####################################################
	# BDNA site parameter definitions
	$BDNA_tormod         = 2.4e-19; # torsional modulus (erg*cm)
	$BDNA_rpb            = 3.4e-8;  # rise/bp (cm)
	$BDNA_helical_repeat = 10.45;   # helical repeat (bp/360 degrees)

	%BDNA = (
		tilt       => 0,
		roll       => 0,
		twist      => 360/$BDNA_helical_repeat,
		tilt_flex  => 4.842,
		roll_flex  => 4.842,
		twist_flex => sqrt( $BDNA_rpb*$k*$Temp/$BDNA_tormod ) * 180/$PI,
		dz         => 3.4,
	);

#####################################################
# Atract site parameter definitions
$Atract_tormod         = 2.4e-19; # torsional modulus (erg*cm)
$Atract_rpb            = 3.4e-8;  # rise/bp (cm)
$Atract_helical_repeat = 10.33;   # helical repeat (bp/360 degrees)

# Default Atract values for middle of Atract region
%Atract = (
        tilt       => 0,        
        roll       => 0,        
        twist      => 360/$Atract_helical_repeat,
        tilt_flex  => 4.842,
        roll_flex  => 4.842,
        twist_flex => sqrt( $Atract_rpb*$k*$Temp/$Atract_tormod ) * 180/$PI,
        dz         => 3.4,
);
$Atract{min} = 4;       # minimum number of A's in Atract
$Atract{max} = 6;       # maximum number of A's in Atract

# Default Atract values for 5' junction of Atract
%Atract_5 = (
        tilt       => -7.7,
        roll       => 4.6,   
        twist      => 360/$Atract_helical_repeat,
        tilt_flex  => 4.842,
        roll_flex  => 4.842,
        twist_flex => sqrt( $Atract_rpb*$k*$Temp/$Atract_tormod )*180/$PI,
        dz         => 3.4,
);

# Default Atract values for 3' junction
%Atract_3 = (
        tilt       => 9.7,
        roll       => 0,
        twist      => 360/$Atract_helical_repeat,
        tilt_flex  => 4.842,
        roll_flex  => 4.842,
        twist_flex => sqrt( $Atract_rpb*$k*$Temp/$Atract_tormod )*180/$PI,
        dz         => 3.4,
);
}
