Switch the go_cds script from tcsh to bash
Former-commit-id: 36041f96b5bb1411a4ac6fecccfbc24b9b90baff Former-commit-id: 6e63fdff4022a2bb895a44eb6009f41d049ba4ae
This commit is contained in:
@ -1,115 +0,0 @@
|
|||||||
#!/usr/bin/env tcsh -f
|
|
||||||
#
|
|
||||||
# Annotate CDS
|
|
||||||
#
|
|
||||||
#========================================================================================
|
|
||||||
#
|
|
||||||
# Annotate CDS
|
|
||||||
#
|
|
||||||
# go_cds.sh <FASTAFILE>
|
|
||||||
#
|
|
||||||
# - <FASTAFILE> : The fasta file containing the genome to annotate
|
|
||||||
#
|
|
||||||
# Results are printed to the standard output
|
|
||||||
#
|
|
||||||
#========================================================================================
|
|
||||||
# usage: go_cds.sh fasta [db_root]
|
|
||||||
#
|
|
||||||
unsetenv ORG_SOURCED
|
|
||||||
|
|
||||||
setenv ORG_HOME `dirname $0`/../../..
|
|
||||||
source $ORG_HOME/scripts/csh_init.sh
|
|
||||||
|
|
||||||
NeedArg 1
|
|
||||||
|
|
||||||
set Fasta = $Argv[1]; Shift
|
|
||||||
|
|
||||||
NeedFile $Fasta
|
|
||||||
|
|
||||||
set Genome = `basename $Fasta:r`
|
|
||||||
|
|
||||||
set DbRoot = $CDS_DATA_DIR/chlorodb
|
|
||||||
|
|
||||||
if ($#Argv > 0) then
|
|
||||||
set DbRoot = $Argv[1]; Shift
|
|
||||||
endif
|
|
||||||
|
|
||||||
NeedDir $DbRoot/core
|
|
||||||
NeedFile $DbRoot/core/Annot.lst
|
|
||||||
|
|
||||||
NeedDir $DbRoot/models
|
|
||||||
|
|
||||||
#
|
|
||||||
# run everything into temporary place
|
|
||||||
#
|
|
||||||
|
|
||||||
set temp = `hostname`.$$.Genome.tmp
|
|
||||||
if (! -d $temp) then
|
|
||||||
Notify "making directory $temp"
|
|
||||||
mkdir $temp
|
|
||||||
endif
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
pushd $temp >& /dev/null
|
|
||||||
ln -s $AbsGenoFile genome.fasta
|
|
||||||
popd >& /dev/null
|
|
||||||
|
|
||||||
set Fasta = $temp/genome.fasta
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# pass1: run exonerate
|
|
||||||
#
|
|
||||||
|
|
||||||
foreach dir ("core" "shell" "dust")
|
|
||||||
if (-d $DbRoot/$dir) then
|
|
||||||
set fams = `ls $DbRoot/$dir/*.clean.fst`
|
|
||||||
Notify "running pass1:$dir exonerate of $Genome on $DbRoot"
|
|
||||||
foreach f ($fams)
|
|
||||||
tcsh -f $PROG_DIR/do_exonerate.csh $Fasta $f $DbRoot/models $temp
|
|
||||||
end
|
|
||||||
endif
|
|
||||||
end
|
|
||||||
|
|
||||||
cp $temp/genome.cds.fasta $Genome.cds.fasta
|
|
||||||
|
|
||||||
#
|
|
||||||
# pass2: transsplicing
|
|
||||||
#
|
|
||||||
|
|
||||||
$PROG_DIR/do_rps12.sh $Fasta > $temp/$Genome.rps12.res
|
|
||||||
|
|
||||||
#
|
|
||||||
# pass3: prokov
|
|
||||||
#
|
|
||||||
|
|
||||||
# $PROG_DIR/do_prokov.sh $Fasta $Genome.cds.fasta $temp
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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
|
|
110
detectors/cds/bin/go_cds.sh
Executable file
110
detectors/cds/bin/go_cds.sh
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Annotate CDS
|
||||||
|
#
|
||||||
|
#========================================================================================
|
||||||
|
#
|
||||||
|
# Annotate CDS
|
||||||
|
#
|
||||||
|
# go_cds.sh <FASTAFILE> [DBROOT]
|
||||||
|
#
|
||||||
|
# - <FASTAFILE> : The fasta file containing the genome to annotate
|
||||||
|
# - [DBROOT] : optionnal argument allowing to specify database directory
|
||||||
|
#
|
||||||
|
# Results are printed to the standard output
|
||||||
|
#
|
||||||
|
#========================================================================================
|
||||||
|
# usage: go_cds.sh fasta [db_root]
|
||||||
|
#
|
||||||
|
|
||||||
|
# -- CAUTION -- Works as long than the script
|
||||||
|
# is not called through a symlink
|
||||||
|
THIS_DIR="$(dirname ${BASH_SOURCE[0]})"
|
||||||
|
source "${THIS_DIR}/../../../scripts/bash_init.sh"
|
||||||
|
|
||||||
|
needarg 1
|
||||||
|
|
||||||
|
Fasta=$1; shift
|
||||||
|
|
||||||
|
needfile $Fasta
|
||||||
|
|
||||||
|
# Genome names is set from the base
|
||||||
|
# name of the genome file without its extension
|
||||||
|
Genome=$(basename ${Fasta%.*})
|
||||||
|
|
||||||
|
# DbRoot is set to its default values except
|
||||||
|
# if the second argument precise another DbRoot
|
||||||
|
|
||||||
|
DbRoot="$CDS_DATA_DIR/chlorodb"
|
||||||
|
|
||||||
|
if (( $# > 0)) ; then
|
||||||
|
DbRoot="$1"; Shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
needdir $DbRoot
|
||||||
|
needdir $DbRoot/core
|
||||||
|
needfile $DbRoot/core/Annot.lst
|
||||||
|
needdir $DbRoot/models
|
||||||
|
|
||||||
|
assignundef cdsdetection_pass1 yes
|
||||||
|
assignundef cdsdetection_pass2 yes
|
||||||
|
|
||||||
|
temp=$(mktempdir $(hostname))
|
||||||
|
|
||||||
|
AbsGenoFile=$(getAbsolutePath $Fasta)
|
||||||
|
pushd $temp >& /dev/null
|
||||||
|
ln -s $AbsGenoFile genome.fasta
|
||||||
|
popd >& /dev/null
|
||||||
|
|
||||||
|
Fasta="$temp/genome.fasta"
|
||||||
|
|
||||||
|
#
|
||||||
|
# pass1: run exonerate
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ "$cdsdetection_pass1" == "yes" ]] ; then
|
||||||
|
for dir in "core" "shell" "dust" ; do
|
||||||
|
if [[ -d $DbRoot/$dir ]] ; then
|
||||||
|
fams=$(ls $DbRoot/$dir/*.clean.fst)
|
||||||
|
loginfo "running pass1:$dir exonerate of $Genome on $DbRoot"
|
||||||
|
for f in $fams ; do
|
||||||
|
tcsh -f $PROG_DIR/do_exonerate.csh $Fasta $f $DbRoot/models $temp
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cp $temp/genome.cds.fasta $Genome.cds.fasta
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# pass2: transsplicing
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ "$cdsdetection_pass2" == "yes" ]] ; then
|
||||||
|
$PROG_DIR/do_rps12.sh $Fasta $temp
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# pass3: prokov
|
||||||
|
#
|
||||||
|
|
||||||
|
# $PROG_DIR/do_prokov.sh $Fasta $Genome.cds.fasta $temp
|
||||||
|
|
||||||
|
#
|
||||||
|
# end : output on stdout
|
||||||
|
#
|
||||||
|
|
||||||
|
cat $temp/*.res
|
||||||
|
|
||||||
|
# cleanup everything
|
||||||
|
|
||||||
|
assignundef TMP_CLEANUP 1
|
||||||
|
|
||||||
|
if (( $TMP_CLEANUP != 0 )) ; then
|
||||||
|
loginfo " cleanup $temp"
|
||||||
|
(\rm -r $temp) >& /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
@ -25,8 +25,16 @@ function getAbsolutePath {
|
|||||||
|
|
||||||
# Manage temp directory
|
# Manage temp directory
|
||||||
|
|
||||||
function pushTmpDir {
|
function mktempdir {
|
||||||
|
local TMP_DIR
|
||||||
TMP_DIR=$(mktemp -d -t "$1_proc_$$_XXXXXX")
|
TMP_DIR=$(mktemp -d -t "$1_proc_$$_XXXXXX")
|
||||||
|
logdebug "Creating temp directory $TMP_DIR"
|
||||||
|
echo $TMP_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushTmpDir {
|
||||||
|
local TMP_DIR
|
||||||
|
TMP_DIR=$(mktempdir "$1")
|
||||||
pushd $TMP_DIR >& /dev/null
|
pushd $TMP_DIR >& /dev/null
|
||||||
TMP_DIR_STACK="$TMP_DIR $TMP_DIR_STACK"
|
TMP_DIR_STACK="$TMP_DIR $TMP_DIR_STACK"
|
||||||
logdebug "Pushing temp directory $TMP_DIR"
|
logdebug "Pushing temp directory $TMP_DIR"
|
||||||
@ -34,8 +42,9 @@ function pushTmpDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function popTmpDir {
|
function popTmpDir {
|
||||||
TMP_DIR=$(echo $TMP_DIR_STACK | $AwkCmd '{print $1}')
|
local TMP_DIR
|
||||||
TMP_DIR_STACK=$(echo $TMP_DIR_STACK | $AwkCmd '{$1="";print $0}')
|
TMP_DIR=$($AwkCmd '{print $1}' <<< $TMP_DIR_STACK)
|
||||||
|
TMP_DIR_STACK=$($AwkCmd '{$1="";print $0}' <<< $TMP_DIR_STACK)
|
||||||
popd >& /dev/null
|
popd >& /dev/null
|
||||||
rm -rf $TMP_DIR >& /dev/null
|
rm -rf $TMP_DIR >& /dev/null
|
||||||
logdebug "Poping temp directory $TMP_DIR"
|
logdebug "Poping temp directory $TMP_DIR"
|
||||||
@ -86,6 +95,42 @@ function logdebug {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Asserts that the number of arguments passed to the script
|
||||||
|
# is at least equal to the first argument of the function.
|
||||||
|
#
|
||||||
|
# needarg 3
|
||||||
|
#
|
||||||
|
# requires that the script is called at least with 3 arguments
|
||||||
|
#
|
||||||
|
__ORG_ANNOT_ARGS_SCRIPT_COUNT__=$#
|
||||||
|
function needarg {
|
||||||
|
if (( $__ORG_ANNOT_ARGS_SCRIPT_COUNT__ < $1 )) ; then
|
||||||
|
logerror "not enougth arguments provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function needfile {
|
||||||
|
if [[ ! -e $1 ]] ; then
|
||||||
|
logerror "File $1 doesn't exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function needdir {
|
||||||
|
if [[ ! -d $1 ]] ; then
|
||||||
|
logerror "Directory $1 doesn't exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function assignundef {
|
||||||
|
local value=$(eval echo \${$1+x})
|
||||||
|
if [[ -z "$value" ]] ; then
|
||||||
|
eval $1=$2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Sequence related functions
|
# Sequence related functions
|
||||||
|
|
||||||
# Counts how many sequences are stored in a fasta file
|
# Counts how many sequences are stored in a fasta file
|
||||||
|
Reference in New Issue
Block a user