Answers.Body: <p>The <code>description</code> field in the <a href="http://biopython.org/wiki/SeqRecord" rel="noreferrer">SeqRecord</a> object has the information you are looking for:</p>
  
  <pre><code>&gt;&gt; from Bio import SeqIO
  &gt;&gt; s = SeqIO.read('genome.fasta', 'fasta') # single sequence fasta file
  &gt;&gt; s.id
  k119_5
  &gt;&gt; s.description
  k119_5 flag=0 multi=141.0706 len=473
  </code></pre>
  
  <p>Edit: as an aside, if you write a <code>SeqRecord</code> object using <code>SeqIO</code>'s <code>write</code> method, the FASTA header should contain the whole original header.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T09:55:54.997Z
Answers.LastActivityDate: 2017-09-01T10:01:47.470Z
Answers.LastEditDate: 2017-09-01T10:01:47.470Z
Answers.UserDisplayName: mgalardini
Body: <p>I am trying to read a fasta file, manipulate is in Python (using BioPython) and then write it back.</p>
  
  <p>The format of my sequences is like:</p>
  
  <pre><code>&gt;k119_5 flag=0 multi=141.0706 len=473
  AGGTTAGTCAGCACCGTTTCCGTGGTGCTGCCTTTCGCTTCAAAACCGACGGCGTCTATTACTGCATCCACGCCCCGGTGACCTGCCGTTTGTTCAATAATTGACTGTGCCGGATCGCTGTCTTCATCAAAATTAATCGGGATCGCGCCGTAGCGGTCGGCGGCGAAATGCAAGCGGTAGGGATGATGATCAACAACAAAAATCTGTTCCGCACCGAGCAACCGTGCACAGGCGATTGTCAACAATCCCACAGGACCAGCACCATAGACTGC
  AACGCTTGAACCTTGTTGGATCTGCGCATTTTTTGCTGCCTGCCATGCCGTTGGCAGAATATCAGAAAGGAAAAGCGCTTTATCATCTGAAAGCAAAGGCGGTACTTTAAACGGCCCCACATTCCCTTTAGGGACGCGGACATATTCCGCCTGCCCACCAGGAACGCCGCCATACAGGTGACTATAACCAAACAATGCCGC
  </code></pre>
  
  <p>which is the result of the assmebly using Megahit. While trying to read, it only recognizes <code>k119_5</code> as the id, while I want the whole first line as the id of the sequence. Is vital information I want to keep! </p>
  
  <p>Any ideas how to work with this?</p>
  
Tags: <fasta><python>
Title: Read and write FASTA files with more information than id and sequence
ThreadText: # Read and write FASTA files with more information than id and sequence
  
  (Asked by: username_0 on 2017-09-01)
  
  I am trying to read a fasta file, manipulate is in Python (using BioPython) and then write it back.
  
  The format of my sequences is like:
  
  ```
  >k119_5 flag=0 multi=141.0706 len=473
  AGGTTAGTCAGCACCGTTTCCGTGGTGCTGCCTTTCGCTTCAAAACCGACGGCGTCTATTACTGCATCCACGCCCCGGTGACCTGCCGTTTGTTCAATAATTGACTGTGCCGGATCGCTGTCTTCATCAAAATTAATCGGGATCGCGCCGTAGCGGTCGGCGGCGAAATGCAAGCGGTAGGGATGATGATCAACAACAAAAATCTGTTCCGCACCGAGCAACCGTGCACAGGCGATTGTCAACAATCCCACAGGACCAGCACCATAGACTGC
  AACGCTTGAACCTTGTTGGATCTGCGCATTTTTTGCTGCCTGCCATGCCGTTGGCAGAATATCAGAAAGGAAAAGCGCTTTATCATCTGAAAGCAAAGGCGGTACTTTAAACGGCCCCACATTCCCTTTAGGGACGCGGACATATTCCGCCTGCCCACCAGGAACGCCGCCATACAGGTGACTATAACCAAACAATGCCGC
  
  ```
  
  which is the result of the assmebly using Megahit. While trying to read, it only recognizes `k119_5` as the id, while I want the whole first line as the id of the sequence. Is vital information I want to keep!
  
  Any ideas how to work with this?
  
  **Tags:** fasta, python
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-01. Score: 8 | Accepted answer
  
  The `description` field in the [SeqRecord](http://biopython.org/wiki/SeqRecord) object has the information you are looking for:
  
  ```
  >> from Bio import SeqIO
  >> s = SeqIO.read('genome.fasta', 'fasta') # single sequence fasta file
  >> s.id
  k119_5
  >> s.description
  k119_5 flag=0 multi=141.0706 len=473
  
  ```
  
  Edit: as an aside, if you write a `SeqRecord` object using `SeqIO`'s `write` method, the FASTA header should contain the whole original header.
  
  
  ---
  
  