SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
running GATK Queue script under PBS environment? orionzhou Bioinformatics 1 12-09-2012 04:24 AM
stampy output manore Bioinformatics 3 11-29-2012 08:25 AM
Are sleep/pause commands in bash scripts ever necessary? Heisman General 8 04-16-2012 01:24 PM
running samtools in shell script zorph Bioinformatics 4 03-02-2012 05:46 AM
Stampy alignment bair Bioinformatics 1 12-21-2010 04:57 AM

Reply
 
Thread Tools
Old 04-19-2012, 08:44 AM   #1
grafab
Junior Member
 
Location: Germany

Join Date: Apr 2012
Posts: 5
Default Running stampy in bash script

Hi folks,

I try to run stampy from a bash script. My problem is more a Unix/bash issue, but some of you may have a working script already, so I hope you can help me.
My script:
...
q10="-q10"
bwa_opt=$q10" "$bwa_ref

command=$stampy' -g '$ref_genome' -h '$ref_genome' -o '$out' --bwa='$bwa' --bwaoptions="'$bwa_opt'" -M '$seq1' '$seq2

echo $command
$command


Output:
./stampy-1.0.17/stampy.py -g hg19 -h hg19 -o out.sam --bwa=./bwa-0.5.7/bwa --bwaoptions="-q10 ~/reference_genome/hg19.fa" -M sequ1.fastq sequ2.fastq
Nothing to do, with unused arguments on command line
First unused argument: '~/reference_genome/hg19.fa"'


The $command looks correct to me from the echo output, but it does not work in the script. When I copy the echo output and paste it to the command line, it does work. "Bash" makes a difference between echo $command and running $command. I could not figure out what is different. Maybe it is something about the quotes of --bwaoptions.

Thanks,
grafab
grafab is offline   Reply With Quote
Old 04-19-2012, 11:05 AM   #2
Alex Renwick
Member
 
Location: Houston, Texas

Join Date: Jul 2011
Posts: 44
Default

try this:

Code:
q10="-q10"
bwa_opt="$q10 $bwa_ref"
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions='$bwa_opt' -M $seq1 $seq2"
Alex Renwick is offline   Reply With Quote
Old 04-20-2012, 01:15 AM   #3
grafab
Junior Member
 
Location: Germany

Join Date: Apr 2012
Posts: 5
Default

Thank you for your quick reply!
Unfortunately it does not solve my problem.

Output with your code:
Code:
./stampy-1.0.17/stampy.py -g hg19 -h hg19 -o out.sam --bwa=./bwa-0.5.7/bwa --bwaoptions='-q10 ~reference_genome/hg19.fa' -M seq1.fastq seq2.fastq
Nothing to do, with unused arguments on command line
First unused argument: '/home/ben4571/tmp/reference_genome/hg19.fa''
0
(The last quotes are two single ones, not one double quote.)

I copied the command from the output and pasted it to the command line, as I did with my output before. Again, this way works very well. But it fails from within the script.

Any suggestions?

I use GNU bash, Version 4.2.10(1)-release (x86_64-suse-linux-gnu).
grafab is offline   Reply With Quote
Old 04-20-2012, 02:01 AM   #4
grafab
Junior Member
 
Location: Germany

Join Date: Apr 2012
Posts: 5
Default

Now I used the "-v 3" option in the stampy call and got the following line in the output:
Quote:
...
stampy: Starting Stampy with the following options:
...
bwaoptions="-q10
...
So apparently the stampy.py script has problems, parsing the arguments.
I just dont understand why it works from the command line...
grafab is offline   Reply With Quote
Old 04-20-2012, 03:32 AM   #5
colindaven
Senior Member
 
Location: Germany

Join Date: Oct 2008
Posts: 414
Default

Perhaps use a very simple Perl script instead ?

I use generic scripts a lot to run aligners, taking arguments from the command line and running the aligner that way. It's very good for sharing to other users.
colindaven is offline   Reply With Quote
Old 04-20-2012, 05:50 AM   #6
grafab
Junior Member
 
Location: Germany

Join Date: Apr 2012
Posts: 5
Default

Quote:
Originally Posted by colindaven View Post
Perhaps use a very simple Perl script instead ?

I use generic scripts a lot to run aligners, taking arguments from the command line and running the aligner that way. It's very good for sharing to other users.
That works, thank you!
But I still would like to know, why the bash script is not working...
grafab is offline   Reply With Quote
Old 04-20-2012, 06:19 AM   #7
Alex Renwick
Member
 
Location: Houston, Texas

Join Date: Jul 2011
Posts: 44
Default

Quote:
Originally Posted by grafab View Post
Thank you for your quick reply!
Unfortunately it does not solve my problem.

Output with your code:
Code:
./stampy-1.0.17/stampy.py -g hg19 -h hg19 -o out.sam --bwa=./bwa-0.5.7/bwa --bwaoptions='-q10 ~reference_genome/hg19.fa' -M seq1.fastq seq2.fastq
Nothing to do, with unused arguments on command line
First unused argument: '/home/ben4571/tmp/reference_genome/hg19.fa''
0
(The last quotes are two single ones, not one double quote.)

I copied the command from the output and pasted it to the command line, as I did with my output before. Again, this way works very well. But it fails from within the script.

Any suggestions?

I use GNU bash, Version 4.2.10(1)-release (x86_64-suse-linux-gnu).
The issue is how white space is being parsed by bash. The script does it's own parsing, then parsing happens again when the command is executed. It sometimes takes some trial and error before I get it right.
Here are some things I would try:

Code:
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions=\"$q10 $bwa_ref\" -M $seq1 $seq2"
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions=$q10\ $bwa_ref -M $seq1 $seq2"
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions=\"$q10\ $bwa_ref\" -M $seq1 $seq2"
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions=$q10\\\ $bwa_ref -M $seq1 $seq2"
Alex Renwick is offline   Reply With Quote
Old 04-23-2012, 02:00 AM   #8
grafab
Junior Member
 
Location: Germany

Join Date: Apr 2012
Posts: 5
Default

Thank you all, for helping me!

I finally got it working. Thanks to the hint that the whitespace might be the problem, I found this HOW-TO. The solution is the eval command.
Code:
...
command="$stampy -g $ref_genome -h $ref_genome -o $out --bwa=$bwa --bwaoptions=\"$q10 $bwa_ref\" -M $seq1 $seq2"
eval $command
grafab is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 06:26 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO