Esta es una recopilación de los comandos que acostumbro a usar al momento de hacer una búsqueda por homología con BLAST.
Los ejemplos están hechos en base a un blastn (nucleotídos contra nucleótidos) pero pueden ser adaptados a otros tipos de BLAST según el requerimiento.
1. Instalar BLAST en Ubuntu (o en Windows con WSL de Ubuntu)
# Este es el comando oficial pero no instalará la última versión
sudo apt update
sudo apt install ncbi-blast+
# Recomiendo descargar e instalar la útima versión desde este sitio
ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST
# Comando de descarga (reemplazar el archivo por el que encuentres en el link de arriba)
wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.12.0+-x64-linux.tar.gz
# descomprimir
tar -zxvf ncbi-blast-2.8.1+-x64-linux.tar.gz
# añadir BLAST al PATH del sistema
export PATH=$HOME/ruta_a_la_carpeta_descomprimida/ncbi-blast-2.12.0+/bin:$PATH
2. Opciones de formato de salida
*** Formatting options
-outfmt <String>
alignment view options:
0 = Pairwise,
1 = Query-anchored showing identities,
2 = Query-anchored no identities,
3 = Flat query-anchored showing identities,
4 = Flat query-anchored no identities,
5 = BLAST XML,
6 = Tabular,
7 = Tabular with comment lines,
8 = Seqalign (Text ASN.1),
9 = Seqalign (Binary ASN.1),
10 = Comma-separated values,
11 = BLAST archive (ASN.1),
12 = Seqalign (JSON),
13 = Multiple-file BLAST JSON,
14 = Multiple-file BLAST XML2,
15 = Single-file BLAST JSON,
16 = Single-file BLAST XML2,
17 = Sequence Alignment/Map (SAM),
18 = Organism Report
Options 6, 7, 10 and 17 can be additionally configured to produce
a custom format specified by space delimited format specifiers,
or in the case of options 6, 7, and 10, by a token specified
by the delim keyword. E.g.: "17 delim=@ qacc sacc score".
The delim keyword must appear after the numeric output format
specification.
The supported format specifiers for options 6, 7 and 10 are:
qseqid means Query Seq-id
qgi means Query GI
qacc means Query accesion
qaccver means Query accesion.version
qlen means Query sequence length
sseqid means Subject Seq-id
sallseqid means All subject Seq-id(s), separated by a ';'
sgi means Subject GI
sallgi means All subject GIs
sacc means Subject accession
saccver means Subject accession.version
sallacc means All subject accessions
slen means Subject sequence length
qstart means Start of alignment in query
qend means End of alignment in query
sstart means Start of alignment in subject
send means End of alignment in subject
qseq means Aligned part of query sequence
sseq means Aligned part of subject sequence
evalue means Expect value
bitscore means Bit score
score means Raw score
length means Alignment length
pident means Percentage of identical matches
nident means Number of identical matches
mismatch means Number of mismatches
positive means Number of positive-scoring matches
gapopen means Number of gap openings
gaps means Total number of gaps
ppos means Percentage of positive-scoring matches
frames means Query and subject frames separated by a '/'
qframe means Query frame
sframe means Subject frame
btop means Blast traceback operations (BTOP)
staxid means Subject Taxonomy ID
ssciname means Subject Scientific Name
scomname means Subject Common Name
sblastname means Subject Blast Name
sskingdom means Subject Super Kingdom
staxids means unique Subject Taxonomy ID(s), separated by a ';'
(in numerical order)
sscinames means unique Subject Scientific Name(s), separated by a ';'
scomnames means unique Subject Common Name(s), separated by a ';'
sblastnames means unique Subject Blast Name(s), separated by a ';'
(in alphabetical order)
sskingdoms means unique Subject Super Kingdom(s), separated by a ';'
(in alphabetical order)
stitle means Subject Title
salltitles means All Subject Title(s), separated by a '<>'
sstrand means Subject Strand
qcovs means Query Coverage Per Subject
qcovhsp means Query Coverage Per HSP
qcovus means Query Coverage Per Unique Subject (blastn only)
When not provided, the default value is:
'qaccver saccver pident length mismatch gapopen qstart qend sstart send
evalue bitscore', which is equivalent to the keyword 'std'
The supported format specifier for option 17 is:
SQ means Include Sequence Data
SR means Subject as Reference Seq
Default = `0'
3. Caso query.fasta vs subject.fasta (blast local donde subject no es una base de datos)
blastn -query query.fasta -subject subject.fasta -evalue 1e-50 -num_alignments 5 -outfmt "7 qseqid sseqid qlen qframe qstart qend slen sframe sstart send pident evalue bitscore length mismatch gapopen" -num_threads 2 -out query_vs_subject.txt
4. Caso query.fasta vs base de datos local
# En caso de querer enmascarar zonas de las secuencias (ej. baja complejidad) y luego crear la base de datos recomiendo este manual.
# Formatear la base de datos (en caso de proteínas, cambiar nucl por prot)
makeblastdb -in mydb.fasta -parse_seqids -title "My database" -dbtype nucl
# Comando blast
blastn -query query.fasta -db mydb -evalue 1e-50 -num_alignments 5 -outfmt "7 qseqid sseqid stitle qlen qframe qstart qend slen sframe sstart send pident evalue bitscore length mismatch gapopen" -out query_vs_nt.txt -num_threads 2 -out query_vs_mydb.txt
En este link podrás encontrar bases de datos de referencia relacionadas con 16S, 18S e ITS.
En este link podrás encontrar todas las bases de datos disponibles en ncbi listas para blast.
5. Caso query.fasta vs base de datos online (-remote)
blastn -query query.fasta -db nt -evalue 1e-50 -num_alignments 5 -outfmt "7 qseqid sseqid stitle qlen qframe qstart qend slen sframe sstart send pident evalue bitscore length mismatch gapopen" -out query_vs_nt.txt -remote
blastn -query query.fasta -db rRNA_typestrains/prokaryotic_16S_ribosomal_RNA -evalue 1e-50 -num_alignments 5 -outfmt "7 qseqid sseqid stitle qlen qframe qstart qend slen sframe sstart send pident evalue bitscore length mismatch gapopen" -out query_vs_nt.txt -remote
En este link encontrarás un listado de las bases de datos disponibles
Si blast remoto arroja un error en Windows WSL la solución es desactivar firewall/antivirus
Error: (302.26) [blastn] SSOCK#29000[5]@130.14.29.110:443: [SOCK::Connect] Failed pending connect(): Closed {error=111,Connection refused}
Error: (303.7) [blastn] [URL_Connect; https://www.ncbi.nlm.nih.gov/Service/dispd.cgi?service=blast4&address=ZenbookZero.localdomain(127.0.1.1)&platform=x86_64-unknown-linux-gnu] Failed to connect: Closed
Warning: (301.21) [blastn] [CONN_Flush(HTTP; https://www.ncbi.nlm.nih.gov/Service/dispd.cgi?service=blast4&address=ZenbookZero.localdomain(127.0.1.1)&platform=x86_64-unknown-linux-gnu)] Failed to flush: Closed
Error: (304.5) [blastn] [blast4] Unable to create connection with network dispatcher at "https://www.ncbi.nlm.nih.gov/Service/dispd.cgi?service=blast4&address=ZenbookZero.localdomain(127.0.1.1)&platform=x86_64-unknown-linux-gnu": Success
Error: (308.5) [blastn] [blast4] Service not found
Error: (301.5) [blastn] [CONN_Open(blast4)] Failed to open connection: Closed
Error: (315.4) [blastn] CConn_Streambuf::overflow(): CONN_Write() failed (blast4): Closed
Error: (315.4) [blastn] CConn_Streambuf::overflow(): CONN_Write() failed (blast4): Closed
Error: (315.4) [blastn] CConn_Streambuf::overflow(): CONN_Write() failed (blast4): Closed
Error: (802.5) [blastn] CObjectOStream: error at byte 53: stack is empty: cannot close output stream
Error: (CIOException::eFlush) [blastn] COStreamBuffer::Flush: failed
Error: (802.4) [blastn] Cannot close serializing output stream (CSerialException::eIoError) byte 53: cannot close output stream
6. Caso query.fasta vs base de datos online (-remote) añadiendo mas información desde taxonomía
# primero es necesario descargar la base de datos de taxonomía y descomprimirla
wget ftp://ftp.ncbi.nlm.nih.gov/blast/db/taxdb.tar.gz
tar xfz
# ahora prodremos hacer blast pidiendo información extra de nuestros subjects
blastn -query query.fasta -db nt -evalue 1e-50 -num_alignments 5 -outfmt "7 qseqid sseqid staxid ssciname staxids sscinames sskingdoms stitle qlen qframe qstart qend slen sframe sstart send pident evalue bitscore length mismatch gapopen" -out 1_vs_nt.txt -remote
7. Algunas opciones
# pre-filtrar el número de alineamientos
-num_alignments y -max_target_seqs me dan el mismo resultado
# pre-filtrar el porcentaje de identidad
-perc_identity