This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert cds .fa to bed

Hi,

I have downloaded cds file for a genome in .fa format from Ensembl (file name: organism.cds.all.fa.gz). However, I need cds in bed format. I am unable to find it on UCSC also. Any guidance would be appreciated.

Thanks!

ensembl bed fasta cds ucsc

1 answer

Instead of starting with a fasta file easiest thing to do is to download a gtf file from Ensembl and convert it to bed. Converting gtf format to bed format

Thanks, but gtf is available for genome and not for cds.

You can filter a gtf to only select records that are CDS.

Would you please provide more directions in this regard as I am new in the field? Thanks.

Sej Modha your approach is good. After downloading the gtf. If you are using a Linux system to Grep records that are CDS.

grep "CDS" input.gtf > output.gtf

Then Convert gtf to bed

You might wanna do the filtering based on a column (I think it is column 3) to ensure that you subset the file properly.

Yes, CDS is the column 3 and grep worked. :)

Ensembl gtf has 1-based coordinate system while bed has 0-based, so the following won't be enough to create bed file?

awk 'BEGIN {OFS="\t"} {print $1,$4,$5}' org_cds.gtf  > org_cds_3cols.bed

Corrected one by substracting 1 from column 4 to convert 1-based to 0-based system (How To Convert Gencode Gtf Into Bed Format ?)

 awk 'BEGIN {OFS="\t"} {print $1,$4-1,$5}' org_cds.gtf  > org_cds_3cols.bed

Log in to answer this question.