Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamilo889
    Member
    • Jul 2014
    • 15

    #1

    How to obtain a full length sequence from bam file

    I have an BAM file from a single chromosome, and I am interested in obtaining a piece of this sequence in FASTA format as consensus.

    I've already try to obtain the sequence and I am interested in put it in another separated file, but this is not a continuous sequence, so I am looking for a way to obtain this piece of sequence in FASTA format. I have tried mpileup, but it does not work (it gives me empty files).

    Does anyone knows how it could work?

    Thank you.
  • deyler
    Member
    • Sep 2013
    • 20

    #2
    It's not clear to me what you mean by consensus. Samtools doesn't generate a consensus sequence; it calls variants relative to the reference sequence. So it seems to me you have two possible workflows:

    1) use samtools to call variants in the region of interest (ROI)
    1a) extract the reference sequence for your ROI from the reference fasta file with samtools faidx
    1b) select the variants you want reflected in your consensus sequence based on whatever criteria you have in mind
    1c) change the sequence of your ROI to match the variants from 1b

    or

    2) use samtools view to extract just the reads from your ROI
    2a) trim the ends of reads that extend outside the ends of your ROI with a custom script
    2b) output the reads in some multiple-sequence alignment format like CLUSTAL
    2c) take the multiple-sequence alignment file and put it into some program that generates consensus sequences

    CAVEATS:
    1) I am not sure I really understand what you are trying to do
    2) These instructions pertain to samtools v 0.19+, not the most recent version

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      It is possible to get a consensus fastq sequence using samtools/bcftools.

      http://samtools.sourceforge.net/mpileup.shtml
      https://www.biostars.org/p/1388/
      https://www.biostars.org/p/70585/

      Comment

      • GenoMax
        Senior Member
        • Feb 2008
        • 7142

        #4
        @kamilo889: What version of samtools did you use to generate the original BAM? Are you using the same version to try and generate the consensus (you likely can't mix and match old/new versions). Unless you have coverage across the entire chromosome I am not sure you will get "full length" sequence.

        Comment

        • deyler
          Member
          • Sep 2013
          • 20

          #5
          What I dislike about the samtools-oriented approach is that it somewhat obscures what is really going on. If samtools has no data at a position, it assumes it's reference (which may not be valid). I would prefer a consensus sequence to reflect the absence of information, rather than to show me a consensus base call based on no data. Furthermore it seems like variant calls are not filtered when you pipe them straight into vcfutils, so you might be feeding in garbage. #1 from my post above gives you the opportunity to filter variant calls; option #2 lets you choose a consensus sequence algorithm other than samtools.

          It all depends on how good of a consensus sequence you need, I suppose, and what you're using it for. I wouldn't use #1 (mpileup | bcftools | vcfutils) to describe the consensus sequence for a binding site. But for generating an improved reference sequence for alignment, it may be fine.

          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, 10-22-2026, 11:13 AM
          0 responses
          55 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-22-2026, 10:48 AM
          0 responses
          40 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          46 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          46 views
          0 reactions
          Last Post SEQadmin2  
          Working...