#! /usr/bin/perl -w
#
# ./replicate_design.pl nstructure shift
#
#  inputs
#  nstructure: # of structures to be generated
#       shift: from a given structure (e.g. n for T_n)     
#  output
#  it generates directories each containing a nucleosome
#  structure accommdating a local sequence.

$nfile      =  $ARGV[0];
$shift      =  $ARGV[1];
$file_num   =  "00000"; 
$seq_dir        = "sequences/";  # path to sequences
$build_DNA_base = "./build_DNA_base.pl"; # needs a path to script if not in '.'    
$nuc_base    = "./nuc_base_r_theta_phi"; # needs a path to script if not in '.' 
$template    = "./1kx5_DNA_with_plane.pdb"; # needs a path to backbone if not in '.'

for ($i=1;$i<=$shift;$i++) {$file_num ++;}
for ($i=1;$i<=$nfile;$i++) {
   $file_num++;
   $seq_file_name = $seq_dir."SEQ_".$file_num.".dat";
   $dir_name  = "1kx5_".$file_num;
   $pdb_name  = "1kx5_DNA.pdb";
   system("mkdir $dir_name");
   system("$build_DNA_base $nuc_base $template $seq_file_name > $pdb_name");
   system("mv $pdb_name $dir_name");
}#endfor#
