Unconfigured Ad

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

    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
          Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
          by SEQadmin2


          Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

          The systematic characterization of the human proteome has
          ...
          Yesterday, 11:48 AM
        • SEQadmin2
          Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
          by SEQadmin2



          Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
          ...
          07-09-2026, 11:10 AM
        • SEQadmin2
          Cancer Drug Resistance: The Lingering Barrier to Rising Survival
          by SEQadmin2



          Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

          There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
          07-08-2026, 05:17 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Yesterday, 11:10 AM
        0 responses
        9 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-13-2026, 10:26 AM
        0 responses
        30 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-09-2026, 10:04 AM
        0 responses
        41 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-08-2026, 10:08 AM
        0 responses
        25 views
        0 reactions
        Last Post SEQadmin2  
        Working...