Mercurial > repos > iuc > jbrowse
comparison jbrowse.py @ 0:2c9e5136b416 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
author | iuc |
---|---|
date | Mon, 04 May 2015 17:21:38 -0400 |
parents | |
children | 497c6bb3b717 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2c9e5136b416 |
---|---|
1 #!/usr/bin/env python | |
2 import os | |
3 import shutil | |
4 import argparse | |
5 import subprocess | |
6 import hashlib | |
7 | |
8 TN_TABLE = { | |
9 'gff3': '--gff', | |
10 'gff': '--gff', | |
11 'bed': '--bed', | |
12 # 'genbank': '--gbk', | |
13 } | |
14 | |
15 | |
16 def process_genome(jbrowse_dir, genome): | |
17 subprocess.check_output(['perl', 'bin/prepare-refseqs.pl', '--fasta', genome], cwd=jbrowse_dir) | |
18 | |
19 | |
20 def process_annotations(jbrowse_dir, annot_file, annot_label, annot_format, | |
21 **kwargs): | |
22 key = hashlib.md5(annot_file).hexdigest() | |
23 | |
24 cmd = ['perl', 'bin/flatfile-to-json.pl', TN_TABLE.get(annot_format, 'gff'), | |
25 annot_file, '--trackLabel', key, '--key', annot_label] | |
26 subprocess.check_output(cmd, cwd=jbrowse_dir) | |
27 | |
28 | |
29 if __name__ == '__main__': | |
30 parser = argparse.ArgumentParser(description="", epilog="") | |
31 parser.add_argument('genome', type=file, help='Input genome file') | |
32 | |
33 parser.add_argument('--gff3', type=file, nargs='*', help='GFF3/BED/GBK File') | |
34 parser.add_argument('--gff3_format', choices=['gff3', 'gff', 'bed', 'gbk'], nargs='*', help='GFF3/BED/GBK Format') | |
35 parser.add_argument('--gff3_label', type=str, nargs='*', help='GFF3/BED/GBK Label') | |
36 | |
37 parser.add_argument('--jbrowse', help='Folder containing a jbrowse release') | |
38 parser.add_argument('--outdir', help='Output directory', default='out') | |
39 args = parser.parse_args() | |
40 | |
41 jbrowse_dir = os.path.join(args.outdir, 'JBrowse-1.11.6') | |
42 shutil.copytree(args.jbrowse, jbrowse_dir) | |
43 | |
44 process_genome(jbrowse_dir, os.path.realpath(args.genome.name)) | |
45 | |
46 for gff3, gff3_format, gff3_label in zip(args.gff3, args.gff3_format, args.gff3_label): | |
47 gff3_path = os.path.realpath(gff3.name) | |
48 process_annotations(jbrowse_dir, gff3_path, gff3_label, gff3_format) | |
49 | |
50 print """ | |
51 <html> | |
52 <body> | |
53 <script type="text/javascript"> | |
54 window.location=JBrowse-1.11.6/index.html | |
55 </script> | |
56 <a href="JBrowse-1.11.6/index.html">Go to JBrowse</a> | |
57 </body> | |
58 </html> | |
59 """ |