annotate TEisotools-1.1.a/commons/core/seq/BioseqDB.py @ 15:255c852351c5 draft

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