annotate TEisotools-1.0/commons/core/seq/BioseqDB.py @ 6:20ec0d14798e draft

Uploaded
author urgi-team
date Wed, 20 Jul 2016 05:00:24 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
1 # Copyright INRA (Institut National de la Recherche Agronomique)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
2 # http://www.inra.fr
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
3 # http://urgi.versailles.inra.fr
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
4 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
5 # This software is governed by the CeCILL license under French law and
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
6 # abiding by the rules of distribution of free software. You can use,
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
7 # modify and/ or redistribute the software under the terms of the CeCILL
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
8 # license as circulated by CEA, CNRS and INRIA at the following URL
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
9 # "http://www.cecill.info".
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
10 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
11 # As a counterpart to the access to the source code and rights to copy,
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
12 # modify and redistribute granted by the license, users are provided only
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
13 # with a limited warranty and the software's author, the holder of the
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
14 # economic rights, and the successive licensors have only limited
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
15 # liability.
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
16 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
17 # In this respect, the user's attention is drawn to the risks associated
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
18 # with loading, using, modifying and/or developing or reproducing the
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
19 # software by the user in light of its specific status of free software,
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
20 # that may mean that it is complicated to manipulate, and that also
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
21 # therefore means that it is reserved for developers and experienced
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
22 # professionals having in-depth computer knowledge. Users are therefore
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
23 # encouraged to load and test the software's suitability as regards their
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
24 # requirements in conditions enabling the security of their systems and/or
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
25 # data to be ensured and, more generally, to use and operate it in the
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
26 # same conditions as regards security.
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
27 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
28 # The fact that you are presently reading this means that you have had
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
29 # knowledge of the CeCILL license and that you accept its terms.
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
30
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
31
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
32 import sys
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
33 import re
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
34 from commons.core.seq.Bioseq import Bioseq
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
35 from commons.core.stat.Stat import Stat
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
36
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
37
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
38 ## Handle a collection of a Bioseq (header-sequence)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
39 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
40 class BioseqDB( object ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
41
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
42 def __init__( self, name="" ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
43 self.idx = {}
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
44 self.idx_renamed = {}
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
45 self.db = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
46 self.name = name
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
47 if name != "":
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
48 faFile = open( name )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
49 self.read( faFile )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
50 faFile.close()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
51 self.mean_seq_lgth = None
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
52 self.stat = Stat()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
53
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
54
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
55 ## Equal operator
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
56 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
57 def __eq__( self, o ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
58 if type(o) is type(self):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
59 selfSize = self.getSize()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
60 if selfSize != o.getSize():
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
61 return False
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
62 nbEqualInstances = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
63 for i in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
64 atLeastOneIsEqual = False
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
65 for j in o.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
66 if i == j:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
67 atLeastOneIsEqual = True
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
68 continue
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
69 if atLeastOneIsEqual:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
70 nbEqualInstances += 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
71 if nbEqualInstances == selfSize:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
72 return True
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
73 return False
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
74
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
75 ## Not equal operator
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
76 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
77 def __ne__(self, o):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
78 return not self.__eq__(o)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
79
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
80 ## Change the name of the BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
81 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
82 # @param name the BioseqDB name
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
83 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
84 def setName(self, name):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
85 self.name = name
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
86
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
87
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
88 ## Record each sequence of the input file as a list of Bioseq instances
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
89 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
90 # @param faFileHandler handler of a fasta file
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
91 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
92 def read( self, faFileHandler ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
93 while True:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
94 seq = Bioseq()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
95 seq.read( faFileHandler )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
96 if seq.sequence == None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
97 break
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
98 self.add( seq )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
99
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
100
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
101 ## Write all Bioseq of BioseqDB in a formatted fasta file (60 character long)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
102 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
103 # @param faFileHandler file handler of a fasta file
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
104 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
105 def write( self, faFileHandler ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
106 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
107 bs.writeABioseqInAFastaFile( faFileHandler )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
108
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
109
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
110 ## Write all Bioseq of BioseqDB in a formatted fasta file (60 character long)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
111 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
112 # @param outFaFileName file name of fasta file
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
113 # @param mode 'write' or 'append'
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
114 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
115 def save( self, outFaFileName, mode="w" ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
116 outFaFile = open( outFaFileName, mode )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
117 self.write( outFaFile )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
118 outFaFile.close()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
119
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
120
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
121 ## Read a formatted fasta file and load it in the BioseqDB instance
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
122 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
123 # @param inFaFileName file name of fasta file
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
124 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
125 def load(self, inFaFileName):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
126 fichier = open(inFaFileName)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
127 self.read(fichier)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
128 fichier.close()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
129
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
130
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
131 ## Reverse each sequence of the collection
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
132 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
133 def reverse( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
134 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
135 bs.reverse()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
136
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
137
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
138 ## Turn each sequence into its complement
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
139 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
140 def complement( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
141 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
142 bs.complement()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
143
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
144
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
145 ## Reverse and complement each sequence
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
146 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
147 def reverseComplement( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
148 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
149 bs.reverseComplement()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
150
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
151
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
152 ## Set the collection from a list of Bioseq instances
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
153 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
154 def setData( self, lBioseqs ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
155 for i in lBioseqs:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
156 self.add( i )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
157
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
158
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
159 ## Initialization of each attribute of the collection
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
160 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
161 def reset( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
162 self.db = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
163 self.idx = {}
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
164 self.name = None
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
165 self.mean_seq_lgth = None
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
166 self.stat.reset()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
167
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
168
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
169 ## Remove all the gap of the sequences of the collection
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
170 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
171 def cleanGap(self):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
172 for iBioSeq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
173 iBioSeq.cleanGap()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
174
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
175
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
176 ## Add a Bioseq instance and update the attributes
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
177 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
178 # @param bs a Bioseq instance
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
179 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
180 def add( self, bs ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
181 if self.idx.has_key( bs.header ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
182 sys.stderr.write( "ERROR: two sequences with same header '%s'\n" % ( bs.header ) )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
183 sys.exit(1)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
184 self.db.append( bs )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
185 self.idx[ bs.header ] = len(self.db) - 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
186 self.idx_renamed[ bs.header.replace("::","-").replace(":","-").replace(",","-").replace(" ","_") ] = len(self.db) - 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
187
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
188
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
189 ## Give the Bioseq instance corresponding to specified index
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
190 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
191 # @return a Bioseq instance
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
192 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
193 def __getitem__(self,index):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
194 if index < len(self.db):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
195 return self.db[index]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
196
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
197
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
198 ## Give the number of sequences in the bank
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
199 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
200 # @return an integer
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
201 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
202 def getSize( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
203 return len( self.db )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
204
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
205
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
206 ## Give the cumulative sequence length in the bank
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
207 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
208 # @return an integer
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
209 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
210 def getLength( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
211 cumLength = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
212 for iBioseq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
213 cumLength += iBioseq.getLength()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
214
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
215 return cumLength
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
216
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
217
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
218 ## Return the length of a given sequence via its header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
219 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
220 # @return an integer
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
221 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
222 def getSeqLength( self, header ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
223 return self.fetch(header).getLength()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
224
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
225
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
226 ## Return a list with the sequence headers
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
227 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
228 def getHeaderList( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
229 lHeaders = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
230 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
231 lHeaders.append( bs.header )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
232 return lHeaders
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
233
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
234
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
235 ## Return a list with the sequences
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
236 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
237 def getSequencesList( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
238 lSeqs = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
239 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
240 lSeqs.append( bs.getSequence() )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
241 return lSeqs
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
242
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
243
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
244 ## Give the Bioseq instance of the BioseqDB specified by its header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
245 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
246 # @warning name of this method not appropriate getBioseqByHeader is proposed
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
247 # @param header string
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
248 # @return a Bioseq instance
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
249 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
250 def fetch( self, header ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
251 idx = self.idx.get(header,None)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
252 if idx is not None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
253 return self.db[idx]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
254 else:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
255 idx = self.idx_renamed.get(header,None)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
256 if idx is not None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
257 return self.db[idx]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
258 else:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
259 raise Exception("Header: "+header+" not found")
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
260
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
261
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
262 ## Get a list of Bioseq instances based on a list of headers
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
263 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
264 # @param lHeader list
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
265 # @return a list of Bioseq instances
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
266 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
267 def fetchList( self, lheader ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
268 result = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
269 for headerName in lheader:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
270 result.append(self.fetch( headerName ))
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
271 return result
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
272
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
273
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
274 ## Sort self on its Bioseq size, possibly by decreasing length
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
275 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
276 # @param reverse boolean
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
277 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
278 def sortByLength(self, reverse = False):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
279 self.db.sort(key = lambda iBS: iBS.getLength(), reverse = reverse)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
280
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
281
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
282 ## Give the Bioseq instance of the BioseqDB specified by its renamed header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
283 # In renamed header "::", ":", "," character are been replaced by "-" and " " by "_"
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
284 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
285 # @param renamedHeader string
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
286 # @return a Bioseq instance
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
287 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
288 def getBioseqByRenamedHeader( self, renamedHeader ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
289 return self.db[self.idx_renamed[renamedHeader]]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
290
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
291
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
292 ## Count the number of times the given nucleotide is present in the bank.
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
293 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
294 # @param nt character (nt or aa)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
295 # @return an integer
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
296 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
297 def countNt( self, nt ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
298 total = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
299 for iBioseq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
300 total+= iBioseq.countNt( nt )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
301 return total
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
302
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
303
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
304 ## Count the number of times each nucleotide (A,T,G,C,N) is present in the bank.
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
305 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
306 # @return a dictionary with nucleotide as key and an integer as values
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
307 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
308 def countAllNt( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
309 dNt2Count = {}
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
310 for nt in ["A","T","G","C","N"]:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
311 dNt2Count[ nt ] = self.countNt( nt )
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
312 return dNt2Count
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
313
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
314
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
315 ## Extract a sub BioseqDB of specified size which beginning at specified start
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
316 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
317 # @param start integer index of first included Bioseq
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
318 # @param size integer size of expected BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
319 # @return a BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
320 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
321 def extractPart(self, start, size):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
322 iShorterBioseqDB = BioseqDB()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
323 for iBioseq in self.db[start:(start + size)]:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
324 iShorterBioseqDB.add(iBioseq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
325 return iShorterBioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
326
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
327
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
328 ## Extract a sub BioseqDB with the specified number of best length Bioseq
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
329 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
330 # @param numBioseq integer the number of Bioseq searched
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
331 # @return a BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
332 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
333 def bestLength(self, numBioseq):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
334 length_list = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
335 numseq = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
336 for each_seq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
337 if each_seq.sequence == None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
338 l=0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
339 else:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
340 l = each_seq.getLength()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
341 length_list.append(l)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
342 numseq = numseq + 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
343
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
344 length_list.sort()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
345 size = len(length_list)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
346 if numBioseq < size:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
347 len_min = length_list[size-numBioseq]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
348 else:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
349 len_min = length_list[0]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
350
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
351 numseq = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
352 nbsave = 0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
353 bestSeqs = BioseqDB()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
354 bestSeqs.setName(self.name)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
355 for each_seq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
356 if each_seq.sequence == None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
357 l=0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
358 else :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
359 l = each_seq.getLength()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
360 numseq = numseq + 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
361 if l >= len_min:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
362 bestSeqs.add(each_seq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
363 nbsave = nbsave + 1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
364 if nbsave == numBioseq :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
365 break
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
366 return bestSeqs
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
367
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
368
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
369 ## Extract a sub BioseqDB from a file with Bioseq header containing the specified pattern
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
370 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
371 # @param pattern regular expression of wished Bioseq header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
372 # @param inFileName name of fasta file in which we want extract the BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
373 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
374 def extractPatternOfFile(self, pattern, inFileName):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
375 if pattern=="" :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
376 return
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
377 srch=re.compile(pattern)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
378 file_db=open(inFileName)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
379 numseq=0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
380 nbsave=0
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
381 while 1:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
382 seq=Bioseq()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
383 seq.read(file_db)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
384 if seq.sequence==None:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
385 break
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
386 numseq+=1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
387 m=srch.search(seq.header)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
388 if m:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
389 self.add(seq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
390 nbsave+=1
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
391 file_db.close()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
392
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
393
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
394 ## Extract a sub BioseqDB from the instance with all Bioseq header containing the specified pattern
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
395 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
396 # @param pattern regular expression of wished Bioseq header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
397 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
398 # @return a BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
399 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
400 def getByPattern(self,pattern):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
401 if pattern=="" :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
402 return
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
403 iBioseqDB=BioseqDB()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
404 srch=re.compile(pattern)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
405 for iBioseq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
406 if srch.search(iBioseq.header):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
407 iBioseqDB.add(iBioseq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
408 return iBioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
409
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
410
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
411 ## Extract a sub BioseqDB from the instance with all Bioseq header not containing the specified pattern
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
412 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
413 # @param pattern regular expression of not wished Bioseq header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
414 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
415 # @return a BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
416 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
417 def getDiffFromPattern(self,pattern):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
418 if pattern=="" :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
419 return
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
420 iBioseqDB=BioseqDB()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
421 srch=re.compile(pattern)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
422 for iBioseq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
423 if not srch.search(iBioseq.header):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
424 iBioseqDB.add(iBioseq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
425 return iBioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
426
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
427 #TODO: to run several times to remove all concerned sequences when big data. How to fix it ?
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
428 ## Remove from the instance all Bioseq which header contains the specified pattern
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
429 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
430 # @param pattern regular expression of not wished Bioseq header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
431 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
432 def rmByPattern(self,pattern):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
433 if pattern=="" :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
434 return
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
435 srch=re.compile(pattern)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
436 for seq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
437 if srch.search(seq.header):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
438 self.db.remove(seq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
439
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
440
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
441 ## Copy a part from another BioseqDB in the BioseqDB if Bioseq have got header containing the specified pattern
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
442 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
443 # @warning this method is called extractPattern in pyRepet.seq.BioseqDB
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
444 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
445 # @param pattern regular expression of wished Bioseq header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
446 # @param sourceBioseqDB the BioseqDB from which we want extract Bioseq
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
447 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
448 def addBioseqFromABioseqDBIfHeaderContainPattern(self, pattern, sourceBioseqDB):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
449 if pattern=="" :
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
450 return
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
451 srch=re.compile(pattern)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
452 for seq in sourceBioseqDB.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
453 m=srch.search(seq.header)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
454 if m:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
455 self.add(seq)
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
456
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
457
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
458 ## Up-case the sequence characters in all sequences
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
459 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
460 def upCase( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
461 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
462 bs.upCase()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
463
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
464
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
465 ## Split each gapped Bioseq in a list and store all in a dictionary
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
466 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
467 # @return a dict, keys are bioseq headers, values are list of Map instances
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
468 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
469 def getDictOfLMapsWithoutGaps( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
470 dSeq2Maps = {}
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
471
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
472 for bs in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
473 dSeq2Maps[ bs.header ] = bs.getLMapWhithoutGap()
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
474
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
475 return dSeq2Maps
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
476
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
477 ## Give the list of the sequence length in the bank
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
478 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
479 # @return an list
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
480 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
481 def getListOfSequencesLength( self ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
482 lLength = []
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
483 for iBioseq in self.db:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
484 lLength.append(iBioseq.getLength())
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
485
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
486 return lLength
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
487
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
488 ## Return sequence length for a list of sequence header
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
489 #
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
490 def getSeqLengthByListOfName( self, lHeaderName ):
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
491 lseqLength=[]
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
492 for headerName in lHeaderName:
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
493 lseqLength.append(self.getSeqLength( headerName ))
20ec0d14798e Uploaded
urgi-team
parents:
diff changeset
494 return lseqLength