comparison scripts/functions.py @ 8:471ed956ff13 draft

planemo upload for repository https://github.com/abims-sbr/adaptsearch commit b7a3030ea134b5dfad89b1a869db659d72d1145c
author abims-sbr
date Wed, 28 Feb 2018 10:37:14 -0500
parents 6709645eff5d
children
comparison
equal deleted inserted replaced
7:f1ee838a8966 8:471ed956ff13
1 import string 1 import string, itertools
2 2
3 # Used in S05 and 3 # Used in S05 and
4 def split_file(path_in, keyword): 4 def split_file(path_in, keyword):
5 5
6 file_in = open(path_in, "r") 6 file_in = open(path_in, "r")
163 list_informations=[length_matched, Expect, Score, identities, hits, identity_percent, divergence_percent,gaps_number, real_divergence_percent, frame, length_matched] 163 list_informations=[length_matched, Expect, Score, identities, hits, identity_percent, divergence_percent,gaps_number, real_divergence_percent, frame, length_matched]
164 164
165 return(list_informations) 165 return(list_informations)
166 166
167 # Used in S06, S09, S11 167 # Used in S06, S09, S11
168 def get_pairs(fasta_file_path): 168 def get_pairs(fasta_file_path):
169 F2 = open(fasta_file_path, "r")
170 list_pairwises = [] 169 list_pairwises = []
171 while 1: 170 with open(fasta_file_path, "r") as F2:
172 next2 = F2.readline() 171 for name, sequence, name2, sequence2 in itertools.izip_longest(*[F2]*4):
173 if not next2: 172 if name[0] == ">":
174 break 173 fasta_name_query = name[:-1]
175 if next2[0] == ">": 174 fasta_seq_query = sequence[:-1]
176 fasta_name_query = next2[:-1] 175 fasta_name_match = name2[:-1]
177 next3 = F2.readline() 176 fasta_seq_match = sequence2[:-1]
178 fasta_seq_query = next3[:-1] 177 pairwise = [fasta_name_query,fasta_seq_query,fasta_name_match,fasta_seq_match]
179 next3 = F2.readline() ## jump one empty line (if any after the sequence) 178
180 fasta_name_match = next3[:-1] 179 ## ADD pairwise with condition
181 next3 = F2.readline() 180 list_pairwises.append(pairwise)
182 fasta_seq_match = next3[:-1]
183 pairwise = [fasta_name_query,fasta_seq_query,fasta_name_match,fasta_seq_match]
184
185 ## ADD pairwise with condition
186 list_pairwises.append(pairwise)
187 F2.close()
188
189 return(list_pairwises) 181 return(list_pairwises)
190 182
191 def extract_length(length_string): # format length string = 57...902 183 def extract_length(length_string): # format length string = 57...902
192 l3 = string.split(length_string, "...") 184 l3 = string.split(length_string, "...")
193 n1 = string.atoi(l3[0]) 185 n1 = string.atoi(l3[0])