comparison annotateviz.py @ 4:92921dfea0b5 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/annotateviz commit 230f5fe14cc469e56626201a5c377686976d81fc
author eduardo
date Sat, 24 Jun 2017 14:55:25 -0400
parents 3302f18f9e16
children
comparison
equal deleted inserted replaced
3:3302f18f9e16 4:92921dfea0b5
16 def main(argv, wayout): 16 def main(argv, wayout):
17 if not len(argv): 17 if not len(argv):
18 argv.append("-h") 18 argv.append("-h")
19 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__) 19 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__)
20 parser.add_argument('-d','--database', help="gffutils sqlite database") 20 parser.add_argument('-d','--database', help="gffutils sqlite database")
21 parser.add_argument('-j','--json', help="report in json format") 21 parser.add_argument('-j','--json', help="annotations in json format")
22 parser.add_argument('-p','--pred', help="predictions in json")
22 args = parser.parse_args(argv) 23 args = parser.parse_args(argv)
23 gffutils.constants.always_return_list = False 24 gffutils.constants.always_return_list = False
24 db = gffutils.interface.FeatureDB(args.database) 25 db = gffutils.interface.FeatureDB(args.database)
25 prediction_list = [] 26 prediction_list = []
26 add_matches(db.features_of_type("protein_match"), prediction_list) 27 add_matches(db.features_of_type("protein_match"), prediction_list)
27 add_matches(db.features_of_type("signalpep"), prediction_list) 28 add_matches(db.features_of_type("signalpep"), prediction_list)
28 add_matches(db.features_of_type("trans_helix"), prediction_list) 29 add_matches(db.features_of_type("trans_helix"), prediction_list)
29 add_matches(db.features_of_type("PFAM"), prediction_list) 30 add_matches(db.features_of_type("PFAM"), prediction_list)
30 fout=open(args.json, 'w') 31 fout=open(args.json, 'w')
31 json.dump(prediction_list,fout) 32 json.dump(prediction_list,fout)
33 # create json for protein predictions
34 array=[]
35 for f in db.features_of_type("gene"):
36 dict = {}
37 dict['seqid'] = f.seqid
38 dict['source'] = f.source
39 dict['featuretype'] = f.featuretype
40 dict['start'] = f.start
41 dict['end'] = f.end
42 dict['score'] = f.score
43 dict['strand'] = f.strand
44 dict['frame'] = f.frame
45 dict['attributes']=f.attributes.__dict__["_d"]
46 array.append(dict)
47 for c in db.children(f):
48 dict = {}
49 dict['seqid'] = c.seqid
50 dict['source'] = c.source
51 dict['featuretype'] = c.featuretype
52 dict['start'] = c.start
53 dict['end'] = c.end
54 dict['score'] = c.score
55 dict['strand'] = c.strand
56 dict['frame'] = c.frame
57 dict['attributes'] = c.attributes.__dict__["_d"]
58 array.append(dict)
59 fout2=open(args.pred,'w')
60 json.dump(array,fout2)
61
32 if __name__ == "__main__": 62 if __name__ == "__main__":
33 main(sys.argv[1:],sys.stdout) 63 main(sys.argv[1:],sys.stdout)