Mercurial > repos > eduardo > annotateviz
comparison annotateviz.py @ 0:7537482eed36 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/annotateviz commit 9bbaa3eacc76ff3bf2b6da313cc0d85705f15dd1-dirty
author | eduardo |
---|---|
date | Sat, 17 Jun 2017 13:31:06 -0400 |
parents | |
children | 3302f18f9e16 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7537482eed36 |
---|---|
1 import sys | |
2 import os | |
3 import gffutils | |
4 import argparse | |
5 import json | |
6 | |
7 def add_matches(matches,array): | |
8 for m in matches: | |
9 trans = {} | |
10 trans['mRNA'] = '.'.join(m.id.split('.',2)[:2]) #hack to recover mRNA from PFAM gff which doesn't include a query field | |
11 trans['Contig'] = m.seqid | |
12 trans['Source'] = m.source | |
13 trans['Score'] = m.score | |
14 trans['Prediction']=m["Name"] | |
15 array.append(trans) | |
16 def main(argv, wayout): | |
17 if not len(argv): | |
18 argv.append("-h") | |
19 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__) | |
20 parser.add_argument('-d','--database', help="gffutils sqlite database") | |
21 parser.add_argument('-j','--json', help="report in json format") | |
22 gffutils.constants.always_return_list = False | |
23 db = gffutils.interface.FeatureDB(args.database) | |
24 prediction_list = [] | |
25 add_matches(db.features_of_type("protein_match"), prediction_list) | |
26 add_matches(db.features_of_type("signalpep"), prediction_list) | |
27 add_matches(db.features_of_type("trans_helix"), prediction_list) | |
28 add_matches(db.features_of_type("PFAM"), prediction_list) | |
29 fout=open(args.json, 'w') | |
30 json.dump(prediction_list,fout) |