Unconfigured Ad

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

    #1

    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

    • SEQadmin2
      16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
      by SEQadmin2




      NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
      10-30-2026, 06:46 AM
    • SEQadmin2
      Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
      by SEQadmin2



      Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

      Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
      ...
      10-14-2026, 09:55 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, 10-28-2026, 09:57 AM
    0 responses
    40 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-28-2026, 09:51 AM
    0 responses
    24 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-22-2026, 11:13 AM
    0 responses
    73 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-22-2026, 10:48 AM
    0 responses
    48 views
    0 reactions
    Last Post SEQadmin2  
    Working...