Cogent
Cogent copied to clipboard
automatically re-run failed contig reconstruction jobs with updated sh script.
Just wanted to share my updated sh script which automatically tries to re-run the failed contig construct mode. It tries until kmer 99, after that it copies the input fasta file to cogent2.fa as pretended output. The parameter kmerSize is the starting kmer to try the first re-run. If that failes, it increases the kmer size by 3.
I first ran the reconstruct scripts with gnu parallel:(by default I run the script with the nx_cycle option)
generate_batch_cmd_for_Cogent_reconstruction.py "./lima_transcript_clustered"|awk '{print "nice "$0 "--nx_cycle_detection >/dev/null 2>&1"}'|parallel -j 12 -v
After that you have to check for the failed jobs:
run as:
bash check_construct_contig.sh dirName 23
#!/bin/bash
counter=0
DIRNAME=$1
kmerSize=$2
for d in $DIRNAME/* ; do
FILE=$d/cogent2.fa
if [ ! -f $FILE ]; then
echo "$d failed. Trying to run again with increased K-mer size..."
sampleName=`echo $d|perl -p -e 's/.+\///g'`
while [ ! -f "$FILE" ]
do
kmerSize=$((kmerSize + 3))
rerunCMD="reconstruct_contig.py ${d} -p ${sampleName} --nx_cycle_detection -k ${kmerSize} >/dev/null 2>&1"
echo ${rerunCMD}
eval ${rerunCMD}
if [ -f $FILE ]; then echo "SUCCESS! The increased Kmer size was successful for ${d}.";fi
if [ ${kmerSize} -gt 99 ];then #one should give up. This aint going to work.
cp ${d}/in.fa $d/cogent2.fa
echo "Failed to succeed with largest Kmer on ${d}. Copied input transcripts to cogent2.fa as output."
fi
done
if [ ! -f $FILE ]; then
counter=$((counter+1))
fi
fi
done
if [ $counter -eq 0 ]; then
echo "All jobs completed! Proceed to reconstruction."
else
echo "Some jobs failed. Please re-run them."
fi