def parseStats(filename): fileLocation = uri2fn(filename) tree = ET.parse(fileLocation) root = tree.getroot() root = _updateStats(root) stats = StatsMetadata(_eleToDictList(root)) stats.record['tag'] = 'SummaryStats' return stats
def parseStats(filename): fileLocation = uri2fn(filename) tree = ET.parse(fileLocation) root = tree.getroot() root = _updateStats(root) stats = StatsMetadata(_eleToDictList(root)) stats.record['tag'] = 'SummaryStats' return stats
def _addFile(dset, filename): handledTypes = {'xml': _addXmlFile, 'bam': _addGenericFile, 'fofn': _addFofnFile, '': _addUnknownFile, 'file': _addUnknownFile} fileType = uri2scheme(filename) fileLocation = uri2fn(filename) handledTypes[fileType](dset, fileLocation)
def _addFile(dset, filename): handledTypes = {'xml': _addXmlFile, 'bam': _addGenericFile, 'fofn': _addFofnFile, '': _addUnknownFile, 'file': _addUnknownFile} fileType = uri2scheme(filename) fileLocation = uri2fn(filename) handledTypes[fileType](dset, fileLocation)
def resolveLocation(fname, possibleRelStart=None): """Find the absolute path of a file that exists relative to possibleRelStart.""" fname = uri2fn(fname) if (possibleRelStart is not None and os.path.exists(possibleRelStart) and os.path.exists(os.path.join(possibleRelStart, fname))): return os.path.abspath(os.path.join(possibleRelStart, fname)) if os.path.exists(fname): return os.path.abspath(fname) log.error("Including unresolved file: {f}".format(f=fname)) return fname
def __parseMetadata(xsd_name, tag_name, return_type, filename): fileLocation = uri2fn(filename) tree = ET.parse(fileLocation) dsm_tag = (".//{http://pacificbiosciences.com/" + xsd_name + "}" + tag_name) try: metadata = _eleToDictList(tree.getroot().find(dsm_tag)) except AttributeError: # the tag wasn't found, we're trying to do something with None raise InvalidDataSetIOError("Unable to parse metadata from " "{f}".format(f=filename)) return return_type(metadata)
def __parseMetadata(xsd_name, tag_name, return_type, filename): fileLocation = uri2fn(filename) tree = ET.parse(fileLocation) dsm_tag = (".//{http://pacificbiosciences.com/" + xsd_name + "}" + tag_name) try: metadata = _eleToDictList(tree.getroot().find(dsm_tag)) except AttributeError: # the tag wasn't found, we're trying to do something with None raise InvalidDataSetIOError("Unable to parse metadata from " "{f}".format(f=filename)) return return_type(metadata)
def resolveLocation(fname, possibleRelStart=None): """Find the absolute path of a file that exists relative to possibleRelStart.""" fname = uri2fn(fname) if (possibleRelStart is not None and os.path.exists(possibleRelStart) and os.path.exists(os.path.join(possibleRelStart, fname))): return os.path.abspath(os.path.join(possibleRelStart, fname)) if os.path.exists(fname): return os.path.abspath(fname) log.error("Including unresolved file: {f}".format(f=fname)) return fname
def parseMetadata(filename): fileLocation = uri2fn(filename) tree = ET.parse(fileLocation) dsm_tag = (".//{http://pacificbiosciences.com/PacBioDatasets.xsd}" "DataSetMetadata") try: metadata = _parseXmlDataSetMetadata(tree.getroot().find(dsm_tag)) except AttributeError: # the tag wasn't found, we're trying to do something with None raise InvalidDataSetIOError("Unable to parse metadata from " "{f}".format(f=filename)) return metadata