<p>You can use <a href="http://ccb.jhu.edu/software/stringtie/gff.shtml#gffread_ex" rel="noreferrer">GFF utilities</a> to get a fasta sequence from a GFF file using a reference genome file.</p>

CC BY-SA 4.0
2019-01-28T11:58:25.000Z
2019-01-28T11:58:25.000Z
geek_y
<p>A gff is a file of annotation.  It generally doesn't include sequence information, so you can not inter-convert.  But the file on your page has a fasta entry at the bottom..  I'd just grab the bottom half of it, and if the sequence length looks right, that's likely what you want.</p>

CC BY-SA 4.0
2019-01-23T22:37:10.970Z
Only to some degree. I would like to conserve the annotations.
Soerendip
CC BY-SA 4.0
2019-01-24T11:00:34.440Z
@Sören could you clarify what you mean by "conserve the annotations"? The annotations are in gff format, that's standard. Do you want to add the annotations to the fasta file for some reason?
terdon
CC BY-SA 4.0
2019-01-23T22:08:47.943Z
2019-01-23T22:08:47.943Z
swbarnes2
<blockquote>
  <p>Is there any tool that converts gff to annotated fasta?</p>
</blockquote>

<p>This is not an uncommon question / request, but perhaps a crash course refresher on file formats would provide some valuable context.</p>

<ul>
<li><strong>FASTA files</strong> are designed to hold nucleotide or amino acid sequences. The "defline" (header) of each record may include some unique identifiers or descriptive metadata. There are no strict requirements, although there are many common conventions. The information that <em>should</em> be the defline of a FASTA record depends primarily on the tool(s) used to produce and analyze the data.</li>
<li><strong>GFF files</strong> are designed to hold annotations corresponding to sequences, most often genomic sequences such as chromosomes or (if it's a draft genome assembly) scaffolds or contigs. Each record in the GFF file specifies a sequence (such as <code>chr6</code> or <code>scaffold1985</code>) and an interval (such as <code>19920557-19997344</code> or <code>2488-2489</code>). The GFF file labels that interval as a gene or transposable element or transcription factor binding site or whatever genomic feature you're interested in.</li>
</ul>

<p>So in this context, a "<em>tool that converts gff to annotated fasta</em>" doesn't make sense since it's an underdefined task. There are many ways to extract sequences from a Fasta file that has been annotated with a GFF file. Many, many scientists have written throwaway programs to do this type of task. It can be done in a hundred subtly different ways, and most of these programs are designed for a single narrow use case. Do you want to:</p>

<ul>
<li>pull out the sequence corresponding to every GFF record? Usually not helpful, since many records are children of other records.</li>
<li>pull out the sequence corresponding to every gene? More common, but since you want to do proteomics you're probably not interested in promoters or introns (if either of these are annotated in your GFF file). </li>
<li>pull out the coding sequence of each gene and translate it into its corresponding peptide sequence?</li>
</ul>

<p>It looks like that last point is most likely, but unless I missed something it looks like Prokka is already doing that for you. So the question remains: <strong>precisely what information exists in your GFF file that you would like in your FASTA file</strong>? You've provided an example of what you have (the FASTA files at least), but can you provide an example of what you <em>want</em>? Only then can we help you to identify the right tool for the task. There's a good chance it will involve writing some code in a programming language like Python or Perl.</p>

CC BY-SA 4.0
2019-01-28T19:21:08.103Z
2019-01-28T19:21:08.103Z
Daniel Standage
<p>I extracted the sequence contained in the gff file into a separate file and added a header according to the fasta file format specifications. I named that file <code>ERS654933.fasta</code> and then used <code>prokka</code> to generate my own annotation.</p>

<p>File header ERS654933.fasta:</p>

<pre><code>&gt;ATCC_NCTN13373
GTGTATAACTTAAAAATTTAAGAAAGATGGAGTAAATTTATGTCGGAAAAAGAAATTTGG
GAAAAAGTGCTTGAAATTGCTCAAGAAAAATTATCAGCTGTAAGTTACTCAACTTTCCTA
AAAGATACTGAGCTTTACACGATCAAAGATGGTGAAGCTATCGTATTATCGAGTATTCCT
TTTAATGCAAATTGGTTAAATCAACAATATGCTGAAATTATCCAAGCAATCTTATTTGAT
GTTGTAGGCTATGAAGTAAAACCTCACTTTATTACTACTGAAGAATTAGCAAATTATAGT
</code></pre>

<p>Then:</p>

<pre><code>prokka ERS654933.fasta
</code></pre>

<p>Which generated a folder with several files. Here is the header of the generated file <code>PROKKA_01232019.faa</code>.</p>

<pre><code>NEOBMGJD_00001 Chromosomal replication initiator protein DnaA
MSEKEIWEKVLEIAQEKLSAVSYSTFLKDTELYTIKDGEAIVLSSIPFNANWLNQQYAEI
IQAILFDVVGYEVKPHFITTEELANYSNNETATPKEATKPSTETTEDNHVLGREQFNAHN
TFDTFVIGPGNRFPHAASLAVAEAPAKAYNPLFIYGGVGLGKTHLMHAIGHHVLDNNPDA
KVIYTSSEKFTNEFIKSIRDNEGEAFRERYRNIDVLLIDDIQFIQNKVQTQEEFFYTFNE
LHQNNKQIVISSDRPPKEIAQLEDRLRSRFEWGLIVDITPPDYETRMAILQKKIEEEKLD
IPPEALNYIANQIQSNIRELEGALTRLLAYSQLLGKPITTELTAEALKDIIQAPKSKKIT
IQDIQKIVGQYYNVRIEDFSAKKRTKSIAYPRQIAMYLSRELTDFSLPKIGEEFGGRDHT
TVIHAHEKISKDLKEDPIFKQEVENLEKEIRNV
&gt;NEOBMGJD_00002 Beta sliding clamp
MMEFTIKRDYFITQLNDTLKAISPRTTLPILTGIKIDAKEHEVILTGSDSEISIEITIPK
TVDGEDIVNISETGSVVLPGRFFVDIIKKLPGKDVKLSTNEQFQTLITSGHSEFNLSGLD
PDQYPLLPQVSRDDAIQLSVKVLKNVIAQTNFAVSTSETRPVLTGVNWLIQENELICTAT
DSHRLAVRKLQLEDVSENKNVIIPGKALAELNKIMSDNEEDIDIFFASNQVLFKVGNVNF
ISRLLEGHYPDTTRLFPENYEIKLSIDNGEFYHAIDRASLLAREGGNNVIKLSTGDDVVE
LSSTSPEIGTVKEEVDANDVEGGSLKISFNSKYMMDALKAIDNDEVEVEFFGTMKPFILK
PKGDDSVTQLILPIRTY
&gt;NEOBMGJD_00003 hypothetical protein
MVQEVVVEGDINLGQFLKTEGIIESGGQAKWFLQDVEVLINGVRETRRGKKLEHQDRIDI
PELPEDAGSFLIIHQGEQ
</code></pre>

<p>So, that way I could create my own annotation, but I am loosing the annotation information in the <code>gff</code> file.</p>

CC BY-SA 4.0
2019-01-24T17:06:49.400Z
You've got gene name and description, and you want more?  You might have to make your own script for that.
swbarnes2
CC BY-SA 4.0
2019-01-24T20:43:32.830Z
I thought, I am probably not the first one doing that. So, I was hoping someone knows how to do that. Rather then inventing the wheel again. I have done that before.
Soerendip
CC BY-SA 4.0
2019-01-23T22:35:27.943Z
2019-01-23T22:35:27.943Z
Soerendip
<p>I downloaded an annotated genome file in gff format <a href="https://www.phe-culturecollections.org.uk/products/bacteria/detail.jsp?refId=NCTC+13373&amp;collection=nctc" rel="nofollow noreferrer">here</a>. I would like to use it for proteomics. Though I need it in fasta format. Is there any tool that converts gff to annotated fasta? I see the file contains the genome sequence in fasta format, but not annotated. Are those file formats convertable?</p>

<fasta><file-formats><format-conversion><gff>
Can a gff file be converted to a fasta file?
# Can a gff file be converted to a fasta file?

(Asked by: username_0 on 2019-01-23)

I downloaded an annotated genome file in gff format [here](https://www.phe-culturecollections.org.uk/products/bacteria/detail.jsp?refId=NCTC+13373&collection=nctc). I would like to use it for proteomics. Though I need it in fasta format. Is there any tool that converts gff to annotated fasta? I see the file contains the genome sequence in fasta format, but not annotated. Are those file formats convertable?

**Tags:** fasta, file-formats, format-conversion, gff

---

## 4 answers

### Answer by username_1 on 2019-01-28. Score: 5

You can use [GFF utilities](http://ccb.jhu.edu/software/stringtie/gff.shtml#gffread_ex) to get a fasta sequence from a GFF file using a reference genome file.


---

### Answer by username_2 on 2019-01-23. Score: 5

A gff is a file of annotation. It generally doesn't include sequence information, so you can not inter-convert. But the file on your page has a fasta entry at the bottom.. I'd just grab the bottom half of it, and if the sequence length looks right, that's likely what you want.

> **Comments:**
> **username_0**: Only to some degree. I would like to conserve the annotations.  
> **username_3**: @Sören could you clarify what you mean by "conserve the annotations"? The annotations are in gff format, that's standard. Do you want to add the annotations to the fasta file for some reason?  

---

### Answer by username_4 on 2019-01-28. Score: 3

> Is there any tool that converts gff to annotated fasta?

This is not an uncommon question / request, but perhaps a crash course refresher on file formats would provide some valuable context.

* **FASTA files** are designed to hold nucleotide or amino acid sequences. The "defline" (header) of each record may include some unique identifiers or descriptive metadata. There are no strict requirements, although there are many common conventions. The information that *should* be the defline of a FASTA record depends primarily on the tool(s) used to produce and analyze the data.
* **GFF files** are designed to hold annotations corresponding to sequences, most often genomic sequences such as chromosomes or (if it's a draft genome assembly) scaffolds or contigs. Each record in the GFF file specifies a sequence (such as `chr6` or `scaffold1985`) and an interval (such as `19920557-19997344` or `2488-2489`). The GFF file labels that interval as a gene or transposable element or transcription factor binding site or whatever genomic feature you're interested in.

So in this context, a "*tool that converts gff to annotated fasta*" doesn't make sense since it's an underdefined task. There are many ways to extract sequences from a Fasta file that has been annotated with a GFF file. Many, many scientists have written throwaway programs to do this type of task. It can be done in a hundred subtly different ways, and most of these programs are designed for a single narrow use case. Do you want to:

* pull out the sequence corresponding to every GFF record? Usually not helpful, since many records are children of other records.
* pull out the sequence corresponding to every gene? More common, but since you want to do proteomics you're probably not interested in promoters or introns (if either of these are annotated in your GFF file).
* pull out the coding sequence of each gene and translate it into its corresponding peptide sequence?

It looks like that last point is most likely, but unless I missed something it looks like Prokka is already doing that for you. So the question remains: **precisely what information exists in your GFF file that you would like in your FASTA file**? You've provided an example of what you have (the FASTA files at least), but can you provide an example of what you *want*? Only then can we help you to identify the right tool for the task. There's a good chance it will involve writing some code in a programming language like Python or Perl.


---

### Answer by username_0 on 2019-01-23. Score: 2

I extracted the sequence contained in the gff file into a separate file and added a header according to the fasta file format specifications. I named that file ERS654933.fasta and then used prokka to generate my own annotation.
File header ERS654933.fasta:
>ATCC_NCTN13373
GTGTATAACTTAAAAATTTAAGAAAGATGGAGTAAATTTATGTCGGAAAAAGAAATTTGG
GAAAAAGTGCTTGAAATTGCTCAAGAAAAATTATCAGCTGTAAGTTACTCAACTTTCCTA
AAAGATACTGAGCTTTACACGATCAAAGATGGTGAAGCTATCGTATTATCGAGTATTCCT
TTTAATGCAAATTGGTTAAATCAACAATATGCTGAAATTATCCAAGCAATCTTATTTGAT
GTTGTAGGCTATGAAGTAAAACCTCACTTTATTACTACTGAAGAATTAGCAAATTATAGT

Then:
prokka ERS654933.fasta

Which generated a folder with several files. Here is the header of the generated file PROKKA_01232019.faa.
NEOBMGJD_00001 Chromosomal replication initiator protein DnaA
MSEKEIWEKVLEIAQEKLSAVSYSTFLKDTELYTIKDGEAIVLSSIPFNANWLNQQYAEI
IQAILFDVVGYEVKPHFITTEELANYSNNETATPKEATKPSTETTEDNHVLGREQFNAHN
TFDTFVIGPGNRFPHAASLAVAEAPAKAYNPLFIYGGVGLGKTHLMHAIGHHVLDNNPDA
KVIYTSSEKFTNEFIKSIRDNEGEAFRERYRNIDVLLIDDIQFIQNKVQTQEEFFYTFNE
LHQNNKQIVISSDRPPKEIAQLEDRLRSRFEWGLIVDITPPDYETRMAILQKKIEEEKLD
IPPEALNYIANQIQSNIRELEGALTRLLAYSQLLGKPITTELTAEALKDIIQAPKSKKIT
IQDIQKIVGQYYNVRIEDFSAKKRTKSIAYPRQIAMYLSRELTDFSLPKIGEEFGGRDHT
TVIHAHEKISKDLKEDPIFKQEVENLEKEIRNV
>NEOBMGJD_00002 Beta sliding clamp
MMEFTIKRDYFITQLNDTLKAISPRTTLPILTGIKIDAKEHEVILTGSDSEISIEITIPK
TVDGEDIVNISETGSVVLPGRFFVDIIKKLPGKDVKLSTNEQFQTLITSGHSEFNLSGLD
PDQYPLLPQVSRDDAIQLSVKVLKNVIAQTNFAVSTSETRPVLTGVNWLIQENELICTAT
DSHRLAVRKLQLEDVSENKNVIIPGKALAELNKIMSDNEEDIDIFFASNQVLFKVGNVNF
ISRLLEGHYPDTTRLFPENYEIKLSIDNGEFYHAIDRASLLAREGGNNVIKLSTGDDVVE
LSSTSPEIGTVKEEVDANDVEGGSLKISFNSKYMMDALKAIDNDEVEVEFFGTMKPFILK
PKGDDSVTQLILPIRTY
>NEOBMGJD_00003 hypothetical protein
MVQEVVVEGDINLGQFLKTEGIIESGGQAKWFLQDVEVLINGVRETRRGKKLEHQDRIDI
PELPEDAGSFLIIHQGEQ

So, that way I could create my own annotation, but I am loosing the annotation information in the gff file.

> **Comments:**
> **username_2**: You've got gene name and description, and you want more?  You might have to make your own script for that.  
> **username_0**: I thought, I am probably not the first one doing that. So, I was hoping someone knows how to do that. Rather then inventing the wheel again. I have done that before.  

---

