Header Leaderboard Ad

Collapse

Shell Scripting help ***

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
                                How RNA-Seq is Transforming Cancer Studies
                                by seqadmin



                                Cancer research has been transformed through numerous molecular techniques, with RNA sequencing (RNA-seq) playing a crucial role in understanding the complexity of the disease. Maša Ivin, Ph.D., Scientific Writer at Lexogen, and Yvonne Goepel Ph.D., Product Manager at Lexogen, remarked that “The high-throughput nature of RNA-seq allows for rapid profiling and deep exploration of the transcriptome.” They emphasized its indispensable role in cancer research, aiding in biomarker...
                                09-07-2023, 11:15 PM
                              • seqadmin
                                Methods for Investigating the Transcriptome
                                by seqadmin




                                Ribonucleic acid (RNA) represents a range of diverse molecules that play a crucial role in many cellular processes. From serving as a protein template to regulating genes, the complex processes involving RNA make it a focal point of study for many scientists. This article will spotlight various methods scientists have developed to investigate different RNA subtypes and the broader transcriptome.

                                Whole Transcriptome RNA-seq
                                Whole transcriptome sequencing...
                                08-31-2023, 11:07 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, Yesterday, 07:42 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 09-22-2023, 09:05 AM
                              0 responses
                              23 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 09-21-2023, 06:18 AM
                              0 responses
                              16 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 09-20-2023, 09:17 AM
                              0 responses
                              16 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X