comparison ensemblref.py @ 5:9e83cc05d384 draft

Uploaded
author jjohnson
date Mon, 06 Feb 2017 09:25:43 -0500
parents c3a9e63e8c51
children
comparison
equal deleted inserted replaced
4:908c68e3c73f 5:9e83cc05d384
45 if t.prot_id: 45 if t.prot_id:
46 self.name_idx[t.prot_id] = t 46 self.name_idx[t.prot_id] = t
47 return self.name_idx 47 return self.name_idx
48 48
49 49
50 def get_gtf_transcript(self,transcript_id): 50 def get_gtf_transcript(self,name):
51 idx = self.get_transcript_idx() 51 idx = self.get_transcript_idx()
52 return idx[transcript_id] if transcript_id in idx else None 52 if name in idx:
53 return idx[name]
54 else:
55 nidx = self.get_name_idx()
56 if name in nidx:
57 return nidx[name]
58 return None
53 59
54 60
55 def transcript_is_coding(self,transcript_id): 61 def transcript_is_coding(self,transcript_id):
56 tx = self.get_transcript_idx()[transcript_id] 62 tx = self.get_transcript_idx()[transcript_id]
57 return len(tx.start_codons) > 0 63 return len(tx.start_codons) > 0
60 def get_transcript_start_codon(self,transcript_id): 66 def get_transcript_start_codon(self,transcript_id):
61 tx = self.get_transcript_idx()[transcript_id] 67 tx = self.get_transcript_idx()[transcript_id]
62 return tx.start_codons[0] if len(tx.start_codons) > 0 else None 68 return tx.start_codons[0] if len(tx.start_codons) > 0 else None
63 69
64 70
65 def get_bed_line(self,transcript_id,coding=False): 71 def get_bed_line(self,transcript_id,score=0,itemRgb='0,0,0',coding=False):
66 tx = self.get_transcript_idx()[transcript_id] 72 tx = self.get_transcript_idx()[transcript_id]
67 chrom = tx.gene.contig 73 chrom = tx.gene.contig
68 chromStart = tx.coding_beg if coding else tx.beg 74 chromStart = tx.coding_beg if coding else tx.beg
69 chromEnd = tx.coding_end if coding else tx.end 75 chromEnd = tx.coding_end if coding else tx.end
70 name = transcript_id 76 name = transcript_id
71 score = 0
72 strand = '+' if tx.gene.strand else '-' 77 strand = '+' if tx.gene.strand else '-'
73 thickStart = tx.coding_beg if tx.coding_beg else chromStart 78 thickStart = tx.coding_beg if tx.coding_beg else chromStart
74 thickEnd = tx.coding_end if tx.coding_end else chromEnd 79 thickEnd = tx.coding_end if tx.coding_end else chromEnd
75 itemRgb = '0,0,0'
76 exons = tx.get_coding_exons() if coding else tx.get_exons()
77 blockCount = len(exons)
78 if tx.gene.strand:
79 strand = '+'
80 blockSizes = [abs(e-s) for s,e in exons]
81
82 def get_bed_line(self,transcript_id,coding=False):
83 tx = self.get_transcript_idx()[transcript_id]
84 chrom = tx.gene.contig
85 chromStart = tx.coding_beg if coding else tx.beg
86 chromEnd = tx.coding_end if coding else tx.end
87 name = transcript_id
88 score = 0
89 strand = '+' if tx.gene.strand else '-'
90 thickStart = tx.coding_beg if tx.coding_beg else chromStart
91 thickEnd = tx.coding_end if tx.coding_end else chromEnd
92 itemRgb = '0,0,0'
93 exons = tx.get_coding_exons() if coding else tx.get_exons() 80 exons = tx.get_coding_exons() if coding else tx.get_exons()
94 blockCount = len(exons) 81 blockCount = len(exons)
95 if tx.gene.strand: 82 if tx.gene.strand:
96 strand = '+' 83 strand = '+'
97 blockSizes = [abs(e-s) for s,e in exons] 84 blockSizes = [abs(e-s) for s,e in exons]