#!/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 =~ dale) then
 	echo "== copying directory to dale"
   scp -rp $newdir dale:/user/francis/znf42/8cyana
  else if ($remote =~ cesg) then
   echo "== copying directory to cesg"
   scp -rp $newdir cesg:/u/francis/znf42/8cyana
  else if ($remote =~ brock) then
   echo "== copying directory to brock"
   scp -rp $newdir brock:/user/francis/znf42/8cyana
  else
    echo
    echo "Unknown remote server - terminating"
  exit
  endif
else
     
echo "== copying $olddir to $newdir"
cp -r $olddir $newdir

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

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

if ($#argv == 3) then
  if ($remote =~ dale) then
   echo "== copying directory to dale"
   scp -rp $newdir dale:/user/francis/znf42/8cyana
  else if ($remote =~ cesg) then
   echo "== copying directory to cesg"
   scp -rp $newdir cesg:/u/francis/znf42/8cyana
  else if ($remote =~ brock) then
   echo "== copying directory to brock"
   scp -rp $newdir brock:/user/francis/znf42/8cyana
  else
    echo
    echo "Unknown remote server - terminating"
  exit
  endif
else
  exit
endif

endif

exit





