diff scripts/S01_find_orf_on_multiple_alignment.py @ 7:35e39b4128ba draft

planemo upload for repository https://github.com/abims-sbr/adaptsearch commit b7a3030ea134b5dfad89b1a869db659d72d1145c
author abims-sbr
date Wed, 28 Feb 2018 10:38:40 -0500
parents ff98ed7849fa
children 716a45028e55
line wrap: on
line diff
--- a/scripts/S01_find_orf_on_multiple_alignment.py	Wed Feb 28 06:05:15 2018 -0500
+++ b/scripts/S01_find_orf_on_multiple_alignment.py	Wed Feb 28 10:38:40 2018 -0500
@@ -17,20 +17,18 @@
 
 def code_universel(F1):
     bash_codeUniversel = {}
-    while 1:
-        next = F1.readline()
-        if not next: break
-        L1 = string.split(next, " ")
-        length1 = len(L1)
-        if length1 == 3:
-            key = L1[0]
-            value = L1[2][:-1]
-            bash_codeUniversel[key] = value
-        else:
-            key =  L1[0]
-            value = L1[2]
-            bash_codeUniversel[key] = value
-    F1.close()
+    with open(F1, "r") as file:
+        for line in file.readlines():
+            L1 = string.split(line, " ")
+            length1 = len(L1)
+            if length1 == 3:
+                key = L1[0]
+                value = L1[2][:-1]
+                bash_codeUniversel[key] = value
+            else:
+                key = L1[0]
+                value = L1[2]
+                bash_codeUniversel[key] = value
     return(bash_codeUniversel)
 ###########################################################
 
@@ -329,9 +327,7 @@
 list_file = str.split(infiles,",")
 
 ### Get Universal Code
-F2 = open(sys.argv[2], 'r')
-bash_codeUniversel = code_universel(F2)  ### DEF2 ###
-F2.close()
+bash_codeUniversel = code_universel(sys.argv[2])  ### DEF2 ###
 
 os.mkdir("04_BEST_ORF_nuc")
 Path_OUT1 = "04_BEST_ORF_nuc"
@@ -359,10 +355,8 @@
 
 for file in list_file:
     count_file_processed = count_file_processed + 1
-    fasta_file_path = "./%s" %file
-    fasta_file = open(fasta_file_path, "r")
-    bash_fasta = dico(fasta_file)   ### DEF 1 ###
-    fasta_file.close()
+    fasta_file_path = "./%s" %file    
+    bash_fasta = dico(fasta_file_path)   ### DEF 1 ###    
     BESTORF_nuc, BESTORF_nuc_CODING, BESTORF_nuc_CDS_with_M, BESTORF_aa, BESTORF_aa_CODING, BESTORF_aa_CDS_with_M  = find_good_ORF_criteria_3(bash_fasta, bash_codeUniversel)   ### DEF 4 - PART 2 - ###
 
     ## a ## OUTPUT BESTORF_nuc