Mercurial > repos > estrain > seqsero_v1
comparison SeqSero/libs/Initial_functions.py @ 0:c577b57b7c74 draft
Uploaded
author | estrain |
---|---|
date | Wed, 06 Dec 2017 15:59:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c577b57b7c74 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 | |
4 def To_list(L): | |
5 import string | |
6 New_list=[] | |
7 for x in L: | |
8 x1=x[:-1] | |
9 x1=string.atoi(x1) | |
10 New_list.append(x1) | |
11 return New_list | |
12 | |
13 | |
14 def Uniq(L): #return the uniq list and the count number | |
15 Old=L | |
16 L.sort() | |
17 L = [L[i] for i in range(len(L)) if L[i] not in L[:i]] | |
18 count=[] | |
19 for j in range(len(L)): | |
20 y=0 | |
21 for x in Old: | |
22 if L[j]==x: | |
23 y+=1 | |
24 count.append(y) | |
25 return (L,count) | |
26 | |
27 | |
28 def Parse_seros_in_genome_trakr(L): #return the sero names in the sra_result.xlsx, the next step is usually "Uniq" in above | |
29 names2=[] | |
30 for x in L: | |
31 if "serovar" in x: | |
32 key_word=x.split("serovar")[1].split("_")[1] #the seronames | |
33 if key_word!="str." and key_word!="group": #to eliminate some "serovar_str." and "serovar_group" | |
34 if key_word in ["I","II","III","IIIa","IIIb","IV","VI","B"]: #the serovar is behind those letters | |
35 if x.split("serovar")[1].split("_")[2]!="str.": | |
36 names2.append(x.split("serovar")[1].split("_")[2]) | |
37 else: | |
38 names2.append(x.split("serovar")[1].split("_")[1]) | |
39 return names2 | |
40 | |
41 | |
42 |