Mercurial > repos > jjohnson > gffutils
annotate create_gffdb.py @ 2:b956465b8893 draft default tip
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit f84d4d6e7fa7617e4b8298007db22e1355071213-dirty
author | jjohnson |
---|---|
date | Tue, 17 Apr 2018 10:19:30 -0400 |
parents | 8880c2e4b2ee |
children |
rev | line source |
---|---|
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
1 #!/usr/bin/env python |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
2 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
3 from __future__ import print_function |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
4 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
5 import argparse |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
6 import json |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
7 import sys |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
8 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
9 import gffutils |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
10 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
11 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
12 def __main__(): |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
13 parser = argparse.ArgumentParser( |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
14 description='Convert mga output to bed and tsv') |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
15 parser.add_argument( |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
16 'input_gff', |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
17 help="gff3 or gtf file to load") |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
18 parser.add_argument( |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
19 'gff_sqlite', |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
20 help="sqlite file") |
1
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
21 parser.add_argument( |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
22 '--create_introns', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
23 action='store_true', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
24 help='') |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
25 parser.add_argument( |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
26 '--disable_infer_transcripts', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
27 action='store_true', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
28 help='') |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
29 parser.add_argument( |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
30 '--disable_infer_genes', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
31 action='store_true', |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
32 help='') |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
33 parser.add_argument( |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
34 '-v', '--verbose', action='store_true', help='Verbose') |
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
35 args = parser.parse_args() |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
36 |
1
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
37 db = gffutils.create_db( |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
38 args.input_gff, args.gff_sqlite, |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
39 disable_infer_transcripts=args.disable_infer_transcripts, |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
40 disable_infer_genes=args.disable_infer_genes) |
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
41 version = db.execute('SELECT version FROM meta').fetchone()[0] |
1
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
42 print('version:%s' % version, file=sys.stdout) |
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
43 dialect = db.execute('SELECT dialect FROM meta').fetchone()[0] |
1
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
44 if args.create_introns: |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
45 db.create_introns() |
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
46 info = json.loads(dialect) |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
47 if 'fmt' in info: |
1
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
48 print('format:%s' % info['fmt'], file=sys.stdout) |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
49 seqids = [r[0] for r in |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
50 db.execute('SELECT distinct seqid FROM features').fetchall()] |
8880c2e4b2ee
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit eeb6499c828d0a99b6a891ed88de690cc1b8aeed-dirty
jjohnson
parents:
0
diff
changeset
|
51 print('seqids:%s' % ','.join(seqids), file=sys.stdout) |
0
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
52 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
53 |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
54 if __name__ == "__main__": |
8ba71aead5bc
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff
changeset
|
55 __main__() |