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

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

import galaxy-central

行番号 
1#Dan Blankenberg
2#takes commandline tree def and input multiple fasta alignment file and runs the branch length ananlysis
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()
17base_freq = sys.argv[5].strip()
18model_options = sys.argv[6].strip()
19
20#Set up Temporary files for hyphy run
21#set up tree file
22tree_filename = hyphy_util.get_filled_temp_filename(tree_contents)
23
24#Guess if this is a single or multiple FASTA input file
25found_blank = False
26is_multiple = False
27for line in open(input_filename):
28    line = line.strip()
29    if line == "": found_blank = True
30    elif line.startswith(">") and found_blank:
31        is_multiple = True
32        break
33    else: found_blank = False
34
35#set up BranchLengths file
36BranchLengths_filename = hyphy_util.get_filled_temp_filename(hyphy_util.BranchLengths)
37if is_multiple:
38    os.unlink(BranchLengths_filename)
39    BranchLengths_filename = hyphy_util.get_filled_temp_filename(hyphy_util.BranchLengthsMF)
40    print "Multiple Alignment Analyses"
41else: print "Single Alignment Analyses"
42
43#setup Config file
44config_filename = hyphy_util.get_branch_lengths_config_filename(input_filename, nuc_model, model_options, base_freq, tree_filename, output_filename, BranchLengths_filename)
45
46#Run Hyphy
47hyphy_cmd = "%s BASEPATH=%s USEPATH=/dev/null %s" % (HYPHY_EXECUTABLE, HYPHY_PATH, config_filename)
48hyphy = os.popen(hyphy_cmd, 'r')
49#print hyphy.read()
50hyphy.close()
51
52#remove temporary files
53os.unlink(BranchLengths_filename)
54os.unlink(tree_filename)
55os.unlink(config_filename)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。