Commit 7e3ddd41 by Eric Coissac

Add a patch for chloroplast annotation when no inverted repeats are

detected
parent bba6581b
......@@ -29,35 +29,37 @@ pushTmpDir ORG.ir
loginfo " --> $genome_length bp"
loginfo "Done"
IR=( $(lookForIR ${QUERY}) )
posIR1=${IR[4]}
posIR2=${IR[6]}
let "lenIR= ( ${IR[5]} + ${IR[7]} ) / 2 "
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
IRDetected=1
IR=( $(lookForIR ${QUERY}) ) || IRDetected=0
beginLSC=1
let "endLSC=$posIR1-1"
let "beginSSC=$endIR1+1"
let "endSSC=$posIR2-1"
if (( IRDetected == 1 )) ; then
posIR1=${IR[4]}
posIR2=${IR[6]}
let "lenIR= ( ${IR[5]} + ${IR[7]} ) / 2 "
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
beginLSC=1
let "endLSC=$posIR1-1"
echo "FT misc_feature ${beginLSC}..${endLSC}"
echo "FT /note=\"large single copy region (LSC)\""
echo "FT repeat_region ${posIR1}..${endIR1}"
echo "FT /rpt_type=INVERTED"
echo "FT /note=\"left inverted repeat B; IRB\""
echo "FT misc_feature ${beginSSC}..${endSSC}"
echo "FT /note=\"small single copy region (SSC)\""
echo "FT repeat_region ${posIR2}..${endIR2}"
echo "FT /rpt_type=INVERTED"
echo "FT /note=\"left inverted repeat A; IRA\""
let "beginSSC=$endIR1+1"
let "endSSC=$posIR2-1"
echo "FT misc_feature ${beginLSC}..${endLSC}"
echo "FT /note=\"large single copy region (LSC)\""
echo "FT repeat_region ${posIR1}..${endIR1}"
echo "FT /rpt_type=INVERTED"
echo "FT /note=\"left inverted repeat B; IRB\""
echo "FT misc_feature ${beginSSC}..${endSSC}"
echo "FT /note=\"small single copy region (SSC)\""
echo "FT repeat_region ${posIR2}..${endIR2}"
echo "FT /rpt_type=INVERTED"
echo "FT /note=\"left inverted repeat A; IRA\""
fi
popTmpDir
......
......@@ -41,128 +41,134 @@ pushTmpDir ORG.normalize
loginfo " --> $genome_length bp"
loginfo "Done"
IR=( $(lookForIR ${QUERY}) )
IRDetected=1
IR=( $(lookForIR ${QUERY}) ) || IRDetected=0
posIR1=${IR[4]}
posIR2=${IR[6]}
if (( IRDetected == 1 )) ; then
let "lenIR= ( ${IR[5]} + ${IR[7]} ) / 2 "
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
posIR1=${IR[4]}
posIR2=${IR[6]}
let "lenIR= ( ${IR[5]} + ${IR[7]} ) / 2 "
if (( "$endIR2" >= "$genome_length" )) ; then
loginfo "IRB is at the end of the original sequence"
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
#
# We just move the IRB at the begining of the sequence
#
if (( "$endIR2" >= "$genome_length" )) ; then
loginfo "IRB is at the end of the original sequence"
#
# We just move the IRB at the begining of the sequence
#
# Extract the IRB sequence
let "posCut=($endIR1+$posIR2)/2"
cutseq ${QUERY} ${posCut} ${genome_length} > ${tmpfasta1}
# Append the remaining part of the genome
let "posCut=$posCut-1"
cutseq ${QUERY} 1 ${posCut} >> ${tmpfasta1}
# merges both the parts
joinfasta ${tmpfasta1} > ${tmpfasta2}
rm -f ${tmpfasta1}
QUERY=${tmpfasta2}
loginfo "Recomputing location of the IR..."
declare -a IR=( $(lookForIR ${QUERY}) )
loginfo "Done"
posIR1="${IR[4]}"
posIR2="${IR[6]}"
let "lenIR=(${IR[5]} + ${IR[7]}) / 2 "
# Extract the IRB sequence
let "posCut=($endIR1+$posIR2)/2"
cutseq ${QUERY} ${posCut} ${genome_length} > ${tmpfasta1}
# Append the remaining part of the genome
let "posCut=$posCut-1"
cutseq ${QUERY} 1 ${posCut} >> ${tmpfasta1}
# merges both the parts
joinfasta ${tmpfasta1} > ${tmpfasta2}
rm -f ${tmpfasta1}
QUERY=${tmpfasta2}
loginfo "Recomputing location of the IR..."
declare -a IR=( $(lookForIR ${QUERY}) )
loginfo "Done"
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
fi
posIR1="${IR[4]}"
posIR2="${IR[6]}"
tmpIR1="tmp_$$_IR1.fasta"
tmpIR2="tmp_$$_IR2.fasta"
let "lenIR=(${IR[5]} + ${IR[7]}) / 2 "
let "endIR2=$posIR2 + $lenIR - 1"
let "endIR1=$posIR1 + $lenIR - 1"
#enregistre les deux fragments IRa et IRb complet
cutseq ${QUERY} ${posIR1} ${endIR1} > ${tmpIR1}
cutseq ${QUERY} ${posIR2} ${endIR2} > ${tmpIR2}
fi
tmpIR1="tmp_$$_IR1.fasta"
tmpIR2="tmp_$$_IR2.fasta"
#enregistre les deux fragments IRa et IRb complet
cutseq ${QUERY} ${posIR1} ${endIR1} > ${tmpIR1}
cutseq ${QUERY} ${posIR2} ${endIR2} > ${tmpIR2}
let "lenSC1=$posIR1 -1 + ($genome_length - endIR2)"
let "lenSC2=$posIR2 - $endIR1"
center="${IR[0]}"
let "lenSC1=$posIR1 -1 + ($genome_length - endIR2)"
let "lenSC2=$posIR2 - $endIR1"
center="${IR[0]}"
tmpLSC="tmp_$$_LSC.fasta"
tmpSSC="tmp_$$_SSC.fasta"
tmpLSC="tmp_$$_LSC.fasta"
tmpSSC="tmp_$$_SSC.fasta"
# Extract the central SC present in between the two IRs
# considering it as LSC
# Extract the central SC present in between the two IRs
# considering it as LSC
let "beginLSC=$endIR1+1"
let "endLSC=$posIR2-1"
cutseq ${QUERY} ${beginLSC} ${endLSC} > ${tmpLSC}
strandLSC="${IR[1]}"
# Extract the external SC present in two parts
# Considering it as SSC
let "beginLSC=$endIR1+1"
let "endLSC=$posIR2-1"
cutseq ${QUERY} ${beginLSC} ${endLSC} > ${tmpLSC}
let "beginSSC=$endIR2+1"
cutseq ${QUERY} ${beginSSC} ${genome_length} > ${tmpSSC}
let "endSSC=$posIR1-1"
cutseq ${QUERY} 1 ${endSSC} >> ${tmpSSC}
joinfasta ${tmpSSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpSSC}
strandLSC="${IR[1]}"
strandSSC="${IR[3]}"
# Extract the external SC present in two parts
# Considering it as SSC
let "beginSSC=$endIR2+1"
cutseq ${QUERY} ${beginSSC} ${genome_length} > ${tmpSSC}
if [[ "$center" == "SSC" ]]; then
let "endSSC=$posIR1-1"
cutseq ${QUERY} 1 ${endSSC} >> ${tmpSSC}
# Actually this is the oposite LSC is SSC and SSC is LSC
# Exchanges the SSC and LSC sequences
mv ${tmpSSC} ${tmpfasta1}
mv ${tmpLSC} ${tmpSSC}
mv ${tmpfasta1} ${tmpLSC}
joinfasta ${tmpSSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpSSC}
# Exchanges the IRa and IRb sequences
mv ${tmpIR1} ${tmpfasta1}
mv ${tmpIR2} ${tmpIR1}
mv ${tmpfasta1} ${tmpIR2}
strandSSC="${IR[3]}"
# Exchanges the strand of both the Single copies
tmp=${strandSSC}
strandSSC=${strandLSC}
strandLSC=${tmp}
fi
# Reverse complement the SSC if needed
if [[ "${strandSSC}" == "-" ]]; then
fastarevcomp -f ${tmpSSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpSSC}
fi
# Reverse complement the LSC if needed
if [[ "${strandLSC}" == "-" ]]; then
fastarevcomp -f ${tmpLSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpLSC}
fi
# Merges the four parts of the genome.
cat ${tmpLSC} ${tmpIR2} ${tmpSSC} ${tmpIR1} | joinfasta
if [[ "$center" == "SSC" ]]; then
# Actually this is the oposite LSC is SSC and SSC is LSC
# Exchanges the SSC and LSC sequences
mv ${tmpSSC} ${tmpfasta1}
mv ${tmpLSC} ${tmpSSC}
mv ${tmpfasta1} ${tmpLSC}
# Exchanges the IRa and IRb sequences
mv ${tmpIR1} ${tmpfasta1}
mv ${tmpIR2} ${tmpIR1}
mv ${tmpfasta1} ${tmpIR2}
# Exchanges the strand of both the Single copies
tmp=${strandSSC}
strandSSC=${strandLSC}
strandLSC=${tmp}
fi
# Reverse complement the SSC if needed
if [[ "${strandSSC}" == "-" ]]; then
fastarevcomp -f ${tmpSSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpSSC}
fi
# Reverse complement the LSC if needed
if [[ "${strandLSC}" == "-" ]]; then
fastarevcomp -f ${tmpLSC} > ${tmpfasta1}
mv ${tmpfasta1} ${tmpLSC}
fi
# Merges the four parts of the genome.
cat ${tmpLSC} ${tmpIR2} ${tmpSSC} ${tmpIR1} | joinfasta
else
# No IR detected --> normalization has no effect
cat ${QUERY}
fi
popTmpDir
exit 0
......
......@@ -38,9 +38,16 @@ function lookForIR {
loginfo "Looking for long inverted repeats..."
repseek -c -p 0.001 -i ${QUERY} 2>> /dev/null > ${REPEATS}
loginfo " --> $(wc -l ${REPEATS} | awk '{print $1}') repeats identified"
nrepeat="$(wc -l ${REPEATS} | awk '{print $1}')"
loginfo "Done"
if (( nrepeat == 0 )) ; then
logwarning "No inverted repeat identified"
return 1
fi
loginfo " --> ${nrepeat} repeats identified"
loginfo "Marking and selecting the best inverted repeat..."
local IR=( $(${SELECTIR} ${MATCHES} ${REPEATS}) )
loginfo "Done"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment