Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parseClustersFromMeta(metaFname, clusterFieldName, fixDot):
" parse cluster -> cellId assignment from meta file, return as dict clusterName -> list of cellIds "
logging.info("Parsing and using first field as the cell ID in file %s" % metaFname)
clusterToCells = defaultdict(list)
metaCellIds = set()
skipCount = 0
for row in cellbrowser.lineFileNextRow(metaFname):
clusterName = row._asdict()[clusterFieldName]
cellId = row[0]
if fixDot:
cellId = cellId.replace(".", "-")
# skip all cells assigned to the "" cluster
if clusterName=="":
skipCount +=1
continue
if cellId in metaCellIds:
errAbort("duplicated cell ID %s in meta data" % cellId)
metaCellIds.add(cellId)
clusterToCells[clusterName].append(cellId)