Question: BLAST: Querying a single sequence without input file in C
0
gravatar for madhurima.das
5.8 years ago by
United States
madhurima.das10 wrote:

This is with reference to the query posted in Local Blast: Querying A Single Sequence Without Input File. Possible ?. If I try to run the following using command line it runs perfectly fine: 

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

But, I am doing the same by a C program where I run BLASTP which takes in two strings (fasta_GWIDD and fasta_UNIPROT in the code) and compares them. The problem that I am encountering is the use of echo/system in the code. Can anyone suggest what am I missing out??  

for(i=0;i<index1;i++)
{
    sprintf(fasta_GWIDD,">%s\\n%s\n",fasta_name1[i],fasta_seq1[i]);
    setenv("GwiddVar", fasta_GWIDD, 1) ;
    sprintf(fasta_UNIPROT,">%s\\n%s\n",fasta_name2[i],fasta_seq2[i]);
    setenv("UniprotVar", fasta_UNIPROT, 1) ;
    system("blastp -query <(echo -e $GwiddVar) -subject<(echo -e $UniprotVar)");
}

The error is:

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `blastp -query <(echo -e $GwiddVar) -subject<(echo -e $UniprotVar)'
blast C • 1.5k views
ADD COMMENTlink modified 5.8 years ago by Pierre Lindenbaum127k • written 5.8 years ago by madhurima.das10

Did you try placing a space between -subject and <(? Also, where does sh point? You're using process substitution for bash. Anyway, there is a C API...

ADD REPLYlink modified 12 weeks ago by RamRS26k • written 5.8 years ago by Devon Ryan94k

Placing a space between -subject and <( doesn't help. It gives the same error:

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `blastp -query <(echo -e $GwiddVar) -subject <(echo -e $UniprotVar)'

Can you please clarify your last lines: "process substitution for bash" and "there is a C API"

ADD REPLYlink modified 12 weeks ago by RamRS26k • written 5.8 years ago by madhurima.das10

As Pierre Lindenbaum mentioned, <(some process) is process substitution in bash, but not other shells. If sh is a different shell, such as the original sh, then that won't work. If you don't know what a shell is, then, well, you have some reading to do.

Since you're writing in C anyway, you might just want to use the C interface (aka, the C API) to blast and avoid all of this. I'm not sure how else to explain an interface if you don't know what that is other than to just link to the documentation.

ADD REPLYlink modified 12 weeks ago by RamRS26k • written 5.8 years ago by Devon Ryan94k
0
gravatar for Pierre Lindenbaum
5.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum127k wrote:

as you can see, the shell engine invoked by system is sh NOT bash.

named pipes like <(echo -e $GwiddVar) are only interpreted by bash

you should first save GwiddVar, in a file using fopen/fputs/fclose , and then invoke system:

blastp -query saved1.fa -subject saved1.fa
ADD COMMENTlink modified 12 weeks ago by RamRS26k • written 5.8 years ago by Pierre Lindenbaum127k

I have already tried writing it into file and got success with it. But I am working with almost 10000 entries and so opening and closing a file takes time. So wanted to use strings rather than files so as to make my program fast and efficient.

Can you suggest any other alternative using strings only.

ADD REPLYlink modified 12 weeks ago by RamRS26k • written 5.8 years ago by madhurima.das10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 989 users visited in the last hour