Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if geneType.startswith("symbol"):
# create a mapping from symbol -> gene locations
if "/" in geneType:
defGenes = geneType.split("/")[1]
elif genome=="hg38":
defGenes = "gencode24"
elif genome=="hg19":
defGenes = "gencode19"
elif genome=="mm10":
defGenes = "gencode-m13"
else:
errAbort("Unclear how to map symbols to genome for db %s. Please adapt cellbrowser.py" % genome)
logging.info("Using %s to map symbols to genome" % defGenes)
geneToSym = cellbrowser.readGeneSymbols({'geneIdType':defGenes})
geneLocsId = cellbrowser.parseGeneLocs(defGenes)
geneLocs = {}
for geneId, locs in iterItems(geneLocsId):
sym = geneToSym[geneId]
geneLocs[sym] = locs
else:
geneToSym = cellbrowser.readGeneSymbols({'geneIdType':geneType})
geneLocs = cellbrowser.parseGeneLocs(geneType)
matOfh = open(outMatrixFname, "w")
clustOfh = open(clusterFname, "w")
mr = cellbrowser.MatrixTsvReader()
mr.open(inMatrixFname)
matType, cellNames = mr.matType, mr.sampleNames
defGenes = "gencode19"
elif genome=="mm10":
defGenes = "gencode-m13"
else:
errAbort("Unclear how to map symbols to genome for db %s. Please adapt cellbrowser.py" % genome)
logging.info("Using %s to map symbols to genome" % defGenes)
geneToSym = cellbrowser.readGeneSymbols({'geneIdType':defGenes})
geneLocsId = cellbrowser.parseGeneLocs(defGenes)
geneLocs = {}
for geneId, locs in iterItems(geneLocsId):
sym = geneToSym[geneId]
geneLocs[sym] = locs
else:
geneToSym = cellbrowser.readGeneSymbols({'geneIdType':geneType})
geneLocs = cellbrowser.parseGeneLocs(geneType)
matOfh = open(outMatrixFname, "w")
clustOfh = open(clusterFname, "w")
mr = cellbrowser.MatrixTsvReader()
mr.open(inMatrixFname)
matType, cellNames = mr.matType, mr.sampleNames
cellIds = range(0, len(cellNames))
cellNameToId = dict(zip(cellNames, cellIds))
# make a list of lists of cellIds, one per cluster, in the right order
clusterCellIds = [] # list of tuples with cell-indexes, one per cluster
allCellNames = [] # list for cellIds, with a matrix, meta and with bam file
allCellIndices = [] # position of all cellIds in allCellNames