def __init__(self, dirname): """ Represents a single metadata.yaml file. Parameters ---------- fn : filename of YAML- or JSON-formatted config file """ self.dirname = dirname self._build_metadata() fn = os.path.join(self.dirname, 'metadata.yaml') if not os.path.exists(fn): raise ValueError("Can't find {0}".format(fn)) self.metadata = yaml.load(open(fn)) schema = yaml.load(utils.get_resource('metadata_schema.yaml')) jsonschema.validate(self.metadata, schema) self.study = self.metadata['study'] self.label = self.metadata['study']['label'] self.study.setdefault('short_label', self.label) self.study.setdefault('long_label', self.study['short_label']) self.study['PMID'] = str(self.study.get('PMID', '')) self.tracks = [Data(d, self.dirname) for d in self.metadata['tracks']] # If description is blank or missing, fill in the contents of the # README. if not self.study.get('description', ''): readme = self._find_readme() if readme: self.study['description'] = open(readme).read()
def __init__(self, dirname): """ Represents a single metadata.yaml file. Parameters ---------- fn : filename of YAML- or JSON-formatted config file """ self.dirname = dirname self._build_metadata() fn = os.path.join(self.dirname, 'metadata.yaml') if not os.path.exists(fn): raise ValueError("Can't find {0}".format(fn)) self.metadata = yaml.load(open(fn)) schema = yaml.load(utils.get_resource('metadata_schema.yaml')) jsonschema.validate(self.metadata, schema) self.study = self.metadata['study'] self.label = self.metadata['study']['label'] self.study.setdefault('short_label', self.label) self.study.setdefault('long_label', self.study['short_label']) self.study.setdefault('description', self.study['long_label']) self.tracks = [Data(d, self.dirname) for d in self.metadata['tracks']]
def __init__(self, dirname): """ Represents a single metadata.yaml file. Parameters ---------- fn : filename of YAML- or JSON-formatted config file """ self.dirname = dirname self._build_metadata() fn = os.path.join(self.dirname, 'metadata.yaml') if not os.path.exists(fn): raise ValueError("Can't find {0}".format(fn)) self.metadata = yaml.load(open(fn)) schema = yaml.load(utils.get_resource('metadata_schema.yaml')) jsonschema.validate(self.metadata, schema) self.study = self.metadata['study'] self.label = self.metadata['study']['label'] self.study.setdefault('short_label', self.label) self.study.setdefault('long_label', self.study['short_label']) self.study.setdefault('description', self.study['long_label']) self.tracks = [Data(d, self.dirname) for d in self.metadata['tracks']]
def __init__(self, fn): self.group = yaml.load(open(fn)) self.filename = fn self.dirname = os.path.dirname(fn) self.group.setdefault('short_label', self.group['name']) self.group.setdefault('long_label', self.group['name']) schema = yaml.load(utils.get_resource('group_schema.yaml')) jsonschema.validate(self.group, schema) self.studies = [ Study(os.path.join(self.dirname, s)) for s in self.group['studies'] ]
def __init__(self, fn): self.group = yaml.load(open(fn)) self.filename = fn self.dirname = os.path.dirname(fn) self.group.setdefault('short_label', self.group['name']) self.group.setdefault('long_label', self.group['name']) schema = yaml.load(utils.get_resource('group_schema.yaml')) jsonschema.validate(self.group, schema) self.studies = [ Study(os.path.join(self.dirname, s)) for s in self.group['studies'] ]