{
  "id": 402580,
  "title": "What is a FASTA File and How To Read It",
  "url": "/competitions/cafa-5-protein-function-prediction/discussion/402580",
  "author_name": "",
  "post_date": "2023-04-18T23:00:24.548886700Z",
  "votes": 24,
  "comment_count": 2,
  "views": 0,
  "content": "<h3>What is a FASTA file?</h3>\n<p>A FASTA file is a common file format used to store DNA or protein sequences along with their identifying information. The file consists of a header line starting with the <code>&gt;</code> character, followed by one or more lines of sequence data.</p>\n<p>Here is an example:</p>\n<pre><code>\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n</code></pre>\n<p>If we parse the file we get:</p>\n<pre><code>ID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n</code></pre>\n<h3>How to read a FASTA file in Python</h3>\n<pre><code> Bio  SeqIO\n\n\nfilename = \nfasta_sequences = SeqIO.parse((filename),)\n\n\n fasta  fasta_sequences:\n    (fasta)\n    (, fasta.)\n    (, (fasta))\n    \n</code></pre>\n<h3>Example</h3>\n<p><img src=\"https://i.imgur.com/0ioLwcI.png\"></p>",
  "messages": [
    {
      "id": "2226436",
      "postDate": "04/18/2023 23:00:24",
      "content": "<h3>What is a FASTA file?</h3>\n<p>A FASTA file is a common file format used to store DNA or protein sequences along with their identifying information. The file consists of a header line starting with the <code>&gt;</code> character, followed by one or more lines of sequence data.</p>\n<p>Here is an example:</p>\n<pre><code>\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n</code></pre>\n<p>If we parse the file we get:</p>\n<pre><code>ID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n</code></pre>\n<h3>How to read a FASTA file in Python</h3>\n<pre><code> Bio  SeqIO\n\n\nfilename = \nfasta_sequences = SeqIO.parse((filename),)\n\n\n fasta  fasta_sequences:\n    (fasta)\n    (, fasta.)\n    (, (fasta))\n    \n</code></pre>\n<h3>Example</h3>\n<p><img src=\"https://i.imgur.com/0ioLwcI.png\"></p>",
      "rawMarkdown": "### What is a FASTA file?\n\nA FASTA file is a common file format used to store DNA or protein sequences along with their identifying information. The file consists of a header line starting with the `>` character, followed by one or more lines of sequence data.\n\nHere is an example:\n```shell\n>P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n```\n\nIf we parse the file we get:\n\n```shell\nID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n```\n\n### How to read a FASTA file in Python\n\n```python\nfrom Bio import SeqIO\n\n# Open the FASTA file\nfilename = \"/kaggle/input/cafa-5-protein-function-prediction/Train/train_sequences.fasta\"\nfasta_sequences = SeqIO.parse(open(filename),'fasta')\n\n# Loop over each sequence and print its ID and length\nfor fasta in fasta_sequences:\n    print(fasta)\n    print(\"Sequence ID:\", fasta.id)\n    print(\"Sequence length:\", len(fasta))\n    break\n```\n\n### Example\n\n<img src=\"https://i.imgur.com/0ioLwcI.png\">",
      "votes": null
    },
    {
      "id": "2226484",
      "postDate": "04/19/2023 01:18:24",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/alejopaullier\" target=\"_blank\">@alejopaullier</a> </p>\n<p>Thanks for the code sample! That's helpful. </p>\n<p>Just to clarify: this not the standard FASTA format:</p>\n<pre><code>ID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n</code></pre>\n<p><strong>This</strong> is a standard FASTA record format that we are providing:</p>\n<pre><code>&gt;P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n</code></pre>\n<p>As stated by <a href=\"https://www.kaggle.com/alejopaullier\" target=\"_blank\">@alejopaullier</a> the line after the \"&gt;\" is the header, and the rest of the record is the amino acid sequence. For more information on the specific header format see File Descriptions in <a href=\"https://www.kaggle.com/competitions/cafa-5-protein-function-prediction/data\" target=\"_blank\">Data</a> section, </p>\n<p>The above code provided by should work in reading the FASTA files, you would need to have <a href=\"https://biopython.org\" target=\"_blank\">biopython</a> installed. Examples on sequence file IO are provided <a href=\"https://biopython.org/wiki/SeqIO\" target=\"_blank\">here</a>.</p>",
      "rawMarkdown": "Hi @alejopaullier \n\nThanks for the code sample! That's helpful. \n\nJust to clarify: this not the standard FASTA format:\n\n```\nID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n```\n\n**This** is a standard FASTA record format that we are providing:\n\n```\n>P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n```\nAs stated by @alejopaullier the line after the \">\" is the header, and the rest of the record is the amino acid sequence. For more information on the specific header format see File Descriptions in [Data](https://www.kaggle.com/competitions/cafa-5-protein-function-prediction/data) section, \n\nThe above code provided by should work in reading the FASTA files, you would need to have [biopython](https://biopython.org) installed. Examples on sequence file IO are provided [here](https://biopython.org/wiki/SeqIO).",
      "votes": null
    },
    {
      "id": "2226512",
      "postDate": "04/19/2023 02:06:43",
      "content": "<p>Thanks for the clarification <a href=\"https://www.kaggle.com/iddux1\" target=\"_blank\">@iddux1</a> I will edit the post!</p>",
      "rawMarkdown": "Thanks for the clarification @iddux1 I will edit the post!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2226484,
      "author_name": "iddux1",
      "author_url": "",
      "post_date": "04/19/2023 01:18:24",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/alejopaullier\" target=\"_blank\">@alejopaullier</a> </p>\n<p>Thanks for the code sample! That's helpful. </p>\n<p>Just to clarify: this not the standard FASTA format:</p>\n<pre><code>ID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n</code></pre>\n<p><strong>This</strong> is a standard FASTA record format that we are providing:</p>\n<pre><code>&gt;P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n</code></pre>\n<p>As stated by <a href=\"https://www.kaggle.com/alejopaullier\" target=\"_blank\">@alejopaullier</a> the line after the \"&gt;\" is the header, and the rest of the record is the amino acid sequence. For more information on the specific header format see File Descriptions in <a href=\"https://www.kaggle.com/competitions/cafa-5-protein-function-prediction/data\" target=\"_blank\">Data</a> section, </p>\n<p>The above code provided by should work in reading the FASTA files, you would need to have <a href=\"https://biopython.org\" target=\"_blank\">biopython</a> installed. Examples on sequence file IO are provided <a href=\"https://biopython.org/wiki/SeqIO\" target=\"_blank\">here</a>.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2226512,
          "author_name": "alejopaullier",
          "author_url": "",
          "post_date": "04/19/2023 02:06:43",
          "content": "<p>Thanks for the clarification <a href=\"https://www.kaggle.com/iddux1\" target=\"_blank\">@iddux1</a> I will edit the post!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2226436": "### What is a FASTA file?\n\nA FASTA file is a common file format used to store DNA or protein sequences along with their identifying information. The file consists of a header line starting with the `>` character, followed by one or more lines of sequence data.\n\nHere is an example:\n```shell\n>P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n```\n\nIf we parse the file we get:\n\n```shell\nID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n```\n\n### How to read a FASTA file in Python\n\n```python\nfrom Bio import SeqIO\n\n# Open the FASTA file\nfilename = \"/kaggle/input/cafa-5-protein-function-prediction/Train/train_sequences.fasta\"\nfasta_sequences = SeqIO.parse(open(filename),'fasta')\n\n# Loop over each sequence and print its ID and length\nfor fasta in fasta_sequences:\n    print(fasta)\n    print(\"Sequence ID:\", fasta.id)\n    print(\"Sequence length:\", len(fasta))\n    break\n```\n\n### Example\n\n<img src=\"https://i.imgur.com/0ioLwcI.png\">",
    "2226484": "Hi @alejopaullier \n\nThanks for the code sample! That's helpful. \n\nJust to clarify: this not the standard FASTA format:\n\n```\nID: P20536\nName: P20536\nDescription: P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nNumber of features: 0\nSeq('MNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLK...FIY')\n```\n\n**This** is a standard FASTA record format that we are providing:\n\n```\n>P20536 sp|P20536|UNG_VACCC Uracil-DNA glycosylase OS=Vaccinia virus (strain Copenhagen) OX=10249 GN=UNG PE=1 SV=1\nMNSVTVSHAPYTITYHDDWEPVMSQLVEFYNEVASWLLRDETSPIPDKFFIQLKQPLRNK\nRVCVCGIDPYPKDGTGVPFESPNFTKKSIKEIASSISRLTGVIDYKGYNLNIIDGVIPWN\nYYLSCKLGETKSHAIYWDKISKLLLQHITKHVSVLYCLGKTDFSNIRAKLESPVTTIVGY\nHPAARDRQFEKDRSFEIINVLLELDNKVPINWAQGFIY\n```\nAs stated by @alejopaullier the line after the \">\" is the header, and the rest of the record is the amino acid sequence. For more information on the specific header format see File Descriptions in [Data](https://www.kaggle.com/competitions/cafa-5-protein-function-prediction/data) section, \n\nThe above code provided by should work in reading the FASTA files, you would need to have [biopython](https://biopython.org) installed. Examples on sequence file IO are provided [here](https://biopython.org/wiki/SeqIO).",
    "2226512": "Thanks for the clarification @iddux1 I will edit the post!"
  },
  "source": "meta"
}