diff fasta_interlacer.py @ 4:d397f5a85464 draft

Uploaded
author petr-novak
date Wed, 18 Sep 2019 06:30:04 -0400
parents a4cd8608ef6b
children
line wrap: on
line diff
--- a/fasta_interlacer.py	Thu Sep 05 09:04:56 2019 -0400
+++ b/fasta_interlacer.py	Wed Sep 18 06:30:04 2019 -0400
@@ -79,7 +79,7 @@
             "last character of sequence id must be used for distinguishing pairs!")
         exit(1)
         # check first thousand!
-    for i in range(1000):
+    for i in range(3):
         seqA = readSingleSeq(fA)
         seqB = readSingleSeq(fB)
         if (not seqA) or (not seqB):
@@ -105,10 +105,8 @@
     buffB_names = []
 
     while True:
-
         seqA = readSingleSeq(fA)
         seqB = readSingleSeq(fB)
-
         if not seqA and not seqB:
             break  # end of file
 
@@ -138,8 +136,8 @@
                 for i in buffA_names:
                     seqtmp = {"name": i + charA, "sequence": buffA[i]}
                     writeSingleSeq(single, seqtmp)
-                    buffA = {}
-                    buffA_names = []
+                buffA = {}
+                buffA_names = []
 
                 j = 0
                 for i in buffB_names:
@@ -166,8 +164,8 @@
                 for i in buffB_names:
                     seqtmp = {"name": i + charB, "sequence": buffB[i]}
                     writeSingleSeq(single, seqtmp)
-                    buffB = {}
-                    buffB_names = []
+                buffB = {}
+                buffB_names = []
 
                 j = 0
                 for i in buffA_names:
@@ -183,17 +181,19 @@
             else:
                 buffB[seqB["name"][:-1]] = seqB['sequence']
                 buffB_names.append(seqB["name"][:-1])
-                fA.close()
-                fB.close()
-                fPairs.close()
-                # write rest of singles:
+
+    fA.close()
+    fB.close()
+    fPairs.close()
+
+    # write rest of singles:
     for i in buffA:
         seqtmp = {"name": i + charA, "sequence": buffA[i]}
         writeSingleSeq(single, seqtmp)
     for i in buffB:
         seqtmp = {"name": i + charB, "sequence": buffB[i]}
         writeSingleSeq(single, seqtmp)
-        single.close()
+    single.close()
 
 
 if __name__ == "__main__":