Ejemplo n.º 1
0
 def _getBlockColumns(self):
     relStarts = []
     sizes = []
     for blk in self.blocks:
         relStarts.append(str(blk.start - self.chromStart))
         sizes.append(str(len(blk)))
     return [intArrayJoin(sizes), intArrayJoin(relStarts)]
Ejemplo n.º 2
0
 def toRow(self):
     "convert PSL to array of strings"
     row = [
         str(self.match),
         str(self.misMatch),
         str(self.repMatch),
         str(self.nCount),
         str(self.qNumInsert),
         str(self.qBaseInsert),
         str(self.tNumInsert),
         str(self.tBaseInsert), self.strand, self.qName,
         str(self.qSize),
         str(self.qStart),
         str(self.qEnd), self.tName,
         str(self.tSize),
         str(self.tStart),
         str(self.tEnd),
         str(self.blockCount),
         intArrayJoin([b.size for b in self.blocks]),
         intArrayJoin([b.qStart for b in self.blocks]),
         intArrayJoin([b.tStart for b in self.blocks])
     ]
     if self.blocks[0].qSeq is not None:
         row.append(strArrayJoin([b.qSeq for b in self.blocks]))
         row.append(strArrayJoin([b.tSeq for b in self.blocks]))
     return row
Ejemplo n.º 3
0
 def __str__(self):
     "return psl as a tab-separated string"
     row = [str(self.match),
            str(self.misMatch),
            str(self.repMatch),
            str(self.nCount),
            str(self.qNumInsert),
            str(self.qBaseInsert),
            str(self.tNumInsert),
            str(self.tBaseInsert),
            self.strand,
            self.qName,
            str(self.qSize),
            str(self.qStart),
            str(self.qEnd),
            self.tName,
            str(self.tSize),
            str(self.tStart),
            str(self.tEnd),
            str(self.blockCount),
            intArrayJoin([b.size for b in self.blocks]),
            intArrayJoin([b.qStart for b in self.blocks]),
            intArrayJoin([b.tStart for b in self.blocks])]
     if self.blocks[0].qSeq is not None:
         row.append(strArrayJoin([b.qSeq for b in self.blocks]))
         row.append(strArrayJoin([b.tSeq for b in self.blocks]))
     return str.join("\t", row)
Ejemplo n.º 4
0
    def getRow(self):
        row = [
            self.name, self.chrom, self.strand,
            str(self.txStart),
            str(self.txEnd),
            str(self.cdsStart),
            str(self.cdsEnd)
        ]
        row.append(str(len(self.exons)))
        starts = []
        ends = []
        for e in self.exons:
            starts.append(e.start)
            ends.append(e.end)
        row.append(intArrayJoin(starts))
        row.append(intArrayJoin(ends))

        hasExt = (self.score is not None) or (self.name2 is not None) or (
            self.cdsStartStat is not None) or self.hasExonFrames

        if self.score is not None:
            row.append(str(self.score))
        elif hasExt:
            row.append("0")
        if self.name2 is not None:
            row.append(self.name2)
        elif hasExt:
            row.append("")
        if self.cdsStartStat is not None:
            row.append(str(self.cdsStartStat))
            row.append(str(self.cdsEndStat))
        elif hasExt:
            row.append(str(CdsStat.unknown))
            row.append(str(CdsStat.unknown))
        if self.hasExonFrames or hasExt:
            frames = []
            if self.hasExonFrames:
                for e in self.exons:
                    frames.append(e.frame)
            else:
                for e in self.exons:
                    frames.append(-1)
            row.append(intArrayJoin(frames))
        return row
Ejemplo n.º 5
0
 def getRow(self):
     row = [self.chrom, str(self.chromStart), str(self.chromEnd), self.name]
     if self.numCols > 4:
         row.append(str(self.score));
     if self.numCols > 5:
         row.append(self.strand)
     if self.numCols > 7:
         row.append(str(self.thickStart))
         row.append(str(self.thickEnd))
     if self.numCols > 8:
         row.append(str(self.itemRgb))
     if self.numCols > 11:
         row.append(str(len(self.blocks)))
         relStarts = []
         sizes = []
         for blk in self.blocks:
             relStarts.append(str(blk.relStart))
             sizes.append(str(blk.size))
         row.append(intArrayJoin(relStarts))
         row.append(intArrayJoin(sizes))
     return row
Ejemplo n.º 6
0
    def getRow(self):
        row = [self.name, self.chrom, self.strand, str(self.txStart), str(self.txEnd), str(self.cdsStart), str(self.cdsEnd)]
        row.append(str(len(self.exons)))
        starts = []
        ends = []
        for e in self.exons:
            starts.append(e.start)
            ends.append(e.end)
        row.append(intArrayJoin(starts))
        row.append(intArrayJoin(ends))

        hasExt = (self.score is not None) or (self.name2 is not None) or (self.cdsStartStat is not None) or self.hasExonFrames

        if self.score is not None:
            row.append(str(self.score))
        elif hasExt:
            row.append("0");
        if self.name2 is not None:
            row.append(self.name2)
        elif hasExt:
            row.append("");
        if self.cdsStartStat is not None:
            row.append(str(self.cdsStartStat))
            row.append(str(self.cdsEndStat))
        elif hasExt:
            row.append(str(CdsStat.unknown))
            row.append(str(CdsStat.unknown))
        if self.hasExonFrames or  hasExt:
            frames = []
            if self.hasExonFrames:
                for e in self.exons:
                    frames.append(e.frame)
            else:
                for e in self.exons:
                    frames.append(-1)
            row.append(intArrayJoin(frames))
        return row