Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sfh838t
    Member
    • Apr 2014
    • 29

    #1

    SAM header, difference between using sam tools or awk to filter ?

    I have filtered SAM files to get only the aligned reads with samtools view -F4.
    my output is a file in SAM format, the header is lost, but I can still convert the file to BAM and then use picardtools "addOrReplaceReadGroups" to add a header.

    this time I have a list of read names in a txt file and I used awk to find the matching rows in the SAM file. of course the header is lost, and I cannot convert this file to BAM to add the header back so I can index the file and visualize the alignments.

    I can open both files in a spreadsheet, they look and act exactly the same.
    is there some kind of identifier that is lost when awk writes the new file? Or will I have to use the matching fastq reads and redo the alignment?

    I am trying to find regions in a virus that has matching sequences in a plant genome. So I did: align all reads to virus genome, filter out aligned reads. align those virus reads to plant genome, filter again. Now I need to see where these reads align in the virus, and since they are already contained in the first alignment file I thought I could just separate them out......
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    You can grab the header from your bam file by doing
    Code:
     samtools view -H your.bam > header.txt
    That can then be added back to your filtered sam.

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      You could also try to do this analysis in one step. Use bbsplit.sh from BBMap with both genomes. Look for reads that map to both genomes. Those would presumably be the reads you are interested in.

      Comment

      • sfh838t
        Member
        • Apr 2014
        • 29

        #4
        Thank you GenoMax.
        the header suggestion almost worked, in one case, not so much in the other because it is too long I suspect.
        and thanks for the BBsplit suggestion as well.It obviously does alignment along the way, but does not mention anything about the aligner and since I work with very short reads, <30 nt, that can be an issue.
        either way, what I really needed to see was the alignments, so I ended up using excel and making histograms from the SAM files.

        Comment

        Latest Articles

        Collapse

        • 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
        • SEQadmin2
          New Genomics Technologies Take Aim at Long-Standing Limits
          by SEQadmin2


          Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

          We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
          ...
          09-28-2026, 10:25 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Yesterday, 11:13 AM
        0 responses
        19 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:48 AM
        0 responses
        18 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-15-2026, 10:52 AM
        0 responses
        36 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-14-2026, 05:39 AM
        0 responses
        42 views
        0 reactions
        Last Post SEQadmin2  
        Working...