Ronald Robertson

Sanjay Singh

Scientist/Writer
  • Emailsanjaysingh765@gmail.com
  • Socail@lampatlex
  • VisitorSince 1982
  • LocationKentucky, USA



How to perform parallel BLAST





BLAST can be time-consuming especially when it includes a large number of the query sequence. Therefore, parallel BLAST can be useful. This Bash script can perform parallel BLASt in three common steps



  • Split fasta file into files with a given number of sequences 

  • BLAST them in parallel fashion

  • Combine their result



Since it doesn't include any additional software except BLAST+, therefore, it is easy to use.  If you want to parse your BLAST result you can always use NCBI BLAST parser from here.


USES


This bash script require following commands

script_name: Name of given script

blast_type: What kind of BLAST you want to perform e.g. blastn

query_file: Name of query file

database_name: Name of the database

number_of_sequence_each_file: how many sequences you want per query file

SCRIPT



#!/bin/bash

########################################################################################################################
#
# split fasta file into files with given number of sequences
# blast them in parallel fashion
# combine their result
########################################################################################################################

prog="$1"
query="$2"
database="$3"
num_seq="$4"


if [[ $# -lt 3 ]] ; then
printf "\033[1;31mGive me a proper command\033[0m\n"
printf "\033[1;31mUsage: script_name blast_type query_file database name number_of_sequence_each_file\033[0m\n\n"

exit;


else

start=`date +%s`

#split fasta sequences in given number of sequences per file
awk -v a_seq=$num_seq 'BEGIN {n_seq=0;} /^>/ {if(n_seq%a_seq==0){file=sprintf("myseq%d.fa",n_seq);} print >> file; n_seq++; next;} { print >> file; }' < $query



#run blast
ls *.fa | parallel -a - $prog -query {} -db $database -out {.}.out -evalue 0.001 -num_descriptions 1 -num_alignments 1 -num_threads 8

cat *.out >$query.blast.result


while true; do
read -p "Do you want to delete intermediate files?" yn
case $yn in
[Yy]* ) rm -f *.out *.fa; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;

esac
done

runtime=$((end-start))
printf "\033[1;31mYour analysis was done in $((($(date +%s)-$start)/60)) minutes\033[0m\n"${reset}
printf "\033[1;31mTHANKS\033[0m\n"${reset}

fi






Comments

design

Onboarding Motivation

Onboarding Motivation
branding

Delivery App Wireframe

Delivery App Wireframe
creative

Guest App Walkthrough Screens

Guest App Walkthrough Screens
art

Project Managment Illustration

Project Managment Illustration
Photography

Photography

Lorem ipsum dolor sit amet consectetuer adipiscing elit aenean commodo ligula eget.

Web Development

Web Development

Lorem ipsum dolor sit amet consectetuer adipiscing elit aenean commodo ligula eget.

UI/UX design

UI/UX design

Lorem ipsum dolor sit amet consectetuer adipiscing elit aenean commodo ligula eget.

Sanjay Singh

Sanjay Singh

I am lexicographer

I'm a Scientist with 20+ years of broad experience in molecular biology and bioinformatics. Extensive experience in the regulation of metabolic pathways in plants. Proven success in the design, development, and deployment of several result-oriented research projects. Have worked with both academic and industrial collaborators.

Get in touch

Let's talk about everything!

Don't like forms? Send me an email. 👋

Experience

2019 - Present

Acamedic Degree

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.

2017 - 2013

Bachelor’s Degree

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.

2013 - 2009

Honours Degree

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.

2019 - Present

Web Designer

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.

2017 - 2013

Front-End Developer

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.

2013 - 2009

Back-End Developer

Lorem ipsum dolor sit amet quo ei simul congue exerci ad nec admodum perfecto.