Debian Codegraph @

debian/patches/2to3.patch

raw symbols SCIP
1 Description: 2to3 to port from python2 to python3
2 Bug-Debian: https://bugs.debian.org/936836
3 Author: Shayan Doust <[email protected]>
4 Last-Update: 2019-09-09
5
6 --- a/lefsebiom/AbundanceTable.py
7 +++ b/lefsebiom/AbundanceTable.py
8 @@ -4,24 +4,24 @@ Description: Class to abstract an abunda
9 """
10
11 #####################################################################################
12 -#Copyright (C) <2012>
13 +# Copyright (C) <2012>
14 #
15 -#Permission is hereby granted, free of charge, to any person obtaining a copy of
16 -#this software and associated documentation files (the "Software"), to deal in the
17 -#Software without restriction, including without limitation the rights to use, copy,
18 -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 -#and to permit persons to whom the Software is furnished to do so, subject to
20 -#the following conditions:
21 +# Permission is hereby granted, free of charge, to any person obtaining a copy of
22 +# this software and associated documentation files (the "Software"), to deal in the
23 +# Software without restriction, including without limitation the rights to use, copy,
24 +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
25 +# and to permit persons to whom the Software is furnished to do so, subject to
26 +# the following conditions:
27 #
28 -#The above copyright notice and this permission notice shall be included in all copies
29 -#or substantial portions of the Software.
30 +# The above copyright notice and this permission notice shall be included in all copies
31 +# or substantial portions of the Software.
32 #
33 -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
34 -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
36 -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37 -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
38 -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
40 +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
41 +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42 +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
43 +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44 +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 #####################################################################################
46
47 __author__ = "Timothy Tickle"
48 @@ -86,11 +86,11 @@ class RowMetadata:
49 self.dictMetadataIDs = {}
50 # Get the ids for the metadata
51 if self.dictRowMetadata:
52 - for dictMetadata in self.dictRowMetadata.values():
53 + for dictMetadata in list(self.dictRowMetadata.values()):
54 dictMetadata = dictMetadata.get(ConstantsBreadCrumbs.c_metadata_lowercase, None)
55
56 if dictMetadata:
57 - for key,value in dictMetadata.items():
58 + for key,value in list(dictMetadata.items()):
59 if self.dictMetadataIDs.get(key, None):
60 self.dictMetadataIDs[key] = max(self.dictMetadataIDs[key],len(dictMetadata[key]))
61 else:
62 @@ -109,7 +109,7 @@ class RowMetadata:
63 lsIDs = []
64 lsKeys = []
65
66 - for key, value in self.dictMetadataIDs.items():
67 + for key, value in list(self.dictMetadataIDs.items()):
68 lsKeys.append( key )
69 if value > 1:
70 lsIDs.extend( [ "_".join( [ key, str( iIndex ) ] ) for iIndex in range( value ) ] )
71 @@ -365,7 +365,7 @@ class AbundanceTable:
72 readData = ""
73 with open(strReadDataFileName,'rU') as f:
74 readData = f.read()
75 - readData = list(filter(None,readData.split(ConstantsBreadCrumbs.c_strEndline)))
76 + readData = list([_f for _f in readData.split(ConstantsBreadCrumbs.c_strEndline) if _f])
77
78 #Read the length of each line and make sure there is no jagged data
79 #Also hold row count for the metadata
80 @@ -507,7 +507,7 @@ class AbundanceTable:
81 result2 = objOther.funcGetMetadataCopy()
82 if sorted(result1.keys()) != sorted(result2.keys()):
83 return False
84 - for strKey in result1.keys():
85 + for strKey in list(result1.keys()):
86 if strKey not in result2:
87 return False
88 if result1[strKey] != result2[strKey]:
89 @@ -682,7 +682,7 @@ class AbundanceTable:
90
91 # If the sample metadata dictionary already has entries then remove the row metadata info from it.
92 if len( metadata ) and len( lsRowMetadataIDs ):
93 - for sKey, lsValues in metadata.items():
94 + for sKey, lsValues in list(metadata.items()):
95 metadata[ sKey ] = lsValues[ iIndexLastMetadataRow: ]
96
97 # Set the metadata without row metadata entries
98 @@ -1213,7 +1213,7 @@ class AbundanceTable:
99 dictCounts = dict()
100 for strTaxaName in lsNames:
101 #Split into the elements of the clades
102 - lsClades = list(filter(None,strTaxaName.split(cNameDelimiter)))
103 + lsClades = list([_f for _f in strTaxaName.split(cNameDelimiter) if _f])
104 #Count clade levels
105 iCladeLength = len(lsClades)
106
107 @@ -1234,7 +1234,7 @@ class AbundanceTable:
108 dictCounts[prevClade] = False
109
110 #Return only the elements that were of count 1
111 - return list(filter( lambda s: dictCounts[s] == True, dictCounts ))
112 + return list([s for s in dictCounts if dictCounts[s] == True])
113
114 #Happy path tested
115 def funcIsNormalized(self):
116 @@ -1349,7 +1349,7 @@ class AbundanceTable:
117 liKeepFeatures = []
118 for iRowIndex, dataRow in enumerate( self._npaFeatureAbundance ):
119 #See which rows meet the criteria and keep the index if needed.
120 - if len( list( filter( lambda d: d >= dMinAbundance, list(dataRow)[1:] ) ) ) >= iMinSamples:
121 + if len( list( [d for d in list(dataRow)[1:] if d >= dMinAbundance] ) ) >= iMinSamples:
122 liKeepFeatures.append(iRowIndex)
123
124 #Compress array
125 @@ -1385,7 +1385,7 @@ class AbundanceTable:
126 liKeepFeatures = []
127 for iRowIndex, dataRow in enumerate( self._npaFeatureAbundance ):
128 #See which rows meet the criteria and keep the index if needed.
129 - if len( list( filter( lambda d: d >= iMinSequence, list(dataRow)[1:] ) ) ) >= iMinSamples:
130 + if len( list( [d for d in list(dataRow)[1:] if d >= iMinSequence] ) ) >= iMinSamples:
131 liKeepFeatures.append(iRowIndex)
132
133 #Compress array
134 @@ -1714,7 +1714,7 @@ class AbundanceTable:
135 setstrFeatures = list(hashFeatures.keys( ))
136
137 #Remove parent clades that are identical to child clades
138 - for strFeature, adCounts in hashFeatures.items( ):
139 + for strFeature, adCounts in list(hashFeatures.items( )):
140 astrFeature = strFeature.strip( ).split( "|" )
141 while len( astrFeature ) > 1:
142 astrFeature = astrFeature[:-1]
143 @@ -1944,7 +1944,7 @@ class AbundanceTable:
144 dictMetadataCopy = self.funcGetMetadataCopy()
145 lMetaData = list()
146 iKeysCounter = 0
147 - for lMetadataCopyEntry in dictMetadataCopy.items():
148 + for lMetadataCopyEntry in list(dictMetadataCopy.items()):
149 iKeysCounter +=1
150 sMetadataName = lMetadataCopyEntry[0]
151 lMetadataEntries = lMetadataCopyEntry[1]
152 @@ -2255,7 +2255,7 @@ class AbundanceTable:
153 dBugNames = list() #Bug Names Table
154 dRowsMetadata = None #Initialize the np.array of the Rows metadata
155 BiomElements = json.loads(BiomTable.to_json(''))
156 - for BiomKey, BiomValue in BiomElements.items():
157 + for BiomKey, BiomValue in list(BiomElements.items()):
158 #****************************************************
159 #* Checking the different keys: format, *
160 #* rows, columns, date, generated_by *
161 @@ -2335,7 +2335,7 @@ class AbundanceTable:
162 for cntMetadata in range(0, lenBiomValue):
163 BiomMetadataEntry = BiomValue[cntMetadata]
164
165 - for key, value in BiomMetadataEntry.items(): #Loop on the entries
166 + for key, value in list(BiomMetadataEntry.items()): #Loop on the entries
167 if key == ConstantsBreadCrumbs.c_id_lowercase: #If id - process it
168 strIDMetadata = ConstantsBreadCrumbs.c_ID
169 if ConstantsBreadCrumbs.c_ID not in BiomMetadata: #If ID not in the common area - initalize it
170 @@ -2345,7 +2345,7 @@ class AbundanceTable:
171 if key == ConstantsBreadCrumbs.c_metadata_lowercase: #If key = metadata
172 if not value is None: #And value is not empty
173 MetadataDict = value #Initialize a dictionary and post the values
174 - for MDkey, MDvalue in MetadataDict.items():
175 + for MDkey, MDvalue in list(MetadataDict.items()):
176 MDkey = MDkey
177 MDvalue = MDvalue
178
179 @@ -2395,7 +2395,7 @@ class AbundanceTable:
180 dictRowsMetadata[str(BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_id_lowercase])] = dict()
181 RowMetadataEntryFromTable = BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_metadata_lowercase]
182 dMetadataTempDict = dict()
183 - for key, value in RowMetadataEntryFromTable.items():
184 + for key, value in list(RowMetadataEntryFromTable.items()):
185 dMetadataTempDict[key] = value
186 dictRowsMetadata[str(BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_id_lowercase])][ConstantsBreadCrumbs.c_metadata_lowercase] = dMetadataTempDict
187 return dictRowsMetadata
188 --- a/lefsebiom/CClade.py
189 +++ b/lefsebiom/CClade.py
190 @@ -4,24 +4,24 @@ Description: Used to create tree structu
191 """
192
193 #####################################################################################
194 -#Copyright (C) <2012>
195 +# Copyright (C) <2012>
196 #
197 -#Permission is hereby granted, free of charge, to any person obtaining a copy of
198 -#this software and associated documentation files (the "Software"), to deal in the
199 -#Software without restriction, including without limitation the rights to use, copy,
200 -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
201 -#and to permit persons to whom the Software is furnished to do so, subject to
202 -#the following conditions:
203 +# Permission is hereby granted, free of charge, to any person obtaining a copy of
204 +# this software and associated documentation files (the "Software"), to deal in the
205 +# Software without restriction, including without limitation the rights to use, copy,
206 +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
207 +# and to permit persons to whom the Software is furnished to do so, subject to
208 +# the following conditions:
209 #
210 -#The above copyright notice and this permission notice shall be included in all copies
211 -#or substantial portions of the Software.
212 +# The above copyright notice and this permission notice shall be included in all copies
213 +# or substantial portions of the Software.
214 #
215 -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
216 -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
217 -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
218 -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
219 -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
220 -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
221 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
222 +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
223 +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
224 +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
225 +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
226 +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
227 #####################################################################################
228
229 __author__ = "Curtis Huttenhower"
230 @@ -84,7 +84,7 @@ class CClade:
231 #Then take a copy of the child's
232 #If they now have a copy of a child's but have other children
233 #Sum their children with thier current values
234 - for pChild in self.m_hashChildren.values( ):
235 + for pChild in list(self.m_hashChildren.values( )):
236 adChild = pChild.impute( )
237 if self.m_adValues:
238 for i in range( len( adChild or [] ) ):
239 @@ -117,7 +117,7 @@ class CClade:
240 #Union all the results from freeze of all children
241 #Call freeze but append the child clade to the clade in the call.
242 #And give an incremented depth
243 - for strChild, pChild in self.m_hashChildren.items( ):
244 + for strChild, pChild in list(self.m_hashChildren.items( )):
245 setiRet |= pChild._freeze( hashValues, iTarget, astrClade + [strChild], iDepth, fLeaves )
246 setiRet = set( ( i + 1 ) for i in setiRet )
247 else:
248 @@ -154,7 +154,7 @@ class CClade:
249 if self.m_hashChildren:
250 strRet += " "
251 if self.m_hashChildren:
252 - strRet += " ".join( p._repr( s ) for (s, p) in self.m_hashChildren.items( ) )
253 + strRet += " ".join( p._repr( s ) for (s, p) in list(self.m_hashChildren.items( )) )
254
255 return ( strRet + ">" )
256
257 --- a/lefsebiom/ConstantsBreadCrumbs.py
258 +++ b/lefsebiom/ConstantsBreadCrumbs.py
259 @@ -4,24 +4,24 @@ Description: Project constants.
260 """
261
262 #####################################################################################
263 -#Copyright (C) <2012>
264 +# Copyright (C) <2012>
265 #
266 -#Permission is hereby granted, free of charge, to any person obtaining a copy of
267 -#this software and associated documentation files (the "Software"), to deal in the
268 -#Software without restriction, including without limitation the rights to use, copy,
269 -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
270 -#and to permit persons to whom the Software is furnished to do so, subject to
271 -#the following conditions:
272 +# Permission is hereby granted, free of charge, to any person obtaining a copy of
273 +# this software and associated documentation files (the "Software"), to deal in the
274 +# Software without restriction, including without limitation the rights to use, copy,
275 +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
276 +# and to permit persons to whom the Software is furnished to do so, subject to
277 +# the following conditions:
278 #
279 -#The above copyright notice and this permission notice shall be included in all copies
280 -#or substantial portions of the Software.
281 +# The above copyright notice and this permission notice shall be included in all copies
282 +# or substantial portions of the Software.
283 #
284 -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
285 -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
286 -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
287 -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
288 -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
289 -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
290 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
291 +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
292 +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
293 +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
294 +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
295 +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
296 #####################################################################################
297
298 __author__ = "Timothy Tickle"
299 @@ -33,13 +33,15 @@ __email__ = "[email protected]"
300 __status__ = "Development"
301
302 ##
303 -#Used to test the FileIO class
304 +# Used to test the FileIO class
305 +
306 +
307 class ConstantsBreadCrumbs():
308 """
309 Class to hold project constants.
310 """
311
312 - #Character Constants
313 + # Character Constants
314 c_strComma = ','
315 c_strColon = ':'
316 c_strConfigFileHeaderChar = '['
317 @@ -56,43 +58,43 @@ class ConstantsBreadCrumbs():
318
319 c_strBreadCrumbsSVMSpace = c_strWhiteSpace
320
321 - #Default values for missing data in the Abundance Table
322 + # Default values for missing data in the Abundance Table
323 c_strEmptyAbundanceData = "0"
324 c_strEmptyDataMetadata = "NA"
325 c_strSVMNoSample = "-"
326
327 - lNAs = list(set(["NA","na","Na","nA",c_strEmptyDataMetadata]))
328 + lNAs = list(set(["NA", "na", "Na", "nA", c_strEmptyDataMetadata]))
329
330 - #TODO remove
331 - #Reference to circlader
332 + # TODO remove
333 + # Reference to circlader
334 c_strCircladerScript = "circlader/circlader.py"
335
336 - #AbundanceTable
337 - #Suffix given to a file that is check with the checkRawDataFile method
338 + # AbundanceTable
339 + # Suffix given to a file that is check with the checkRawDataFile method
340 OUTPUT_SUFFIX = "-checked.pcl"
341
342 - #BIOM related
343 - #PCL File metadata defaults (many of these come from biom file requirements
344 - #ID
345 + # BIOM related
346 + # PCL File metadata defaults (many of these come from biom file requirements
347 + # ID
348 c_strIDKey = "id"
349 c_strDefaultPCLID = None
350
351 - #File date
352 + # File date
353 c_strDateKey = "date"
354
355 - #File format type
356 + # File format type
357 c_strFormatKey = "format"
358 c_strDefaultPCLFileFormateType = "PCL"
359
360 - #File generation source
361 + # File generation source
362 c_strSourceKey = "source"
363 c_strDefaultPCLGenerationSource = None
364
365 - #File type
366 + # File type
367 c_strTypekey = "type"
368 c_strDefaultPCLFileTpe = None
369
370 - #Allowable file types for biom files
371 + # Allowable file types for biom files
372 c_strOTUType = "OTU"
373 c_strOTUBIOMType = "OTU table"
374 c_strPathwayType = "Pathway"
375 @@ -107,14 +109,15 @@ class ConstantsBreadCrumbs():
376 c_strMetaboliteBIOMType = "Metabolite table"
377 c_strTaxonType = "Taxon"
378 c_strTaxonBIOMType = "Taxon table"
379 - c_dictFileType = {c_strOTUType:c_strOTUBIOMType, c_strPathwayType:c_strPathwayBIOMType, c_strFunctionType:c_strFunctionBIOMType, c_strOrthologType:c_strOrthologBIOMType, c_strGeneType:c_strGeneBIOMType, c_strMetaboliteType:c_strMetaboliteBIOMType, c_strTaxonType:c_strTaxonType}
380 + c_dictFileType = {c_strOTUType: c_strOTUBIOMType, c_strPathwayType: c_strPathwayBIOMType, c_strFunctionType: c_strFunctionBIOMType,
381 + c_strOrthologType: c_strOrthologBIOMType, c_strGeneType: c_strGeneBIOMType, c_strMetaboliteType: c_strMetaboliteBIOMType, c_strTaxonType: c_strTaxonType}
382
383 - #File URL
384 + # File URL
385 c_strURLKey = "url"
386 c_strDefaultPCLURL = None
387 - c_strFormatUrl = "format_url"
388 + c_strFormatUrl = "format_url"
389
390 - #File sparse matrix
391 + # File sparse matrix
392 c_strSparsityKey = "sparsity"
393 c_fDefaultPCLSparsity = False
394
395 @@ -122,9 +125,9 @@ class ConstantsBreadCrumbs():
396 # Data shape
397 c_strDataShapeKey = "shape"
398
399 - ######################################################################
400 - # Constants related to biom import and export files #
401 - ######################################################################
402 + ######################################################################
403 + # Constants related to biom import and export files #
404 + ######################################################################
405 # Biom file extension
406 c_strBiomFile = "biom"
407 c_BiomTaxData = "BiomTaxData"
408 @@ -132,14 +135,14 @@ class ConstantsBreadCrumbs():
409 c_Metadata = "Metadata"
410 c_metadata_lowercase = "metadata"
411 c_sLastMetadata = "sLastMetadata"
412 - c_columns = "columns"
413 + c_columns = "columns"
414 c_rows = "rows"
415 - c_ascii = "ascii"
416 - c_ignore = "ignore"
417 - c_Dtype = "Dtype"
418 - c_ID = "ID"
419 - c_id_lowercase = "id"
420 - c_f4 = "f8"
421 + c_ascii = "ascii"
422 + c_ignore = "ignore"
423 + c_Dtype = "Dtype"
424 + c_ID = "ID"
425 + c_id_lowercase = "id"
426 + c_f4 = "f8"
427 c_biom_file_generated_by = "BreadCrumbs"
428 c_strPCLFile = "pcl"
429 c_taxonomy = "taxonomy"
430 @@ -150,6 +153,5 @@ class ConstantsBreadCrumbs():
431 c_MetadataEntriesTotal = "MetadataEntriesTotal"
432 c_MaximumLength = "MaximumLength"
433
434 -
435 def __init__(self):
436 - pass
437 + pass
438 --- a/lefsebiom/ValidateData.py
439 +++ b/lefsebiom/ValidateData.py
440 @@ -4,24 +4,24 @@ Description: Validate Data containing me
441 """
442
443 #####################################################################################
444 -#Copyright (C) <2012>
445 +# Copyright (C) <2012>
446 #
447 -#Permission is hereby granted, free of charge, to any person obtaining a copy of
448 -#this software and associated documentation files (the "Software"), to deal in the
449 -#Software without restriction, including without limitation the rights to use, copy,
450 -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
451 -#and to permit persons to whom the Software is furnished to do so, subject to
452 -#the following conditions:
453 +# Permission is hereby granted, free of charge, to any person obtaining a copy of
454 +# this software and associated documentation files (the "Software"), to deal in the
455 +# Software without restriction, including without limitation the rights to use, copy,
456 +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
457 +# and to permit persons to whom the Software is furnished to do so, subject to
458 +# the following conditions:
459 #
460 -#The above copyright notice and this permission notice shall be included in all copies
461 -#or substantial portions of the Software.
462 +# The above copyright notice and this permission notice shall be included in all copies
463 +# or substantial portions of the Software.
464 #
465 -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
466 -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
467 -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
468 -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
469 -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
470 -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
471 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
472 +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
473 +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
474 +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
475 +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
476 +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
477 #####################################################################################
478
479 __author__ = "Timothy Tickle"
480 @@ -32,16 +32,17 @@ __maintainer__ = "Timothy Tickle"
481 __email__ = "[email protected]"
482 __status__ = "Development"
483
484 -#Import local code
485 +# Import local code
486 from types import *
487 import decimal
488 import os
489 import re
490 import string
491
492 +
493 class ValidateData:
494
495 - #Tested 5
496 + # Tested 5
497 @staticmethod
498 def funcIsValidBoolean(parameterValue):
499 """
500 @@ -53,16 +54,16 @@ class ValidateData:
501 :type Boolean
502 """
503
504 - #Check to make sure it is not null
505 + # Check to make sure it is not null
506 if parameterValue == None:
507 return False
508
509 - #Check to make sure it is a string
510 + # Check to make sure it is a string
511 if not type(parameterValue) is BooleanType:
512 return False
513 return True
514
515 - #Tested 6
516 + # Tested 6
517 @staticmethod
518 def funcIsTrue(parameterValue):
519 """
520 @@ -79,7 +80,7 @@ class ValidateData:
521 return True
522 return False
523
524 - #Tested 6
525 + # Tested 6
526 @staticmethod
527 def funcIsFalse(parameterValue):
528 """
529 @@ -96,7 +97,7 @@ class ValidateData:
530 return True
531 return False
532
533 - #Tested 5
534 + # Tested 5
535 @staticmethod
536 def funcIsValidInteger(parameterValue):
537 """
538 @@ -108,19 +109,19 @@ class ValidateData:
539 :type Boolean
540 """
541
542 - #Check to make sure it is not null
543 + # Check to make sure it is not null
544 if (parameterValue == None):
545 return False
546
547 - #Check to make sure it is an integer
548 + # Check to make sure it is an integer
549 if not type(parameterValue) is IntType:
550 return False
551
552 return True
553
554 - #Tested 5
555 + # Tested 5
556 @staticmethod
557 - def funcIsValidPositiveInteger(parameterValue, tempZero = False):
558 + def funcIsValidPositiveInteger(parameterValue, tempZero=False):
559 """
560 Validates a parameter as false.
561
562 @@ -132,20 +133,20 @@ class ValidateData:
563 :type Boolean
564 """
565
566 - #Check to make sure it is not null
567 + # Check to make sure it is not null
568 if not ValidateData.funcIsValidInteger(parameterValue):
569 return False
570
571 - #Check to see it is positive
572 + # Check to see it is positive
573 if (parameterValue < 0):
574 return False
575
576 - #Check for zero value
577 + # Check for zero value
578 if(parameterValue == 0):
579 return tempZero
580 return True
581
582 - #Tested 14
583 + # Tested 14
584 @staticmethod
585 def funcIsValidNumeric(parameterValue):
586 """
587 @@ -157,16 +158,16 @@ class ValidateData:
588 :type Boolean
589 """
590
591 - #Check to make sure it is not null
592 + # Check to make sure it is not null
593 if (parameterValue == None):
594 return False
595 - #Check to make sure it is an integer
596 + # Check to make sure it is an integer
597 if((type(parameterValue) == IntType)or(type(parameterValue) == LongType)or(type(parameterValue) == FloatType)or(type(parameterValue) == ComplexType)or(str(type(parameterValue)) == "<type 'numpy.float64'>")):
598 if(not type(parameterValue) == BooleanType):
599 return True
600 return False
601
602 - #Tested 5
603 + # Tested 5
604 @staticmethod
605 def funcIsValidStringType(parameterValue):
606 """
607 @@ -178,17 +179,17 @@ class ValidateData:
608 :type Boolean
609 """
610
611 - #Check to make sure it is not null
612 + # Check to make sure it is not null
613 if parameterValue == None:
614 return False
615
616 - #Check to make sure it is a string
617 + # Check to make sure it is a string
618 if not type(parameterValue) is StringType:
619 return False
620
621 return True
622
623 - #Tested 5
624 + # Tested 5
625 @staticmethod
626 def funcIsValidString(parameterValue):
627 """
628 @@ -200,11 +201,11 @@ class ValidateData:
629 :type Boolean
630 """
631
632 - #Type check
633 + # Type check
634 if not ValidateData.funcIsValidStringType(parameterValue):
635 return False
636
637 - #Check to see it is not blank
638 + # Check to see it is not blank
639 if parameterValue.strip() == "":
640 return False
641 return True
642 @@ -218,11 +219,11 @@ class ValidateData:
643 :type Unknown
644 """
645
646 - #Type string check
647 + # Type string check
648 if not ValidateData.funcIsValidStringType(parameterValue):
649 return False
650
651 - #Check to see if the string can be converted to an integer
652 + # Check to see if the string can be converted to an integer
653 try:
654 int(parameterValue)
655 except:
656 @@ -238,18 +239,18 @@ class ValidateData:
657 :type Unknown
658 """
659
660 - #Type string check
661 + # Type string check
662 if not ValidateData.funcIsValidStringType(parameterValue):
663 return False
664
665 - #Check to see if the string can be converted to a double
666 + # Check to see if the string can be converted to a double
667 try:
668 float(parameterValue)
669 except:
670 return False
671 return True
672
673 - #Tested 6
674 + # Tested 6
675 @staticmethod
676 def funcIsValidFormatString(parameterValue):
677 """
678 @@ -270,7 +271,7 @@ class ValidateData:
679 break
680 return lettersValid
681
682 - #Tested 5
683 + # Tested 5
684 @staticmethod
685 def funcIsValidChar(parameterValue):
686 """
687 @@ -284,7 +285,7 @@ class ValidateData:
688
689 return ValidateData.funcIsValidString(parameterValue)
690
691 - #Tested 13
692 + # Tested 13
693 @staticmethod
694 def funcIsValidPositiveNumberChar(parameterValue):
695 """
696 @@ -296,11 +297,11 @@ class ValidateData:
697 :type Boolean
698 """
699
700 - #Check to make sure is a valid string
701 + # Check to make sure is a valid string
702 if not ValidateData.funcIsValidString(parameterValue):
703 return False
704
705 - #Try to convert to decimal
706 + # Try to convert to decimal
707 try:
708 decimalConversion = decimal.Decimal(parameterValue)
709 if decimalConversion < 0:
710 @@ -309,7 +310,7 @@ class ValidateData:
711 return False
712 return True
713
714 - #Tested 9
715 + # Tested 9
716 @staticmethod
717 def funcIsValidFlagChar(parameterValue):
718 """
719 @@ -325,7 +326,7 @@ class ValidateData:
720 return True
721 return False
722
723 - #Tested 15
724 + # Tested 15
725 @staticmethod
726 def funcIsValidBoundedIntegerChar(parameterValue, iValueOne, iValueTwo):
727 """
728 @@ -341,19 +342,19 @@ class ValidateData:
729 :type Boolean
730 """
731
732 - #Check to make sure is a valid string
733 + # Check to make sure is a valid string
734 if not ValidateData.funcIsValidString(parameterValue):
735 return False
736
737 - #Check to make sure is a valid integer
738 + # Check to make sure is a valid integer
739 if not ValidateData.funcIsValidInteger(iValueOne):
740 return False
741
742 - #Check to make sure is a valid integer
743 + # Check to make sure is a valid integer
744 if not ValidateData.funcIsValidInteger(iValueTwo):
745 return False
746
747 - #Try to convert to decimal
748 + # Try to convert to decimal
749 try:
750 intConversion = int(parameterValue)
751 if(iValueOne < iValueTwo):
752 @@ -371,7 +372,7 @@ class ValidateData:
753 except:
754 return False
755
756 - #Tested 9
757 + # Tested 9
758 @staticmethod
759 def funcIsValidList(parameterValue):
760 """
761 @@ -383,17 +384,17 @@ class ValidateData:
762 :type Boolean
763 """
764
765 - #Check to make sure it is not null
766 + # Check to make sure it is not null
767 if parameterValue == None:
768 return False
769
770 - #Check to make sure it is a list
771 + # Check to make sure it is a list
772 if not type(parameterValue) is ListType:
773 return False
774
775 - #Check elements
776 + # Check elements
777 listSize = len(parameterValue)
778 - for i in range(0,listSize):
779 + for i in range(0, listSize):
780 if parameterValue[i] == None:
781 return False
782 if type(parameterValue[i]) is ListType:
783 @@ -401,7 +402,7 @@ class ValidateData:
784 return False
785 return True
786
787 - #Tested 9
788 + # Tested 9
789 @staticmethod
790 def funcIsValidTuple(parameterValue):
791 """
792 @@ -413,17 +414,17 @@ class ValidateData:
793 :type Boolean
794 """
795
796 - #Check to make sure it is not null
797 + # Check to make sure it is not null
798 if parameterValue == None:
799 return False
800
801 - #Check to make sure it is a string
802 + # Check to make sure it is a string
803 if not type(parameterValue) is TupleType:
804 return False
805
806 - #Check elements
807 + # Check elements
808 tupleSize = len(parameterValue)
809 - for i in range(0,tupleSize):
810 + for i in range(0, tupleSize):
811 if parameterValue[i] == None:
812 return False
813 if type(parameterValue[i]) is TupleType:
814 @@ -431,7 +432,7 @@ class ValidateData:
815 return False
816 return True
817
818 - #Tested 7
819 + # Tested 7
820 @staticmethod
821 def funcIsValidNumericList(parameterValue):
822 """
823 @@ -489,17 +490,17 @@ class ValidateData:
824 :type Boolean
825 """
826
827 - #Check to make sure it is not null
828 + # Check to make sure it is not null
829 if parameterValue == None:
830 return False
831
832 - #Check to make sure it is a structure array
833 + # Check to make sure it is a structure array
834 if not str(type(parameterValue)) == "<type 'numpy.ndarray'>":
835 return False
836
837 return True
838
839 - #Tested 9
840 + # Tested 9
841 @staticmethod
842 def funcIsValidDictionary(parameterValue):
843 """
844 @@ -541,7 +542,7 @@ class ValidateData:
845 return False
846 return True
847
848 - #Tested 18
849 + # Tested 18
850 @staticmethod
851 def funcIsValidDNASequence(parameterValue):
852 """
853 @@ -560,7 +561,7 @@ class ValidateData:
854 return True
855 return False
856
857 - #Tested 15
858 + # Tested 15
859 @staticmethod
860 def funcIsValidNucleotideBase(parameterValue):
861 """
862 @@ -577,7 +578,7 @@ class ValidateData:
863 return True
864 return False
865
866 - #Testing 4
867 + # Testing 4
868 @staticmethod
869 def funcIsValidFileName(parameterValue):
870 """
871 @@ -595,7 +596,7 @@ class ValidateData:
872 return os.path.exists(parameterValue)
873 return False
874
875 - #Tested 5
876 + # Tested 5
877 @staticmethod
878 def funcIsValidClass(parameterValue, strCorrectName):
879 """
880 @@ -609,7 +610,7 @@ class ValidateData:
881 :type Boolean
882 """
883
884 - if(parameterValue==None):
885 + if(parameterValue == None):
886 return False
887 if not ValidateData.funcIsValidString(strCorrectName):
888 return False
889 @@ -617,7 +618,7 @@ class ValidateData:
890 if(classType == strCorrectName):
891 return True
892 if(classType == 'instance'):
893 - if(parameterValue.__class__.__name__==strCorrectName):
894 + if(parameterValue.__class__.__name__ == strCorrectName):
895 return True
896 else:
897 return False