Convert a cram file to fasta
0
0
Entering edit mode
2.2 years ago
Samanta • 0

How can I go from a cram file to a fasta without having to convert to a .bam, index and map?

At the moment I'm trying to pass bam, but I'm not succeeding either

I already tried with this line

samtools view -b -T /media/SSD1/reference.fasta -o 15132.bam 15132_657.cram

but it throws me this error

[W::find_file_url] Failed to open reference "https://www.ebi.ac.uk/ena/cram/md5/17d0aca68c27ef37c9f0ebbd12de292b": Protocol not supported
[E::cram_get_ref] Failed to populate reference for id 1
[E::cram_decode_slice] Unable to fetch reference #1 206..211482
[E::cram_next_slice] Failure to decode slice
[main_samview] truncated file.
cram fasta samtools • 1.3k views
ADD COMMENT
0
Entering edit mode

Something like this may be simpler:

samtools view -b -T /media/SSD1/reference.fasta 15132_657.cram | samtools sort -n - | samtools fasta ...option

That said it appears that you may be using incorrect reference.See: Failed to populate reference for id 1?

You may be able to simply use

$ samtools fasta
Usage: samtools fasta [options...] <in.bam>

Description:
Converts a SAM, BAM or **CRAM** to FASTA format.
ADD REPLY
0
Entering edit mode

what is your ultimate goal in "converting CRAM to FASTA"

ADD REPLY
0
Entering edit mode

To do my selection and linkage disequilibrium assays

ADD REPLY
0
Entering edit mode

You will likely not be closer to your goal by converting CRAM to FASTA. Instead you likely want to do variant calling on your CRAM file(s) to generate a VCF, and do population analysis and things on that. see linkage disequilibrium analysis for an example of linkage disequilibrium analysis on a VCF. It is often important to be clear about what your end goal is when asking a question because "converting CRAM to FASTA" is sort of a non-sense operation (the answer given above converts each individual read to a line in the FASTA, which is rarely what you want), it's much more common to analyze your variants in VCF/PLINK style workflows. see also https://pixy.readthedocs.io/en/latest/

ADD REPLY

Login before adding your answer.

Traffic: 2560 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6