-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset_galaxy_blastdb.sh
executable file
·82 lines (71 loc) · 2.61 KB
/
set_galaxy_blastdb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# Blast DB Indexer Mini Pipeline for Galaxy
#
# Author:
# Jacob Israel Cervantes Luevano <[email protected]>
#
# Copyright (c) 2011 Jacob
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# input values
# $2 --> fasta filename
# $4 --> blast format: F->nucleotide, T->protein
# $6 --> database filename
# $8 --> descriptor format (ncbi-gbk , other)
# cli variables
shelp=$1
fasta=$2
blast_type_file=$4
blast_dbname=$6
fastadir=${fasta%/*}
fastafile=${fasta##*/}
tmpfasta="$fasta.tmp"
newfasta="$fastadir/new.$fastafile"
fastadesc=$8
galaxy_blastdb_loc="blastdb.loc"
# Usage
if [ "$shelp" = "-help" ]; then
echo "||Blast DB Indexer Mini Pipeline for Galaxy. by Jacob @ Cinvestav Langebio MEXICO 2011"
echo "||Allows to format blast databases, set galaxy format and create galaxy reference loc files"
echo "||Usage: set_galaxy_blastdb.sh -help"
echo "||Usage: set_galaxy_blastdb.sh -fasta filename -p T|F -n blastdb_name -fastadesc ncbi-gk|other"
echo "||where:"
echo "|| filename: fasta filename"
echo "|| -p T if your database are protein sequences"
echo "|| -p F if your database are nucleotide sequences"
echo "|| -n blastdb_name set database filename for Galaxy Loc File"
echo "|| -fastadesc ncbi-gk option if your fasta ID is like gi|gi-number|gb|accesión|locus"
echo "|| -fastadesc other option"
exit 0
fi
echo "--> Analyzing Sequences from $fastafile.."
if [ "$fastadesc" = "ncbi-gk" ]; then
echo "--> Setting Galaxy Format.."
python megablast-prepdb.py < $fasta > $newfasta
fi
if [ "$fastadesc" = "other" ]; then
sed -e 's/>/>0|/g' $fasta > $tmpfasta
echo "--> Setting Galaxy Format.."
python megablast-prepdb.py < $tmpfasta > $newfasta
fi
cd $fastadir
echo "--> Format Reference Database.."
formatdb -i $newfasta -p $blast_type_file -n $blast_dbname
echo "--> Setting Up Megablast Galaxy Loc File.."
echo -e "$blast_dbname\t$blast_dbname\t$fastadir/$blast_dbname" > $fastadir/$galaxy_blastdb_loc
echo "--> Deleting temp files.."
rm $tmpfasta 2> /dev/null
echo "Done."
echo "Galaxy Blast Database are ready !!"