Mercurial > repos > eduardo > annotateviz
diff 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 |
line wrap: on
line diff
--- a/annotateviz.py Sat Jun 17 15:10:53 2017 -0400 +++ b/annotateviz.py Sat Jun 24 14:55:25 2017 -0400 @@ -18,7 +18,8 @@ argv.append("-h") parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__) parser.add_argument('-d','--database', help="gffutils sqlite database") - parser.add_argument('-j','--json', help="report in json format") + parser.add_argument('-j','--json', help="annotations in json format") + parser.add_argument('-p','--pred', help="predictions in json") args = parser.parse_args(argv) gffutils.constants.always_return_list = False db = gffutils.interface.FeatureDB(args.database) @@ -29,5 +30,34 @@ add_matches(db.features_of_type("PFAM"), prediction_list) fout=open(args.json, 'w') json.dump(prediction_list,fout) + # create json for protein predictions + array=[] + for f in db.features_of_type("gene"): + dict = {} + dict['seqid'] = f.seqid + dict['source'] = f.source + dict['featuretype'] = f.featuretype + dict['start'] = f.start + dict['end'] = f.end + dict['score'] = f.score + dict['strand'] = f.strand + dict['frame'] = f.frame + dict['attributes']=f.attributes.__dict__["_d"] + array.append(dict) + for c in db.children(f): + dict = {} + dict['seqid'] = c.seqid + dict['source'] = c.source + dict['featuretype'] = c.featuretype + dict['start'] = c.start + dict['end'] = c.end + dict['score'] = c.score + dict['strand'] = c.strand + dict['frame'] = c.frame + dict['attributes'] = c.attributes.__dict__["_d"] + array.append(dict) + fout2=open(args.pred,'w') + json.dump(array,fout2) + if __name__ == "__main__": main(sys.argv[1:],sys.stdout)