TreeSAK 1.29.2__tar.gz → 1.29.4__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 (162) hide show
  1. TreeSAK-1.29.4/PKG-INFO +26 -0
  2. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/README.md +2 -2
  3. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE.py +6 -5
  4. TreeSAK-1.29.4/TreeSAK/ALE5.py +210 -0
  5. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/OMA.py +16 -8
  6. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/OMA2.py +43 -34
  7. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/PlotMcmcNode.py +20 -14
  8. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/VERSION +1 -1
  9. TreeSAK-1.29.4/TreeSAK/gtdb_root.py +288 -0
  10. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/pRTC.py +4 -4
  11. TreeSAK-1.29.4/TreeSAK/tmp_3.py +39 -0
  12. TreeSAK-1.29.4/TreeSAK.egg-info/PKG-INFO +26 -0
  13. TreeSAK-1.29.4/TreeSAK.egg-info/SOURCES.txt +88 -0
  14. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/bin/TreeSAK +12 -8
  15. TreeSAK-1.29.2/.gitignore +0 -1
  16. TreeSAK-1.29.2/PKG-INFO +0 -14
  17. TreeSAK-1.29.2/TreeSAK/BMGE.jar +0 -0
  18. TreeSAK-1.29.2/TreeSAK/deltaLL_gene_removal.ipynb +0 -399
  19. TreeSAK-1.29.2/TreeSAK/iTOL.py +0 -464
  20. TreeSAK-1.29.2/TreeSAK/tmp_3.py +0 -44
  21. TreeSAK-1.29.2/TreeSAK.egg-info/PKG-INFO +0 -14
  22. TreeSAK-1.29.2/TreeSAK.egg-info/SOURCES.txt +0 -154
  23. TreeSAK-1.29.2/TreeSAK_DateArTree/4.sampling_th.py +0 -222
  24. TreeSAK-1.29.2/TreeSAK_DateArTree/AssessMarker.py +0 -306
  25. TreeSAK-1.29.2/TreeSAK_DateArTree/HGT/backup/HGT_ALE.py +0 -929
  26. TreeSAK-1.29.2/TreeSAK_DateArTree/HGT/backup/HGT_MetaCHIP.py +0 -481
  27. TreeSAK-1.29.2/TreeSAK_DateArTree/HGT/runALE.py +0 -987
  28. TreeSAK-1.29.2/TreeSAK_DateArTree/combine_trees.py +0 -61
  29. TreeSAK-1.29.2/TreeSAK_DateArTree/distribution_plot_Tianhua.py +0 -126
  30. TreeSAK-1.29.2/TreeSAK_DateArTree/get_outgroup_gnms.py +0 -43
  31. TreeSAK-1.29.2/TreeSAK_DateArTree/get_prokka_cmds.py +0 -23
  32. TreeSAK-1.29.2/TreeSAK_DateArTree/iTOL_tree.py +0 -60
  33. TreeSAK-1.29.2/TreeSAK_DateArTree/prototypeSelection.py +0 -618
  34. TreeSAK-1.29.2/TreeSAK_DateArTree/s1_select_ar_gnm.py +0 -37
  35. TreeSAK-1.29.2/TreeSAK_DateArTree/s2_psiblast.py +0 -152
  36. TreeSAK-1.29.2/TreeSAK_DateArTree/s3_Prep_gnm_metadata.py +0 -55
  37. TreeSAK-1.29.2/TreeSAK_DateArTree/s6_decorate_tree.py +0 -71
  38. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/Marker2Tree.py +0 -367
  39. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/ModifyTopo.py +0 -114
  40. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/Tianhua_deltaLL.py +0 -126
  41. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/Tianhua_main_deno100.py +0 -368
  42. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/batch_access_itol_Tianhua.py +0 -54
  43. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/deltaLL_gene_removal.ipynb +0 -399
  44. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/do_rrtc.rb +0 -364
  45. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/fit_mcmctree_posterior.R +0 -156
  46. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/itol_tree.py +0 -44
  47. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/merged_two_trees.py +0 -26
  48. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/plot_tree.py +0 -151
  49. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/s2_assess_markers.py +0 -305
  50. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/s2_select_assessed_marker.py +0 -114
  51. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/s4_get_dm_Mash.py +0 -45
  52. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/s4_get_dm_fastANI.py +0 -44
  53. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/tmp_1.py +0 -87
  54. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/tmp_2.py +0 -38
  55. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/tmp_3.py +0 -13
  56. TreeSAK-1.29.2/TreeSAK_DateArTree/script_backup/true_by_prob.py +0 -17
  57. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/dating_pro.py +0 -420
  58. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/deltaLL.py +0 -210
  59. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/final_params.py +0 -80
  60. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/main_deno100.py +0 -368
  61. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/multiple_sbatch.py +0 -155
  62. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/untouched_backup/deltaLL.py +0 -126
  63. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/untouched_backup/final_params.py +0 -80
  64. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/untouched_backup/main_deno100.py +0 -368
  65. TreeSAK-1.29.2/TreeSAK_DateArTree/scripts/untouched_backup/multiple_sbatch.py +0 -155
  66. TreeSAK-1.29.2/TreeSAK_DateArTree/submit_cmds.py +0 -27
  67. TreeSAK-1.29.2/TreeSAK_DateArTree/tests_to_perform.py +0 -13
  68. TreeSAK-1.29.2/TreeSAK_DateArTree/tmp_1.py +0 -49
  69. TreeSAK-1.29.2/TreeSAK_DateArTree/tmp_2.py +0 -49
  70. TreeSAK-1.29.2/TreeSAK_DateArTree/tmp_3.py +0 -57
  71. TreeSAK-1.29.2/TreeSAK_DateArTree/tmp_4.py +0 -72
  72. TreeSAK-1.29.2/TreeSAK_DateArTree/tmp_5.py +0 -404
  73. TreeSAK-1.29.2/TreeSAK_Sponge/extract_gnm_source.py +0 -47
  74. TreeSAK-1.29.2/TreeSAK_Sponge/get_prokka_cmds.py +0 -30
  75. TreeSAK-1.29.2/TreeSAK_Sponge/prep_metadata.py +0 -344
  76. TreeSAK-1.29.2/TreeSAK_Sponge/summarise_OMA_annotation.py +0 -97
  77. TreeSAK-1.29.2/TreeSAK_Sponge/tmp_1.py +0 -48
  78. TreeSAK-1.29.2/TreeSAK_Sponge/tmp_2.py +0 -21
  79. TreeSAK-1.29.2/TreeSAK_Sponge/tmp_3.py +0 -43
  80. TreeSAK-1.29.2/TreeSAK_Sponge/tmp_4.py +0 -42
  81. TreeSAK-1.29.2/TreeSAK_Sponge/tmp_5.py +0 -19
  82. TreeSAK-1.29.2/bin/__init__.py +0 -0
  83. TreeSAK-1.29.2/docs/BMGE_doc.pdf +0 -0
  84. TreeSAK-1.29.2/images/Bioinformatics.jpg +0 -0
  85. TreeSAK-1.29.2/images/windows_cmds.docx +0 -0
  86. TreeSAK-1.29.2/images/windows_cmds.pdf +0 -0
  87. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/LICENSE +0 -0
  88. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/MANIFEST.in +0 -0
  89. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE1.py +0 -0
  90. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE2.py +0 -0
  91. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE2RTC.py +0 -0
  92. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE3.py +0 -0
  93. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE4.py +0 -0
  94. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ALE_backup.py +0 -0
  95. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/AlignmentPruner.py +0 -0
  96. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/AssessCVG.py +0 -0
  97. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/AssessMarker.py +0 -0
  98. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/AssessMarkerDeltaLL.py +0 -0
  99. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/AssessMarkerPA.py +0 -0
  100. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/BMGE.py +0 -0
  101. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/CompareMCMC.py +0 -0
  102. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ConcateMSA.py +0 -0
  103. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ConvertMSA.py +0 -0
  104. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/Dating.py +0 -0
  105. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/Dir.rb +0 -0
  106. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ExtractMarkerSeq.py +0 -0
  107. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/FastRoot.py +0 -0
  108. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/FastRoot_backup.py +0 -0
  109. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/GTDB_tree.py +0 -0
  110. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/KEGG_Luo17.py +0 -0
  111. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/LcaToLeaves.py +0 -0
  112. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/MCMCtreeR.py +0 -0
  113. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/MarkerRef2Tree.py +0 -0
  114. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/MarkerRef2Tree_backup.py +0 -0
  115. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/MarkerSeq2Tree.py +0 -0
  116. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ModifyTopo.py +0 -0
  117. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/OneLineAln.py +0 -0
  118. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/PMSF.py +0 -0
  119. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/RootTree.py +0 -0
  120. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SequentialDating.py +0 -0
  121. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SingleAleHGT.py +0 -0
  122. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SingleLinePhy.py +0 -0
  123. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SliceMSA.py +0 -0
  124. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SplitScore.py +0 -0
  125. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SplitScore1.py +0 -0
  126. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SplitScore1OMA.py +0 -0
  127. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/SplitScore2.py +0 -0
  128. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/TaxaCountStats.R +0 -0
  129. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/TreeSAK_config.py +0 -0
  130. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/VisHPD95.R +0 -0
  131. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/VisHPD95.py +0 -0
  132. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/__init__.py +0 -0
  133. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ale_parser.py +0 -0
  134. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/ale_splitter.py +0 -0
  135. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/compare_trees.R +0 -0
  136. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/compare_trees.py +0 -0
  137. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/do_rrtc.rb +0 -0
  138. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/fa2phy.py +0 -0
  139. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/format_leaf_name.py +0 -0
  140. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/get_arCOG_seq.py +0 -0
  141. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/global_functions.py +0 -0
  142. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/parse_deltall_stdout.py +0 -0
  143. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/plot_distruibution_th.py +0 -0
  144. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/prep_mcmctree_ctl.py +0 -0
  145. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/print_leaves.py +0 -0
  146. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/rename_leaves.py +0 -0
  147. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/replace_clades.py +0 -0
  148. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/root_with_out_group.py +0 -0
  149. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/run_TaxaCountStats_R_s1.py +0 -0
  150. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/subsample_drep_gnms.py +0 -0
  151. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/subset_tree.py +0 -0
  152. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/subset_tree_stupid_old_way.py +0 -0
  153. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/test_1.py +0 -0
  154. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/test_2.py +0 -0
  155. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/tmp_1.py +0 -0
  156. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/tmp_2.py +0 -0
  157. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK/weighted_rand.rb +0 -0
  158. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK.egg-info/dependency_links.txt +0 -0
  159. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK.egg-info/requires.txt +0 -0
  160. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/TreeSAK.egg-info/top_level.txt +0 -0
  161. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/setup.cfg +0 -0
  162. {TreeSAK-1.29.2 → TreeSAK-1.29.4}/setup.py +0 -0
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.1
2
+ Name: TreeSAK
3
+ Version: 1.29.4
4
+ Summary: BioSAK
5
+ Home-page: https://github.com/songweizhi/TreeSAK
6
+ Author: Weizhi Song
7
+ Author-email: songwz03@gmail.com
8
+ License: GPL3+
9
+ Keywords: Bioinformatics
10
+ License-File: LICENSE
11
+ Requires-Dist: biopython
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: numpy
14
+ Requires-Dist: scipy
15
+ Requires-Dist: itolapi
16
+ Requires-Dist: networkx
17
+ Requires-Dist: seaborn
18
+ Requires-Dist: lxml
19
+ Requires-Dist: beautifulsoup4
20
+ Requires-Dist: ete3
21
+ Requires-Dist: arviz
22
+ Requires-Dist: plotly
23
+ Requires-Dist: kaleido
24
+ Requires-Dist: PyPDF3
25
+
26
+ TreeSAK v1.29.4
@@ -7,8 +7,8 @@
7
7
  Contact
8
8
  ---
9
9
 
10
- + **Weizhi Song**, Postdoctoral Researcher
11
- + School of Life Sciences, The Chinese University of Hong Kong
10
+ + Dr Weizhi Song
11
+ + Department of Ocean Science, Hong Kong University of Science and Technology, Hong Kong
12
12
  + E-mail: songwz03@gmail.com
13
13
 
14
14
 
@@ -3,11 +3,12 @@ ALE_usage = '''
3
3
  ================================================= ALE example commands =================================================
4
4
 
5
5
  # ALE modules
6
- TreeSAK ALE1 -> Step 1: get gene tree
7
- TreeSAK ALE2 -> Step 2: run ALE
8
- TreeSAK ALE3 -> Step 3: parse ALE outputs
9
- TreeSAK ALE4 -> Filter ALE identified HGTs
10
- TreeSAK SingleAleHGT -> Perform HGT analysis using ALE for single protein family
6
+ TreeSAK ALE1 -> Step 1: get gene tree
7
+ TreeSAK ALE2 -> Step 2: run ALE
8
+ TreeSAK ALE3 -> Step 3: parse ALE outputs
9
+ TreeSAK ALE4 -> Filter ALE identified HGTs
10
+ TreeSAK ALE5 -> Get RTC file based on ALE detected HGTs
11
+ TreeSAK SingleAleHGT -> Perform HGT analysis using ALE for single protein family
11
12
 
12
13
  # Example commands
13
14
  TreeSAK ALE1 -i OrthologousGroups.txt -s combined_d__Archaea_o_rs.faa -p oma -m 50 -t 12 -jst 3 -f -o ALE1_op_dir
@@ -0,0 +1,210 @@
1
+ import os
2
+ import glob
3
+ import operator
4
+ from ete3 import Tree
5
+ from itertools import chain
6
+ from itertools import combinations
7
+
8
+
9
+ def sep_path_basename_ext(file_in):
10
+
11
+ # separate path and file name
12
+ f_path, file_name = os.path.split(file_in)
13
+ if f_path == '':
14
+ f_path = '.'
15
+
16
+ # separate file basename and extension
17
+ f_base, f_ext = os.path.splitext(file_name)
18
+
19
+ return f_path, f_base, f_ext
20
+
21
+
22
+ def powerset(iterable):
23
+
24
+ " powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) "
25
+
26
+ s = list(iterable) # allows duplicate elements
27
+ chain_obj = chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
28
+ combo_lol = []
29
+ for _, combo in enumerate(chain_obj, 1):
30
+ if len(list(combo)) > 0:
31
+ combo_lol.append(list(combo))
32
+
33
+ return combo_lol
34
+
35
+
36
+ def lca_to_two_leaves(species_tree_from_ale, internal_node_id):
37
+
38
+ # read in ale species tree
39
+ stree_ale = Tree(species_tree_from_ale, format=1)
40
+
41
+ # get all leaves of the internal node
42
+ internal_node = stree_ale.search_nodes(name=internal_node_id)[0]
43
+ internal_node_leaf_object = internal_node.get_leaves()
44
+ internal_node_leaf_set = set()
45
+ for each_leaf in internal_node_leaf_object:
46
+ internal_node_leaf_set.add(each_leaf.name)
47
+
48
+ # get the two leaves needed
49
+ targeted_two_leaves = []
50
+ leaves_found = False
51
+ for leaf_1 in internal_node_leaf_set:
52
+ for leaf_2 in internal_node_leaf_set:
53
+ if leaf_1 != leaf_2:
54
+ if leaves_found is False:
55
+ current_lca_id = stree_ale.get_common_ancestor(leaf_1, leaf_2).name
56
+ if current_lca_id == internal_node_id:
57
+ targeted_two_leaves.append(leaf_1)
58
+ targeted_two_leaves.append(leaf_2)
59
+ leaves_found = True
60
+
61
+ return targeted_two_leaves[0], targeted_two_leaves[1]
62
+
63
+
64
+ def keep_highest_rrtc(rrtc_in, rrtc_out):
65
+
66
+ rrtc_highest_prob_dict = dict()
67
+ for each_rrtc in open(rrtc_in):
68
+ rrtc_r = each_rrtc.strip().split(':')[0].split('\t')[0]
69
+ rrtc_d = each_rrtc.strip().split(':')[0].split('\t')[1]
70
+ rrtc_v = float(each_rrtc.strip().split(':')[1])
71
+ rrtc_key = '%s___%s' % (rrtc_r, rrtc_d)
72
+ if rrtc_key not in rrtc_highest_prob_dict:
73
+ rrtc_highest_prob_dict[rrtc_key] = rrtc_v
74
+ else:
75
+ if rrtc_v > rrtc_highest_prob_dict[rrtc_key]:
76
+ rrtc_highest_prob_dict[rrtc_key] = rrtc_v
77
+
78
+ with open(rrtc_out, 'w') as rrtc_out_handle:
79
+ for each_rrtc in sorted(rrtc_highest_prob_dict.items(), key=operator.itemgetter(1))[::-1]:
80
+ rrtc_r = each_rrtc[0].split('___')[0]
81
+ rrtc_d = each_rrtc[0].split('___')[1]
82
+ rrtc_v = each_rrtc[1]
83
+ rrtc_out_handle.write('%s\t%s:%s\n' % (rrtc_r, rrtc_d, rrtc_v))
84
+
85
+
86
+ ########################################################################################################################
87
+
88
+ # file in
89
+ ip_dir = '/Users/songweizhi/Desktop/DateArTree/01_HGT_ALE_with_OMA'
90
+ species_tree_from_ale = '/Users/songweizhi/Desktop/DateArTree/05_pRTC_wd/genome_tree.newick.ufboot.ale.stree'
91
+ round_list = [1, 2, 3, 4, 5]
92
+ color_list = ['dodgerblue', 'goldenrod1', 'darkorange1', 'seagreen3', 'orchid3']
93
+ min_detected_times = 2
94
+
95
+ # file out
96
+ op_dir = '/Users/songweizhi/Desktop/DateArTree/05_pRTC_wd/HGTs_5_rds_ALE'
97
+
98
+ ########################################################################################################################
99
+
100
+ rscript = '%s/rscript.R' % op_dir
101
+ plot_file = '%s/Venn.pdf' % op_dir
102
+ rtc_txt = '%s/rrtc.txt' % op_dir
103
+ rtc_txt_highest = '%s/rrtc_uniq_by_highest_prob.txt' % op_dir
104
+
105
+ if os.path.isdir(op_dir):
106
+ os.system('rm -r %s' % op_dir)
107
+ os.system('mkdir %s' % op_dir)
108
+
109
+ ########################################################################################################################
110
+
111
+ hgt_dict = dict()
112
+ rd_to_hgt_dict= dict()
113
+ for each_rd in round_list:
114
+
115
+ rd_id = each_rd
116
+ current_rd_op_dir = '%s/ALE4_op_dir_%s_0.3' % (ip_dir, each_rd)
117
+ pdf_file_re = '%s/*.%s' % (current_rd_op_dir, 'pdf')
118
+ pdf_file_list = glob.glob(pdf_file_re)
119
+
120
+ rd_to_hgt_dict[rd_id] = set()
121
+
122
+ for each_pdf in pdf_file_list:
123
+ f_path, f_base, f_ext = sep_path_basename_ext(each_pdf)
124
+ f_base_split = f_base.split('_')
125
+ id_by_d_to_r = '%s_to_%s' % (f_base_split[3], f_base_split[5])
126
+ rd_og = '%s_%s' % (each_rd, f_base_split[0])
127
+ rd_og_value = '%s_%s_%s' % (each_rd, f_base_split[0], f_base_split[6])
128
+
129
+ rd_to_hgt_dict[rd_id].add(id_by_d_to_r)
130
+
131
+ if id_by_d_to_r not in hgt_dict:
132
+ hgt_dict[id_by_d_to_r] = []
133
+ hgt_dict[id_by_d_to_r].append(rd_og_value)
134
+
135
+ ################################################### get Venn diagram ###################################################
136
+
137
+ combination_list = powerset(round_list)
138
+
139
+ value_str_list = []
140
+ for each_cmbo in combination_list:
141
+ current_str = ''
142
+ if len(each_cmbo) == 1:
143
+ current_value = rd_to_hgt_dict[each_cmbo[0]]
144
+ current_str = 'area%s=%s' % (each_cmbo[0], len(current_value))
145
+ value_str_list.append(current_str)
146
+ else:
147
+ value_lol = []
148
+ for each_element in each_cmbo:
149
+ ele_value = rd_to_hgt_dict[each_element]
150
+ value_lol.append(ele_value)
151
+ shared = set(value_lol[0]).intersection(*value_lol)
152
+ current_str = 'n%s=%s' % (''.join([str(i) for i in each_cmbo]), len(shared))
153
+ value_str_list.append(current_str)
154
+
155
+ value_str = ', '.join(value_str_list)
156
+ label_str = '"' + '", "'.join([str(i) for i in round_list]) + '"'
157
+ color_str = '"' + '", "'.join([str(i) for i in color_list]) + '"'
158
+ font_size_str = ', '.join(['1.2']*len(combination_list))
159
+
160
+ rscript_handle = open(rscript, 'w')
161
+ rscript_handle.write('library(futile.logger)\n')
162
+ rscript_handle.write('library(gridBase)\n')
163
+ rscript_handle.write('library(VennDiagram)\n')
164
+ rscript_handle.write('pdf(file="%s")\n' % plot_file)
165
+ rscript_handle.write('venn.plot <- draw.quintuple.venn(%s, category=c(%s), fill=c(%s), cat.col=c(%s), cat.cex=1.2, cat.dist=0.3, margin=0.05, cex=c(%s), ind=TRUE)\n' % (value_str, label_str, color_str, color_str, font_size_str))
166
+ rscript_handle.write('dev.off()\n')
167
+ rscript_handle.close()
168
+
169
+ os.system('Rscript %s' % rscript)
170
+
171
+ ########################################################################################################################
172
+
173
+ rtc_txt_handle = open(rtc_txt, 'w')
174
+ qualified_hgt_num = 0
175
+ for each_hgt in hgt_dict:
176
+
177
+ occurence_list = hgt_dict[each_hgt]
178
+ pdf_dir = '%s/%s_%s' % (op_dir, each_hgt, len(occurence_list))
179
+ if len(occurence_list) >= min_detected_times:
180
+
181
+ #################### prepare rtc file ####################
182
+
183
+ donor_id = each_hgt.split('_to_')[0][2:]
184
+ recipient_id = each_hgt.split('_to_')[1][2:]
185
+ d_leaf_1, d_leaf_2 = lca_to_two_leaves(species_tree_from_ale, donor_id)
186
+ r_leaf_1, r_leaf_2 = lca_to_two_leaves(species_tree_from_ale, recipient_id)
187
+
188
+ for each_occurence in occurence_list:
189
+ value = each_occurence.split('_')[-1]
190
+ rtc_str = '%s,%s\t%s,%s:%s' % (r_leaf_1, r_leaf_2, d_leaf_1, d_leaf_2, value)
191
+ rtc_txt_handle.write(rtc_str + '\n')
192
+
193
+ ##########################################################
194
+
195
+ qualified_hgt_num += 1
196
+ os.system('mkdir %s' % pdf_dir)
197
+ for each_h in occurence_list:
198
+ rd_id = each_h.split('_')[0]
199
+ og_id = each_h.split('_')[1]
200
+ value = each_h.split('_')[2]
201
+ pwd_input_pdf_in = '%s/ALE4_op_dir_%s_0.3/%s_HGT_*_%s_%s.pdf' % (ip_dir, rd_id, og_id, each_hgt,value)
202
+ pwd_input_pdf_out = '%s/%s_%s_%s_%s.pdf' % (pdf_dir, rd_id, og_id, each_hgt,value)
203
+ os.system('cp %s %s' % (pwd_input_pdf_in, pwd_input_pdf_out))
204
+ rtc_txt_handle.close()
205
+
206
+ # remove redundant HGTs, keep the one with the highest probability
207
+ keep_highest_rrtc(rtc_txt, rtc_txt_highest)
208
+
209
+ print('The number of HGTs detected in >= %s runs is %s.' % (min_detected_times, qualified_hgt_num))
210
+ print('Done!')
@@ -4,11 +4,11 @@ import argparse
4
4
 
5
5
 
6
6
  OMA_usage = '''
7
- ========================= OMA example commands =========================
7
+ ======================= OMA example commands =======================
8
8
 
9
9
  TreeSAK OMA -i faa_files -x faa -og og_gnm.txt -o OMA_wd -f -t 32
10
10
 
11
- ========================================================================
11
+ ====================================================================
12
12
  '''
13
13
 
14
14
  def sep_path_basename_ext(file_in):
@@ -102,16 +102,25 @@ def OMA(args):
102
102
  exit()
103
103
 
104
104
  # copy genome files into DB folder
105
- pwd_gnm_rename_txt_handle = open(pwd_gnm_rename_txt, 'w')
106
105
  gnm_id_rename_dict = dict()
106
+ rename_list = []
107
107
  for each_gnm in gnm_file_list:
108
108
  gnm_path, gnm_base, gnm_ext = sep_path_basename_ext(each_gnm)
109
109
  gnm_base_renamed = gnm_base.replace('.', '_')
110
110
  pwd_gnm_db = '%s/%s.fa' % (oma_input_dir, gnm_base_renamed)
111
- pwd_gnm_rename_txt_handle.write('%s\t%s\n' % (gnm_base, gnm_base_renamed))
111
+ if gnm_base != gnm_base_renamed:
112
+ rename_list.append('%s\t%s' % (gnm_base, gnm_base_renamed))
112
113
  gnm_id_rename_dict[gnm_base] = gnm_base_renamed
113
114
  os.system('cp %s %s' % (each_gnm, pwd_gnm_db))
114
- pwd_gnm_rename_txt_handle.close()
115
+
116
+ # write out rename file
117
+ if len(rename_list) > 0:
118
+ pwd_gnm_rename_txt_handle = open(pwd_gnm_rename_txt, 'w')
119
+ for each_e in sorted(rename_list):
120
+ pwd_gnm_rename_txt_handle.write(each_e + '\n')
121
+ pwd_gnm_rename_txt_handle.close()
122
+ else:
123
+ print('Format of file names passed checking')
115
124
 
116
125
  # get default_para_dict
117
126
  default_para_dict = get_default_para_dict()
@@ -121,7 +130,6 @@ def OMA(args):
121
130
  for each_og_gnm in open(og_gnm_txt):
122
131
  og_gnm_renamed = gnm_id_rename_dict[each_og_gnm.strip()]
123
132
  renamed_og_gnm_list.append(og_gnm_renamed)
124
- print(renamed_og_gnm_list)
125
133
 
126
134
  # write out parameter file
127
135
  with open(pwd_parameter_file, 'w') as pwd_parameter_file_handle:
@@ -145,6 +153,7 @@ def OMA(args):
145
153
  print('You can run OMA with:')
146
154
  print('cd %s' % op_dir)
147
155
  print('oma -n %s' % num_threads)
156
+ print('# You may want to customize parameters specified in %s ' % pwd_parameter_file)
148
157
 
149
158
 
150
159
  if __name__ == '__main__':
@@ -153,10 +162,9 @@ if __name__ == '__main__':
153
162
  OMA_parser.add_argument('-i', required=True, help='genome folder')
154
163
  OMA_parser.add_argument('-x', required=True, help='genome file extension')
155
164
  OMA_parser.add_argument('-st', required=False, default='AA', help='sequence type, AA or DNA, default: AA')
156
- OMA_parser.add_argument('-og', required=True, help='id of outgroup genomes, without file extension')
165
+ OMA_parser.add_argument('-og', required=True, help='outgroup genomes, without file extension')
157
166
  OMA_parser.add_argument('-o', required=True, default=None, help='output dir, i.e., OMA working directory')
158
167
  OMA_parser.add_argument('-f', required=False, action="store_true", help='force overwrite')
159
168
  OMA_parser.add_argument('-t', required=False, type=int, default=6, help='number of threads for running OMA, default: 6')
160
169
  args = vars(OMA_parser.parse_args())
161
170
  OMA(args)
162
-
@@ -4,11 +4,11 @@ from Bio import SeqIO
4
4
 
5
5
 
6
6
  OMA2_usage = '''
7
- =========================================== OMA2 example commands ===========================================
7
+ ============================ OMA2 example commands ============================
8
8
 
9
- TreeSAK OMA2 -i OrthologousGroups.txt -s OrthologousGroups_combined.fasta -g interested_gnms.txt -o OMA_op_filtered -f
9
+ TreeSAK OMA2 -i OrthologousGroups.txt -s OrthologousGroupsFasta -o op_dir -f
10
10
 
11
- =============================================================================================================
11
+ ===============================================================================
12
12
  '''
13
13
 
14
14
 
@@ -46,15 +46,25 @@ def select_seq(seq_in, seq_id_list, seq_out):
46
46
 
47
47
  def OMA2(args):
48
48
 
49
- og_txt = args['i']
50
- og_seq_combined = args['s']
51
- gnm_txt = args['g']
52
- op_dir = args['o']
53
- force_overwrite = args['f']
54
- min_gene_num = args['n']
49
+ og_txt = args['i']
50
+ og_seq_dir = args['s']
51
+ gnm_txt = args['g']
52
+ op_dir = args['o']
53
+ force_overwrite = args['f']
54
+ min_gene_num = args['n']
55
55
 
56
- og_txt_out = '%s/OrthologousGroups.txt' % op_dir
57
- og_seq_out = '%s/OrthologousGroups.fasta' % op_dir
56
+ og_txt_out = '%s/OrthologousGroups_min%s.txt' % (op_dir, min_gene_num)
57
+ filtered_seq_dir = '%s/OrthologousGroupsFasta_min%s' % (op_dir, min_gene_num)
58
+
59
+ # check genome files
60
+ interested_gnm_set = set()
61
+ if gnm_txt is not None:
62
+ if os.path.isfile(gnm_txt) is True:
63
+ for each_gnm in open(gnm_txt):
64
+ interested_gnm_set.add(each_gnm.strip())
65
+ else:
66
+ print('%s not found, program exited!' % gnm_txt)
67
+ exit()
58
68
 
59
69
  # create dir
60
70
  if os.path.isdir(op_dir) is True:
@@ -64,38 +74,37 @@ def OMA2(args):
64
74
  print('output folder detected, program exited!')
65
75
  exit()
66
76
  os.system('mkdir %s' % op_dir)
77
+ os.system('mkdir %s' % filtered_seq_dir)
67
78
 
68
- # check genome files
69
- interested_gnm_set = set()
70
- for each_gnm in open(gnm_txt):
71
- interested_gnm_set.add(each_gnm.strip())
72
-
73
- gene_set_to_extract = set()
74
- og_to_gene_dict = dict()
79
+ id_to_name_dict = dict()
80
+ gene_to_extract_dict = dict()
75
81
  og_txt_out_handle = open(og_txt_out, 'w')
76
82
  for each_line in open(og_txt):
77
- if each_line.startswith('#'):
78
- og_txt_out_handle.write(each_line)
79
- else:
83
+ if not each_line.startswith('#'):
80
84
  each_line_split = each_line.strip().split('\t')
81
85
  og_id = each_line_split[0]
86
+ filename = 'OG%s' % int(og_id[3:])
87
+ id_to_name_dict[og_id] = filename
82
88
  gene_list = each_line_split[1:]
83
- filtered_gene_list = [og_id]
84
- filtered_gene_list_only_id = set()
89
+ filtered_gene_set = set()
85
90
  for each_gene in gene_list:
86
91
  gene_gnm = each_gene.split(':')[0]
87
- gene_id = each_gene.split(':')[-1].split(' ')[0]
88
- if gene_gnm in interested_gnm_set:
89
- filtered_gene_list.append(each_gene)
90
- filtered_gene_list_only_id.add(gene_id)
91
- if len(filtered_gene_list) > (min_gene_num + 1):
92
- og_txt_out_handle.write('\t'.join(filtered_gene_list) + '\n')
93
- for i in filtered_gene_list_only_id:
94
- gene_set_to_extract.add(i)
92
+ gene_id = each_gene.split(':')[1].split(' ')[0]
93
+ if len(interested_gnm_set) == 0:
94
+ filtered_gene_set.add(gene_id)
95
+ else:
96
+ if gene_gnm in interested_gnm_set:
97
+ filtered_gene_set.add(gene_id)
98
+ if len(filtered_gene_set) > min_gene_num:
99
+ og_txt_out_handle.write('%s\t%s\n' % (filename, ','.join(sorted(list(filtered_gene_set)))))
100
+ gene_to_extract_dict[og_id] = filtered_gene_set
95
101
  og_txt_out_handle.close()
96
102
 
97
- # get sequences
98
- select_seq(og_seq_combined, gene_set_to_extract, og_seq_out)
103
+ for each_og in gene_to_extract_dict:
104
+ seq_file_name = id_to_name_dict[each_og]
105
+ source_file = '%s/%s.fa' % (og_seq_dir, seq_file_name)
106
+ filtered_file = '%s/%s.fa' % (filtered_seq_dir, seq_file_name)
107
+ select_seq(source_file, gene_to_extract_dict[each_og], filtered_file)
99
108
 
100
109
  print('Done!')
101
110
 
@@ -105,7 +114,7 @@ if __name__ == '__main__':
105
114
  OMA_parser = argparse.ArgumentParser()
106
115
  OMA_parser.add_argument('-i', required=True, help='OrthologousGroups.txt')
107
116
  OMA_parser.add_argument('-s', required=True, help='sequence dir, OrthologousGroupsFasta')
108
- OMA_parser.add_argument('-g', required=True, help='id of interested genomes')
117
+ OMA_parser.add_argument('-g', required=False, default=None, help='id of interested genomes')
109
118
  OMA_parser.add_argument('-o', required=True, default=None, help='output directory')
110
119
  OMA_parser.add_argument('-n', required=False, type=int, default=3, help='minimal number of gene in a OG, deafult: 3')
111
120
  OMA_parser.add_argument('-f', required=False, action="store_true", help='force overwrite')
@@ -144,10 +144,11 @@ def get_internal_node_to_plot(node_txt, mo_file):
144
144
 
145
145
  def PlotMcmcNode(args):
146
146
 
147
- mcmc_in = args['i']
148
- node_txt = args['n']
149
- output_plot = args['o']
150
- y_label_txt = args['l']
147
+ mcmc_in = args['i']
148
+ node_txt = args['n']
149
+ output_plot = args['o']
150
+ specified_out_file = args['of']
151
+ y_label_txt = args['l']
151
152
 
152
153
  # check MCMCTree output file/dir
153
154
  if os.path.isfile(mcmc_in) is True:
@@ -160,15 +161,16 @@ def PlotMcmcNode(args):
160
161
  print('*mcmc.txt file not found, program exited!')
161
162
  exit()
162
163
 
163
- missed_out_file_list = []
164
- for each_mcmc_file in mcmc_file_list:
165
- pwd_out_file = each_mcmc_file.replace('_mcmc.txt', '_out.txt')
166
- if os.path.isfile(pwd_out_file) is False:
167
- missed_out_file_list.append(pwd_out_file)
168
- if len(missed_out_file_list) > 0:
169
- print('The following *out.txt files are missing, program exited!')
170
- print('\n'.join(sorted(missed_out_file_list)))
171
- exit()
164
+ if specified_out_file is None:
165
+ missed_out_file_list = []
166
+ for each_mcmc_file in mcmc_file_list:
167
+ pwd_out_file = each_mcmc_file.replace('_mcmc.txt', '_out.txt')
168
+ if os.path.isfile(pwd_out_file) is False:
169
+ missed_out_file_list.append(pwd_out_file)
170
+ if len(missed_out_file_list) > 0:
171
+ print('The following *out.txt files are missing, program exited!')
172
+ print('\n'.join(sorted(missed_out_file_list)))
173
+ exit()
172
174
 
173
175
  # read in y-axis label file
174
176
  y_label_dict = dict()
@@ -197,7 +199,10 @@ def PlotMcmcNode(args):
197
199
  if '/' in mcmc_file_no_path:
198
200
  mcmc_file_no_path = mcmc_file_no_path.split('/')[-1]
199
201
 
200
- pwd_current_run_mcmc_out = mcmc_file.replace('_mcmc.txt', '_out.txt')
202
+ if specified_out_file is None:
203
+ pwd_current_run_mcmc_out = mcmc_file.replace('_mcmc.txt', '_out.txt')
204
+ else:
205
+ pwd_current_run_mcmc_out = specified_out_file
201
206
  node_set, node_rename_dict, tree_str = get_internal_node_to_plot(node_txt, pwd_current_run_mcmc_out)
202
207
  op_tree_tmp_handle.write('%s\t%s\n' % (mcmc_file_no_path.replace('_mcmc.txt', ''), tree_str))
203
208
  label_to_write = y_label_dict.get(mcmc_file_no_path, mcmc_file_no_path)
@@ -229,6 +234,7 @@ if __name__ == '__main__':
229
234
 
230
235
  parser = argparse.ArgumentParser()
231
236
  parser.add_argument('-i', required=True, help='folder holds the *mcmc.txt and *out.txt files')
237
+ parser.add_argument('-of', required=False, default=None, help='the *out.txt file')
232
238
  parser.add_argument('-n', required=True, help='Nodes to plot')
233
239
  parser.add_argument('-l', required=False, default=None, help='labels on y axis')
234
240
  parser.add_argument('-o', required=True, help='Output plot')
@@ -1,4 +1,4 @@
1
- 1.29.2
1
+ 1.29.4
2
2
  - fixed bugs
3
3
 
4
4
  1.29.0