def fromGTF(cls, gtf_rows): ob = cls() ob.transcripts = sorted([Transcript.fromGTF(rows) for rows in iter.groupBy(gtf_rows, "transcript_id")]) ob.range = range.bounds([transcript.range for transcript in ob.transcripts]) ob.chromosome = ob.transcripts[0].chromosome ob.strand = ob.transcripts[0].strand ob.name = ob.transcripts[0].gene return ob
def fromGTF(cls, gtf_rows): ob = cls() ob.cds = [row.range for row in itertools.ifilter(lambda row: row.feature == "CDS", gtf_rows)] ob.exons = [row.range for row in itertools.ifilter(lambda row: row.feature == "exon", gtf_rows)] ob.name = gtf_rows[0].transcript_id ob.gene = gtf_rows[0].gene_id ob.strand = gtf_rows[0].strand ob.chromosome = gtf_rows[0].seq_id ob.range = range.bounds(ob.exons) return ob