Skip to content

Instantly share code, notes, and snippets.

@23jodys
Created June 12, 2015 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 23jodys/3d7423479e24e5efaaf9 to your computer and use it in GitHub Desktop.
Save 23jodys/3d7423479e24e5efaaf9 to your computer and use it in GitHub Desktop.
class SampleHighlight(object):
def __init__(self, job_id, sample_name, field1):
errors = []
if not job_id.startswith("JOB_ID"):
errors.append("STRUCTURAL FAILURE: bad job_id")
try:
self._check_sample_name(sample_name)
except Exception as error:
errors.append(error.message)
# and so on performing any sturctural validation that makes sense
# in the context of the abstract object
@staticmethod
def fromFile(self, filename):
if not os.isfile(filename):
raise Exception("STRUCTURAL ERROR: can't read file")
with open(filename) as file_to_read:
try:
job_id = line[0][1]
except KeyError as error:
raise Exception("STRUCTURAL ERROR: expected a job id")
# etc try except blocks for the rest of the things to pass strcutural validation
sample_name = filename
field1 = line[1]
return SampleHighlight(job_id, sample_name, field1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment