This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Get Ref.Fasta

Hi,

I want to use samtools command

samtools faidx <ref.fasta> [region1 [...]]

My question: where can I get ref.fasta or how to create ref.fasta by some command? Suppose I have a bam file already.

Thanks.

samtools sequence

Which genome was used to create your BAM file? By that I mean, to which genome were the reads aligned?

Human genome. dbGaP phenotype release

Which human genome? hg18, hg19, another one? Normally you can download the hgXX as single chromosomes and merged them to hgXX.fasta, meaning ref.fasta

hg18 genome. Where can I download it?

just a warning: if you already have a BAM file it means that the reads have already been mapped, so the reference file should have already been available. you should try to retrieve such reference file, because if you download a different file you would end having nomenclature or position errors that won't be easy to deal with.

2 answers

Get it here:

http://hgdownload.cse.ucsc.edu/goldenPath/hg18/bigZips/

and download hg18.2bit, this is hg18 binary coded. This one you can convert to the fasta format using twoBitToFa. You can download this tool here:

http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/

//Edit:

Ok, then you can download the single chromosomes here:

http://hgdownload.cse.ucsc.edu/goldenPath/hg18/chromosomes/

Skip that ones with random in the name, just from chr1.fa.gz to chrY.fa.gz (depends on what you need - may ask the guy who did the alignment).

After that unzip them and merge. How this works please find here:

Fasta File Vs Fa File

fa equals fasta

Let us know if it works. If not try the Link which you posted. Seems also to be hg18.fasta and you don't have to convert formats.

twoBitToFa is a corrupt text file. If you have a direct download for hg18.fasta, please let me know. Thanks.

Edit my post...

The BAM file will not contain the reference genome (if that is what you are asking). Check the header:

samtools view -H my.bam

You may find some information about the exact version that was used to align the data. If you can't find anything I'd suggest you contact the person that generated the alignments.

Yes, that's exactly what you want to do.

Log in to answer this question.