Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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()