Skip to content

Commit 9049b28

Browse files
committed
fix BLAST fasta_file input
1 parent c748961 commit 9049b28

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/pipecraft-core/service_scripts/taxonomy_BLAST.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ db1_temp=$(echo $database_file | grep -oP "$regex")
1919
db1=$(printf "/extraFiles/$db1_temp")
2020
echo "db1 = $db1"
2121

22+
### input fasta file
23+
IN=$(echo $fasta_file | grep -oP "$regex")
24+
# overwrite fileFormat variable; get it from input fasta_file
25+
fileFormat=$(echo $IN | awk -F. '{print $NF}')
26+
export fileFormat
27+
2228
#mandatory options
2329
task=$"-task ${task}" # e.g. blastn, megablast
2430
strands=$"-strand ${strands}" # both, plus
@@ -42,30 +48,30 @@ fi
4248
source /scripts/submodules/framework.functions.sh
4349

4450
#output dir
45-
output_dir=$"/input/taxonomy_out"
51+
output_dir=$"/input/taxonomy_out.blast"
4652

4753
#############################
4854
### Start of the workflow ###
4955
#############################
56+
echo "output_dir = $output_dir"
57+
if [[ -d $output_dir ]]; then
58+
rm -rf $output_dir
59+
fi
60+
mkdir $output_dir
61+
62+
### Start time
63+
start_time=$(date)
5064
start=$(date +%s)
5165

5266
### Check if files with specified extension exist in the dir
5367
first_file_check
5468

55-
### Prepare working env and check single-end data
56-
prepare_SE_env
57-
5869
#If input is compressed, then decompress (keeping the compressed file, but overwriting if filename exists!)
5970
check_gz_zip_SE
6071

6172
### Check input formats (fasta supported)
6273
check_extension_fasta
6374

64-
### Select last fasta file in the folder as input for BLAST
65-
for file in *.$fileFormat; do
66-
IN=$(echo $file)
67-
done
68-
echo "input = $IN"
6975

7076
### Check and assign BLAST database
7177
d1=$(echo $db1 | awk 'BEGIN{FS=OFS="."}{print $NF}') #get the extension
@@ -286,11 +292,15 @@ db_x=$(echo $db1 | sed -e 's/\/extraFiles\///')
286292
# Make README.txt file
287293
printf "# Taxonomy was assigned using BLAST (see 'Core command' below for the used settings).
288294
295+
Start time: $start_time
296+
End time: $(date)
297+
Runtime: $runtime seconds
298+
289299
Query = $IN
290300
Database = $db_x
291301
292-
BLAST_1st_best_hit.txt = BLAST results for the 1st best hit in the used database (sim_score and adj_qcov appended).
293-
BLAST_10_best_hits.txt = BLAST results for the 10 best hits in the used database, with sim_score and adj_qcov inserted after pident in each block.
302+
BLAST_1st_best_hit.txt = BLAST results for the 1st best hit in the used database
303+
BLAST_10_best_hits.txt = BLAST results for the 10 best hits in the used database
294304
295305
BLAST values field separator is '+'. When pasting the taxonomy results to e.g. Excel, then first denote '+' as the field separator to align the columns.
296306
@@ -318,8 +328,6 @@ adj_qcov = adjusted query coverage; if qlen > slen then ((send-sstart+1)/slen)*
318328
Core command ->
319329
blastn -query $IN $strands $database $task -max_target_seqs 10 $evalue $wordsize $reward $penalty $gapopen $gapextend -max_hsps 1
320330
321-
Total run time was $runtime sec.
322-
323331
##########################################################
324332
###Third-party applications [PLEASE CITE]:
325333
#BLAST 2.14.0+
@@ -334,4 +342,4 @@ printf "Total time: $runtime sec.\n "
334342
echo "#variables for all services: "
335343
echo "workingDir=$output_dir"
336344
echo "fileFormat=$extension"
337-
echo "readType=single_end"
345+
echo "readType=single_end"

0 commit comments

Comments
 (0)