Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • grafab
    Junior Member
    • Apr 2012
    • 5

    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
  • Alex Renwick
    Member
    • Jul 2011
    • 44

    #2
    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"

    Comment

    • grafab
      Junior Member
      • Apr 2012
      • 5

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

      Comment

      • grafab
        Junior Member
        • Apr 2012
        • 5

        #4
        Now I used the "-v 3" option in the stampy call and got the following line in the output:
        ...
        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...

        Comment

        • colindaven
          Senior Member
          • Oct 2008
          • 417

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

          Comment

          • grafab
            Junior Member
            • Apr 2012
            • 5

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

            Comment

            • Alex Renwick
              Member
              • Jul 2011
              • 44

              #7
              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"

              Comment

              • grafab
                Junior Member
                • Apr 2012
                • 5

                #8
                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

                Comment

                Latest Articles

                Collapse

                • seqadmin
                  Pathogen Surveillance with Advanced Genomic Tools
                  by seqadmin




                  The COVID-19 pandemic highlighted the need for proactive pathogen surveillance systems. As ongoing threats like avian influenza and newly emerging infections continue to pose risks, researchers are working to improve how quickly and accurately pathogens can be identified and tracked. In a recent SEQanswers webinar, two experts discussed how next-generation sequencing (NGS) and machine learning are shaping efforts to monitor viral variation and trace the origins of infectious...
                  03-24-2025, 11:48 AM
                • seqadmin
                  New Genomics Tools and Methods Shared at AGBT 2025
                  by seqadmin


                  This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

                  The Headliner
                  The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
                  03-03-2025, 01:39 PM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by seqadmin, 03-20-2025, 05:03 AM
                0 responses
                42 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-19-2025, 07:27 AM
                0 responses
                53 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-18-2025, 12:50 PM
                0 responses
                38 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-03-2025, 01:15 PM
                0 responses
                194 views
                0 reactions
                Last Post seqadmin  
                Working...