prokkaC.smk 1.39 KB
Newer Older
Patrick May's avatar
Patrick May committed
1 2
rule annotate:
    input:
3
        'Assembly/%s.assembly.merged.fa' % ASS
Patrick May's avatar
Patrick May committed
4
    output:
Patrick May's avatar
Patrick May committed
5
        "Analysis/annotation/annotation.filt.gff",
Patrick May's avatar
Patrick May committed
6 7 8 9
        "Analysis/annotation/prokka.faa",
        "Analysis/annotation/prokka.fna",
        "Analysis/annotation/prokka.ffn",
        "Analysis/annotation/prokka.fsa",
10
        "Analysis/annotation/prokka.txt"
Patrick May's avatar
Patrick May committed
11 12 13 14 15
    threads: 8
    params:
        runtime = "8:00:00",
        mem = MEMCORE
    log: "logs/analysis_annotate.log"
Patrick May's avatar
yaml  
Patrick May committed
16
    conda: ENVDIR + "/IMP_annotation.yaml"
Patrick May's avatar
Patrick May committed
17 18 19 20
    message: "annotate: Running prokkaC."
    shell:
        """
        export PERL5LIB=$CONDA_PREFIX/lib/site_perl/5.26.2
Patrick May's avatar
Patrick May committed
21
        export LC_ALL=en_US.utf-8
Patrick May's avatar
Patrick May committed
22 23 24
        if [ ! -f $CONDA_PREFIX/db/hmm/HAMAP.hmm.h3m ]; then
          {BINDIR}/prokkaC --dbdir $CONDA_PREFIX/db --setupdb
        fi 
Patrick May's avatar
Patrick May committed
25
	{BINDIR}/prokkaC --dbdir $CONDA_PREFIX/db --force --outdir Analysis/annotation --prefix prokka --noanno --cpus {threads} --metagenome {input[0]} >> {log} 2>&1
Patrick May's avatar
Patrick May committed
26 27 28 29
        
	# Prokka gives a gff file with a long header and with all the contigs at the bottom.  The command below removes the
        # And keeps only the gff table.

Patrick May's avatar
Patrick May committed
30
        LN=`grep -Hn "^>" Analysis/annotation/prokka.gff | head -n1 | cut -f2 -d ":" || if [[ $? -eq 141 ]]; then true; else exit $?; fi`
Patrick May's avatar
Patrick May committed
31 32
        LN1=1
        LN=$(($LN-$LN1))
Patrick May's avatar
Patrick May committed
33
        head -n $LN Analysis/annotation/prokka.gff | grep -v "^#" | sort | uniq | grep -v "^==" > {output[0]}
Patrick May's avatar
Patrick May committed
34 35
        """