annotate create_gffdb.py @ 0:8ba71aead5bc draft

planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
author jjohnson
date Sun, 08 Apr 2018 13:26:47 -0400
parents
children 8880c2e4b2ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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")
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
21 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
22
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
23 db = gffutils.create_db(args.input_gff, args.gff_sqlite)
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
24 version = db.execute('SELECT version FROM meta').fetchone()[0]
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
25 print('version:%s' % version,file=sys.stdout)
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
26 dialect = db.execute('SELECT dialect FROM meta').fetchone()[0]
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
27 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
28 if 'fmt' in info:
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
29 print('format:%s' % info['fmt'],file=sys.stdout)
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
30 seqids = [r[0] for r in db.execute('SELECT distinct seqid FROM features').fetchall()]
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
31 print('seqids:%s' % ','.join(seqids),file=sys.stdout)
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
32
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
33
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
34 if __name__ == "__main__":
8ba71aead5bc planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/gffutils commit 186424e18ed21f2aea293fa7c4b654a9a4fb5d8c-dirty
jjohnson
parents:
diff changeset
35 __main__()