This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Local Blast: Querying A Single Sequence Without Input File. Possible ?

Hi,

When using BLASTALL by command line, is there any way of querying BLASTALL without using any input file but a directly a sequence ?

I would like to do something like:

blastall -n blastn -d MyBud.fna -XX "ATCGTTAGCT"

Thx for your help

blast

3 answers

no, but you can provide your sequence via stdin:

echo -e ">Name\nATCGTTAGCT" | blastall -n blastn -d MyBud.fna

i Query File [File In]

default = stdin

The query should be in FASTA format. If multiple FASTA entries are in the input file, all queries will be searched.

Perfect! That will do the trick. Thanks for your help

Just an add (because I just tried it on a server): if your interpreter is sh (not bash), then you need not the use of "-e" (which does not exist in sh anyway).

Just an add (because I just tried it on a server): if your interpreter is csh (not bash or sh), then you need not the use of "-e" which does not exist in csh anyway.

Another tip, the new blast+ suite takes bash subprocesses, so, you could even do:

blastn -query <(echo -e ">Name\nATCGTTAGCT") -subject <(echo -e ">Name\nATCGTTAGCT")

etc...

This is very useful. Note that process substitution is invoked by bash, not shell. So if use this in Perl, you can do something like this:

my $seq1=">seq1\\nTGAAAGATGG";
my $seq2=">seq2\\nTGAAAGATGG";
my $line="blastn -subject <(echo -e \"$seq1\") -query <(echo -e \"$seq2\") -outfmt 6";
my $result=qx(bash -c '$line');
print "$result\n";

Hope it helps!

blastn -subject <(echo -e \"$seq1\") -query <(echo -e \"$seq2\") -outfmt 6

for this command how it can be run in python , if you know please reply asap. if i want to put directly Sequence in place of $seq2 , how it is possible

because i am trying this command in python but getting this error

Warning: (1431.1) CFastaReader: Ignoring invalid residue " at line 1, position 0 Warning: (1431.1) CFastaReader: Ignoring invalid residue " at line 1, position 78

I was interested in performing the same operation from within python and thought I'd share an example of my implementation in case it is valuable to anyone else in the same boat.

import subprocess

blastn = subprocess.Popen('blastn -db PVY -outfmt 6', shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

results, err = blastn.communicate('AAATTAAAACAACTCAATACAACATAAGAAAATCAACGCAAAAACACTCACAAAAGCTTTC')

Log in to answer this question.