comparison scripts/functions.py @ 2:988467f963f0 draft

planemo upload for repository htpps://github.com/abims-sbr/adaptearch commit cf1b9c905931ca2ca25faa4844d45c908756472f
author abims-sbr
date Wed, 17 Jan 2018 08:57:49 -0500
parents
children f1e24200e5ae
comparison
equal deleted inserted replaced
1:8de21b6eb110 2:988467f963f0
1 def simplify_fasta_name(fasta_name,LT):
2 for abbreviation in LT:
3 if abbreviation in fasta_name:
4 new_fasta_name = abbreviation
5
6 return(new_fasta_name)
7
8 ## Generates bash, with key = fasta name; value = sequence (WITH GAP, IF ANY, REMOVED IN THIS FUNCTION)
9 def dico(fasta_file,LT):
10
11 count_fastaName=0
12 F1 = open(fasta_file, "r")
13
14 bash1 = {}
15 while 1:
16 nextline = F1.readline()
17 #print nextline
18 if not nextline :
19 break
20
21 if nextline[0] == ">":
22 count_fastaName = count_fastaName + 1
23 fasta_name = nextline[1:-1]
24 nextline = F1.readline()
25 sequence = nextline[:-1]
26
27 if fasta_name not in bash1.keys():
28 fasta_name = simplify_fasta_name(fasta_name,LT) ### DEF 0 ###
29 bash1[fasta_name] = sequence
30 else:
31 print fasta_name
32
33 # Find alignment length
34 kk = bash1.keys()
35 key0 = kk[0]
36 seq0 = bash1[key0]
37 ln_seq = len(seq0)
38
39 F1.close()
40
41 return(bash1)