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