Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skingan
    Member
    • Feb 2010
    • 17

    #1

    bam -> vcf -> fasta

    Hi Everyone,

    I am trying to generate a FASTA sequence from a BAM file using a BCF/VCF file as an intermediate. I would like to create a temporary BCF/VCF file from which I can make a FASTA sequence as well as estimate nucleotide polymorphism using the vcftools package.

    Fasta sequences can only generated for a single sample at a time, so I need to create a BCF/VCF file with a single sample. To do this, I have two commands: one that converts from BAM to BCF/VCF and the other which converts fro BCF/VCF to FASTA. Frustratingly, when I select a single sample in the second command, my FASTA sequence contains lots of ambiguities. But when I select it in the first, it works just fine. I would like to create a single BCF/VCF file for a region of interest and then generate FASTA sequences for each sample, rather than having to make a BCF/VCF file for every sample (waste of space!).

    Bear with me while I give each pair of commands with the FASTA formatted output. The first two use a VCF intermediate, the last two use a BCF.

    samtools mpileup -gIq20 -r 2L:53202-53313 -f /home/data/mau12/mau12.fa /home/data/maupoly/maupolyI.bam | bcftools view -g - > all.vcf
    bcftools view -Ss mel.txt all.vcf | vcfutils.pl vcf2fq | seqtk fq2fa - | seqtk cutN -
    >0:53202-53313
    TGTAAGTAAATARAAAGGAACTAGAATTTAATCCTAGATCTGRATAAGTATSAAAACAAG
    ACCTMCRSGTACTTGCTARRACTCGACATTYAAAAAAYRTATTKCTTTTTAG

    samtools mpileup -gIq20 -r 2L:53202-53313 -f /home/data/mau12/mau12.fa /home/data/maupoly/maupolyI.bam | bcftools view -gs mel.txt - > mel.vcf
    bcftools view -S tmp.vcf | vcfutils.pl vcf2fq | seqtk fq2fa - | seqtk cutN -
    >2L:53202-53313
    TGTAAGTAAATARAAAGGAACTAGAATTTAATCCTAGATCTGRATAAGTATSAAAACAAG
    ACCTMCRSGTACTTGCTARRACTCGACATTYAAAAAAYRTATTKCTTTTTAG


    samtools mpileup -gIq20 -r 2L:53202-53313 -f /home/data/mau12/mau12.fa /home/data/maupoly/maupolyI.bam | bcftools view -bgs mel.txt - > mel.bcf
    bcftools view mel.bcf | vcfutils.pl vcf2fq | seqtk fq2fa - | seqtk cutN -
    >2L:53202-53313
    TGTAAGTAAATAAAAAGGAACTAGAATTTAATCCTAGATCTGAATAAGTATCAAAACAAG
    ACCTCCGCGTACTTGCTAAGACTCGACATTTAAAAAACGTATTTCTTTTTAG

    samtools mpileup -gIq20 -r 2L:53202-53313 -f /home/data/mau12/mau12.fa /home/data/maupoly/maupolyI.bam | bcftools view -bg - > all.bcf
    bcftools view -s mel.txt all.bcf | vcfutils.pl vcf2fq | seqtk fq2fa - | seqtk cutN -
    >2L:53202-53313
    TGTAAGTAAATARAAAGGAACTAGAATTTAATCCTAGATCTGRATAAGTATSAAAACAAG
    ACCTMCRSGTACTTGCTARRACTCGACATTYAAAAAAYRTATTKCTTTTTAG

    The third set of commands gives me the right output: no ambiguities, and I've check that this is 100% correct from an independent source.

    Does anyone have any idea why this happens???

    Thanks in advance.

    Sarah
  • nthompson
    Junior Member
    • Dec 2013
    • 1

    #2
    Hello,

    Does anyone knows how I could convert a .vcf file to .fasta format? I have used the following string in samtools, however, I am seeing only n's in the fasta output.

    <vcfutils.pl vcf2fq mappedreads.vcf > mappedreads.fq>

    Thanks in advance!

    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
    23 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-22-2026, 10:48 AM
    0 responses
    20 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...