# HG changeset patch
# User earlhaminst
# Date 1488544172 18000
# Node ID fa59d6fea7f5f652b62b1d79c899f00931f28466
# Parent  78dd29aa7fc17c4dada7c1bce950b42272ac458d
planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/t_coffee commit 988b1fc1cb8739e45648465adbf099f3fdaf87f8

diff -r 78dd29aa7fc1 -r fa59d6fea7f5 filter_by_fasta_ids.py
--- a/filter_by_fasta_ids.py	Mon Feb 20 06:25:50 2017 -0500
+++ b/filter_by_fasta_ids.py	Fri Mar 03 07:29:32 2017 -0500
@@ -9,20 +9,20 @@
 
 
 def FASTAReader_gen(fasta_filename):
-    fasta_file = open(fasta_filename)
-    line = fasta_file.readline()
-    while True:
-        if not line:
-            return
-        assert line.startswith('>'), "FASTA headers must start with >"
-        header = line.rstrip()
-        sequence_parts = []
+    with open(fasta_filename) as fasta_file:
         line = fasta_file.readline()
-        while line and line[0] != '>':
-            sequence_parts.append(line.rstrip())
+        while True:
+            if not line:
+                return
+            assert line.startswith('>'), "FASTA headers must start with >"
+            header = line.rstrip()
+            sequence_parts = []
             line = fasta_file.readline()
-        sequence = "".join(sequence_parts)
-        yield Sequence(header, sequence)
+            while line and line[0] != '>':
+                sequence_parts.append(line.rstrip())
+                line = fasta_file.readline()
+            sequence = "".join(sequence_parts)
+            yield Sequence(header, sequence)
 
 
 def target_match(target, search_entry):
@@ -47,7 +47,6 @@
 
     work_summary['wanted'] = len(targets)
 
-    # output = open(sys.argv[3], "w")
     for entry in FASTAReader_gen(sys.argv[2]):
         target_matched_results = target_match(targets, entry.header)
         if target_matched_results: