comparison 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
comparison
equal deleted inserted replaced
6:c03ba6a7c5f2 7:35e39b4128ba
15 ### KEY = codon 15 ### KEY = codon
16 ### VALUE = Amino Acid 16 ### VALUE = Amino Acid
17 17
18 def code_universel(F1): 18 def code_universel(F1):
19 bash_codeUniversel = {} 19 bash_codeUniversel = {}
20 while 1: 20 with open(F1, "r") as file:
21 next = F1.readline() 21 for line in file.readlines():
22 if not next: break 22 L1 = string.split(line, " ")
23 L1 = string.split(next, " ") 23 length1 = len(L1)
24 length1 = len(L1) 24 if length1 == 3:
25 if length1 == 3: 25 key = L1[0]
26 key = L1[0] 26 value = L1[2][:-1]
27 value = L1[2][:-1] 27 bash_codeUniversel[key] = value
28 bash_codeUniversel[key] = value 28 else:
29 else: 29 key = L1[0]
30 key = L1[0] 30 value = L1[2]
31 value = L1[2] 31 bash_codeUniversel[key] = value
32 bash_codeUniversel[key] = value
33 F1.close()
34 return(bash_codeUniversel) 32 return(bash_codeUniversel)
35 ########################################################### 33 ###########################################################
36 34
37 35
38 ###################################################################################################################### 36 ######################################################################################################################
327 325
328 ## INPUT / OUTPUT 326 ## INPUT / OUTPUT
329 list_file = str.split(infiles,",") 327 list_file = str.split(infiles,",")
330 328
331 ### Get Universal Code 329 ### Get Universal Code
332 F2 = open(sys.argv[2], 'r') 330 bash_codeUniversel = code_universel(sys.argv[2]) ### DEF2 ###
333 bash_codeUniversel = code_universel(F2) ### DEF2 ###
334 F2.close()
335 331
336 os.mkdir("04_BEST_ORF_nuc") 332 os.mkdir("04_BEST_ORF_nuc")
337 Path_OUT1 = "04_BEST_ORF_nuc" 333 Path_OUT1 = "04_BEST_ORF_nuc"
338 os.mkdir("04_BEST_ORF_aa") 334 os.mkdir("04_BEST_ORF_aa")
339 Path_OUT2 = "04_BEST_ORF_aa" 335 Path_OUT2 = "04_BEST_ORF_aa"
357 count_file_without_CDS = 0 353 count_file_without_CDS = 0
358 count_file_with_CDS_plus_M = 0 354 count_file_with_CDS_plus_M = 0
359 355
360 for file in list_file: 356 for file in list_file:
361 count_file_processed = count_file_processed + 1 357 count_file_processed = count_file_processed + 1
362 fasta_file_path = "./%s" %file 358 fasta_file_path = "./%s" %file
363 fasta_file = open(fasta_file_path, "r") 359 bash_fasta = dico(fasta_file_path) ### DEF 1 ###
364 bash_fasta = dico(fasta_file) ### DEF 1 ###
365 fasta_file.close()
366 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 - ### 360 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 - ###
367 361
368 ## a ## OUTPUT BESTORF_nuc 362 ## a ## OUTPUT BESTORF_nuc
369 if BESTORF_nuc != {}: 363 if BESTORF_nuc != {}:
370 count_file_with_CDS = count_file_with_CDS +1 364 count_file_with_CDS = count_file_with_CDS +1