#!/bin/csh
# copy
# script for copying peaklists and prot file to cyana subdir
# and then copying the dir over to remote server 
# 
# usage: copy <old dir> <new dir> <remote server (optional)>      
#        Use a value of 0 for old dir if copying over to server only
#
if ($#argv == 2) then
   set olddir=$argv[1]
   set newdir=$argv[2]
else if ($#argv == 3) then      
   set olddir=$argv[1]
   set newdir=$argv[2]
   set remote=$argv[3]
else
  echo
  echo "missing an argument! - terminating"
  echo "Usage: copy <old dir> <new dir> <remote server>"
  echo
  exit
endif

if ($olddir == 0) then
  if ($remote =~ elgar) then
   scp -rp $newdir elgar:/data/elgar/cesg/at1g16640/8cyana
  else if ($remote =~ cesg) then
   scp -rp $newdir cesg:/u/volkman/at1g16640/8cyana
  else
    echo
    echo "Unknown remote server - terminating"
  exit
  endif
else
     
#if ($newdir =~ b* && $remote = cesg) then
#   echo
#   echo "new directory name does not match server!"
#   echo
#   exit
#else if ($newdir =~ c* && $remote = elgar) then
#   echo
#   echo "new directory name does not match server!"
#   echo
#   exit
#endif
      
echo "== copying $olddir to $newdir"
cp -r $olddir $newdir

echo "== removing old files"
cd $newdir
rm *.peaks*
rm *.prot*
clean.csh
cd ..

echo "== copying over peaklists and prot file"
cp ../6noesy/c13ar/c13ar.peaks ./$newdir
cp ../6noesy/c13no/c13no.peaks ./$newdir
cp ../6noesy/n15no/n15no.peaks ./$newdir
cp ../6noesy/at1g16640.prot ./$newdir
#cp ../6noesy/at1g16640.aco ./$newdir

if ($#argv == 3) then
  if ($remote =~ elgar) then
   scp -rp $newdir elgar:/data/elgar/cesg/at1g16640/8cyana
  else if ($remote =~ cesg) then
   scp -rp $newdir cesg:/u/volkman/at1g16640/8cyana
  else
    echo
    echo "Unknown remote server - terminating"
  exit
  endif
else
  exit
endif

endif

exit



