Seqanswers Leaderboard Ad

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

    Sam to Bam Conversion Failing ****

    Hi All ,
    Can any one please clarify why samtools view is failing .
    I am writing shell script like this

    #!/bin/bash
    #PBS -l nodes=2pn=2
    for files in *.sra
    do
    OUT=(${files%.sra}.bam)
    ref=($"/raid/references-and-indexes/hg19/bwa/hg19.fa")
    fq=$(fastq-dump $files)
    # Main code

    bwa aln -t 8 $ref $fq|bwa samse $ref - $fq -|samtools view -bSh - /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT
    done

    I tried different combination for view like -bS
    -Shu
    by using the option -o still is failing
    the code is working pretty fine till point of samtools view
    I am getting following error many times and creating empty bam files
    bwa_seq_open] fail to open file 'Written' : No such file or directory
    [fread] Unexpected end of file
    [samopen] no @SQ lines in the header.
    [main_samview] random alignment retrieval only works for indexed BAM files.

    [bam_header_read] EOF marker is absent. The input is probably truncated.

    I am not understanding why this is failing

    Thanks in advance ,
    Anusha.Ch
  • gringer
    David Eccles (gringer)
    • May 2011
    • 845

    #2
    Originally posted by AnushaC View Post
    Code:
    samtools view -bSh -  /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT
    Assuming BWA is producing a properly-formatted SAM file as output (which I'm doubtful of, given the error messages), it looks like you're not specifying the input/output files correctly. Samtools view takes a single non-option parameter (the input file name, or '-' for standard input), and the output (default to standard out) can be redirected to a different file using the '-o' parameter.

    So, there are two ways to output to a file (instead of standard out):
    Code:
    samtools view [options] <input> -o <output> # redirect using samtools 
    samtools view [options] <input> > <output> # redirect using the shell
    Subsituting in the bits from your code for these two options:
    Code:
    samtools view -bSh  - -o /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT # note two dashes separated by a space
    samtools view -bSh  - > /raid/development/anusha/python_test/shelltest/fetalbrain_bam/$OUT
    Of course, that all assumes your other options are correct. If you're sending output to a binary BAM file (option -b), then you don't need to include the SAM header (option -h), because you can't have a BAM file without a header.

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