annotate defuse_results_to_vcf.py @ 14:038a5210392a draft

Deleted selected files
author jjohnson
date Tue, 12 Dec 2017 10:02:00 -0500
parents b22f8634ff84
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
1 #!/usr/bin/env python
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
2 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
3 #
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
4 #------------------------------------------------------------------------------
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
5 # University of Minnesota
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
6 # Copyright 2012, Regents of the University of Minnesota
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
7 #------------------------------------------------------------------------------
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
8 # Author:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
9 #
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
10 # James E Johnson
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
11 # Jesse Erdmann
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
12 #
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
13 #------------------------------------------------------------------------------
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
14 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
15
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
16
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
17 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
18 This tool takes the defuse results.tsv tab-delimited file as input and creates a Variant Call Format file as output.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
19 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
20
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
21 import sys,re,os.path
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
22 import optparse
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
23 from optparse import OptionParser
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
24
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
25 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
26 http://www.1000genomes.org/wiki/analysis/variant-call-format/vcf-variant-call-format-version-42
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
27
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
28 5. INFO keys used for structural variants
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
29 When the INFO keys reserved for encoding structural variants are used for imprecise variants, the values should be best estimates. When a key reflects a property of a single alt allele (e.g. SVLEN), then when there are multiple alt alleles there will be multiple values for the key corresponding to each alelle (e.g. SVLEN=-100,-110 for a deletion with two distinct alt alleles).
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
30 The following INFO keys are reserved for encoding structural variants. In general, when these keys are used by imprecise variants, the values should be best estimates. When a key reflects a property of a single alt allele (e.g. SVLEN), then when there are multiple alt alleles there will be multiple values for the key corresponding to each alelle (e.g. SVLEN=-100,-110 for a deletion with two distinct alt alleles).
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
31 ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
32 ##INFO=<ID=NOVEL,Number=0,Type=Flag,Description="Indicates a novel structural variation">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
33 ##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the variant described in this record">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
34 For precise variants, END is POS + length of REF allele - 1, and the for imprecise variants the corresponding best estimate.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
35 ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
36 Value should be one of DEL, INS, DUP, INV, CNV, BND. This key can be derived from the REF/ALT fields but is useful for filtering.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
37 ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
38 One value for each ALT allele. Longer ALT alleles (e.g. insertions) have positive values, shorter ALT alleles (e.g. deletions) have negative values.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
39 ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
40 ##INFO=<ID=CIEND,Number=2,Type=Integer,Description="Confidence interval around END for imprecise variants">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
41 ##INFO=<ID=HOMLEN,Number=.,Type=Integer,Description="Length of base pair identical micro-homology at event breakpoints">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
42 ##INFO=<ID=HOMSEQ,Number=.,Type=String,Description="Sequence of base pair identical micro-homology at event breakpoints">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
43 ##INFO=<ID=BKPTID,Number=.,Type=String,Description="ID of the assembled alternate allele in the assembly file">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
44 For precise variants, the consensus sequence the alternate allele assembly is derivable from the REF and ALT fields. However, the alternate allele assembly file may contain additional information about the characteristics of the alt allele contigs.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
45 ##INFO=<ID=MEINFO,Number=4,Type=String,Description="Mobile element info of the form NAME,START,END,POLARITY">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
46 ##INFO=<ID=METRANS,Number=4,Type=String,Description="Mobile element transduction info of the form CHR,START,END,POLARITY">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
47 ##INFO=<ID=DGVID,Number=1,Type=String,Description="ID of this element in Database of Genomic Variation">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
48 ##INFO=<ID=DBVARID,Number=1,Type=String,Description="ID of this element in DBVAR">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
49 ##INFO=<ID=DBRIPID,Number=1,Type=String,Description="ID of this element in DBRIP">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
50 ##INFO=<ID=MATEID,Number=.,Type=String,Description="ID of mate breakends">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
51 ##INFO=<ID=PARID,Number=1,Type=String,Description="ID of partner breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
52 ##INFO=<ID=EVENT,Number=1,Type=String,Description="ID of event associated to breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
53 ##INFO=<ID=CILEN,Number=2,Type=Integer,Description="Confidence interval around the length of the inserted material between breakends">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
54 ##INFO=<ID=DP,Number=1,Type=Integer,Description="Read Depth of segment containing breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
55 ##INFO=<ID=DPADJ,Number=.,Type=Integer,Description="Read Depth of adjacency">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
56 ##INFO=<ID=CN,Number=1,Type=Integer,Description="Copy number of segment containing breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
57 ##INFO=<ID=CNADJ,Number=.,Type=Integer,Description="Copy number of adjacency">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
58 ##INFO=<ID=CICN,Number=2,Type=Integer,Description="Confidence interval around copy number for the segment">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
59 ##INFO=<ID=CICNADJ,Number=.,Type=Integer,Description="Confidence interval around copy number for the adjacency">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
60 6. FORMAT keys used for structural variants
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
61 ##FORMAT=<ID=CN,Number=1,Type=Integer,Description="Copy number genotype for imprecise events">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
62 ##FORMAT=<ID=CNQ,Number=1,Type=Float,Description="Copy number genotype quality for imprecise events">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
63 ##FORMAT=<ID=CNL,Number=.,Type=Float,Description="Copy number genotype likelihood for imprecise events">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
64 ##FORMAT=<ID=NQ,Number=1,Type=Integer,Description="Phred style probability score that the variant is novel with respect to the genome's ancestor">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
65 ##FORMAT=<ID=HAP,Number=1,Type=Integer,Description="Unique haplotype identifier">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
66 ##FORMAT=<ID=AHAP,Number=1,Type=Integer,Description="Unique identifier of ancestral haplotype">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
67 These keys are analogous to GT/GQ/GL and are provided for genotyping imprecise events by copy number (either because there is an unknown number of alternate alleles or because the haplotypes cannot be determined). CN specifies the integer copy number of the variant in this sample. CNQ is encoded as a phred quality -10log_10p(copy number genotype call is wrong). CNL specifies a list of log10 likelihoods for each potential copy number, starting from zero. When possible, GT/GQ/GL should be used instead of (or in addition to) these keys.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
68
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
69 Specifying Complex Rearrangements with Breakends
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
70 An arbitrary rearrangement event can be summarized as a set of novel adjacencies.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
71 Each adjacency ties together 2 breakends. The two breakends at either end of a novel adjacency are called mates.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
72 There is one line of VCF (i.e. one record) for each of the two breakends in a novel adjacency. A breakend record is identified with the tag SYTYPE=BND" in the INFO field. The REF field of a breakend record indicates a base or sequence s of bases beginning at position POS, as in all VCF records. The ALT field of a breakend record indicates a replacement for s. This "breakend replacement" has three parts:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
73 the string t that replaces places s. The string t may be an extended version of s if some novel bases are inserted during the formation of the novel adjacency.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
74 The position p of the mate breakend, indicated by a string of the form "chr:pos". This is the location of the first mapped base in the piece being joined at this novel adjacency.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
75 The direction that the joined sequence continues in, starting from p. This is indicated by the orientation of square brackets surrounding p.
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
76 These 3 elements are combined in 4 possible ways to create the ALT. In each of the 4 cases, the assertion is that s is replaced with t, and then some piece starting at position p is joined to t. The cases are:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
77 REF ALT Meaning
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
78 s t[p[ piece extending to the right of p is joined after t
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
79 s t]p] reverse comp piece extending left of p is joined after t
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
80 s ]p]t piece extending to the left of p is joined before t
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
81 s [p[t reverse comp piece extending right of p is joined before t
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
82
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
83 Examples:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
84 #CHROM POS ID REF ALT QUAL FILT INFO
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
85 2 321681 bnd_W G G]17:198982] 6 PASS SVTYPE=BND;MATEID=bnd_Y
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
86 2 321682 bnd_V T ]13:123456]T 6 PASS SVTYPE=BND;MATEID=bnd_U
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
87 13 123456 bnd_U C C[2:321682[ 6 PASS SVTYPE=BND;MATEID=bnd_V
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
88 13 123457 bnd_X A [17:198983[A 6 PASS SVTYPE=BND;MATEID=bnd_Z
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
89 17 198982 bnd_Y A A]2:321681] 6 PASS SVTYPE=BND;MATEID=bnd_W
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
90 17 198983 bnd_Z C [13:123457[C 6 PASS SVTYPE=BND;MATEID=bnd_X
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
91 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
92
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
93 vcf_header = """\
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
94 ##fileformat=VCFv4.1
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
95 ##source=defuse
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
96 ##reference=%s
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
97 ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
98 ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
99 ##INFO=<ID=MATEID,Number=1,Type=String,Description="ID of the BND mate">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
100 ##INFO=<ID=MATELOC,Number=1,Type=String,Description="The chrom:position of the BND mate">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
101 ##INFO=<ID=GENESTRAND,Number=2,Type=String,Description="Strands">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
102 ##INFO=<ID=DP,Number=1,Type=Integer,Description="Read Depth of segment containing breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
103 ##INFO=<ID=SPLITCNT,Number=1,Type=Integer,Description="number of split reads supporting the prediction">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
104 ##INFO=<ID=SPANCNT,Number=1,Type=Integer,Description="number of spanning reads supporting the fusion">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
105 ##INFO=<ID=HOMLEN,Number=1,Type=Integer,Description="Length of base pair identical micro-homology at event breakpoints">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
106 ##INFO=<ID=SPLICESCORE,Number=1,Type=Integer,Description="number of nucleotides similar to GTAG at fusion splice">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
107 ##INFO=<ID=GENE,Number=2,Type=String,Description="Gene Names at each breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
108 ##INFO=<ID=GENEID,Number=2,Type=String,Description="Gene IDs at each breakend">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
109 ##INFO=<ID=GENELOC,Number=2,Type=String,Description="location of breakpoint releative to genes">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
110 ##INFO=<ID=EXPR,Number=2,Type=Integer,Description="expression of genes as number of concordant pairs aligned to exons">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
111 ##INFO=<ID=ORF,Number=0,Type=Flag,Description="fusion combines genes in a way that preserves a reading frame">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
112 ##INFO=<ID=EXONBND,Number=0,Type=Flag,Description="fusion splice at exon boundaries">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
113 ##INFO=<ID=INTERCHROM,Number=0,Type=Flag,Description="fusion produced by an interchromosomal translocation">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
114 ##INFO=<ID=READTHROUGH,Number=0,Type=Flag,Description="fusion involving adjacent potentially resulting from co-transcription rather than genome rearrangement">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
115 ##INFO=<ID=ADJACENT,Number=0,Type=Flag,Description="fusion between adjacent genes">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
116 ##INFO=<ID=ALTSPLICE,Number=0,Type=Flag,Description="fusion likely the product of alternative splicing between adjacent genes">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
117 ##INFO=<ID=DELETION,Number=0,Type=Flag,Description="fusion produced by a genomic deletion">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
118 ##INFO=<ID=EVERSION,Number=0,Type=Flag,Description="fusion produced by a genomic eversion">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
119 ##INFO=<ID=INVERSION,Number=0,Type=Flag,Description="fusion produced by a genomic inversion">
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
120 #CHROM POS ID REF ALT QUAL FILTER INFO\
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
121 """
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
122
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
123 def cmp_alphanumeric(s1,s2):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
124 if s1 == s2:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
125 return 0
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
126 a1 = re.findall("\d+|[a-zA-Z]+",s1)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
127 a2 = re.findall("\d+|[a-zA-Z]+",s2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
128 for i in range(min(len(a1),len(a2))):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
129 if a1[i] == a2[i]:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
130 continue
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
131 if a1[i].isdigit() and a2[i].isdigit():
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
132 return int(a1[i]) - int(a2[i])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
133 return 1 if a1[i] > a2[i] else -1
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
134 return len(a1) - len(a2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
135
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
136 def __main__():
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
137 # VCF functions
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
138 chr_dict = dict()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
139 def add_vcf_line(chr,pos,id,line):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
140 if chr not in chr_dict:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
141 pos_dict = dict()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
142 chr_dict[chr] = pos_dict
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
143 if pos not in chr_dict[chr]:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
144 id_dict = dict()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
145 chr_dict[chr][pos] = id_dict
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
146 chr_dict[chr][pos][id] = line
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
147
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
148 def write_vcf():
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
149 print >> outputFile, vcf_header % (refname)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
150 for chr in sorted(chr_dict.keys(),cmp=cmp_alphanumeric):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
151 for pos in sorted(chr_dict[chr].keys()):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
152 for id in chr_dict[chr][pos]:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
153 print >> outputFile, chr_dict[chr][pos][id]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
154 #Parse Command Line
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
155 parser = optparse.OptionParser()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
156 # files
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
157 parser.add_option( '-i', '--input', dest='input', help='The input defuse results.tsv file (else read from stdin)' )
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
158 parser.add_option( '-o', '--output', dest='output', help='The output vcf file (else write to stdout)' )
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
159 parser.add_option( '-r', '--reference', dest='reference', default=None, help='The genomic reference id' )
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
160 (options, args) = parser.parse_args()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
161
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
162 # results.tsv input
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
163 if options.input != None:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
164 try:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
165 inputPath = os.path.abspath(options.input)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
166 inputFile = open(inputPath, 'r')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
167 except Exception, e:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
168 print >> sys.stderr, "failed: %s" % e
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
169 exit(2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
170 else:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
171 inputFile = sys.stdin
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
172 # vcf output
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
173 if options.output != None:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
174 try:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
175 outputPath = os.path.abspath(options.output)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
176 outputFile = open(outputPath, 'w')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
177 except Exception, e:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
178 print >> sys.stderr, "failed: %s" % e
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
179 exit(3)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
180 else:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
181 outputFile = sys.stdout
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
182
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
183 refname = options.reference if options.reference else 'unknown'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
184
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
185 svtype = 'SVTYPE=BND'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
186 filt = 'PASS'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
187 columns = []
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
188 try:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
189 for linenum,line in enumerate(inputFile):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
190 ## print >> sys.stderr, "%d: %s\n" % (linenum,line)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
191 fields = line.strip().split('\t')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
192 if line.startswith('cluster_id'):
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
193 columns = fields
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
194 ## print >> sys.stderr, "columns: %s\n" % columns
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
195 continue
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
196 cluster_id = fields[columns.index('cluster_id')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
197 gene_chromosome1 = fields[columns.index('gene_chromosome1')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
198 gene_chromosome2 = fields[columns.index('gene_chromosome2')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
199 genomic_strand1 = fields[columns.index('genomic_strand1')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
200 genomic_strand2 = fields[columns.index('genomic_strand2')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
201 gene1 = fields[columns.index('gene1')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
202 gene2 = fields[columns.index('gene2')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
203 gene_info = 'GENEID=%s,%s' % (gene1,gene2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
204 gene_name1 = fields[columns.index('gene_name1')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
205 gene_name2 = fields[columns.index('gene_name2')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
206 gene_name_info = 'GENE=%s,%s' % (gene_name1,gene_name2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
207 gene_location1 = fields[columns.index('gene_location1')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
208 gene_location2 = fields[columns.index('gene_location2')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
209 gene_loc = 'GENELOC=%s,%s' % (gene_location1,gene_location2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
210 expression1 = int(fields[columns.index('expression1')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
211 expression2 = int(fields[columns.index('expression2')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
212 expr = 'EXPR=%d,%d' % (expression1,expression2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
213 genomic_break_pos1 = int(fields[columns.index('genomic_break_pos1')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
214 genomic_break_pos2 = int(fields[columns.index('genomic_break_pos2')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
215 breakpoint_homology = int(fields[columns.index('breakpoint_homology')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
216 homlen = 'HOMLEN=%s' % breakpoint_homology
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
217 orf = fields[columns.index('orf')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
218 exonboundaries = fields[columns.index('exonboundaries')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
219 read_through = fields[columns.index('read_through')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
220 interchromosomal = fields[columns.index('interchromosomal')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
221 adjacent = fields[columns.index('adjacent')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
222 altsplice = fields[columns.index('altsplice')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
223 deletion = fields[columns.index('deletion')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
224 eversion = fields[columns.index('eversion')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
225 inversion = fields[columns.index('inversion')] == 'Y'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
226 span_count = int(fields[columns.index('span_count')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
227 splitr_count = int(fields[columns.index('splitr_count')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
228 splice_score = int(fields[columns.index('splice_score')])
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
229 probability = fields[columns.index('probability')] if columns.index('probability') else '.'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
230 splitr_sequence = fields[columns.index('splitr_sequence')]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
231 split_seqs = splitr_sequence.split('|')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
232 mate_id1 = "bnd_%s_1" % cluster_id
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
233 mate_id2 = "bnd_%s_2" % cluster_id
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
234 ref1 = split_seqs[0][-1]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
235 ref2 = split_seqs[1][0]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
236 b1 = '[' if genomic_strand1 == '+' else ']'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
237 b2 = '[' if genomic_strand2 == '+' else ']'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
238 alt1 = "%s%s%s:%d%s" % (ref1,b2,gene_chromosome2,genomic_break_pos2,b2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
239 alt2 = "%s%s:%d%s%s" % (b1,gene_chromosome1,genomic_break_pos1,b1,ref2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
240 #TODO evaluate what should be included in the INFO field
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
241 info = ['DP=%d' % (span_count + splitr_count),'SPLITCNT=%d' % splitr_count,'SPANCNT=%d' % span_count,gene_name_info,gene_info,gene_loc,expr,homlen,'SPLICESCORE=%d' % splice_score]
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
242 if orf:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
243 info.append('ORF')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
244 if exonboundaries:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
245 info.append('EXONBND')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
246 if interchromosomal:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
247 info.append('INTERCHROM')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
248 if read_through:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
249 info.append('READTHROUGH')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
250 if adjacent:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
251 info.append('ADJACENT')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
252 if altsplice:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
253 info.append('ALTSPLICE')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
254 if deletion:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
255 info.append('DELETION')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
256 if eversion:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
257 info.append('EVERSION')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
258 if inversion:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
259 info.append('INVERSION')
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
260 info1 = [svtype,'MATEID=%s;MATELOC=%s:%d' % (mate_id2,gene_chromosome2,genomic_break_pos2)] + info
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
261 info2 = [svtype,'MATEID=%s;MATELOC=%s:%d' % (mate_id1,gene_chromosome1,genomic_break_pos1)] + info
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
262 qual = int(float(fields[columns.index('probability')]) * 255) if columns.index('probability') else '.'
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
263 vcf1 = '%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s'% (gene_chromosome1,genomic_break_pos1, mate_id1, ref1, alt1, qual, filt, ';'.join(info1) )
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
264 vcf2 = '%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s'% (gene_chromosome2,genomic_break_pos2, mate_id2, ref2, alt2, qual, filt, ';'.join(info2) )
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
265 add_vcf_line(gene_chromosome1,genomic_break_pos1,mate_id1,vcf1)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
266 add_vcf_line(gene_chromosome2,genomic_break_pos2,mate_id2,vcf2)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
267 write_vcf()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
268 except Exception, e:
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
269 print >> sys.stderr, "failed: %s" % e
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
270 sys.exit(1)
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
271
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
272 if __name__ == "__main__" : __main__()
b22f8634ff84 planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/defuse commit 23b94b5747c6956360cd2eca0a07a669929ea141-dirty
jjohnson
parents:
diff changeset
273