diff cherry_pick_fasta.py @ 2:d04b7de95782 draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cherry_pick_fasta commit 3e1f8bb17e712d70e64ebb541775e9555acc038f"
author artbio
date Fri, 21 May 2021 11:48:25 +0000
parents 19a1ce11945e
children 30d0cba983be
line wrap: on
line diff
--- a/cherry_pick_fasta.py	Fri May 21 09:33:44 2021 +0000
+++ b/cherry_pick_fasta.py	Fri May 21 11:48:25 2021 +0000
@@ -77,9 +77,13 @@
     with open(file, 'w') as f:
         for header in sorted(fasta_dict):
             f.write('>%s\n' % header)
-            for i in range(line_length, len(fasta_dict[header]), line_length):
-                f.write('%s\n' % fasta_dict[header][i-line_length:i])
-            f.write('%s\n' % fasta_dict[header][i:])
+            if len(fasta_dict[header]) <= line_length:
+                f.write('%s\n' % fasta_dict[header])
+            else:
+                for i in range(line_length, len(fasta_dict[header]),
+                               line_length):
+                    f.write('%s\n' % fasta_dict[header][i-line_length:i])
+                f.write('%s\n' % fasta_dict[header][i:])
 
 
 def __main__():