Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • AnushaC
    Member
    • Sep 2013
    • 78

    Shell Scripting help ***

    i ,
    can you please answer my question
    I am trying to use shell scripting to convert sra file to bam file
    I have 3 commands i am using

    1) fastq-dump SRR203400.sra
    2) bowtie -v 3 -k 2 --sam /raid/references-and-indexes/hg19/bowtie-indexes/hg19 /raid/development/anusha/SRR203400.fastq > /raid/development/anusha/SRR203400.bowtieold.sam
    3)samtools view -b -S SRR203400.bowtieold.sam > SRR203400.bowtieold.bam
    Now i am trying use shell scripting piping operation

    #!/bin/bash
    # generating a fastq file using fastq dump
    $1=='sraip'

    $2=='hg19ref'
    fastq-dump sraip |bowtie -v 3 -k 2 --sam hg19ref fastqop > $3
    I am getting confused on how to pipe fast-dump output to bow tie option and use it in samtools view

    Thanks in advance ,
    Anusha.Ch
  • rhinoceros
    Senior Member
    • Apr 2013
    • 372

    #2
    Code:
    #!/bin/bash
    # generating a fastq file using fastq dump
    sraip=$1
    hg19ref=$2
    fastq-dump $sraip | bowtie -v 3 -k 2 --sam $hg19ref fastqop > outputfile
    or alternatively

    Code:
    #!/bin/bash
    # generating a fastq file using fastq dump
    fastq-dump $1 | bowtie -v 3 -k 2 --sam $2 fastqop > outputfile
    Now you would call your script "script.sh /where/ever/it/is/sraip.file /where/ever/it/is/hg19reffile". Don't know if it works. I'm just demonstrating how you hadn't quite grasped how to use variables. In shell scripts $1 is the first thing after the program name when calling the script, $2 the second, etc. Variables are assigned as variableA="something" and then referred to by $variableA, e.g.

    Code:
    variableA="Hello"
    echo $variableA
    Last edited by rhinoceros; 10-04-2013, 12:40 AM.
    savetherhino.org

    Comment

    • dpryan
      Devon Ryan
      • Jul 2011
      • 3478

      #3
      @rhinoceros, yeah, that won't do what you want.

      Code:
      fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 - $3
      where $3 is an output name. You need to use the -Z flag so fastq-dump doesn't write instead to a file and pass - as the input file name to bowtie so it knows to read from stdin. In a real script, you'd have the output name generated according to the name of the SRA file. Also, piping input into bowtie won't work for paired-end data (not to mention that you should always QC SRA data prior to alignment as a lot of it is low quality).

      Comment

      • AnushaC
        Member
        • Sep 2013
        • 78

        #4
        shell Scripting ***

        Hi ,
        I need to pipe third program which is samtools view to make sam to bam


        fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 - |samtools view -b -S > $3

        what will direct my output to sam tools view.


        Thanks in advance ,
        Anusha.Ch

        Comment

        • dpryan
          Devon Ryan
          • Jul 2011
          • 3478

          #5
          Originally posted by AnushaC View Post
          fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 - |samtools view -b -S > $3
          That's almost correct. Have a look at the samtools manual for what you're missing (hint, it's a -).

          Comment

          • AnushaC
            Member
            • Sep 2013
            • 78

            #6
            Hi ,
            You guys talking about only two of my outputs but i have three program i am using samtools view to convert sam file to bam file . I am trying but will direct sam to bam output with piping

            Thanks,
            Anusha.Ch

            Comment

            • dpryan
              Devon Ryan
              • Jul 2011
              • 3478

              #7
              Originally posted by AnushaC View Post
              You guys talking about only two of my outputs but i have three program i am using samtools view to convert sam file to bam file.
              I'm aware that you're trying to then convert to a BAM file by piping to samtools. Please actually read my reply and then do what I wrote. I could simply write the full command, but then you'd not start to learn how to properly create these commands yourself.

              Comment

              • AnushaC
                Member
                • Sep 2013
                • 78

                #8
                Hi Ryan,
                That is not correct . I am getting error


                Thanks,
                Anusha.Ch

                Comment

                • dpryan
                  Devon Ryan
                  • Jul 2011
                  • 3478

                  #9
                  Originally posted by AnushaC View Post
                  That is not correct . I am getting error
                  Whatever you're typing may be incorrect, but what I told you to do is not (btw, when you receive an error message, it's usually best to actually post it).

                  Comment

                  • AnushaC
                    Member
                    • Sep 2013
                    • 78

                    #10
                    Hi Ryan ,



                    fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 -|samtools view -u -t -F 4 -$3

                    will this work do i need to use faidix also

                    Thanks,
                    Anusha.Ch

                    Comment

                    • dpryan
                      Devon Ryan
                      • Jul 2011
                      • 3478

                      #11
                      Originally posted by AnushaC View Post
                      fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 -|samtools view -u -t -F 4 -$3
                      Again, the samtools command isn't specified correctly. Reread the samtools manual (and why are you using -t?).

                      Comment

                      • AnushaC
                        Member
                        • Sep 2013
                        • 78

                        #12
                        Hi Ryan,
                        I read the manual and If `-t' is
                        applied, the input file is assumed to be in the SAM format. so i started using -t but it did not work for -t or -T i did try by giving reference file . I did not understand where i am going wrong .

                        Thanks,
                        Anusha.Ch

                        Comment

                        • dpryan
                          Devon Ryan
                          • Jul 2011
                          • 3478

                          #13
                          That's not what the manual says regarding -t.

                          Comment

                          • AnushaC
                            Member
                            • Sep 2013
                            • 78

                            #14
                            By default, this command assumes the file on the command line is in
                            the BAM format and it prints the alignments in SAM. If `-t' is
                            applied, the input file is assumed to be in the SAM format. The
                            file supplied with `-t' is SPACE/TAB delimited with the first two
                            fields of each line consisting of the reference name and the
                            corresponding sequence length. The `.fai' file generated by `faidx'
                            can be used here. This file may be empty if reads are unaligned.

                            this what i got when i trying to run command then i changed to like this


                            #!/bin/bash
                            # generating a fastq file using fastq dump
                            sraip=$1
                            hg19ref=$2
                            fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 -|samtools view -u -S -$3

                            It also did not work ,then i tried giving samtools view -u -T $2 -$3 and
                            samtools view -u -t $2 -$3 none of this worked

                            Comment

                            • AnushaC
                              Member
                              • Sep 2013
                              • 78

                              #15
                              Hi ,


                              fastq-dump -Z $1 | bowtie -v 3 -k 2 --sam $2 -|samtools $2 -| samtools view -u -t -$3

                              will this work ?

                              Thanks,
                              Anusha.Ch

                              Comment

                              Latest Articles

                              Collapse

                              • 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
                              • seqadmin
                                Investigating the Gut Microbiome Through Diet and Spatial Biology
                                by seqadmin




                                The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
                                02-24-2025, 06:31 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

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