Local Blast: Querying A Single Sequence Without Input File. Possible ?
3
4
Entering edit mode
9.8 years ago
Pasta ★ 1.3k

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"

blast • 9.1k views
11
Entering edit mode
9.8 years ago

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.

0
Entering edit mode

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

0
Entering edit mode

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).

0
Entering edit mode

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.

5
Entering edit mode
9.8 years ago
Sujai Kumar ▴ 250

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...

0
Entering edit mode

thats pretty cool :)

0
Entering edit mode

Excellent. Thanks.

0
Entering edit mode

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!

0
Entering edit mode

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

2
Entering edit mode
7.9 years ago
jwhabig ▴ 20

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')

0
Entering edit mode

This is what I was looking for!