Description: 2to3 to port from python2 to python3 Bug-Debian: https://bugs.debian.org/936836 Author: Shayan Doust Last-Update: 2019-09-09 --- a/lefsebiom/AbundanceTable.py +++ b/lefsebiom/AbundanceTable.py @@ -4,24 +4,24 @@ Description: Class to abstract an abunda """ ##################################################################################### -#Copyright (C) <2012> +# Copyright (C) <2012> # -#Permission is hereby granted, free of charge, to any person obtaining a copy of -#this software and associated documentation files (the "Software"), to deal in the -#Software without restriction, including without limitation the rights to use, copy, -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -#and to permit persons to whom the Software is furnished to do so, subject to -#the following conditions: +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in the +# Software without restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -#The above copyright notice and this permission notice shall be included in all copies -#or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all copies +# or substantial portions of the Software. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ##################################################################################### __author__ = "Timothy Tickle" @@ -86,11 +86,11 @@ class RowMetadata: self.dictMetadataIDs = {} # Get the ids for the metadata if self.dictRowMetadata: - for dictMetadata in self.dictRowMetadata.values(): + for dictMetadata in list(self.dictRowMetadata.values()): dictMetadata = dictMetadata.get(ConstantsBreadCrumbs.c_metadata_lowercase, None) if dictMetadata: - for key,value in dictMetadata.items(): + for key,value in list(dictMetadata.items()): if self.dictMetadataIDs.get(key, None): self.dictMetadataIDs[key] = max(self.dictMetadataIDs[key],len(dictMetadata[key])) else: @@ -109,7 +109,7 @@ class RowMetadata: lsIDs = [] lsKeys = [] - for key, value in self.dictMetadataIDs.items(): + for key, value in list(self.dictMetadataIDs.items()): lsKeys.append( key ) if value > 1: lsIDs.extend( [ "_".join( [ key, str( iIndex ) ] ) for iIndex in range( value ) ] ) @@ -365,7 +365,7 @@ class AbundanceTable: readData = "" with open(strReadDataFileName,'rU') as f: readData = f.read() - readData = list(filter(None,readData.split(ConstantsBreadCrumbs.c_strEndline))) + readData = list([_f for _f in readData.split(ConstantsBreadCrumbs.c_strEndline) if _f]) #Read the length of each line and make sure there is no jagged data #Also hold row count for the metadata @@ -507,7 +507,7 @@ class AbundanceTable: result2 = objOther.funcGetMetadataCopy() if sorted(result1.keys()) != sorted(result2.keys()): return False - for strKey in result1.keys(): + for strKey in list(result1.keys()): if strKey not in result2: return False if result1[strKey] != result2[strKey]: @@ -682,7 +682,7 @@ class AbundanceTable: # If the sample metadata dictionary already has entries then remove the row metadata info from it. if len( metadata ) and len( lsRowMetadataIDs ): - for sKey, lsValues in metadata.items(): + for sKey, lsValues in list(metadata.items()): metadata[ sKey ] = lsValues[ iIndexLastMetadataRow: ] # Set the metadata without row metadata entries @@ -1213,7 +1213,7 @@ class AbundanceTable: dictCounts = dict() for strTaxaName in lsNames: #Split into the elements of the clades - lsClades = list(filter(None,strTaxaName.split(cNameDelimiter))) + lsClades = list([_f for _f in strTaxaName.split(cNameDelimiter) if _f]) #Count clade levels iCladeLength = len(lsClades) @@ -1234,7 +1234,7 @@ class AbundanceTable: dictCounts[prevClade] = False #Return only the elements that were of count 1 - return list(filter( lambda s: dictCounts[s] == True, dictCounts )) + return list([s for s in dictCounts if dictCounts[s] == True]) #Happy path tested def funcIsNormalized(self): @@ -1349,7 +1349,7 @@ class AbundanceTable: liKeepFeatures = [] for iRowIndex, dataRow in enumerate( self._npaFeatureAbundance ): #See which rows meet the criteria and keep the index if needed. - if len( list( filter( lambda d: d >= dMinAbundance, list(dataRow)[1:] ) ) ) >= iMinSamples: + if len( list( [d for d in list(dataRow)[1:] if d >= dMinAbundance] ) ) >= iMinSamples: liKeepFeatures.append(iRowIndex) #Compress array @@ -1385,7 +1385,7 @@ class AbundanceTable: liKeepFeatures = [] for iRowIndex, dataRow in enumerate( self._npaFeatureAbundance ): #See which rows meet the criteria and keep the index if needed. - if len( list( filter( lambda d: d >= iMinSequence, list(dataRow)[1:] ) ) ) >= iMinSamples: + if len( list( [d for d in list(dataRow)[1:] if d >= iMinSequence] ) ) >= iMinSamples: liKeepFeatures.append(iRowIndex) #Compress array @@ -1714,7 +1714,7 @@ class AbundanceTable: setstrFeatures = list(hashFeatures.keys( )) #Remove parent clades that are identical to child clades - for strFeature, adCounts in hashFeatures.items( ): + for strFeature, adCounts in list(hashFeatures.items( )): astrFeature = strFeature.strip( ).split( "|" ) while len( astrFeature ) > 1: astrFeature = astrFeature[:-1] @@ -1944,7 +1944,7 @@ class AbundanceTable: dictMetadataCopy = self.funcGetMetadataCopy() lMetaData = list() iKeysCounter = 0 - for lMetadataCopyEntry in dictMetadataCopy.items(): + for lMetadataCopyEntry in list(dictMetadataCopy.items()): iKeysCounter +=1 sMetadataName = lMetadataCopyEntry[0] lMetadataEntries = lMetadataCopyEntry[1] @@ -2255,7 +2255,7 @@ class AbundanceTable: dBugNames = list() #Bug Names Table dRowsMetadata = None #Initialize the np.array of the Rows metadata BiomElements = json.loads(BiomTable.to_json('')) - for BiomKey, BiomValue in BiomElements.items(): + for BiomKey, BiomValue in list(BiomElements.items()): #**************************************************** #* Checking the different keys: format, * #* rows, columns, date, generated_by * @@ -2335,7 +2335,7 @@ class AbundanceTable: for cntMetadata in range(0, lenBiomValue): BiomMetadataEntry = BiomValue[cntMetadata] - for key, value in BiomMetadataEntry.items(): #Loop on the entries + for key, value in list(BiomMetadataEntry.items()): #Loop on the entries if key == ConstantsBreadCrumbs.c_id_lowercase: #If id - process it strIDMetadata = ConstantsBreadCrumbs.c_ID if ConstantsBreadCrumbs.c_ID not in BiomMetadata: #If ID not in the common area - initalize it @@ -2345,7 +2345,7 @@ class AbundanceTable: if key == ConstantsBreadCrumbs.c_metadata_lowercase: #If key = metadata if not value is None: #And value is not empty MetadataDict = value #Initialize a dictionary and post the values - for MDkey, MDvalue in MetadataDict.items(): + for MDkey, MDvalue in list(MetadataDict.items()): MDkey = MDkey MDvalue = MDvalue @@ -2395,7 +2395,7 @@ class AbundanceTable: dictRowsMetadata[str(BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_id_lowercase])] = dict() RowMetadataEntryFromTable = BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_metadata_lowercase] dMetadataTempDict = dict() - for key, value in RowMetadataEntryFromTable.items(): + for key, value in list(RowMetadataEntryFromTable.items()): dMetadataTempDict[key] = value dictRowsMetadata[str(BiomValue[iIndexRowMetaData][ConstantsBreadCrumbs.c_id_lowercase])][ConstantsBreadCrumbs.c_metadata_lowercase] = dMetadataTempDict return dictRowsMetadata --- a/lefsebiom/CClade.py +++ b/lefsebiom/CClade.py @@ -4,24 +4,24 @@ Description: Used to create tree structu """ ##################################################################################### -#Copyright (C) <2012> +# Copyright (C) <2012> # -#Permission is hereby granted, free of charge, to any person obtaining a copy of -#this software and associated documentation files (the "Software"), to deal in the -#Software without restriction, including without limitation the rights to use, copy, -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -#and to permit persons to whom the Software is furnished to do so, subject to -#the following conditions: +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in the +# Software without restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -#The above copyright notice and this permission notice shall be included in all copies -#or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all copies +# or substantial portions of the Software. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ##################################################################################### __author__ = "Curtis Huttenhower" @@ -84,7 +84,7 @@ class CClade: #Then take a copy of the child's #If they now have a copy of a child's but have other children #Sum their children with thier current values - for pChild in self.m_hashChildren.values( ): + for pChild in list(self.m_hashChildren.values( )): adChild = pChild.impute( ) if self.m_adValues: for i in range( len( adChild or [] ) ): @@ -117,7 +117,7 @@ class CClade: #Union all the results from freeze of all children #Call freeze but append the child clade to the clade in the call. #And give an incremented depth - for strChild, pChild in self.m_hashChildren.items( ): + for strChild, pChild in list(self.m_hashChildren.items( )): setiRet |= pChild._freeze( hashValues, iTarget, astrClade + [strChild], iDepth, fLeaves ) setiRet = set( ( i + 1 ) for i in setiRet ) else: @@ -154,7 +154,7 @@ class CClade: if self.m_hashChildren: strRet += " " if self.m_hashChildren: - strRet += " ".join( p._repr( s ) for (s, p) in self.m_hashChildren.items( ) ) + strRet += " ".join( p._repr( s ) for (s, p) in list(self.m_hashChildren.items( )) ) return ( strRet + ">" ) --- a/lefsebiom/ConstantsBreadCrumbs.py +++ b/lefsebiom/ConstantsBreadCrumbs.py @@ -4,24 +4,24 @@ Description: Project constants. """ ##################################################################################### -#Copyright (C) <2012> +# Copyright (C) <2012> # -#Permission is hereby granted, free of charge, to any person obtaining a copy of -#this software and associated documentation files (the "Software"), to deal in the -#Software without restriction, including without limitation the rights to use, copy, -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -#and to permit persons to whom the Software is furnished to do so, subject to -#the following conditions: +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in the +# Software without restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -#The above copyright notice and this permission notice shall be included in all copies -#or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all copies +# or substantial portions of the Software. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ##################################################################################### __author__ = "Timothy Tickle" @@ -33,13 +33,15 @@ __email__ = "ttickle@sph.harvard.edu" __status__ = "Development" ## -#Used to test the FileIO class +# Used to test the FileIO class + + class ConstantsBreadCrumbs(): """ Class to hold project constants. """ - #Character Constants + # Character Constants c_strComma = ',' c_strColon = ':' c_strConfigFileHeaderChar = '[' @@ -56,43 +58,43 @@ class ConstantsBreadCrumbs(): c_strBreadCrumbsSVMSpace = c_strWhiteSpace - #Default values for missing data in the Abundance Table + # Default values for missing data in the Abundance Table c_strEmptyAbundanceData = "0" c_strEmptyDataMetadata = "NA" c_strSVMNoSample = "-" - lNAs = list(set(["NA","na","Na","nA",c_strEmptyDataMetadata])) + lNAs = list(set(["NA", "na", "Na", "nA", c_strEmptyDataMetadata])) - #TODO remove - #Reference to circlader + # TODO remove + # Reference to circlader c_strCircladerScript = "circlader/circlader.py" - #AbundanceTable - #Suffix given to a file that is check with the checkRawDataFile method + # AbundanceTable + # Suffix given to a file that is check with the checkRawDataFile method OUTPUT_SUFFIX = "-checked.pcl" - #BIOM related - #PCL File metadata defaults (many of these come from biom file requirements - #ID + # BIOM related + # PCL File metadata defaults (many of these come from biom file requirements + # ID c_strIDKey = "id" c_strDefaultPCLID = None - #File date + # File date c_strDateKey = "date" - #File format type + # File format type c_strFormatKey = "format" c_strDefaultPCLFileFormateType = "PCL" - #File generation source + # File generation source c_strSourceKey = "source" c_strDefaultPCLGenerationSource = None - #File type + # File type c_strTypekey = "type" c_strDefaultPCLFileTpe = None - #Allowable file types for biom files + # Allowable file types for biom files c_strOTUType = "OTU" c_strOTUBIOMType = "OTU table" c_strPathwayType = "Pathway" @@ -107,14 +109,15 @@ class ConstantsBreadCrumbs(): c_strMetaboliteBIOMType = "Metabolite table" c_strTaxonType = "Taxon" c_strTaxonBIOMType = "Taxon table" - 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} + 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} - #File URL + # File URL c_strURLKey = "url" c_strDefaultPCLURL = None - c_strFormatUrl = "format_url" + c_strFormatUrl = "format_url" - #File sparse matrix + # File sparse matrix c_strSparsityKey = "sparsity" c_fDefaultPCLSparsity = False @@ -122,9 +125,9 @@ class ConstantsBreadCrumbs(): # Data shape c_strDataShapeKey = "shape" - ###################################################################### - # Constants related to biom import and export files # - ###################################################################### + ###################################################################### + # Constants related to biom import and export files # + ###################################################################### # Biom file extension c_strBiomFile = "biom" c_BiomTaxData = "BiomTaxData" @@ -132,14 +135,14 @@ class ConstantsBreadCrumbs(): c_Metadata = "Metadata" c_metadata_lowercase = "metadata" c_sLastMetadata = "sLastMetadata" - c_columns = "columns" + c_columns = "columns" c_rows = "rows" - c_ascii = "ascii" - c_ignore = "ignore" - c_Dtype = "Dtype" - c_ID = "ID" - c_id_lowercase = "id" - c_f4 = "f8" + c_ascii = "ascii" + c_ignore = "ignore" + c_Dtype = "Dtype" + c_ID = "ID" + c_id_lowercase = "id" + c_f4 = "f8" c_biom_file_generated_by = "BreadCrumbs" c_strPCLFile = "pcl" c_taxonomy = "taxonomy" @@ -150,6 +153,5 @@ class ConstantsBreadCrumbs(): c_MetadataEntriesTotal = "MetadataEntriesTotal" c_MaximumLength = "MaximumLength" - def __init__(self): - pass + pass --- a/lefsebiom/ValidateData.py +++ b/lefsebiom/ValidateData.py @@ -4,24 +4,24 @@ Description: Validate Data containing me """ ##################################################################################### -#Copyright (C) <2012> +# Copyright (C) <2012> # -#Permission is hereby granted, free of charge, to any person obtaining a copy of -#this software and associated documentation files (the "Software"), to deal in the -#Software without restriction, including without limitation the rights to use, copy, -#modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -#and to permit persons to whom the Software is furnished to do so, subject to -#the following conditions: +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in the +# Software without restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -#The above copyright notice and this permission notice shall be included in all copies -#or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all copies +# or substantial portions of the Software. # -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ##################################################################################### __author__ = "Timothy Tickle" @@ -32,16 +32,17 @@ __maintainer__ = "Timothy Tickle" __email__ = "ttickle@sph.harvard.edu" __status__ = "Development" -#Import local code +# Import local code from types import * import decimal import os import re import string + class ValidateData: - #Tested 5 + # Tested 5 @staticmethod def funcIsValidBoolean(parameterValue): """ @@ -53,16 +54,16 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if parameterValue == None: return False - #Check to make sure it is a string + # Check to make sure it is a string if not type(parameterValue) is BooleanType: return False return True - #Tested 6 + # Tested 6 @staticmethod def funcIsTrue(parameterValue): """ @@ -79,7 +80,7 @@ class ValidateData: return True return False - #Tested 6 + # Tested 6 @staticmethod def funcIsFalse(parameterValue): """ @@ -96,7 +97,7 @@ class ValidateData: return True return False - #Tested 5 + # Tested 5 @staticmethod def funcIsValidInteger(parameterValue): """ @@ -108,19 +109,19 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if (parameterValue == None): return False - #Check to make sure it is an integer + # Check to make sure it is an integer if not type(parameterValue) is IntType: return False return True - #Tested 5 + # Tested 5 @staticmethod - def funcIsValidPositiveInteger(parameterValue, tempZero = False): + def funcIsValidPositiveInteger(parameterValue, tempZero=False): """ Validates a parameter as false. @@ -132,20 +133,20 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if not ValidateData.funcIsValidInteger(parameterValue): return False - #Check to see it is positive + # Check to see it is positive if (parameterValue < 0): return False - #Check for zero value + # Check for zero value if(parameterValue == 0): return tempZero return True - #Tested 14 + # Tested 14 @staticmethod def funcIsValidNumeric(parameterValue): """ @@ -157,16 +158,16 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if (parameterValue == None): return False - #Check to make sure it is an integer + # Check to make sure it is an integer if((type(parameterValue) == IntType)or(type(parameterValue) == LongType)or(type(parameterValue) == FloatType)or(type(parameterValue) == ComplexType)or(str(type(parameterValue)) == "")): if(not type(parameterValue) == BooleanType): return True return False - #Tested 5 + # Tested 5 @staticmethod def funcIsValidStringType(parameterValue): """ @@ -178,17 +179,17 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if parameterValue == None: return False - #Check to make sure it is a string + # Check to make sure it is a string if not type(parameterValue) is StringType: return False return True - #Tested 5 + # Tested 5 @staticmethod def funcIsValidString(parameterValue): """ @@ -200,11 +201,11 @@ class ValidateData: :type Boolean """ - #Type check + # Type check if not ValidateData.funcIsValidStringType(parameterValue): return False - #Check to see it is not blank + # Check to see it is not blank if parameterValue.strip() == "": return False return True @@ -218,11 +219,11 @@ class ValidateData: :type Unknown """ - #Type string check + # Type string check if not ValidateData.funcIsValidStringType(parameterValue): return False - #Check to see if the string can be converted to an integer + # Check to see if the string can be converted to an integer try: int(parameterValue) except: @@ -238,18 +239,18 @@ class ValidateData: :type Unknown """ - #Type string check + # Type string check if not ValidateData.funcIsValidStringType(parameterValue): return False - #Check to see if the string can be converted to a double + # Check to see if the string can be converted to a double try: float(parameterValue) except: return False return True - #Tested 6 + # Tested 6 @staticmethod def funcIsValidFormatString(parameterValue): """ @@ -270,7 +271,7 @@ class ValidateData: break return lettersValid - #Tested 5 + # Tested 5 @staticmethod def funcIsValidChar(parameterValue): """ @@ -284,7 +285,7 @@ class ValidateData: return ValidateData.funcIsValidString(parameterValue) - #Tested 13 + # Tested 13 @staticmethod def funcIsValidPositiveNumberChar(parameterValue): """ @@ -296,11 +297,11 @@ class ValidateData: :type Boolean """ - #Check to make sure is a valid string + # Check to make sure is a valid string if not ValidateData.funcIsValidString(parameterValue): return False - #Try to convert to decimal + # Try to convert to decimal try: decimalConversion = decimal.Decimal(parameterValue) if decimalConversion < 0: @@ -309,7 +310,7 @@ class ValidateData: return False return True - #Tested 9 + # Tested 9 @staticmethod def funcIsValidFlagChar(parameterValue): """ @@ -325,7 +326,7 @@ class ValidateData: return True return False - #Tested 15 + # Tested 15 @staticmethod def funcIsValidBoundedIntegerChar(parameterValue, iValueOne, iValueTwo): """ @@ -341,19 +342,19 @@ class ValidateData: :type Boolean """ - #Check to make sure is a valid string + # Check to make sure is a valid string if not ValidateData.funcIsValidString(parameterValue): return False - #Check to make sure is a valid integer + # Check to make sure is a valid integer if not ValidateData.funcIsValidInteger(iValueOne): return False - #Check to make sure is a valid integer + # Check to make sure is a valid integer if not ValidateData.funcIsValidInteger(iValueTwo): return False - #Try to convert to decimal + # Try to convert to decimal try: intConversion = int(parameterValue) if(iValueOne < iValueTwo): @@ -371,7 +372,7 @@ class ValidateData: except: return False - #Tested 9 + # Tested 9 @staticmethod def funcIsValidList(parameterValue): """ @@ -383,17 +384,17 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if parameterValue == None: return False - #Check to make sure it is a list + # Check to make sure it is a list if not type(parameterValue) is ListType: return False - #Check elements + # Check elements listSize = len(parameterValue) - for i in range(0,listSize): + for i in range(0, listSize): if parameterValue[i] == None: return False if type(parameterValue[i]) is ListType: @@ -401,7 +402,7 @@ class ValidateData: return False return True - #Tested 9 + # Tested 9 @staticmethod def funcIsValidTuple(parameterValue): """ @@ -413,17 +414,17 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if parameterValue == None: return False - #Check to make sure it is a string + # Check to make sure it is a string if not type(parameterValue) is TupleType: return False - #Check elements + # Check elements tupleSize = len(parameterValue) - for i in range(0,tupleSize): + for i in range(0, tupleSize): if parameterValue[i] == None: return False if type(parameterValue[i]) is TupleType: @@ -431,7 +432,7 @@ class ValidateData: return False return True - #Tested 7 + # Tested 7 @staticmethod def funcIsValidNumericList(parameterValue): """ @@ -489,17 +490,17 @@ class ValidateData: :type Boolean """ - #Check to make sure it is not null + # Check to make sure it is not null if parameterValue == None: return False - #Check to make sure it is a structure array + # Check to make sure it is a structure array if not str(type(parameterValue)) == "": return False return True - #Tested 9 + # Tested 9 @staticmethod def funcIsValidDictionary(parameterValue): """ @@ -541,7 +542,7 @@ class ValidateData: return False return True - #Tested 18 + # Tested 18 @staticmethod def funcIsValidDNASequence(parameterValue): """ @@ -560,7 +561,7 @@ class ValidateData: return True return False - #Tested 15 + # Tested 15 @staticmethod def funcIsValidNucleotideBase(parameterValue): """ @@ -577,7 +578,7 @@ class ValidateData: return True return False - #Testing 4 + # Testing 4 @staticmethod def funcIsValidFileName(parameterValue): """ @@ -595,7 +596,7 @@ class ValidateData: return os.path.exists(parameterValue) return False - #Tested 5 + # Tested 5 @staticmethod def funcIsValidClass(parameterValue, strCorrectName): """ @@ -609,7 +610,7 @@ class ValidateData: :type Boolean """ - if(parameterValue==None): + if(parameterValue == None): return False if not ValidateData.funcIsValidString(strCorrectName): return False @@ -617,7 +618,7 @@ class ValidateData: if(classType == strCorrectName): return True if(classType == 'instance'): - if(parameterValue.__class__.__name__==strCorrectName): + if(parameterValue.__class__.__name__ == strCorrectName): return True else: return False