go_cds.csh 2.02 KB
Newer Older
1
#!/usr/bin/env tcsh -f
alain viari's avatar
alain viari committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
#                           Annotate CDS 
#
#========================================================================================
#
#  Annotate CDS
#
#  go_cds.sh <FASTAFILE>
#
#		- <FASTAFILE> : The fasta file containing the genome to annotate
#
#  Results are printed to the standard output
#
#========================================================================================
Alain Viari's avatar
Alain Viari committed
16
# usage: go_cds.sh fasta [db_root]
alain viari's avatar
alain viari committed
17
#
alain viari's avatar
alain viari committed
18
unsetenv ORG_SOURCED
alain viari's avatar
alain viari committed
19 20 21 22 23 24

setenv ORG_HOME `dirname $0`/../../..
source $ORG_HOME/scripts/csh_init.sh

NeedArg 1

alain viari's avatar
alain viari committed
25
set Fasta = $Argv[1]; Shift
alain viari's avatar
alain viari committed
26 27 28 29 30

NeedFile $Fasta

set Genome = `basename $Fasta:r`

Alain Viari's avatar
Alain Viari committed
31
set DbRoot = $CDS_DATA_DIR/chlorodb
alain viari's avatar
alain viari committed
32 33

if ($#Argv > 0) then
Alain Viari's avatar
Alain Viari committed
34
  set DbRoot = $Argv[1]; Shift
alain viari's avatar
alain viari committed
35 36
endif

Alain Viari's avatar
Alain Viari committed
37 38 39 40
NeedDir $DbRoot/core
NeedFile $DbRoot/core/Annot.lst

NeedDir $DbRoot/models
alain viari's avatar
alain viari committed
41 42 43 44 45

#
# run everything into temporary place
#

46
set temp = `hostname`.$$.Genome.tmp
alain viari's avatar
alain viari committed
47 48 49 50 51
if (! -d $temp) then
  Notify "making directory $temp"
  mkdir $temp
endif

52 53 54 55 56 57 58 59 60 61 62 63 64
#
# find the absolute path of the fasta genome file
#
echo $Fasta | grep '^/' > /dev/null
if ( $status == 1 ) then
	set AbsGenoFile = `pwd`/$Fasta
	set DirGenoFile = `dirname $AbsGenoFile`
	set DirGenoFile = `(cd $DirGenoFile;pwd)`
	set AbsGenoFile = $DirGenoFile/`basename $AbsGenoFile`
else
	set AbsGenoFile = $Fasta
endif

65
pushd $temp >& /dev/null
66
ln -s $AbsGenoFile genome.fasta
67
popd >& /dev/null
68 69 70 71

set Fasta = $temp/genome.fasta


alain viari's avatar
alain viari committed
72 73 74 75
#
# pass1: run exonerate
#

Alain Viari's avatar
Alain Viari committed
76 77
foreach dir ("core" "shell" "dust")
  if (-d $DbRoot/$dir) then
78
    set fams = `ls $DbRoot/$dir/*.clean.fst`
Alain Viari's avatar
Alain Viari committed
79 80
    Notify "running pass1:$dir exonerate of $Genome on $DbRoot"
    foreach f ($fams)
81
      tcsh -f $PROG_DIR/do_exonerate.csh $Fasta $f $DbRoot/models $temp
Alain Viari's avatar
Alain Viari committed
82 83
    end
  endif
alain viari's avatar
alain viari committed
84 85
end

86
cp $temp/genome.cds.fasta $Genome.cds.fasta 
87

alain viari's avatar
alain viari committed
88 89 90 91 92 93 94 95
#
# pass2: transsplicing
#

#
# pass3: prokov
#

96
# $PROG_DIR/do_prokov.sh $Fasta $Genome.cds.fasta $temp
97

alain viari's avatar
alain viari committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
#
# end : output on stdout
#

cat $temp/*.res

# cleanup everything

AssignUndef TMP_CLEANUP 1

if ($TMP_CLEANUP != 0) then
  Notify "  cleanup $temp"
  (\rm -r $temp) >& /dev/null
endif

Exit 0