} } if __name__=="__main__": parser = collect_args() params = parser.parse_args() if params.clean: config["clean"] = True if params.json: config["in"] = params.json config["newick_tree_options"]["raxml"] = not params.no_raxml runner = process(config) runner.align() runner.build_tree() runner.timetree_setup_filter_run() runner.run_geo_inference() runner.save_as_nexus() runner.auspice_export() # plot an approximate skyline - needs testing plot_skyline = False if plot_skyline: # plot an approximate skyline from matplotlib import pyplot as plt T = runner.tree.tt plt.figure() skyline, confidence = T.merger_model.skyline_inferred(gen = 50, confidence=2.0) plt.fill_between(skyline.x, confidence[0], confidence[1], color=(0.8, 0.8, 0.8))
else: # Look for serotype-specific JSONs in the ./prepared/ directory if 'multiple' in args.serotypes: # "multiple" = run all 5 builds args.serotypes = ['denv1', 'denv2', 'denv3', 'denv4', 'all'] else: args.serotypes = args.serotypes args.json = ['./prepared/dengue_%s.json'%s for s in args.serotypes] # Look for ./prepared/dengue_SEROTYPE.json if no file paths given for j in args.json: # validate input JSONs exist assert os.path.isfile(j) ### Run analyses ### for prepared_json in args.json: try: print("Processing %s"%prepared_json) runner = process(make_config(prepared_json, args)) # parse runner.align() # run alignment with mafft runner.build_tree() # build tree with fasttree -> raxml runner.timetree_setup_filter_run() # infer ML ancestral states (geo traits, node dates, mutations) runner.run_geo_inference() # run mugration model to infer transmissions # estimate mutation frequencies here. if runner.config["estimate_mutation_frequencies"]: pivots = runner.get_pivots_via_spacing() runner.estimate_mutation_frequencies(pivots=pivots, min_freq=0.02, inertia=np.exp(-1.0/12), stiffness=2) # estimate tree frequencies here. if runner.config["estimate_tree_frequencies"]: # methods @ [ref] pivots = runner.get_pivots_via_spacing() runner.estimate_tree_frequencies(pivots=pivots, stiffness=2) # stiffness ~= amount of smoothing
def parse(xml, debug=False): handler = Handler(debug) process(xml, handler) return handler.props
# "auspice": { ## settings for auspice JSON export # "extra_attr": ['serum', 'clade', 'dTiter', 'cTiter'], # keys from tree.tree.clade['attr'] to include in export # "color_options": { # which traits to color the tree by in auspice; titer colorbys are added in dengue_titers # "country":{"key":"country", "legendTitle":"Country", "menuItem":"country", "type":"discrete"}, # "region":{"key":"region", "legendTitle":"Region", "menuItem":"region", "type":"discrete"}, # "gt":{"key":"genotype", "legendTitle":"Genotype", "menuItem":"genotype", "type":"discrete"}, # }, # "controls": {'authors':['authors']}, # "defaults": {'geoResolution': 'region', 'colorBy': 'region', 'distanceMeasure': 'div', 'mapTriplicate': True} # }, ##### Parse input files/params and run ##### ### Run analyses ### print("Processing %s" % args.json) runner = process(config) # parse runner.align() # run alignment with mafft runner.build_tree() # build tree with fasttree -> raxml runner.timetree_setup_filter_run( ) # infer ML ancestral states (geo traits, node dates, mutations) runner.run_geo_inference() # run mugration model to infer transmissions # estimate tree frequencies here. if runner.config["estimate_tree_frequencies"]: pivots = runner.get_pivots_via_spacing() runner.estimate_tree_frequencies(region='southeast_asia', stiffness=2) # titers if runner.config["fit_titer_model"] and runner.config[ "titers"]: # methods @ Neher et al., PNAS 2016 if args.titer_model == 'tree':
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/27272219.jpg</image> </album> <toptags> <tag> <name>electronic</name> <url>http://www.last.fm/tag/electronic</url> </tag> <tag> <name>new wave</name> <url>http://www.last.fm/tag/new%20wave</url> </tag> <tag> <name>synthpop</name> <url>http://www.last.fm/tag/synthpop</url> </tag> <tag> <name>80s</name> <url>http://www.last.fm/tag/80s</url> </tag> <tag> <name>depeche mode</name> <url>http://www.last.fm/tag/depeche%20mode</url> </tag> </toptags> </track></lfm> """ handler = Handler(debug=False) process(r_test, handler) print handler.props