TreeSAK 1.58.4__tar.gz → 1.58.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {treesak-1.58.4/treesak.egg-info → treesak-1.58.6}/PKG-INFO +2 -2
  2. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/MarkerRef2Tree.py +1 -1
  3. treesak-1.58.6/TreeSAK/PhyloHessian.py +19 -0
  4. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/VERSION +1 -1
  5. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/iTOL.py +6 -1
  6. treesak-1.58.6/TreeSAK/mcmc2tree.py +93 -0
  7. treesak-1.58.6/TreeSAK/replace_clade.py +130 -0
  8. {treesak-1.58.4 → treesak-1.58.6}/bin/TreeSAK +1 -1
  9. {treesak-1.58.4 → treesak-1.58.6/treesak.egg-info}/PKG-INFO +2 -2
  10. {treesak-1.58.4 → treesak-1.58.6}/treesak.egg-info/SOURCES.txt +1 -0
  11. treesak-1.58.4/TreeSAK/mcmc2tree.py +0 -58
  12. treesak-1.58.4/TreeSAK/replace_clade.py +0 -87
  13. {treesak-1.58.4 → treesak-1.58.6}/LICENSE +0 -0
  14. {treesak-1.58.4 → treesak-1.58.6}/MANIFEST.in +0 -0
  15. {treesak-1.58.4 → treesak-1.58.6}/README.md +0 -0
  16. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE.py +0 -0
  17. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE1.py +0 -0
  18. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE2.py +0 -0
  19. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE2RTC.py +0 -0
  20. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE3.py +0 -0
  21. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE4.py +0 -0
  22. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE5.py +0 -0
  23. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE6.py +0 -0
  24. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE7.py +0 -0
  25. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ALE_backup.py +0 -0
  26. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/AssessCVG.py +0 -0
  27. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/AssessMarker.py +0 -0
  28. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/AssessMarkerDeltaLL.py +0 -0
  29. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/AssessMarkerPA.py +0 -0
  30. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/BMGE.jar +0 -0
  31. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/BMGE.py +0 -0
  32. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/C60SR4.nex +0 -0
  33. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/CompareMCMC.py +0 -0
  34. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ConcateMSA.py +0 -0
  35. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ConvertMSA.py +0 -0
  36. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/Dir.rb +0 -0
  37. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ExtractMarkerSeq.py +0 -0
  38. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/FastRoot.py +0 -0
  39. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/FastRoot_backup.py +0 -0
  40. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/FigTree.py +0 -0
  41. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/GTDB_tree.py +0 -0
  42. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/GeneTree.py +0 -0
  43. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/KEGG_Luo17.py +0 -0
  44. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/LcaToLeaves.py +0 -0
  45. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/MarkerRef2Tree_backup.py +0 -0
  46. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/MarkerSeq2Tree.py +0 -0
  47. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/MarkerSeq2Tree_backup.py +0 -0
  48. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ModifyTopo.py +0 -0
  49. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/Newick_tree_plotter.py +0 -0
  50. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/OMA.py +0 -0
  51. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/OMA2.py +0 -0
  52. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/OneLineAln.py +0 -0
  53. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PB.py +0 -0
  54. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PMSF.py +0 -0
  55. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PhyloBiAssoc.R +0 -0
  56. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PhyloBiAssoc.py +0 -0
  57. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PlotMCMC.py +0 -0
  58. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PlotMcmcNode.py +0 -0
  59. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/PlotMcmcNode_old.py +0 -0
  60. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/RootTree.py +0 -0
  61. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/RootTreeGTDB.py +0 -0
  62. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/RootTreeGTDB214.py +0 -0
  63. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/RootTreeGTDB220.py +0 -0
  64. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SequentialDating.py +0 -0
  65. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SingleAleHGT.py +0 -0
  66. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SingleLinePhy.py +0 -0
  67. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SliceMSA.py +0 -0
  68. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SplitScore.py +0 -0
  69. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SplitScore1.py +0 -0
  70. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SplitScore1OMA.py +0 -0
  71. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/SplitScore2.py +0 -0
  72. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/TaxaCountStats.R +0 -0
  73. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/TaxonTree.py +0 -0
  74. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/TreeSAK_config.py +0 -0
  75. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/VisHPD95.R +0 -0
  76. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/VisHPD95.py +0 -0
  77. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/__init__.py +0 -0
  78. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ale_parser.py +0 -0
  79. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/ale_splitter.py +0 -0
  80. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/alignment_pruner.pl +0 -0
  81. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/assessOG.py +0 -0
  82. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/assessPB.py +0 -0
  83. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/batch_itol.py +0 -0
  84. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/catfasta2phy.py +0 -0
  85. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/cogTree.py +0 -0
  86. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/compare_trees.R +0 -0
  87. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/compare_trees.py +0 -0
  88. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/cophyloplot.R +0 -0
  89. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/cophyloplot.py +0 -0
  90. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/dating.py +0 -0
  91. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/dating_ss.py +0 -0
  92. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/deltall.py +0 -0
  93. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/do_rrtc.rb +0 -0
  94. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/fa2phy.py +0 -0
  95. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/filter_rename_ar53.py +0 -0
  96. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/format_leaf_name.py +0 -0
  97. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/gap_stats.py +0 -0
  98. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/get_SCG_tree.py +0 -0
  99. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/get_arCOG_seq.py +0 -0
  100. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/get_lca_id.py +0 -0
  101. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/global_functions.py +0 -0
  102. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/gnm_leaves.py +0 -0
  103. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/guide_tree.py +0 -0
  104. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/iTOL_Tanglegram.py +0 -0
  105. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/iTOL_gene_tree.py +0 -0
  106. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/itol_msa_stats.py +0 -0
  107. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/keep_highest_rrtc.py +0 -0
  108. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/koTree.py +0 -0
  109. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/label_gene_tree_by_gnm.py +0 -0
  110. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/label_tree.R +0 -0
  111. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/label_tree.py +0 -0
  112. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mad.py +0 -0
  113. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mcmcTC copy.py +0 -0
  114. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mcmcTC.py +0 -0
  115. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mcmctree_out.py +0 -0
  116. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mcmctree_vs_reltime.R +0 -0
  117. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/mcmctree_vs_reltime.py +0 -0
  118. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/merge_pdf.py +0 -0
  119. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/pRTC.py +0 -0
  120. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/parse_mcmctree.py +0 -0
  121. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/parse_reltime.py +0 -0
  122. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/phy2fa.py +0 -0
  123. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/plot_distruibution_th.py +0 -0
  124. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/prep_mcmctree_ctl.py +0 -0
  125. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/print_leaves.py +0 -0
  126. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/pruneMSA.py +0 -0
  127. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/recode.py +0 -0
  128. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/remove_bias.R +0 -0
  129. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/rename_leaves.py +0 -0
  130. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/rm_leaf.py +0 -0
  131. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/root_with_out_group.py +0 -0
  132. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/run_TaxaCountStats_R_s1.py +0 -0
  133. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/subsample_drep_gnms.py +0 -0
  134. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/subset.py +0 -0
  135. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/subset_tree_stupid_old_way.py +0 -0
  136. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/supertree.py +0 -0
  137. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/tmp_1.py +0 -0
  138. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/tmp_2.py +0 -0
  139. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/tmp_3.py +0 -0
  140. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/tmp_4.py +0 -0
  141. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/tree_fmt.py +0 -0
  142. {treesak-1.58.4 → treesak-1.58.6}/TreeSAK/weighted_rand.rb +0 -0
  143. {treesak-1.58.4 → treesak-1.58.6}/setup.cfg +0 -0
  144. {treesak-1.58.4 → treesak-1.58.6}/setup.py +0 -0
  145. {treesak-1.58.4 → treesak-1.58.6}/treesak.egg-info/dependency_links.txt +0 -0
  146. {treesak-1.58.4 → treesak-1.58.6}/treesak.egg-info/requires.txt +0 -0
  147. {treesak-1.58.4 → treesak-1.58.6}/treesak.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: treesak
3
- Version: 1.58.4
3
+ Version: 1.58.6
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -24,4 +24,4 @@ Requires-Dist: kaleido
24
24
  Requires-Dist: PyPDF3
25
25
  Requires-Dist: dendropy
26
26
 
27
- TreeSAK v1.58.4
27
+ TreeSAK v1.58.6
@@ -354,7 +354,7 @@ def MarkerRef2Tree(args):
354
354
  # get marker id set
355
355
  marker_seq_re = '%s/*.%s' % (marker_seq_dir, marker_seq_ext)
356
356
  marker_seq_list = [os.path.basename(file_name) for file_name in glob.glob(marker_seq_re)]
357
- marker_id_set = set()
357
+ marker_id_set = set()
358
358
  for each_marker_seq_file in marker_seq_list:
359
359
  _, marker_seq_basename, _ = sep_path_basename_ext(each_marker_seq_file)
360
360
  marker_id_set.add(marker_seq_basename)
@@ -1,4 +1,4 @@
1
- 1.58.4
1
+ 1.58.6
2
2
  - fixed bugs
3
3
 
4
4
  1.58.0
@@ -48,6 +48,11 @@ Genome_id SampleA SampleB SampleC
48
48
  genome_1 6.15 2.23 1.56
49
49
  genome_2 6.63 1.72 2.55
50
50
 
51
+ # Collapse file format
52
+ GCA964588035_1|GCA035283565_1 g__JBBDNF01
53
+ GCA035456305_1|GCA013330055_1 g__UBA8516
54
+ GCA964531195_1|GCA016201435_1 g__TA-20
55
+
51
56
  # chart.ttl is available at https://github.com/i-c-stratigraphy/chart/blob/main/chart.ttl
52
57
 
53
58
  ===============================================================================================
@@ -542,7 +547,7 @@ def iTOL(args):
542
547
  col_color_list = [Column_to_Color_dict.get(i, ColumnColor) for i in col_name_list]
543
548
 
544
549
  Binary_FileOut_handle.write('DATASET_BINARY\n\nSEPARATOR TAB\nDATASET_LABEL\t%s\nCOLOR\t%s\n' % (LegendTitle, Binary_color))
545
- Binary_FileOut_handle.write('SHOW_LABELS\t1\nLABEL_ROTATION\t45\nLABEL_SHIFT\t5\n')
550
+ Binary_FileOut_handle.write('SHOW_LABELS\t1\nLABEL_ROTATION\t45\nLABEL_SHIFT\t5\nSIZE_FACTOR\t2\n')
546
551
  Binary_FileOut_handle.write('FIELD_LABELS\t%s\n' % '\t'.join(col_name_list))
547
552
  Binary_FileOut_handle.write('FIELD_COLORS\t%s\n' % '\t'.join(col_color_list))
548
553
  Binary_FileOut_handle.write('MARGIN\t10\n')
@@ -0,0 +1,93 @@
1
+ import os
2
+ import argparse
3
+ from ete3 import Tree
4
+
5
+
6
+ mcmc2tree_usage = '''
7
+ =============== mcmc2tree example commands ===============
8
+
9
+ TreeSAK mcmc2tree -i mcmctree.out
10
+
11
+ # This module will extract two trees from the input file
12
+ 1. one tree with mcmctree added internal node ids
13
+ 2. another tree with node ages
14
+
15
+ =========================================================
16
+ '''
17
+
18
+
19
+ def sep_path_basename_ext(file_in):
20
+
21
+ f_path, f_name = os.path.split(file_in)
22
+ if f_path == '':
23
+ f_path = '.'
24
+ f_base, f_ext = os.path.splitext(f_name)
25
+ f_ext = f_ext[1:]
26
+
27
+ return f_name, f_path, f_base, f_ext
28
+
29
+
30
+ def mcmc2tree(args):
31
+
32
+ mamctree_out = args['i']
33
+
34
+ # define output file name
35
+ _, _, file_in_base, _ = sep_path_basename_ext(mamctree_out)
36
+
37
+ op_tree_with_internal_node = '%s_with_mcmctree_internal_node.treefile' % file_in_base
38
+ op_tree_with_node_age = '%s_with_node_age.treefile' % file_in_base
39
+
40
+ if os.path.isfile(mamctree_out) is False:
41
+ print('%s not found, program exited!' % mamctree_out)
42
+
43
+ # get tree string from mcmctree_out
44
+ tree_str_list = []
45
+ add_str_to_list = False
46
+ for each_line in open(mamctree_out):
47
+ each_line = each_line.strip()
48
+ if 'Species tree for FigTree. Branch lengths = posterior mean times; 95% CIs = labels' in each_line:
49
+ add_str_to_list = True
50
+ if 'Posterior mean (95% Equal-tail CI) (95% HPD CI) HPD-CI-width' in each_line:
51
+ add_str_to_list = False
52
+
53
+ if add_str_to_list is True:
54
+ if (not each_line.startswith('Species tree for FigTree.')) and (len(each_line) > 0):
55
+ tree_str_list.append(each_line.replace(' ', ''))
56
+
57
+ tree_str_with_internal_node_id = tree_str_list[0]
58
+ tree_str_with_node_age = tree_str_list[-1]
59
+
60
+ # rename internal nodes
61
+ t = Tree(tree_str_with_internal_node_id, format=1)
62
+ for each_node in t.traverse():
63
+ if each_node.is_leaf():
64
+ node_name_new = '_'.join(each_node.name.split('_')[1:])
65
+ else:
66
+ node_name_new = 't_n%s' % each_node.name
67
+ each_node.name = node_name_new
68
+
69
+ # write out tree_str_with_node_age
70
+ op_tree_with_node_age_handle = open(op_tree_with_node_age, 'w')
71
+ op_tree_with_node_age_handle.write(tree_str_with_node_age + '\n')
72
+ op_tree_with_node_age_handle.close()
73
+
74
+ # rename tree nodes
75
+ t = Tree(tree_str_with_internal_node_id, format=1)
76
+ for each_node in t.traverse():
77
+ if each_node.is_leaf():
78
+ node_name_new = '_'.join(each_node.name.split('_')[1:])
79
+ else:
80
+ node_name_new = 't_n%s' % each_node.name
81
+ each_node.name = node_name_new
82
+
83
+ op_tree_with_internal_node_handle = open(op_tree_with_internal_node, 'w')
84
+ op_tree_with_internal_node_handle.write(t.write(format=8) + '\n')
85
+ op_tree_with_internal_node_handle.close()
86
+
87
+
88
+ if __name__ == '__main__':
89
+
90
+ mcmc2tree_parser = argparse.ArgumentParser()
91
+ mcmc2tree_parser.add_argument('-i', required=True, help='the .out file from mcmctree')
92
+ args = vars(mcmc2tree_parser.parse_args())
93
+ mcmc2tree(args)
@@ -0,0 +1,130 @@
1
+ import os
2
+ import argparse
3
+ from ete3 import Tree
4
+
5
+
6
+ replace_clade_usage = '''
7
+ ====================== replace_clade example commands ======================
8
+
9
+ TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaves.txt
10
+ TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaf1
11
+ TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaf1,leaf2
12
+
13
+ # https://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html
14
+ 0 flexible with support values
15
+ 1 flexible with internal node names
16
+ 2 all branches + leaf names + internal supports
17
+ 3 all branches + all names
18
+ 4 leaf branches + leaf names
19
+ 5 internal and leaf branches + leaf names
20
+ 6 internal branches + leaf names
21
+ 7 leaf branches + all names
22
+ 8 all names
23
+ 9 leaf names
24
+ 100 topology only
25
+
26
+ python3 /Users/songweizhi/PycharmProjects/TreeSAK/TreeSAK/replace_clade.py
27
+
28
+
29
+ ============================================================================
30
+ '''
31
+
32
+
33
+ def replace_clade(args):
34
+
35
+ main_tree_file = args['m']
36
+ main_tree_fmt = args['mf']
37
+ sub_tree_file = args['s']
38
+ sub_tree_fmt = args['sf']
39
+ leaf_txt = args['l']
40
+ tree_out = args['o']
41
+ tree_out_fmt = args['of']
42
+ batch_file = args['b']
43
+
44
+ if os.path.isfile(main_tree_file) is False:
45
+ print('%s does not exist, program exited!' % main_tree_file)
46
+ exit()
47
+
48
+ # read in main tree
49
+ main_tre = Tree(main_tree_file, quoted_node_names=True, format=main_tree_fmt)
50
+
51
+ if batch_file is None:
52
+
53
+ if os.path.isfile(sub_tree_file) is False:
54
+ print('%s does not exist, program exited!' % sub_tree_file)
55
+ exit()
56
+
57
+ # read in subtree
58
+ sub_tre = Tree(sub_tree_file, quoted_node_names=True, format=sub_tree_fmt)
59
+
60
+ # read in leaves
61
+ leaf_list = []
62
+ if os.path.isfile(leaf_txt) is True:
63
+ for each_leaf in open(leaf_txt):
64
+ leaf_list.append(each_leaf.strip())
65
+ else:
66
+ leaf_list = leaf_txt.split(',')
67
+
68
+ # remove clades
69
+ if len(leaf_list) == 1:
70
+ lca = main_tre.search_nodes(name=leaf_list[0])[0]
71
+ else:
72
+ lca = main_tre.get_common_ancestor(leaf_list)
73
+
74
+ lca_p = lca.up
75
+ lca_p.remove_child(lca)
76
+ lca_p.add_child(sub_tre)
77
+
78
+ else:
79
+ if os.path.isfile(batch_file) is False:
80
+ print('%s does not exist, program exited!' % batch_file)
81
+ exit()
82
+
83
+ subtrees_not_found = []
84
+ replace_dict = dict()
85
+ for each_line in open(batch_file):
86
+ each_line_split = each_line.strip().split('\t')
87
+ leaves_to_replace = each_line_split[0]
88
+ currents_subset_tree = each_line_split[1]
89
+ replace_dict[leaves_to_replace] = currents_subset_tree
90
+ if os.path.isfile(currents_subset_tree) is False:
91
+ subtrees_not_found.append(currents_subset_tree)
92
+
93
+ if len(subtrees_not_found) > 0:
94
+ print('The following subtrees do not exist in the batch file, program exited!')
95
+ print('\n'.join(subtrees_not_found))
96
+ exit()
97
+
98
+ for each_replace in replace_dict:
99
+
100
+ current_subtree_file = replace_dict[each_replace]
101
+ current_leaf_list = each_replace.split(',')
102
+ current_sub_tre = Tree(current_subtree_file, quoted_node_names=True, format=sub_tree_fmt)
103
+
104
+ # remove clades
105
+ if len(current_leaf_list) == 1:
106
+ lca = main_tre.search_nodes(name=current_leaf_list[0])[0]
107
+ else:
108
+ lca = main_tre.get_common_ancestor(current_leaf_list)
109
+
110
+ lca_p = lca.up
111
+ lca_p.remove_child(lca)
112
+ lca_p.add_child(current_sub_tre)
113
+
114
+ # write out updated tree
115
+ main_tre.write(outfile=tree_out, format=tree_out_fmt)
116
+
117
+
118
+ if __name__ == '__main__':
119
+
120
+ replace_clade_parser = argparse.ArgumentParser()
121
+ replace_clade_parser.add_argument('-m', required=True, help='main tree file')
122
+ replace_clade_parser.add_argument('-mf', required=False, default=1, type=int, help='main tree format, default: 1')
123
+ replace_clade_parser.add_argument('-s', required=True, help='subtree file')
124
+ replace_clade_parser.add_argument('-b', required=False, default=None, help='replace multiple clades in batch manner')
125
+ replace_clade_parser.add_argument('-sf', required=False, default=1, type=int, help='subtree format, default: 1')
126
+ replace_clade_parser.add_argument('-l', required=True, help='leaves on main tree to be replaced')
127
+ replace_clade_parser.add_argument('-o', required=True, help='output tree')
128
+ replace_clade_parser.add_argument('-of', required=False, default=9, type=int, help='output tree format, default is 9')
129
+ args = vars(replace_clade_parser.parse_args())
130
+ replace_clade(args)
@@ -696,6 +696,7 @@ if __name__ == '__main__':
696
696
  replace_clade_parser.add_argument('-m', required=True, help='main tree file')
697
697
  replace_clade_parser.add_argument('-mf', required=False, default=1, type=int, help='main tree format, default: 1')
698
698
  replace_clade_parser.add_argument('-s', required=True, help='subtree file')
699
+ replace_clade_parser.add_argument('-b', required=False, default=None, help='replace multiple clades in batch manner')
699
700
  replace_clade_parser.add_argument('-sf', required=False, default=1, type=int, help='subtree format, default: 1')
700
701
  replace_clade_parser.add_argument('-l', required=True, help='leaves on main tree to be replaced')
701
702
  replace_clade_parser.add_argument('-o', required=True, help='output tree')
@@ -856,7 +857,6 @@ if __name__ == '__main__':
856
857
  from TreeSAK import mcmc2tree
857
858
  mcmc2tree_parser = subparsers.add_parser('mcmc2tree', usage=mcmc2tree.mcmc2tree_usage)
858
859
  mcmc2tree_parser.add_argument('-i', required=True, help='the .out file from mcmctree')
859
- mcmc2tree_parser.add_argument('-o', required=True, help='output tree file')
860
860
  args = vars(parser.parse_args())
861
861
  mcmc2tree.mcmc2tree(args)
862
862
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: treesak
3
- Version: 1.58.4
3
+ Version: 1.58.6
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -24,4 +24,4 @@ Requires-Dist: kaleido
24
24
  Requires-Dist: PyPDF3
25
25
  Requires-Dist: dendropy
26
26
 
27
- TreeSAK v1.58.4
27
+ TreeSAK v1.58.6
@@ -44,6 +44,7 @@ TreeSAK/PB.py
44
44
  TreeSAK/PMSF.py
45
45
  TreeSAK/PhyloBiAssoc.R
46
46
  TreeSAK/PhyloBiAssoc.py
47
+ TreeSAK/PhyloHessian.py
47
48
  TreeSAK/PlotMCMC.py
48
49
  TreeSAK/PlotMcmcNode.py
49
50
  TreeSAK/PlotMcmcNode_old.py
@@ -1,58 +0,0 @@
1
- import os
2
- import argparse
3
- from ete3 import Tree
4
-
5
-
6
- mcmc2tree_usage = '''
7
- ============ mcmc2tree example commands ============
8
-
9
- TreeSAK mcmc2tree -i mcmctree.out -o renamed.tree
10
-
11
- ====================================================
12
- '''
13
-
14
-
15
- def mcmc2tree(args):
16
-
17
- mamctree_out = args['i']
18
- tree_file = args['o']
19
-
20
- if os.path.isfile(mamctree_out) is False:
21
- print('%s not found, program exited!' % mamctree_out)
22
-
23
- # get tree string from mcmctree_out
24
- tree_str = ''
25
- tree_line = 0
26
- current_line = 1
27
- for each_line in open(mamctree_out):
28
- if 'Species tree for FigTree. Branch lengths = posterior mean times; 95% CIs = labels' in each_line:
29
- tree_line = current_line + 1
30
- if tree_line == current_line:
31
- tree_str = each_line.strip()
32
- current_line += 1
33
-
34
- tree_str_no_space = tree_str.replace(' ', '')
35
-
36
- # rename tree nodes
37
- t = Tree(tree_str_no_space, format=1)
38
- for each_node in t.traverse():
39
- if each_node.is_leaf():
40
- node_name_new = '_'.join(each_node.name.split('_')[1:])
41
- else:
42
- node_name_new = 't_n%s' % each_node.name
43
- each_node.name = node_name_new
44
-
45
- tree_str_renamed = t.write(format=8)
46
-
47
- tree_file_handle = open(tree_file, 'w')
48
- tree_file_handle.write(tree_str_renamed + '\n')
49
- tree_file_handle.close()
50
-
51
-
52
- if __name__ == '__main__':
53
-
54
- mcmc2tree_parser = argparse.ArgumentParser()
55
- mcmc2tree_parser.add_argument('-i', required=True, help='the .out file from mcmctree')
56
- mcmc2tree_parser.add_argument('-o', required=True, help='output tree file')
57
- args = vars(mcmc2tree_parser.parse_args())
58
- mcmc2tree(args)
@@ -1,87 +0,0 @@
1
- import os
2
- import argparse
3
- from ete3 import Tree
4
-
5
-
6
- replace_clade_usage = '''
7
- ====================== replace_clade example commands ======================
8
-
9
- TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaves.txt
10
- TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaf1
11
- TreeSAK replace_clade -m main.tree -s sub.tree -o out.tree -l leaf1,leaf2
12
-
13
- # https://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html
14
- 0 flexible with support values
15
- 1 flexible with internal node names
16
- 2 all branches + leaf names + internal supports
17
- 3 all branches + all names
18
- 4 leaf branches + leaf names
19
- 5 internal and leaf branches + leaf names
20
- 6 internal branches + leaf names
21
- 7 leaf branches + all names
22
- 8 all names
23
- 9 leaf names
24
- 100 topology only
25
-
26
- ============================================================================
27
- '''
28
-
29
-
30
- def replace_clade(args):
31
-
32
- main_tree_file = args['m']
33
- main_tree_fmt = args['mf']
34
- sub_tree_file = args['s']
35
- sub_tree_fmt = args['sf']
36
- leaf_txt = args['l']
37
- tree_out = args['o']
38
- tree_out_fmt = args['of']
39
-
40
- if os.path.isfile(main_tree_file) is False:
41
- print('%s does not exist, program exited!' % main_tree_file)
42
- exit()
43
-
44
- if os.path.isfile(sub_tree_file) is False:
45
- print('%s does not exist, program exited!' % sub_tree_file)
46
- exit()
47
-
48
- # read in subtree
49
- sub_tre = Tree(sub_tree_file, quoted_node_names=True, format=sub_tree_fmt)
50
-
51
- # read in leaves
52
- leaf_list = []
53
- if os.path.isfile(leaf_txt) is True:
54
- for each_leaf in open(leaf_txt):
55
- leaf_list.append(each_leaf.strip())
56
- else:
57
- leaf_list = leaf_txt.split(',')
58
-
59
- # read in main tree
60
- main_tre = Tree(main_tree_file, quoted_node_names=True, format=main_tree_fmt)
61
-
62
- # remove clades
63
- if len(leaf_list) == 1:
64
- lca = main_tre.search_nodes(name=leaf_list[0])[0]
65
- else:
66
- lca = main_tre.get_common_ancestor(leaf_list)
67
-
68
- lca_p = lca.up
69
- lca_p.remove_child(lca)
70
- lca_p.add_child(sub_tre)
71
-
72
- # write out updated tree
73
- main_tre.write(outfile=tree_out, format=tree_out_fmt)
74
-
75
-
76
- if __name__ == '__main__':
77
-
78
- replace_clade_parser = argparse.ArgumentParser()
79
- replace_clade_parser.add_argument('-m', required=True, help='main tree file')
80
- replace_clade_parser.add_argument('-mf', required=False, default=1, type=int, help='main tree format, default: 1')
81
- replace_clade_parser.add_argument('-s', required=True, help='subtree file')
82
- replace_clade_parser.add_argument('-sf', required=False, default=1, type=int, help='subtree format, default: 1')
83
- replace_clade_parser.add_argument('-l', required=True, help='leaves on main tree to be replaced')
84
- replace_clade_parser.add_argument('-o', required=True, help='output tree')
85
- replace_clade_parser.add_argument('-of', required=False, default=9, type=int, help='output tree format, default is 9')
86
- args = vars(replace_clade_parser.parse_args())
87
- replace_clade(args)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes