def addUTR(self,filename,genes): hash=self.hashGenes(genes) reader=BedReader(filename) while(True): record=reader.nextRecord() if(not record): break if(not record.isBed6()): raise Exception("BED file has too few fields") id=record.name gene=hash.get(id,None) if(not gene): gene=BedGene(id,record.chr,record.strand) genes.append(gene) hash[id]=gene gene.addUTR(record.interval) for gene in genes: gene.coalesce()
def readCDS(self, filename): reader = BedReader(filename) genes = [] genesByName = {} while (True): record = reader.nextRecord() if (not record): break if (not record.isBed6()): raise Exception("BED file has too few fields") id = record.name gene = genesByName.get(id, None) if (not gene): gene = BedGene(id, record.chr, record.strand) genesByName[id] = gene genes.append(gene) gene.addCDS(record.interval) reader.close() return genes
def readCDS(self,filename): reader=BedReader(filename) genes=[] genesByName={} while(True): record=reader.nextRecord() if(not record): break if(not record.isBed6()): raise Exception("BED file has too few fields") id=record.name gene=genesByName.get(id,None) if(not gene): gene=BedGene(id,record.chr,record.strand) genesByName[id]=gene genes.append(gene) gene.addCDS(record.interval) reader.close() return genes
def addUTR(self, filename, genes): hash = self.hashGenes(genes) reader = BedReader(filename) while (True): record = reader.nextRecord() if (not record): break if (not record.isBed6()): raise Exception("BED file has too few fields") id = record.name gene = hash.get(id, None) if (not gene): gene = BedGene(id, record.chr, record.strand) genes.append(gene) hash[id] = gene gene.addUTR(record.interval) for gene in genes: gene.coalesce()