1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | """ |
---|
4 | Convert from VCF file to summary tree file. |
---|
5 | |
---|
6 | usage: %prog in_file out_file |
---|
7 | """ |
---|
8 | from __future__ import division |
---|
9 | |
---|
10 | import optparse |
---|
11 | import galaxy_utils.sequence.vcf |
---|
12 | from galaxy.visualization.tracks.summary import SummaryTree |
---|
13 | |
---|
14 | def main(): |
---|
15 | # Read options, args. |
---|
16 | parser = optparse.OptionParser() |
---|
17 | (options, args) = parser.parse_args() |
---|
18 | in_file, out_file = args |
---|
19 | |
---|
20 | # Do conversion. |
---|
21 | st = SummaryTree(block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30) |
---|
22 | for line in list( galaxy_utils.sequence.vcf.Reader( open( in_file ) ) ): |
---|
23 | # VCF format provides a chrom and 1-based position for each variant. |
---|
24 | # SummaryTree expects 0-based coordinates. |
---|
25 | st.insert_range( line.chrom, long( line.pos-1 ), long( line.pos ) ) |
---|
26 | |
---|
27 | st.write(out_file) |
---|
28 | |
---|
29 | if __name__ == "__main__": |
---|
30 | main() |
---|