text: user10513: First of all, sorry if this question has been posted previously (I could not found a solution accessing the previous Q&A).
  I have a fasta file as follow:
  >LNIV02000036.519060.520603 Pseudomonas aeruginosa
  GAACTGAAGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAA...
  
  >LDLH01000045.361.1876 Pseudomonas aeruginosa
  AGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAACACATG...
  
  >LNMQ01000087.5825.7394 Enterococcus faecium
  TTTTTATGAGAGTTTGATCCTGGCTCAGGACGAACGCTGGCGGCGTGC...
  
  ...
  
  I would like to filter sequences or extract entries for a specific species, let's say Pseudomonas (I have others in mind...). I tried a few things but I think the main problem is my skills associated with bioinformatics. I would like to create a file content Pseudomonas entries (~9k entries in the current database). Any suggestion or tip?
  Thank you for your time.
  Best,
  Fabricio
  
  user104: Using Biopython:
  from Bio import SeqIO
  
  for record in SeqIO.parse("input.fa", "fasta"):
      if record.description.split()[-2:] == ["Pseudomonas", "aeruginosa"]:
          print(record.format("fasta"))
  
  
  user3577: You can do this using seqkit as follows:
  seqkit grep -r -n -p '.*Pseudomonas.*' temp.fa
  
  To explain a little, seqkit grep will allow you to search FASTA/Q files by sequence name or sequence itself. In this instance:
  
  -r tells that the pattern is a regular expression
  -n to match by full name instead of just id
  -p to specify the regular expression pattern to search
  
  There are a bunch of other tools that come with seqkit that can prove indispensable for basic sequence analyses.
  
original_text: 10513: <p>First of all, sorry if this question has been posted previously (I could not found a solution accessing the previous Q&amp;A).</p>
  <p>I have a fasta file as follow:</p>
  <pre><code>&gt;LNIV02000036.519060.520603 Pseudomonas aeruginosa
  GAACTGAAGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAA...
  
  &gt;LDLH01000045.361.1876 Pseudomonas aeruginosa
  AGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAACACATG...
  
  &gt;LNMQ01000087.5825.7394 Enterococcus faecium
  TTTTTATGAGAGTTTGATCCTGGCTCAGGACGAACGCTGGCGGCGTGC...
  
  ...
  </code></pre>
  <p>I would like to filter sequences or extract entries for a specific species, let's say Pseudomonas (I have others in mind...). I tried a few things but I think the main problem is my skills associated with bioinformatics. I would like to create a file content Pseudomonas entries (~9k entries in the current database). Any suggestion or tip?</p>
  <p>Thank you for your time.</p>
  <p>Best,<br />
  Fabricio</p>
   104: <p>Using Biopython:</p>
  <pre><code>from Bio import SeqIO
  
  for record in SeqIO.parse(&quot;input.fa&quot;, &quot;fasta&quot;):
      if record.description.split()[-2:] == [&quot;Pseudomonas&quot;, &quot;aeruginosa&quot;]:
          print(record.format(&quot;fasta&quot;))
  </code></pre>
   3577: <p>You can do this using <a href="https://bioinf.shenwei.me/seqkit/" rel="nofollow noreferrer"><code>seqkit</code></a> as follows:</p>
  <pre><code>seqkit grep -r -n -p '.*Pseudomonas.*' temp.fa
  </code></pre>
  <p>To explain a little, <code>seqkit grep</code> will allow you to search FASTA/Q files by sequence name or sequence itself. In this instance:</p>
  <ul>
  <li><code>-r</code> tells that the pattern is a regular expression</li>
  <li><code>-n</code> to match by full name instead of just id</li>
  <li><code>-p</code> to specify the regular expression pattern to search</li>
  </ul>
  <p>There are a bunch of other tools that come with <code>seqkit</code> that can prove indispensable for basic sequence analyses.</p>
  