<p>Unless I'm mistaken, the only variant of GFF that explicitly permits Fasta entries is GFF3, and the data you've shown above is definitely not valid GFF3. The mRNA entry seems to correctly use the <code>=</code> symbol to separate keys from values in each attribute, but the remaining columns all use spaces and quotation marks (GTF style) instead. This is likely to cause all kinds of problems with software packages that take GFF data as input.</p>

<p>But to more directly address your question, there is no "right" way to connect feature entries to sequence entries in a GFF3 file. There are some <em>conventions</em>, but these are all very specific to a small set of tools and community of practice, and it is rare that these conventions are objectively enforced. Some options include:</p>

<ul>
<li>Placing genomic nucleotide sequences in the <code>##FASTA</code> section, and then using feature coordinates to pull out mature mRNA sequences and translate them <em>in silico</em> to derive the corresponding peptide sequence. In this case, the Fasta entries would be genomic sequence identifiers that correspond to the first field/column in each feature entry.</li>
<li>Placing mature mRNA sequences in the <code>##FASTA</code> section, and then directly translating this sequence to derive the corresponding peptide sequence. In this case, you'll want the sequence IDs in the <code>##FASTA</code> section to match the <code>ID</code> attribute of the corresponding mRNA feature.</li>
<li>Placing the peptide sequences directly in the <code>##FASTA</code> section. In this case, you would either want to have <code>protein</code> features declared in the GFF3 file (uncommon) or have some sort of <code>protein_id</code> attribute associated with each mRNA feature, in which case you'd want the sequence IDs in the <code>##FASTA</code> section to match this <code>protein_id</code> attribute.</li>
</ul>

<p>There are probably other ways of doing it, too. Which way is "right"? The GFF3 specification has nothing to say about it. It depends on the tools you are using to do the subsequent processing and analysis. If you're lucky, those tools might even document what they expect in terms of input.</p>

<hr>

<p>Let me just say, as a post-script, that I think placing sequences and feature annotations in the same file is a horrible idea. I've never liked this about GFF3.</p>

CC BY-SA 3.0
2017-12-27T19:12:00.960Z
2017-12-27T19:12:00.960Z
Daniel Standage
<p>To answer your specific question, you should use the identifier from the first column of the GFF in the ##Fasta section. As you note, this won't work if you are trying to add multiple protein sequence for each seqid. Try using the scaffold DNA sequences in this section and add amino acid translations as an attribute of the annotations.</p>

CC BY-SA 3.0
2017-10-23T22:06:10.833Z
Thanks for your reply. `add amino acid translations as an attribute of the annotations` Which annotations? Where exactly would you add the translations?
Cleb
CC BY-SA 3.0
2017-10-23T12:48:04.660Z
2017-10-23T12:48:04.660Z
heathobrien
<p>I have a gff file like this</p>

<pre><code>scaffold_1  source  mRNA    2987526 2992430 .   -   .   ID=protein_id_68892;Name="foobar";locus_tag=my_organism_68892;translation=MHTGDALEGSTGNVSILV...
scaffold_1  source  exon    2987526 2987805 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2987526 2987805 .   -   1   name "foobar"; proteinId 68892; exonNumber 5;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2988610 2988745 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2988610 2988745 .   -   2   name "foobar"; proteinId 68892; exonNumber 4;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2989157 2989645 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2989157 2989645 .   -   2   name "foobar"; proteinId 68892; exonNumber 3;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2990903 2991541 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2990903 2991541 .   -   2   name "foobar"; proteinId 68892; exonNumber 2;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2991587 2992430 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2991587 2992430 .   -   0   name "foobar"; proteinId 68892; exonNumber 1;locus_tag=my_organism_68892;Parent=protein_id_68892
</code></pre>

<p>The <code>mRNA</code>entry was not present at first and I added it in. I also have the protein fast file available and would now like to add the amino acid sequences to the gff. I originally added them in column 9 to the <code>mRNA</code>entry which is apparently incorrect. <a href="https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md" rel="nofollow noreferrer">Here</a> it is written that the sequences should go at the end of the file in the <code>##Fasta</code>section. However, I struggle to figure out which identifier I should use to link it to my <code>mRNA</code> entries.</p>

<p>Do I have to use</p>

<pre><code>##Fasta
&gt;protein_id_68892
MHTGDALEGSTGNVSILV...
</code></pre>

<p>or does it work with the locus_tag</p>

<pre><code>##Fasta
&gt;my_organism_68892
MHTGDALEGSTGNVSILV...
</code></pre>

<p>or is it something completely else? Where and how do can I add the translation information?</p>

<p>In the link above (and also in the comments it is suggested) the identifier in the first column is used, in my case that would be <code>scaffold_1</code>. However, I do have a lot of entries with <code>scaffold_1</code>in my file so a link between <code>scaffold_1</code>and an amino acid sequence would not be unique as I would have</p>

<pre><code>##Fasta
&gt;scaffold_1
MHTGDALEGSTGNVSILV...
&gt;scaffold_1
GDAHTEGSTGNVSILV...
</code></pre>

<p>. In the end, I want to create a genbank file (which does not exist yet) where I can link a CDS to an amino acid sequence.</p>

CC BY-SA 3.0
2017-10-23T10:31:38.023Z
Normally, the ##Fasta section contains the nucleotide sequences corresponding to the seqid column. Most GFF parsers can generate amino acid sequences on the fly from this information
heathobrien
CC BY-SA 3.0
2017-10-23T10:37:06.510Z
@heathobrien: Thanks for the info. But the problem would remain: Which identifier should be used there?
Cleb
CC BY-SA 3.0
2017-10-23T10:41:56.753Z
in your example, scaffold_1
heathobrien
CC BY-SA 3.0
2017-10-23T10:45:07.777Z
@heathobrien: but in the file I see `scaffold_1` for a lot of proteins.  Then it would still unclear which sequence to add. Also, in the link in my question is written `This notation indicates that the annotation portion of the file is at an end and that the remainder of the file contains one or more sequences (nucleotide or protein) in FASTA format.` So adding proteins should be ok. Any ideas?
Cleb
CC BY-SA 3.0
2017-10-23T10:52:20.900Z
It's normal for multiple genes to be coded on the same DNA sequence. The GFF tells you which portion of the sequence codes for each gene. Ultimately, you can add whatever you want. It really depends what you're planning to do with the file.
heathobrien
<gff3>
Which identifier do I have to use when I want to add a ##Fasta section to a gff?
# Which identifier do I have to use when I want to add a ##Fasta section to a gff?

(Asked by: username_0 on 2017-10-23)

I have a gff file like this
scaffold_1  source  mRNA    2987526 2992430 .   -   .   ID=protein_id_68892;Name="foobar";locus_tag=my_organism_68892;translation=MHTGDALEGSTGNVSILV...
scaffold_1  source  exon    2987526 2987805 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2987526 2987805 .   -   1   name "foobar"; proteinId 68892; exonNumber 5;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2988610 2988745 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2988610 2988745 .   -   2   name "foobar"; proteinId 68892; exonNumber 4;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2989157 2989645 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2989157 2989645 .   -   2   name "foobar"; proteinId 68892; exonNumber 3;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2990903 2991541 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2990903 2991541 .   -   2   name "foobar"; proteinId 68892; exonNumber 2;locus_tag=my_organism_68892;Parent=protein_id_68892
scaffold_1  source  exon    2991587 2992430 .   -   .   name "foobar"; transcriptId 68892;locus_tag=my_organism_68892
scaffold_1  source  CDS     2991587 2992430 .   -   0   name "foobar"; proteinId 68892; exonNumber 1;locus_tag=my_organism_68892;Parent=protein_id_68892

The mRNAentry was not present at first and I added it in. I also have the protein fast file available and would now like to add the amino acid sequences to the gff. I originally added them in column 9 to the mRNAentry which is apparently incorrect. Here it is written that the sequences should go at the end of the file in the ##Fastasection. However, I struggle to figure out which identifier I should use to link it to my mRNA entries.
Do I have to use
##Fasta
>protein_id_68892
MHTGDALEGSTGNVSILV...

or does it work with the locus_tag
##Fasta
>my_organism_68892
MHTGDALEGSTGNVSILV...

or is it something completely else? Where and how do can I add the translation information?
In the link above (and also in the comments it is suggested) the identifier in the first column is used, in my case that would be scaffold_1. However, I do have a lot of entries with scaffold_1in my file so a link between scaffold_1and an amino acid sequence would not be unique as I would have
##Fasta
>scaffold_1
MHTGDALEGSTGNVSILV...
>scaffold_1
GDAHTEGSTGNVSILV...

. In the end, I want to create a genbank file (which does not exist yet) where I can link a CDS to an amino acid sequence.

**Tags:** gff3
> **Comments:**
> **username_1**: Normally, the ##Fasta section contains the nucleotide sequences corresponding to the seqid column. Most GFF parsers can generate amino acid sequences on the fly from this information  
> **username_0**: @heathobrien: Thanks for the info. But the problem would remain: Which identifier should be used there?  
> **username_1**: in your example, scaffold_1  
> **username_0**: @heathobrien: but in the file I see `scaffold_1` for a lot of proteins.  Then it would still unclear which sequence to add. Also, in the link in my question is written `This notation indicates that the annotation portion of the file is at an end and that the remainder of the file contains one or more sequences (nucleotide or protein) in FASTA format.` So adding proteins should be ok. Any ideas?  
> **username_1**: It's normal for multiple genes to be coded on the same DNA sequence. The GFF tells you which portion of the sequence codes for each gene. Ultimately, you can add whatever you want. It really depends what you're planning to do with the file.  

---

## 2 answers

### Answer by username_2 on 2017-12-27. Score: 2

Unless I'm mistaken, the only variant of GFF that explicitly permits Fasta entries is GFF3, and the data you've shown above is definitely not valid GFF3. The mRNA entry seems to correctly use the `=` symbol to separate keys from values in each attribute, but the remaining columns all use spaces and quotation marks (GTF style) instead. This is likely to cause all kinds of problems with software packages that take GFF data as input.

But to more directly address your question, there is no "right" way to connect feature entries to sequence entries in a GFF3 file. There are some *conventions*, but these are all very specific to a small set of tools and community of practice, and it is rare that these conventions are objectively enforced. Some options include:

* Placing genomic nucleotide sequences in the `##FASTA` section, and then using feature coordinates to pull out mature mRNA sequences and translate them *in silico* to derive the corresponding peptide sequence. In this case, the Fasta entries would be genomic sequence identifiers that correspond to the first field/column in each feature entry.
* Placing mature mRNA sequences in the `##FASTA` section, and then directly translating this sequence to derive the corresponding peptide sequence. In this case, you'll want the sequence IDs in the `##FASTA` section to match the `ID` attribute of the corresponding mRNA feature.
* Placing the peptide sequences directly in the `##FASTA` section. In this case, you would either want to have `protein` features declared in the GFF3 file (uncommon) or have some sort of `protein_id` attribute associated with each mRNA feature, in which case you'd want the sequence IDs in the `##FASTA` section to match this `protein_id` attribute.

There are probably other ways of doing it, too. Which way is "right"? The GFF3 specification has nothing to say about it. It depends on the tools you are using to do the subsequent processing and analysis. If you're lucky, those tools might even document what they expect in terms of input.

---

Let me just say, as a post-script, that I think placing sequences and feature annotations in the same file is a horrible idea. I've never liked this about GFF3.


---

### Answer by username_1 on 2017-10-23. Score: 0

To answer your specific question, you should use the identifier from the first column of the GFF in the ##Fasta section. As you note, this won't work if you are trying to add multiple protein sequence for each seqid. Try using the scaffold DNA sequences in this section and add amino acid translations as an attribute of the annotations.

> **Comments:**
> **username_0**: Thanks for your reply. `add amino acid translations as an attribute of the annotations` Which annotations? Where exactly would you add the translations?  

---

