Mercurial > repos > jjohnson > ensembl_variant_report
annotate ensembl_variant_report.py @ 1:a67b4de184c2 draft
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
author | jjohnson |
---|---|
date | Thu, 14 Jun 2018 18:08:15 -0400 |
parents | 9f4ea174ce3d |
children | f87fe6bc48f4 |
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 #!/usr/bin/env python |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
2 """ |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
3 Report variants to Ensembl Transcripts |
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 FrameShift report line |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
6 # Gene Variant Position Reference Variation Prevalence Sequencing Depth Transcript AA Position AA change AA Length Stop Codon Stop Region AA Variation |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
7 TIGD6 chr5:149374879 AAG AG 1.00 13 ENSG00000164296|ENST00000296736 345 Q344 522 A-TGA-T KRWTSSRPST* |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
8 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
9 MissSense report line |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
10 # Gene Variant Position Reference Variation Prevalence Sequencing Depth Transcript AA Position AA change AA Length Stop Codon Stop Region AA Variation |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
11 FN1 chr2:216235089 G A 1.00 7394 ENSG00000115414|ENST00000354785 2261 V2261I 2478 G-TAA TGLTRGATYN_I_IVEALKDQQR |
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 import sys |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
14 import os.path |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
15 import re |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
16 import time |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
17 import optparse |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
18 from ensemblref import EnsemblRef |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
19 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
|
20 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
21 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
22 def __main__(): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
23 #Parse Command Line |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
24 parser = optparse.OptionParser() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
25 #I/O |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
26 parser.add_option( '-i', '--input', dest='input', default=None, help='Tabular file with peptide_sequence column' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
27 parser.add_option( '-s', '--format', dest='format', default='tabular', choices=['tabular','snpeff'], help='Tabular file with peptide_sequence column' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
28 #Columns for tabular input |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
29 parser.add_option( '-C', '--chrom_column', type='int', dest='chrom_column', default=1, help='column ordinal with Ensembl transctip ID' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
30 parser.add_option( '-P', '--pos_column', type='int', dest='pos_column', default=2, help='column ordinal with Ensembl transctip ID' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
31 parser.add_option( '-R', '--ref_column', type='int', dest='ref_column', default=3, help='column ordinal with Ensembl transctip ID' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
32 parser.add_option( '-A', '--alt_column', type='int', dest='alt_column', default=4, help='column ordinal with Ensembl transctip ID' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
33 parser.add_option( '-T', '--transcript_column', type='int', dest='transcript_column', default=1, help='column ordinal with Ensembl transctip ID' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
34 parser.add_option( '-F', '--dpr_column', type='int', dest='dpr_column', default=1, help='column with VCF: DPR or AD' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
35 parser.add_option( '-D', '--dp_column', type='int', dest='dp_column', default=1, help='column with VCF: DP' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
36 parser.add_option( '-g', '--gene_model', dest='gene_model', default=None, help='GTF gene model file. Used to annotate NSJ peptide entries.') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
37 parser.add_option( '-2', '--twobit', dest='twobit', default=None, help='Reference genome in UCSC twobit format') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
38 #Output file |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
39 parser.add_option( '-o', '--output', dest='output', default=None, help='The output report (else write to stdout)' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
40 #filters |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
41 parser.add_option( '-d', '--min_depth', type='int', dest='min_depth', default=None, help='Minimum read depth to report' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
42 parser.add_option( '-f', '--min_freq', type='float', dest='min_freq', default=None, help='Minimum variant frequency to report' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
43 #peptide options |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
44 parser.add_option( '-l', '--leading_aa', type='int', dest='leading_aa', default=10, help='Number AAs before missense variant' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
45 parser.add_option( '-t', '--trailing_aa', type='int', dest='trailing_aa', default=10, help='Number AAs after missense variant' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
46 parser.add_option( '-r', '--readthrough', type='int', dest='readthrough', default=0, help='' ) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
47 # |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
48 parser.add_option('--debug', dest='debug', action='store_true', default=False, help='Print debugging messages') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
49 (options, args) = parser.parse_args() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
50 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
51 ##INPUTS## |
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 options.input != None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
53 try: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
54 inputPath = os.path.abspath(options.input) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
55 inputFile = open(inputPath, 'r') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
56 except Exception, e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
57 print >> sys.stderr, "failed: %s" % e |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
58 exit(2) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
59 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
60 inputFile = sys.stdin |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
61 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
62 if options.output != None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
63 try: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
64 outputPath = os.path.abspath(options.output) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
65 outputFile = open(outputPath, 'w') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
66 except Exception, e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
67 print >> sys.stderr, "failed: %s" % e |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
68 exit(3) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
69 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
70 outputFile = sys.stdout |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
71 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
72 def parse_tabular(): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
73 ci = options.chrom_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
74 pi = options.pos_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
75 ri = options.ref_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
76 ai = options.alt_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
77 ti = options.transcript_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
78 di = options.dp_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
79 fi = options.dpr_column - 1 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
80 for linenum,line in enumerate(inputFile): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
81 if options.debug: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
82 print >> sys.stderr, "%d: %s\n" % (linenum,line) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
83 if line.startswith('#'): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
84 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
85 if line.strip() == '': |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
86 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
87 fields = line.rstrip('\r\n').split('\t') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
88 transcript = fields[ti] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
89 if not transcript: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
90 print >> sys.stderr, "%d: %s\n" % (linenum,line) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
91 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
92 chrom = fields[ci] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
93 pos = int(fields[pi]) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
94 ref = fields[ri] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
95 alts = fields[ai] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
96 dp = int(fields[di]) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
97 dpr = [int(x) for x in fields[fi].split(',')] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
98 for i,alt in enumerate(alts.split(',')): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
99 freq = float(dpr[i+1])/float(sum(dpr)) if dpr 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
|
100 yield (transcript,pos,ref,alt,dp,freq) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
101 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
102 def parse_snpeff_vcf(): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
103 for linenum,line in enumerate(inputFile): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
104 if line.startswith('##'): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
105 if line.find('SnpEffVersion=') > 0: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
106 SnpEffVersion = re.search('SnpEffVersion="?(\d+\.\d+)',line).groups()[0] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
107 elif line.startswith('#CHROM'): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
108 pass |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
109 else: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
110 fields = line.strip('\r\n').split('\t') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
111 if options.debug: print >> sys.stderr, "\n%s" % (fields) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
112 (chrom, pos, id, ref, alts, qual, filter, info) = fields[0:8] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
113 alt_list = alts.split(',') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
114 pos = int(pos) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
115 qual = float(qual) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
116 dp = None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
117 dpr = None |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
118 for info_item in info.split(';'): |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
119 if info_item.find('=') < 0: continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
120 (key, val) = info_item.split('=', 1) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
121 if key == 'DP': |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
122 dp = int(val) |
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 key == 'DPR': |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
124 dpr = [int(x) for x in val.split(',')] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
125 if key in ['EFF','ANN']: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
126 for effect in val.split(','): |
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 options.debug: print >> sys.stderr, "\n%s" % (effect.split('|')) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
128 if key == 'ANN': |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
129 (alt,eff,impact,gene_name,gene_id,feature_type,transcript,biotype,exon,c_hgvs,p_hgvs,cdna,cds,aa,distance,info) = effect.split('|') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
130 elif key == 'EFF': |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
131 (eff, effs) = effect.rstrip(')').split('(') |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
132 (impact, functional_class, codon_change, aa_change, aa_len, gene_name, biotype, coding, transcript, exon, alt) = effs.split('|')[0:11] |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
133 i = alt_list.index(alt) if alt in alt_list else 0 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
134 freq = float(dpr[i+1])/float(sum(dpr)) if dpr 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
|
135 yield (transcript,pos,ref,alt,dp,freq) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
136 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
137 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
138 #Process gene model |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
139 ens_ref = None |
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 options.gene_model != None: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
141 try: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
142 geneModelFile = os.path.abspath(options.gene_model) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
143 twoBitFile = os.path.abspath(options.twobit) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
144 print >> sys.stderr, "Parsing ensembl ref: %s %s" % (options.gene_model,options.twobit) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
145 time1 = time.time() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
146 ens_ref = EnsemblRef(geneModelFile,twoBitFile) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
147 time2 = time.time() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
148 print >> sys.stderr, "Parsing ensembl ref: %d seconds" % (int(time2-time1)) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
149 except Exception, e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
150 print >> sys.stderr, "Parsing gene model failed: %s" % e |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
151 exit(2) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
152 try: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
153 parse_input = parse_tabular if options.format == 'tabular' else parse_snpeff_vcf |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
154 for tid,pos1,ref,alt,dp,freq in parse_input(): |
1
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
155 if options.debug: print >> sys.stderr, "%s\t%d\t%s\t%s\t%d\t%f" % (tid,pos1,ref,alt,dp,freq) |
0
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
156 if not tid: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
157 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
158 if options.min_depth and dp is not None and dp < options.min_depth: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
159 continue |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
160 if options.min_freq and freq is not None and freq < options.min_freq: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
161 continue |
1
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
162 try: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
163 ## transcript_id, pos, ref, alt, dp, dpr |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
164 tx = ens_ref.get_gtf_transcript(tid) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
165 if not tx and tid.find('.') > 0: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
166 tid = tid.split('.')[0] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
167 tx = ens_ref.get_gtf_transcript(tid) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
168 if not tx: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
169 continue |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
170 if options.debug: print >> sys.stderr, "%s" % (tx) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
171 coding = ens_ref.transcript_is_coding(tid) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
172 if not coding: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
173 continue |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
174 frame_shift = len(ref) != len(alt) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
175 cds = ens_ref.get_cds(tid) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
176 if options.debug or not cds: print >> sys.stderr, "cds:\n%s" % (cds) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
177 pos0 = pos1 - 1 # zero based position |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
178 spos = pos0 if tx.gene.strand else pos0 + len(ref) - 1 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
179 alt_seq = alt if tx.gene.strand else reverse_complement(alt) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
180 ref_seq = ref if tx.gene.strand else reverse_complement(ref) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
181 cds_pos = ens_ref.genome_to_cds_pos(tid, spos) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
182 if options.debug: print >> sys.stderr, "cds_pos: %s" % (str(cds_pos)) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
183 alt_cds = cds[:cds_pos] + alt_seq + cds[cds_pos+len(ref):] if cds_pos+len(ref) < len(cds) else '' |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
184 offset = 0 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
185 if tx.gene.strand: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
186 for i in range(min(len(ref),len(alt))): |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
187 if ref[i] == alt[i]: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
188 offset = i |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
189 else: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
190 break |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
191 else: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
192 for i in range(-1,-min(len(ref),len(alt)) -1,-1): |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
193 if ref[i] == alt[i]: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
194 offset = i |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
195 else: |
0
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
196 break |
1
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
197 refpep = translate(cds[:len(cds)/3*3]) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
198 pep = translate(alt_cds[:len(alt_cds)/3*3]) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
199 peplen = len(pep) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
200 aa_pos = (cds_pos + offset) / 3 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
201 reported_stop_codon = '' |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
202 if aa_pos >= len(pep): |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
203 print >> sys.stderr, "aa_pos %d >= peptide length %d : %s %d %s %s" % (aa_pos,len(pep),tid,pos1,ref,alt) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
204 continue |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
205 if frame_shift: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
206 #find stop_codons |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
207 nstops = 0 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
208 stop_codons = [] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
209 for i in range(aa_pos,peplen): |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
210 if refpep[i] != pep[i]: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
211 aa_pos = i |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
212 break |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
213 reported_peptide = pep[aa_pos:] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
214 for i in range(aa_pos,peplen): |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
215 if pep[i] == '*': |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
216 nstops += 1 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
217 stop_codons.append("%s-%s%s" % (alt_cds[i*3-1],alt_cds[i*3:i*3+3],"-%s" % alt_cds[i*3+4] if len(alt_cds) > i*3 else '')) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
218 if nstops > options.readthrough: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
219 reported_peptide = pep[aa_pos:i+1] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
220 reported_stop_codon = ','.join(stop_codons) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
221 break |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
222 else: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
223 reported_stop_codon = "%s-%s" % (alt_cds[peplen*3-4],alt_cds[peplen*3-3:peplen*3]) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
224 reported_peptide = "%s_%s_%s" % (pep[max(aa_pos-options.leading_aa,0):aa_pos], |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
225 pep[aa_pos], |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
226 pep[aa_pos+1:min(aa_pos+1+options.trailing_aa,len(pep))]) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
227 cs_pos = aa_pos * 3 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
228 aa_pos = (cds_pos + offset) / 3 |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
229 ref_codon = cds[cs_pos:cs_pos+3] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
230 ref_aa = translate(ref_codon) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
231 alt_codon = alt_cds[cs_pos:cs_pos+3] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
232 alt_aa = translate(alt_codon) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
233 gene = tx.gene.names[0] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
234 report_fields = [tx.gene.names[0], |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
235 '%s:%d %s' % (tx.gene.contig,pos1,'+' if tx.gene.strand else '-'), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
236 ref_seq, |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
237 alt_seq, |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
238 "%1.2f" % freq if freq is not None else '', |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
239 str(dp), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
240 "%s|%s" % (tx.gene.gene_id,tx.cdna_id), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
241 "%d" % (aa_pos + 1), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
242 "%s%d%s" % (ref_aa,aa_pos + 1,alt_aa), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
243 "%d" % len(pep), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
244 reported_stop_codon, |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
245 reported_peptide, |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
246 tx.get_transcript_type_name() |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
247 ] |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
248 if options.debug: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
249 report_fields.append("%d %d %d %d %s %s" % (cds_pos, offset, cs_pos,aa_pos,ref_codon,alt_codon)) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
250 outputFile.write('\t'.join(report_fields)) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
251 if options.debug: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
252 print >> sys.stderr, "%s %s\n%s\n%s\n%s %s" % ( |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
253 cds[cs_pos-6:cs_pos], cds[cs_pos:cs_pos+15], |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
254 translate(cds[cs_pos-6:cs_pos+15]), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
255 translate(alt_cds[cs_pos-6:cs_pos+15]), |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
256 alt_cds[cs_pos-6:cs_pos], alt_cds[cs_pos:cs_pos+15]) |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
257 outputFile.write('\n') |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
258 except Exception, e: |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
259 print >> sys.stderr, "failed: %s" % e |
a67b4de184c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit b62e927469f96a857e880c77530c50c885ad92fc-dirty
jjohnson
parents:
0
diff
changeset
|
260 print >> sys.stderr, "%s\t%d\t%s\t%s\t%d\t%f\t%s" % (tid,pos1,ref,alt,dp,freq,e) |
0
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
261 except Exception, e: |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
262 print >> sys.stderr, "failed: %s" % e |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
263 exit(1) |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
264 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
265 |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
266 if __name__ == "__main__" : __main__() |
9f4ea174ce3d
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit e6aa05bbbee3cc7d98f16354fc41c674f439ff1b-dirty
jjohnson
parents:
diff
changeset
|
267 |