Mercurial > repos > jjohnson > ensembl_variant_report
annotate ensemblref.py @ 4:7fc91849ab21 draft default tip
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit 4078a495c5569e9055b4eba33004fe609ee42aff"
author | jjohnson |
---|---|
date | Sat, 25 Jan 2020 15:22:46 -0500 |
parents | 9f4ea174ce3d |
children |
rev | line source |
---|---|
0
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
1 """ |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
2 with gtf and twobit |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
3 get_bed(transcript_id) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
4 """ |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
5 from gtf_to_genes import gene, gene_utilities |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
6 from twobitreader import TwoBitFile |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
7 from Bio.Seq import reverse_complement, translate |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
8 import logging |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
9 logger = logging.getLogger("test") |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
10 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
11 class EnsemblRef(object): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
12 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
13 def __init__(self,gtf_file,twobitfile,read_now=True): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
14 self.gtf_file = gtf_file |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
15 self.twobitfile = twobitfile |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
16 self.twobit = TwoBitFile(self.twobitfile) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
17 self.gene_dict = None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
18 self.transcript_idx = None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
19 self.name_idx = None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
20 if read_now: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
21 self.get_transcript_idx() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
22 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
23 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
24 def get_gene_dict(self): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
25 if self.gene_dict is None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
26 gene_structures = gene.t_parse_gtf('test') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
27 self.gene_dict = gene_structures.get_genes(self.gtf_file,logger=logger) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
28 return self.gene_dict |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
29 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
30 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
31 def get_transcript_idx(self): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
32 if self.transcript_idx is None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
33 self.transcript_idx = gene_utilities.index_transcripts(self.get_gene_dict(),by_prot_id=False) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
34 return self.transcript_idx |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
35 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
36 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
37 def get_name_idx(self): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
38 if self.name_idx is None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
39 self.name_idx = dict() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
40 for i,t in self.get_transcript_idx().items(): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
41 for name in t.gene.names: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
42 self.name_idx[name] = t.gene |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
43 for name in t.names: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
44 self.name_idx[name] = t |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
45 if t.prot_id: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
46 self.name_idx[t.prot_id] = t |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
47 return self.name_idx |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
48 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
49 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
50 def get_gtf_transcript(self,name): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
51 idx = self.get_transcript_idx() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
52 if name in idx: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
53 return idx[name] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
54 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
55 nidx = self.get_name_idx() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
56 if name in nidx: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
57 return nidx[name] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
58 return None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
59 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
60 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
61 def transcript_is_coding(self,transcript_id): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
62 tx = self.get_transcript_idx()[transcript_id] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
63 return len(tx.start_codons) > 0 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
64 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
65 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
66 def get_transcript_start_codon(self,transcript_id): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
67 tx = self.get_transcript_idx()[transcript_id] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
68 return tx.start_codons[0] if len(tx.start_codons) > 0 else None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
69 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
70 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
71 def get_bed_line(self,transcript_id,score=0,itemRgb='0,0,0',coding=False): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
72 tx = self.get_transcript_idx()[transcript_id] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
73 chrom = tx.gene.contig |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
74 chromStart = tx.coding_beg if coding else tx.beg |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
75 chromEnd = tx.coding_end if coding else tx.end |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
76 name = transcript_id |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
77 strand = '+' if tx.gene.strand else '-' |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
78 thickStart = tx.coding_beg if tx.coding_beg else chromStart |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
79 thickEnd = tx.coding_end if tx.coding_end else chromEnd |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
80 exons = tx.get_coding_exons() if coding else tx.get_exons() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
81 blockCount = len(exons) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
82 if tx.gene.strand: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
83 strand = '+' |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
84 blockSizes = [abs(e-s) for s,e in exons] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
85 blockStarts = [s - chromStart for s,e in exons] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
86 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
87 strand = '-' |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
88 blockSizes = [abs(e-s) for s,e in reversed(exons)] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
89 blockStarts = [s - chromStart for s,e in reversed(exons)] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
90 blockSizes = ','.join([str(x) for x in blockSizes]) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
91 blockStarts = ','.join([str(x) for x in blockStarts]) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
92 return '%s\t%d\t%d\t%s\t%s\t%s\t%d\t%d\t%s\t%d\t%s\t%s' % (chrom,chromStart,chromEnd,name,score,strand,thickStart,thickEnd,itemRgb,blockCount,blockSizes,blockStarts) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
93 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
94 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
95 def transcripts_in_range(self,chrom,startpos,endpos,strand=None): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
96 spos = min(startpos,endpos) if endpos else startpos |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
97 epos = max(startpos,endpos) if endpos else startpos |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
98 transcripts = [] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
99 for i,t in self.get_transcript_idx().items(): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
100 if t.gene.contig == chrom and t.beg <= epos and spos <= t.end: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
101 if strand and t.gene.strand != strand: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
102 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
103 transcripts.append(t) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
104 return transcripts |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
105 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
106 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
107 def genes_in_range(self,chrom,startpos,endpos,strand=None,gene_types=None): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
108 spos = min(startpos,endpos) if endpos else startpos |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
109 epos = max(startpos,endpos) if endpos else startpos |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
110 gene_dict = self.get_gene_dict() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
111 gtypes = set(gene_types) & set(gene_dict.keys()) if gene_types else set(gene_dict.keys()) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
112 genes = [] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
113 for gt in gtypes: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
114 for gene in gene_dict[gt]: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
115 if gene.contig == chrom and gene.beg <= epos and spos <= gene.end: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
116 if strand and gene.strand != strand: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
117 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
118 genes.append(gene) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
119 return genes |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
120 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
121 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
122 def get_sequence(self,chrom,start,end): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
123 if self.twobit: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
124 if chrom in self.twobit: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
125 return self.twobit[chrom][start:end] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
126 contig = chrom[3:] if chrom.startswith('chr') else 'chr%s' % chrom |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
127 if contig in self.twobit: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
128 return self.twobit[contig][start:end] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
129 return None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
130 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
131 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
132 def sequence_sizes(self): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
133 return self.twobit.sequence_sizes() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
134 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
135 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
136 def get_transcript_seq(self,transcript_id,coding=False): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
137 tx = self.get_transcript_idx()[transcript_id] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
138 chrom = tx.gene.contig |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
139 exonbnds = tx.get_coding_exons() if coding else tx.get_exons() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
140 if tx.gene.strand: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
141 seqs = [self.get_sequence(chrom,s,e) for s,e in exonbnds] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
142 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
143 seqs = [reverse_complement(self.get_sequence(chrom,s,e)) for s,e in exonbnds] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
144 return ''.join(seqs) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
145 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
146 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
147 def get_cdna(self,transcript_id): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
148 return self.get_transcript_seq(transcript_id,coding=False) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
149 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
150 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
151 def get_cds(self,transcript_id): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
152 return self.get_transcript_seq(transcript_id,coding=True) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
153 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
154 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
155 def genome_to_transcript_pos(self,transcript_id,genome_pos,coding=False): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
156 tx = self.get_transcript_idx()[transcript_id] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
157 if not tx.beg <= genome_pos < tx.end: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
158 return None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
159 exonbnds = tx.get_coding_exons() if coding else tx.get_exons() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
160 cdna_pos = 0 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
161 if tx.gene.strand: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
162 for s,e in exonbnds: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
163 if s <= genome_pos < e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
164 cdna_pos += genome_pos - s |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
165 break |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
166 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
167 cdna_pos += e - s |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
168 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
169 for s,e in exonbnds: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
170 if s <= genome_pos < e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
171 cdna_pos += e - genome_pos - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
172 break |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
173 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
174 cdna_pos += e - s |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
175 return cdna_pos |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
176 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
177 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
178 def genome_to_cdna_pos(self,transcript_id,genome_pos): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
179 return self.genome_to_transcript_pos(transcript_id,genome_pos,coding=False) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
180 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
181 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
182 def genome_to_cds_pos(self,transcript_id,genome_pos): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
183 return self.genome_to_transcript_pos(transcript_id,genome_pos,coding=True) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
184 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
185 |