#!/bin/bash
# RNA-Seq 
# 2021-01

#SBATCH --nodes=1			
#SBATCH --ntasks-per-node=6
#SBATCH --mem=64GB
#SBATCH --job-name=BLAST_Uniprot


# Choose between long or short: A short job will start quickly after submitting, but will be terminated after 30 minutes

#SBATCH --time=24:00:00
##SBATCH -p short

export PERL5LIB=/data/pg-molgen/software/molgentools_mirror/lib
module load BioPerl/1.7.7-GCCcore-9.3.0
module load BLAST+/2.10.1-gompi-2020a

# parameters: Modify for your folders
	cpu=6
	SCRATCHDIR=/scratch/p276244
	dbDIR=/data/pg-molgen/databases/uniprot_sprot
	molgentools=/data/pg-molgen/software/molgentools_mirror

# =====================================================================================================================================================
# ==                                                          Database setup                                                                         ==
# =====================================================================================================================================================

# only once after update;  makeblastdb -in uniprot_sprot_clean.fasta -dbtype prot
# For uniprot update see GSEA-Pro and FACOP

# =====================================================================================================================================================
# ==                                                          MAIN                                                                                   ==
# =====================================================================================================================================================

function my_blast {
	blastp -outfmt 6 -db $dbDIR/uniprot_sprot_clean.fasta -query $datadir/$query -max_target_seqs 1 -num_threads $cpu -evalue 10E-09 -out $datadir/$result
	# filter for best blast hit only
	$molgentools/blast/parse_blast_uniref_table.pl -i $datadir/$result -o $datadir/$result.filtered
	# Align the blast output with the description of Uniprot
	$molgentools/genomics/g2d_align_tables.pl -s $datadir -k $dbDIR/uniprot_sprot.description -r Align_anycolumn -t $datadir/$result.filtered -o $result.filtered.description
}


datadir=/data/p127804/PROJECTS/JanMaarten/Yanyan_202101/Aa_annotation-chapter2
query=all_nr.fasta
result=all_nr.uniprot.blast

# call the BLAST
my_blast	


