Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hin175
    Junior Member
    • Feb 2015
    • 2

    #1

    Extracting fasta sequence from bam file with bed intervals

    Hello,
    maybe the question have already been answered, but I cannot find anything about...
    I'm mining 4 transcriptomes to identify common loci, for developing new loci for phylogenetic analyses.
    I have bam files from the transcriptomes sequences aligned against a reference genome (after some filters), I have a bed file containing the intervals found in the 4 transcriptomes (multiIntersect in BedTools), and I would like to retrieve the sequences for these intervals in each of the transcriptomes. I don't want the complete scaffolds, just the portion of the transcriptome scaffold (not from the reference genome) that is located in the intervals.
    I looked to the bedtools getfasta, but I got my reference sequence, and several other tools or combination of tools, but each time, I got only the reference sequence, or the entire scaffolds...
    Any idea that could help me ?
  • goutham.atla
    Junior Member
    • Oct 2012
    • 7

    #2
    If you want the fasta from BAM file, I don't think so there is any tool. But what could you do is to get the reads mapped to regions of interests using samtools with -L option and then try to merge them based on overlaps.

    Comment

    • Michael.Ante
      Senior Member
      • Oct 2011
      • 127

      #3
      You can try the samtools pipeline to extract a consensus-sequence like here:
      Code:
      samtools mpileup -uf ref.fa aln.bam | bcftools view -cg - | vcfutils.pl vcf2fq > cns.fq
      In order to restrict it to your targets, you can loop it over them and restricting it with -r in the mpileup call.
      Afterwards, you need to convert the fastq to fasta with e.g. fastq_to_fasta from the fastx toolkit.

      Cheers,
      Michael

      Comment

      • dena.dinesh
        Member
        • Feb 2013
        • 58

        #4
        Originally posted by Michael.Ante View Post
        You can try the samtools pipeline to extract a consensus-sequence like here:
        Code:
        samtools mpileup -uf ref.fa aln.bam | bcftools view -cg - | vcfutils.pl vcf2fq > cns.fq
        In order to restrict it to your targets, you can loop it over them and restricting it with -r in the mpileup call.
        Afterwards, you need to convert the fastq to fasta with e.g. fastq_to_fasta from the fastx toolkit.

        Cheers,
        Michael
        Hi Michael,

        I am new to RNAseq data analysis. I also want to obtain the complete sequence for every transcript that has been aligned from a bam file not just only consensus part. With the above is it possible to obtain the complete sequence?

        I used your above code and generated the fastq file but when opened the fastq file I found 'n's in between sequences. Also I found that some nucleotides are in Capital letters and while some are in small letters. Is the Nucleotides with Capital letters means they are consensus region?

        kindly guide me

        Comment

        • Michael.Ante
          Senior Member
          • Oct 2011
          • 127

          #5
          Hi Dena,

          I'd suggest to have a look at your data with the IGV browser first to get an impression of your read-distribution and coverage. Alternatively, you can use samtools tview.
          You mapped your reads against the genome while your data is from the transcriptome. The Ns are most likely derived from exon-exon junctions. If more than 80% of the nucleotides are identical, they are depicted in capital letters.

          Comment

          • dena.dinesh
            Member
            • Feb 2013
            • 58

            #6
            Originally posted by Michael.Ante View Post
            Hi Dena,

            I'd suggest to have a look at your data with the IGV browser first to get an impression of your read-distribution and coverage. Alternatively, you can use samtools tview.
            You mapped your reads against the genome while your data is from the transcriptome. The Ns are most likely derived from exon-exon junctions. If more than 80% of the nucleotides are identical, they are depicted in capital letters.
            Hi Michael,

            The organism on which I work has no genome available so far so all I have to depend only on transcriptome for alignment.

            I want to find the mutation from RNAseq data. So I mapped the RNAseq data to my reference transcription and later generate a bam file. Using the command
            Code:
            samtools mpileup -uf ref.fa aln.bam | bcftools view -cg - | vcfutils.pl vcf2fq > cns.fq
            I generated fasta file only with aligned reads. To find the mutation, the aligned transcript will be compared with its own reference transcript from trancriptome to find the number of nucleotides have been mutated. Is my approach is right?

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
              by SEQadmin2



              CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

              Despite this, “CRISPR helped turn genome editing from a specialized technique into
              ...
              07-31-2026, 11:01 AM
            • 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
              ...
              07-20-2026, 11:48 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, 08-13-2026, 12:22 PM
            0 responses
            27 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-11-2026, 10:35 AM
            0 responses
            22 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-06-2026, 07:41 AM
            0 responses
            36 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-03-2026, 10:13 AM
            0 responses
            51 views
            0 reactions
            Last Post SEQadmin2  
            Working...