Question: gff3 to CDS fasta
0
gravatar for n.caillou
2.3 years ago by
n.caillou0
n.caillou0 wrote:

Given a genomic fasta file and a GFF3 file like this (this is just one transcript):

groupI  AUGUSTUS        gene    24128   27467   1       +       .       ID=g2
groupI  AUGUSTUS        transcript      24128   27467   .       +       .       ID=g2.t1;Parent=g2
groupI  AUGUSTUS        start_codon     24128   24130   .       +       0       Parent=g2.t1
groupI  AUGUSTUS        CDS     24128   24311   .       +       0       ID=g2.t1.cds;Parent=g2.t1
groupI  AUGUSTUS        CDS     25287   25354   .       +       2       ID=g2.t1.cds;Parent=g2.t1
groupI  AUGUSTUS        CDS     27267   27467   .       +       0       ID=g2.t1.cds;Parent=g2.t1
groupI  AUGUSTUS        stop_codon      27465   27467   .       +       0       Parent=g2.t1

Is there a simple way to extract a fasta of the CDS (or of the translated sequence) for each transcript?

I have already seen:

Isn't there something more simple and reliable than the above custom scripts?

sequence gff3 genome • 4.6k views
ADD COMMENTlink modified 2.3 years ago by A. Domingues1.8k • written 2.3 years ago by n.caillou0
1

Did you try bedtools getfasta ?

ADD REPLYlink modified 2.3 years ago • written 2.3 years ago by Santosh Anand4.6k

I did, see my answer to WouterDeCoster below. I cannot get per-transcript CDS sequences, I just get each element (gene, transcript, start/end codons, and each CDS fragment) separately. Is this the expected result?

ADD REPLYlink written 2.3 years ago by n.caillou0

I see what you mean. This might help you A: Gencode Gtf To Bed12 Or Psl

ADD REPLYlink written 2.2 years ago by Santosh Anand4.6k
2
gravatar for A. Domingues
2.3 years ago by
A. Domingues1.8k
Mainz, Germany
A. Domingues1.8k wrote:

Are you happy with R/Bioconductor? There is a solution here which could solve your problem. Look for item #6 of 'Alignments (and genomic annotations)'. I will transcribe the relevant (but incomplete) bits of code here for convenience, but all credits go to Martin Morgan.

## cds for all transcripts
cdsByTx <- cdsBy(TxDb.Hsapiens.UCSC.hg19.knownGene, "tx")

## reference genome
library(BSgenome.Hsapiens.UCSC.hg19)

dna <- extractTranscriptSeqs(BSgenome.Hsapiens.UCSC.hg19, cdsByTx)
protein <- translate(dna)
ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by A. Domingues1.8k

If I am going to do a non-trivial amount of scripting I'd probably go with Biopython. Also, would this work with any fasta/gff3 pair of files?

ADD REPLYlink written 2.3 years ago by n.caillou0

Assuming the gff3 is well formatted, that is, contains the CDS information, yes. Of course, when it comes to bioinformatics assuming a file is well formatted and that things will go as expected it a big ask so ymmv.

ADD REPLYlink written 2.3 years ago by A. Domingues1.8k
1
gravatar for WouterDeCoster
2.3 years ago by
Belgium
WouterDeCoster36k wrote:

I would suggest to try if bedtools getfasta fit your needs.

ADD COMMENTlink written 2.3 years ago by WouterDeCoster36k

Thanks, but actually, I have also tried getfasta. And I can only get the sequences of each element separately.

Would the -split option do what I want? Apparently it will only work if the input is BED. How do I convert my GFF3 to BED? Which other tool do I have to use besides getfasta?

edit: The converter is bedops's gff2bed, I suppose. It didn't help, though (same result).

ADD REPLYlink modified 2.3 years ago • written 2.3 years ago by n.caillou0

And can't you pre filter your gff to only contain 'transcript' features, e.g. using grep "transcript" yourfile.gff > onlytranscript.gff?

ADD REPLYlink written 2.3 years ago by WouterDeCoster36k

I can do that to have all the CDS and just them (that's part of the "shell tricks" in my answer below), but then I would have to piece them together. Definitely possible but not simple either.

ADD REPLYlink written 2.3 years ago by n.caillou0

But the transcript annotation in a gff is the full transcript, entire CDS of a gene, right? I don't understand what you would need to paste together.

ADD REPLYlink written 2.3 years ago by WouterDeCoster36k
1

As I understand the question of n.caillou, he wants to extract coding sequences, not transcript sequence (i.e. he needs to paste together exons for multi-exon genes)...

ADD REPLYlink written 13 months ago by al-ash100
1
gravatar for Daniel Standage
2.3 years ago by
Daniel Standage3.8k
Davis, California, USA
Daniel Standage3.8k wrote:

The xtractore program from the AEGeAn Toolkit should work for this. Set --type=CDS on the command line. For CDSs and other discontiguous features, xtractore pastes the fragments together correctly, taking into account strand, etc.

ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by Daniel Standage3.8k

This would work, thanks. But isn't there something more standard? It is very impractical for me to install new software.

ADD REPLYlink written 2.3 years ago by n.caillou0
1

I'm not sure I understand your constraints. If you are uncomfortable evaluating custom Perl/Python scripts and if installing new software is impractical for you, you may be in the wrong field!

I'm not trying to be witty or smug, I'm being completely frank. The bioinformatics state of the art unfortunately provides very few clean solutions; almost always you must get your hands a bit dirty to piece together a working solution.

ADD REPLYlink written 2.3 years ago by Daniel Standage3.8k

Hello Daniel,

I used xtractore to extract CDS from a gff file. It does extract CDS taking into account strand and so on, but it does not paste CDS fragments belonging to the same gene together. Am I missing sth?

Also, the -w option does not seem to work properly:

xtractore -t CDS -w 0 -o timema_cristinae.fa timema_cristinae.gff Timema_cristinae_scaffolds.fas

Setting -w to zero gives me an empty output fasta file. In the documentation it is mentioned: "-w|--width: INT width of each line of sequence in the Fasta output; default is 80; set to 0 for no formatting"

Anyways, thanx for your program, it would take 2-3 days to write a CDS extractor myself :P

ADD REPLYlink modified 9 months ago • written 9 months ago by panosprov0
0
gravatar for n.caillou
2.3 years ago by
n.caillou0
n.caillou0 wrote:

Using bedops and bedtools and shell tricks I can get a TSV file like:

g2.t1.cds   ATGAAGACGACGCTTGC...
g2.t1.cds   AGCGGAGTACCACGTGT...
g2.t1.cds   CACCACCGCGACCCC...TGA

But it is just a pile of hacks, and it is not even finished.

ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by n.caillou0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 965 users visited in the last hour