root/galaxy-central/tools/hyphy/hyphy_dnds_wrapper.py

リビジョン 2, 1.9 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#Guru
2#takes fasta alignments, a distance metric and builds neighbor joining trees
3import os, sys
4from galaxy import eggs
5from galaxy.tools.util import hyphy_util
6
7#Retrieve hyphy path, this will need to be the same across the cluster
8tool_data = sys.argv.pop()
9HYPHY_PATH = os.path.join( tool_data, "HYPHY" )
10HYPHY_EXECUTABLE = os.path.join( HYPHY_PATH, "HYPHY" )
11
12#Read command line arguments
13input_filename = os.path.abspath(sys.argv[1].strip())
14output_filename = os.path.abspath(sys.argv[2].strip())
15tree_contents = sys.argv[3].strip()
16nuc_model = sys.argv[4].strip()
17analysis = sys.argv[5].strip()
18
19if tree_contents == "":
20    print >> sys.stderr, "Please specify a valid tree definition."
21    sys.exit()
22       
23tree_filename = hyphy_util.get_filled_temp_filename(tree_contents)
24
25if analysis == "local":
26    fitter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.SimpleLocalFitter)
27else:
28    fitter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.SimpleGlobalFitter)
29
30tabwriter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.TabWriter)
31FastaReader_filename = hyphy_util.get_filled_temp_filename(hyphy_util.FastaReader)
32#setup Config file
33config_filename = hyphy_util.get_dnds_config_filename(fitter_filename, tabwriter_filename, "Universal", tree_filename, input_filename, nuc_model, output_filename, FastaReader_filename)
34
35#Run Hyphy
36hyphy_cmd = "%s BASEPATH=%s USEPATH=/dev/null %s" % (HYPHY_EXECUTABLE, HYPHY_PATH, config_filename)
37hyphy = os.popen(hyphy_cmd, 'r')
38#print hyphy.read()
39hyphy.close()
40
41#remove temporary files
42os.unlink(fitter_filename)
43os.unlink(tabwriter_filename)
44os.unlink(tree_filename)
45os.unlink(FastaReader_filename)
46os.unlink(config_filename)
47
48if nuc_model == "000000":
49    model = "F81"
50elif nuc_model == "010010":
51    model = "HKY85"
52else:
53    model = "REV"
54   
55print "Analysis: %s; Model: %s; Tree: %s" %(analysis, model, tree_contents)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。