Mercurial > repos > miller-lab > genome_diversity
diff phylogenetic_tree.py @ 24:248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Tue, 28 May 2013 16:24:19 -0400 |
parents | 2c498d40ecde |
children | 8997f2ca8c7a |
line wrap: on
line diff
--- a/phylogenetic_tree.py Wed May 22 15:58:18 2013 -0400 +++ b/phylogenetic_tree.py Tue May 28 16:24:19 2013 -0400 @@ -19,22 +19,102 @@ ################################################################################ -if len(sys.argv) < 11: - print >> sys.stderr, "Usage" +# <command interpreter="python"> +# phylogenetic_tree.py "$input" "$output" "$output.files_path" +# +# #if $input_type.choice == '0' +# "gd_snp" +# #if $input_type.data_source.choice == '0' +# "sequence_coverage" +# "$input_type.data_source.minimum_coverage" +# "$input_type.data_source.minimum_quality" +# #else if $input_type.data_source.choice == '1' +# "estimated_genotype" +# #else if $input_type.choice == '1' +# "gd_genotype" +# #end if +# +# #if $individuals.choice == '0' +# "all_individuals" +# #else if $individuals.choice == '1' +# "$individuals.p1_input" +# #end if +# +# #if ((str($input.metadata.scaffold) == str($input.metadata.ref)) and (str($input.metadata.pos) == str($input.metadata.rPos))) or (str($include_reference) == '0') +# "none" +# #else +# "$input.metadata.dbkey" +# #end if +# +# #set $draw_tree_options = ''.join(str(x) for x in [$branch_style, $scale_style, $length_style, $layout_style]) +# #if $draw_tree_options == '' +# "" +# #else +# "-$draw_tree_options" +# #end if +# +# #for $individual_name, $individual_col in zip($input.dataset.metadata.individual_names, $input.dataset.metadata.individual_columns) +# #set $arg = '%s:%s' % ($individual_col, $individual_name) +# "$arg" +# #end for +# </command> + +################################################################################ + +# if len(sys.argv) < 11: +# print >> sys.stderr, "Usage" +# sys.exit(1) +# +# input, p1_input, output, extra_files_path, minimum_coverage, minimum_quality, dbkey, data_source, draw_tree_options = sys.argv[1:10] +# +# individual_metadata = sys.argv[10:] +# +# # note: TEST THIS +# if dbkey in ['', '?', 'None']: +# dbkey = 'none' +# +# p_total = Population() +# p_total.from_tag_list(individual_metadata) + +if len(sys.argv) < 5: + print >> sys.stderr, 'Usage' sys.exit(1) -input, p1_input, output, extra_files_path, minimum_coverage, minimum_quality, dbkey, data_source, draw_tree_options = sys.argv[1:10] +input, output, extra_files_path, input_type = sys.argv[1:5] +args = sys.argv[5:] + +data_source = '1' +minimum_coverage = '0' +minimum_quality = '0' -individual_metadata = sys.argv[10:] +if input_type == 'gd_snp': + data_source_arg = args.pop(0) + if data_source_arg == 'sequence_coverage': + data_source = '0' + minimum_coverage = args.pop(0) + minimum_quality = args.pop(0) + elif data_source_arg == 'estimated_genotype': + pass + else: + print >> sys.stderr, 'Unsupported data_source:', data_source_arg + sys.exit(1) +elif input_type == 'gd_genotype': + pass +else: + print >> sys.stderr, 'Unsupported input_type:', input_type + sys.exit(1) + +p1_input, dbkey, draw_tree_options = args[:3] # note: TEST THIS if dbkey in ['', '?', 'None']: dbkey = 'none' +individual_metadata = args[3:] + p_total = Population() p_total.from_tag_list(individual_metadata) - ################################################################################ mkdir_p(extra_files_path) @@ -88,6 +168,9 @@ tags = p1.tag_list() for tag in tags: + if input_type == 'gd_genotype': + column, name = tag.split(':') + tag = '{0}:{1}'.format(int(column) - 2, name) args.append(tag) fh = open(phylip_outfile, 'w')