Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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


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


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


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


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


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


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


                Thanks,
                Anusha.Ch

                Comment


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


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


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


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


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

                          Comment


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


                            • #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
                                Strategies for Sequencing Challenging Samples
                                by seqadmin


                                Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                                03-22-2024, 06:39 AM
                              • seqadmin
                                Techniques and Challenges in Conservation Genomics
                                by seqadmin



                                The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                                Avian Conservation
                                Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                                03-08-2024, 10:41 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, Yesterday, 06:37 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, Yesterday, 06:07 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-22-2024, 10:03 AM
                              0 responses
                              49 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-21-2024, 07:32 AM
                              0 responses
                              67 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X