Answers.Body: <p>I was wanting more time, but okay here's what I'm thinking,</p>
  
  <blockquote>
    <p>Would it make more sense to use the strain used as the vaccine
    candidate as the reference genome?</p>
  </blockquote>
  
  <p>Neither, because the GTF format is based on an HA protein structure (likely a crystal structure but could be cryoEM). This is not the same as an alignment position within a surface antigen, because most alignments of pathogen surface antigen genes will contain indels, e.g. between the GTF and your influenza epidemic. If HA doesn't have any indels fine, but I would be surprised. </p>
  
  <p>The indels will cause artifactual shifts in the GTF domain boundaries unless they are corrected. Put simply an alignment position (particularly for pathogen surface antigen proteins) is rarely the same as the amino acid position of GFT because a protein structure of a surface antigen doesn't comprise indels in its native form. </p>
  
  <p>If you do this work in detail, i.e. shifting between protein structure and phylogeny, you always write scripts which convert between aligned positions and "reference" (crystal/ cryoEM structure) positions. Its a common way of thinking.</p>
  
  <p>So in summary, your reference sequence is the GTF sequence because that is the basis of the structure&lt;-> alignment conversion  </p>
  
  <hr>
  
  <p>For positive selection analysis it does not matter what the reference is, <strong>all that matters is the correct rooting</strong>. For demarcation of domains within HA the GFT sequence needs to be at the top of the alignment 1) because it helps easily identify whether it contains indels 2) structure programs will expect the reference sequence to be there. If you are using the vaccine in a positive selection analysis ... you need to think hard about the question you are asking and the coverage of the vaccine. Epidemiologically speaking thats complicated because the passage of the vaccine will be an important source of selection and you will mistake that as the wild-type "escaping" the vaccine.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T20:00:51.507Z
Answers.Text: What I was suggesting was using the sequence for the HA segment of the vaccine candidate as the reference sequence used for the mapping and subsequent generation of the gtf. I'm not sure I made that clear. As you say, the HAs of the epidemic are likely to have a lot of indels, but still, some sequence must be considered the reference on which to align. In viruses with high mutation rates, what would make a good reference sequence?
Answers.UserDisplayName: Lindsey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T20:56:33.233Z
Answers.Text: I've amended above
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T19:00:05.283Z
Answers.Text: So if I am understanding you correctly, I could use either the consensus sequence or the vaccine candidate HA sequence (or any sequence) as the reference in a positive selection analysis as long as I have the correct rooting. I'm not sure if I fully understood the last part of what you amended, but my set of HA sequences come from influenza cases, none are from the vaccine.
Answers.UserDisplayName: Lindsey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T21:19:10.960Z
Answers.Text: Hi Lindsey, .... firstly NEVER use the consensus sequence in a positive selection analysis - even if we disagree about the epidemiological focus of your study - NEVER use consequence in a phylogenetics analysis. However, yes the maximum likelihood approach to positive selection (the only one worth bothering about), the correct root is important. In other positive selection calculations (distance), it is will not make much difference.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T18:38:25.643Z
Answers.LastActivityDate: 2019-03-05T21:02:13.850Z
Answers.LastEditDate: 2019-03-05T21:02:13.850Z
Answers.UserDisplayName: M__
Answers.Body: <p>"Transforming" Fasta files to GTF or GFF3 files is a common request, as are similar tasks such as "converting" BAM files to VCF files. But these are underdefined questions, and "transform" or "convert" isn't really the right way to think about the task.</p>
  
  <p>As far as your particular request is concerned, Fasta files and GTF files contain fundamentally different types data.</p>
  
  <ul>
  <li>Fasta files contain sequences, which could be chromosomes, assembled contigs, polypeptides, transcripts, or other biological sequences.</li>
  <li>GTF (and GFF3 and BED) files contain <em>intervals</em>, indicating that some feature of interest occurs at such-and-such position on such-and-such sequence. A hypothetical example: a transcription factor binding site occurs on chromosome 2 from position 40011 to 40017.</li>
  </ul>
  
  <p>So you are correct: it's not really helpful to think of your task in terms of "transforming" Fasta to GTF. The process of creating a GTF/GFF3/BED file is often called <em>annotation</em>. There are many different methods to annotate many different types of genomic features: transposable elements, segmental duplications, protein-coding genes, non-coding RNAs, and so on.</p>
  
  <p>As a result, it's meaningless to say "I need a GTF file" without clearly specifying what that GTF file will annotate. (It's kind of like saying "I need an XML file" or "I need an Excel spreadsheet" without indicating what the contents of those files would be.) The things you need to clarify are:</p>
  
  <ol>
  <li>What will the intervals in my GTF file represent?</li>
  <li>What precise sequences will serve as the reference and provide interval coordinates for the GTF file?</li>
  <li>How are those intervals to be determined?</li>
  </ol>
  
  <p>It sounds like 3. is a big part of your question. If I'm reading things correctly, you want to annotate a particular class of genes on an influenza genome. Is that correct? Did you perform <em>de novo</em> sequencing of influenza viruses, and now hope to characterize variation in their HA genes? Stating what you hope to get out of your analysis would be helpful in finding a good way forward.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T18:02:30.503Z
Answers.Text: Thank you for replying! I have updated my question to be more informative of what I want to accomplish.
Answers.UserDisplayName: Lindsey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T13:39:26.653Z
Answers.Text: If I was doing this analysis, I'd want to assess selection signal against domain boundaries. In a selection calculation its one approach to demarcate the loci. For example the hydrophobic "stem" (I don't know HA terminology) will not be of huge interest in this particular question, so could be delineated to provide a control
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T17:31:53.860Z
Answers.LastActivityDate: 2019-03-05T17:37:55.610Z
Answers.LastEditDate: 2019-03-05T17:37:55.610Z
Answers.UserDisplayName: Daniel Standage
Answers.Body: <p>Since you know that your sequences in your fastas are your genes of interest, why not just dummy up a gtf where every sequence is a gene?</p>
  
  <p>The point of a gtf is to tell software which genomic regions matter for a certain procedure, and which regions do not.  But if you already know that your sequences are pared down to genes, then you know that the whole thing is what's relevant.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T18:38:41.873Z
Answers.LastActivityDate: 2019-03-05T18:38:41.873Z
Answers.UserDisplayName: swbarnes2
Body: <p>I am new to using bioinformatic tools and I was hoping this community could help clear something up for me. I need to generate a gtf file. My data are a set of complete HA genes for influenza B viruses in fasta format. From reading through forums and other internet searches, my understanding is that fasta cannot be transformed to gtf or gff because these last two provide location information which fasta does not (unless available in the header). I saw someone suggest mapping sequences to a reference sequence and generating the gtf from that mapping.</p>
  
  <p>My question is, would it make sense to use the consensus sequence selected for alignment as this reference sequence? The alignment algorithm is a simple majority rule. Because all my data are complete genes, I would think the mapping of locations (start codon and stop codon) would be the same no matter which sequence in my data set I choose to use. Is this not so?</p>
  
  <p>I am looking at viral evolution in the HA segment and my end goal is to calculate the dS/dN ratio for a set influenza B viruses collected during a particular season. The program I want to use requires a gtf, but likely other options would only require the reference genome. Would it make more sense to use the strain used as the vaccine candidate as the reference genome?</p>
  
  <p>I appreciate any help you can provide me!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T14:57:20.643Z
Comments.Text: Welcome to the site. I am not used to work with gtf, but you'll probably need a reference genome in order to align your sequences to the genome. Do you have a reference genome for the influenza B virus? What I know is that viruses change quite a lot and probably there are several genomes available. You seem familiar with alignments but you way that it is a matter of "simple majority rule", some algorithms are designed for short sequences or faster while some other are optimized for more accurate mapping, so it is not just a majority rule, but others will answer you with more detail than I can.
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T15:26:06.857Z
Comments.Text: I think the answer is no. Let me check with my colleague who has more expertise in gtf or gff, before I cite my reasons and suggested way forward. Are you working within or associated with Derek Smith's lab (Cambridge)?
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T15:28:41.360Z
Comments.Text: In summary, yes to this "I saw someone suggest mapping sequences to a reference sequence and generating the gtf from that mapping." and no to this "My question is, would it make sense to use the consensus sequence selected for alignment as this reference sequence?"
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T16:55:19.220Z
Comments.Text: @MichaelG. Thank you for looking into this for me! No, I am not working within or associated with Derek Smith's lab in any way. Could you expand on why using the consensus sequence does not make sense?
Comments.UserDisplayName: Lindsey
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T17:21:43.153Z
Comments.Text: I would still like to understand why using the consensus sequence does not make sense, but my other way forward is to use the sequence for the strain used as the vaccine candidate for that particular season. Does this make more sense? Because influenza has such a high mutation rate, it would seem that having a "standard" reference genome would not apply as it does for human genomes.
Comments.UserDisplayName: Lindsey
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T17:23:35.917Z
Comments.Text: Is making a gtf file really your end goal?  I have the feeling that you are trying to do something else, and think that you need a gtf, but maybe that's not the case.
Comments.UserDisplayName: swbarnes2
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T17:34:33.487Z
Comments.Text: @swbarnes2 My end goal is to calculate the dS/dN ratio and the program I want to use requires a gtf. I imagine other software options would not require a gtf and instead would ask for a reference genome.
Comments.UserDisplayName: Lindsey
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-05T17:39:48.903Z
Comments.Text: Welcome @Lindsey! It looks like these comments are getting somewhere. Please use the `[edit]` button above to update your original question to include a bit more about what you're trying to accomplish. It looks like you've sequenced some flu strains and would like to look at the evolution of HA genes?
Comments.UserDisplayName: Daniel Standage
Tags: <fasta><gtf><gff>
Title: GTF from consensus sequence
ThreadText: # GTF from consensus sequence
  
  (Asked by: username_0 on 2019-03-05)
  
  I am new to using bioinformatic tools and I was hoping this community could help clear something up for me. I need to generate a gtf file. My data are a set of complete HA genes for influenza B viruses in fasta format. From reading through forums and other internet searches, my understanding is that fasta cannot be transformed to gtf or gff because these last two provide location information which fasta does not (unless available in the header). I saw someone suggest mapping sequences to a reference sequence and generating the gtf from that mapping.
  
  My question is, would it make sense to use the consensus sequence selected for alignment as this reference sequence? The alignment algorithm is a simple majority rule. Because all my data are complete genes, I would think the mapping of locations (start codon and stop codon) would be the same no matter which sequence in my data set I choose to use. Is this not so?
  
  I am looking at viral evolution in the HA segment and my end goal is to calculate the dS/dN ratio for a set influenza B viruses collected during a particular season. The program I want to use requires a gtf, but likely other options would only require the reference genome. Would it make more sense to use the strain used as the vaccine candidate as the reference genome?
  
  I appreciate any help you can provide me!
  
  **Tags:** fasta, gtf, gff
  
  > **Comments:**
  > **username_1**: Welcome to the site. I am not used to work with gtf, but you'll probably need a reference genome in order to align your sequences to the genome. Do you have a reference genome for the influenza B virus? What I know is that viruses change quite a lot and probably there are several genomes available. You seem familiar with alignments but you way that it is a matter of "simple majority rule", some algorithms are designed for short sequences or faster while some other are optimized for more accurate mapping, so it is not just a majority rule, but others will answer you with more detail than I can.  
  > **username_2**: I think the answer is no. Let me check with my colleague who has more expertise in gtf or gff, before I cite my reasons and suggested way forward. Are you working within or associated with Derek Smith's lab (Cambridge)?  
  > **username_2**: In summary, yes to this "I saw someone suggest mapping sequences to a reference sequence and generating the gtf from that mapping." and no to this "My question is, would it make sense to use the consensus sequence selected for alignment as this reference sequence?"  
  > **username_0**: @MichaelG. Thank you for looking into this for me! No, I am not working within or associated with Derek Smith's lab in any way. Could you expand on why using the consensus sequence does not make sense?  
  > **username_0**: I would still like to understand why using the consensus sequence does not make sense, but my other way forward is to use the sequence for the strain used as the vaccine candidate for that particular season. Does this make more sense? Because influenza has such a high mutation rate, it would seem that having a "standard" reference genome would not apply as it does for human genomes.  
  > **username_3**: Is making a gtf file really your end goal?  I have the feeling that you are trying to do something else, and think that you need a gtf, but maybe that's not the case.  
  > **username_0**: @username_3 My end goal is to calculate the dS/dN ratio and the program I want to use requires a gtf. I imagine other software options would not require a gtf and instead would ask for a reference genome.  
  > **username_4**: Welcome @username_0! It looks like these comments are getting somewhere. Please use the `[edit]` button above to update your original question to include a bit more about what you're trying to accomplish. It looks like you've sequenced some flu strains and would like to look at the evolution of HA genes?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2019-03-05. Score: 1 | Accepted answer
  
  I was wanting more time, but okay here's what I'm thinking,
  
  > Would it make more sense to use the strain used as the vaccine
  > candidate as the reference genome?
  
  Neither, because the GTF format is based on an HA protein structure (likely a crystal structure but could be cryoEM). This is not the same as an alignment position within a surface antigen, because most alignments of pathogen surface antigen genes will contain indels, e.g. between the GTF and your influenza epidemic. If HA doesn't have any indels fine, but I would be surprised.
  
  The indels will cause artifactual shifts in the GTF domain boundaries unless they are corrected. Put simply an alignment position (particularly for pathogen surface antigen proteins) is rarely the same as the amino acid position of GFT because a protein structure of a surface antigen doesn't comprise indels in its native form.
  
  If you do this work in detail, i.e. shifting between protein structure and phylogeny, you always write scripts which convert between aligned positions and "reference" (crystal/ cryoEM structure) positions. Its a common way of thinking.
  
  So in summary, your reference sequence is the GTF sequence because that is the basis of the structure<-> alignment conversion
  
  ---
  
  For positive selection analysis it does not matter what the reference is, **all that matters is the correct rooting**. For demarcation of domains within HA the GFT sequence needs to be at the top of the alignment 1) because it helps easily identify whether it contains indels 2) structure programs will expect the reference sequence to be there. If you are using the vaccine in a positive selection analysis ... you need to think hard about the question you are asking and the coverage of the vaccine. Epidemiologically speaking thats complicated because the passage of the vaccine will be an important source of selection and you will mistake that as the wild-type "escaping" the vaccine.
  
  > **Comments:**
  > **username_0**: What I was suggesting was using the sequence for the HA segment of the vaccine candidate as the reference sequence used for the mapping and subsequent generation of the gtf. I'm not sure I made that clear. As you say, the HAs of the epidemic are likely to have a lot of indels, but still, some sequence must be considered the reference on which to align. In viruses with high mutation rates, what would make a good reference sequence?  
  > **username_2**: I've amended above  
  > **username_0**: So if I am understanding you correctly, I could use either the consensus sequence or the vaccine candidate HA sequence (or any sequence) as the reference in a positive selection analysis as long as I have the correct rooting. I'm not sure if I fully understood the last part of what you amended, but my set of HA sequences come from influenza cases, none are from the vaccine.  
  > **username_2**: Hi username_0, .... firstly NEVER use the consensus sequence in a positive selection analysis - even if we disagree about the epidemiological focus of your study - NEVER use consequence in a phylogenetics analysis. However, yes the maximum likelihood approach to positive selection (the only one worth bothering about), the correct root is important. In other positive selection calculations (distance), it is will not make much difference.  
  
  ---
  
  ### Answer by username_4 on 2019-03-05. Score: 3
  
  "Transforming" Fasta files to GTF or GFF3 files is a common request, as are similar tasks such as "converting" BAM files to VCF files. But these are underdefined questions, and "transform" or "convert" isn't really the right way to think about the task.
  
  As far as your particular request is concerned, Fasta files and GTF files contain fundamentally different types data.
  
  * Fasta files contain sequences, which could be chromosomes, assembled contigs, polypeptides, transcripts, or other biological sequences.
  * GTF (and GFF3 and BED) files contain *intervals*, indicating that some feature of interest occurs at such-and-such position on such-and-such sequence. A hypothetical example: a transcription factor binding site occurs on chromosome 2 from position 40011 to 40017.
  
  So you are correct: it's not really helpful to think of your task in terms of "transforming" Fasta to GTF. The process of creating a GTF/GFF3/BED file is often called *annotation*. There are many different methods to annotate many different types of genomic features: transposable elements, segmental duplications, protein-coding genes, non-coding RNAs, and so on.
  
  As a result, it's meaningless to say "I need a GTF file" without clearly specifying what that GTF file will annotate. (It's kind of like saying "I need an XML file" or "I need an Excel spreadsheet" without indicating what the contents of those files would be.) The things you need to clarify are:
  
  1. What will the intervals in my GTF file represent?
  2. What precise sequences will serve as the reference and provide interval coordinates for the GTF file?
  3. How are those intervals to be determined?
  
  It sounds like 3. is a big part of your question. If I'm reading things correctly, you want to annotate a particular class of genes on an influenza genome. Is that correct? Did you perform *de novo* sequencing of influenza viruses, and now hope to characterize variation in their HA genes? Stating what you hope to get out of your analysis would be helpful in finding a good way forward.
  
  > **Comments:**
  > **username_0**: Thank you for replying! I have updated my question to be more informative of what I want to accomplish.  
  > **username_2**: If I was doing this analysis, I'd want to assess selection signal against domain boundaries. In a selection calculation its one approach to demarcate the loci. For example the hydrophobic "stem" (I don't know HA terminology) will not be of huge interest in this particular question, so could be delineated to provide a control  
  
  ---
  
  ### Answer by username_3 on 2019-03-05. Score: 1
  
  Since you know that your sequences in your fastas are your genes of interest, why not just dummy up a gtf where every sequence is a gene?
  
  The point of a gtf is to tell software which genomic regions matter for a certain procedure, and which regions do not. But if you already know that your sequences are pared down to genes, then you know that the whole thing is what's relevant.
  
  
  ---
  
  