Skip to content

Instantly share code, notes, and snippets.

@mpkocher
Created December 5, 2013 21:47
Show Gist options
  • Save mpkocher/7814530 to your computer and use it in GitHub Desktop.
Save mpkocher/7814530 to your computer and use it in GitHub Desktop.
Class style constants.
import sys
class FILE_FORMATS(object):
FOFN = "FOFN"
FASTA = "FASTA"
BAS = "BAS"
BAX = "BAX"
PLS = "PLS_H5"
PLX = "PLX_H5"
SAM = "SAM"
CMP = "CMP_H5"
RGN = "RGN_H5"
SA = "SA"
XML = "XML"
UNKNOWN = "UNKNOWN"
CCS = "CCS_H5"
# These are really just for internal use
_VALID_INPUT_FORMATS = [FASTA, PLS, PLX, SAM, BAS, BAX, FOFN]
_VALID_REGIONTABLE_FORMATS = [RGN, FOFN]
_VALID_OUTPUT_FORMATS = [CMP, SAM]
@staticmethod
def is_valid_region_table_format(f):
return f in FILE_FORMATS._VALID_REGIONTABLE_FORMATS
@staticmethod
def is_valid_input_format(f):
return f in FILE_FORMATS._VALID_INPUT_FORMATS
@staticmethod
def is_valid_output_format(f):
return f in FILE_FORMATS._VALID_OUTPUT_FORMATS
def main():
print repr(FILE_FORMATS)
f = "RGN"
print f, FILE_FORMATS.is_valid_region_table_format(f)
print FILE_FORMATS.FASTA
f = "SAM"
print f, FILE_FORMATS.is_valid_input_format(f)
# this won't raise an exception, but will work the same as the class
# this is odd, but the not a big deal.
f = 'FASTA'
ff = FILE_FORMATS()
print f, ff.is_valid_input_format(f)
return 0
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment