Created
June 12, 2015 17:02
-
-
Save 23jodys/3d7423479e24e5efaaf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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