TreeSAK 1.7.3__tar.gz → 1.7.5__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 (35) hide show
  1. {TreeSAK-1.7.3/TreeSAK.egg-info → TreeSAK-1.7.5}/PKG-INFO +2 -2
  2. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/AssessMarkerPA.py +63 -15
  3. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/Marker2Tree.py +2 -2
  4. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/VERSION +1 -1
  5. {TreeSAK-1.7.3 → TreeSAK-1.7.5/TreeSAK.egg-info}/PKG-INFO +2 -2
  6. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/.gitignore +0 -0
  7. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/LICENSE +0 -0
  8. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/MANIFEST.in +0 -0
  9. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/README.md +0 -0
  10. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/AssessCVG.py +0 -0
  11. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/ConvertMSA.py +0 -0
  12. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/OneLineAln.py +0 -0
  13. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/SliceMSA.py +0 -0
  14. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/TreeSAK_config copy.py +0 -0
  15. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/TreeSAK_config.py +0 -0
  16. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/__init__.py +0 -0
  17. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/compare_trees.R +0 -0
  18. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/compare_trees.py +0 -0
  19. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/format_leaf_name.py +0 -0
  20. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/get_arCOG_seq.py +0 -0
  21. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/iTOL.py +0 -0
  22. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/parse_deltall_stdout.py +0 -0
  23. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/rename_leaves.py +0 -0
  24. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK/subset_tree.py +0 -0
  25. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK.egg-info/SOURCES.txt +0 -0
  26. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK.egg-info/dependency_links.txt +0 -0
  27. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK.egg-info/requires.txt +0 -0
  28. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/TreeSAK.egg-info/top_level.txt +0 -0
  29. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/bin/TreeSAK +0 -0
  30. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/bin/__init__.py +0 -0
  31. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/images/Bioinformatics.jpg +0 -0
  32. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/images/windows_cmds.docx +0 -0
  33. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/images/windows_cmds.pdf +0 -0
  34. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/setup.cfg +0 -0
  35. {TreeSAK-1.7.3 → TreeSAK-1.7.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TreeSAK
3
- Version: 1.7.3
3
+ Version: 1.7.5
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -10,5 +10,5 @@ Keywords: Bioinformatics
10
10
  Platform: UNKNOWN
11
11
  License-File: LICENSE
12
12
 
13
- TreeSAK v1.7.3
13
+ TreeSAK v1.7.5
14
14
 
@@ -47,10 +47,9 @@ def AssessMarkerPA(args):
47
47
  gnm_set.add(faa_basename)
48
48
 
49
49
  # read in genome metadata
50
- group_to_gnm_dict = dict()
51
- group_to_gnm_num_dict = dict()
52
- gnm_to_group_dict = dict()
53
- gnms_without_group_info = set()
50
+ group_to_gnm_dict = dict()
51
+ group_to_gnm_num_dict = dict()
52
+ gnm_to_group_dict = dict()
54
53
  for each_gnm in open(gnm_group_txt):
55
54
  each_gnm_split = each_gnm.strip().split('\t')
56
55
  gnm_id = each_gnm_split[0]
@@ -69,15 +68,18 @@ def AssessMarkerPA(args):
69
68
  else:
70
69
  group_to_gnm_dict[domain_name].add(gnm_id)
71
70
 
72
- else:
73
- gnms_without_group_info.add(gnm_id)
74
-
75
71
  group_id_list_sorted = sorted(list(group_to_gnm_dict.keys()))
76
72
 
77
73
  # exit program if group information is missing
74
+ gnms_without_group_info = set()
75
+ for gnm in gnm_set:
76
+ if gnm not in gnm_to_group_dict:
77
+ gnms_without_group_info.add(gnm)
78
+
78
79
  if len(gnms_without_group_info) > 0:
79
80
  print('Group information for the following genomes are missing from %s, program exited!' % gnm_group_txt)
80
81
  print(','.join(gnms_without_group_info))
82
+ print('Group information for the above genomes are missing from %s, program exited!' % gnm_group_txt)
81
83
  exit()
82
84
 
83
85
  # create folder
@@ -92,8 +94,9 @@ def AssessMarkerPA(args):
92
94
 
93
95
  # read in provided cutoffs
94
96
  present_pct_cutoff_list = [int(i) for i in cutoff_str.split('-')]
95
- assess_summary_1_txt = '%s/assessment_PA.txt' % op_dir
96
- assess_summary_2_txt = '%s/assessment_PA_summary.txt' % op_dir
97
+ assess_summary_1_txt = '%s/assessment_PA.txt' % op_dir
98
+ assess_summary_2_txt = '%s/assessment_PA_summary.txt' % op_dir
99
+ itol_binary_txt = '%s/assessment_PA_iTOL_binary.txt' % op_dir
97
100
 
98
101
  trimmed_aln_file_re = '%s/*.%s' % (trimmed_aln_dir, trimmed_aln_ext)
99
102
  trimmed_aln_file_list = [os.path.basename(file_name) for file_name in glob.glob(trimmed_aln_file_re)]
@@ -102,16 +105,31 @@ def AssessMarkerPA(args):
102
105
  assess_summary_1_txt_handle.write('Marker\t%s\n' % '\t'.join([str(i) for i in group_id_list_sorted]))
103
106
  assess_summary_2_txt_handle = open(assess_summary_2_txt, 'w')
104
107
  assess_summary_2_txt_handle.write('Marker\t%s\n' % '\t'.join([str(i) for i in present_pct_cutoff_list]))
105
- cutoff_to_qualified_marker_num_dict = dict()
108
+ cutoff_to_qualified_marker_dict = dict()
109
+ gnm_to_identified_marker_dict = dict()
110
+ marker_id_list = []
106
111
  for each_aln in trimmed_aln_file_list:
107
112
 
108
113
  marker_id = each_aln.split(('.%s' % trimmed_aln_ext))[0]
114
+ marker_id_list.append(marker_id)
109
115
  pwd_aln = '%s/%s' % (trimmed_aln_dir, each_aln)
110
116
 
111
117
  current_marker_num_by_group_dict = dict()
112
118
  for each_seq in SeqIO.parse(pwd_aln, 'fasta'):
113
119
  gnm_id = each_seq.id
114
- gnm_group = gnm_to_group_dict[gnm_id]
120
+
121
+ # get genome to marker dist
122
+ if gnm_id not in gnm_to_identified_marker_dict:
123
+ gnm_to_identified_marker_dict[gnm_id] = {marker_id}
124
+ else:
125
+ gnm_to_identified_marker_dict[gnm_id].add(marker_id)
126
+
127
+ if gnm_id in gnm_to_group_dict:
128
+ gnm_group = gnm_to_group_dict[gnm_id]
129
+ else:
130
+ print('Not all genomes used to generate the MSA being found in -aa, program exited!')
131
+ exit()
132
+
115
133
  if gnm_group not in current_marker_num_by_group_dict:
116
134
  current_marker_num_by_group_dict[gnm_group] = 1
117
135
  else:
@@ -121,6 +139,7 @@ def AssessMarkerPA(args):
121
139
  pct_list = []
122
140
  for each_grp in group_id_list_sorted:
123
141
  grp_pct = current_marker_num_by_group_dict.get(each_grp, 0)*100/group_to_gnm_num_dict[each_grp]
142
+ grp_pct = float("{0:.2f}".format(grp_pct))
124
143
  pct_list.append(grp_pct)
125
144
  assess_summary_1_txt_handle.write('%s\t%s\n' % (marker_id, '\t'.join([str(i) for i in pct_list])))
126
145
 
@@ -133,22 +152,51 @@ def AssessMarkerPA(args):
133
152
  if each_pct < each_cutoff:
134
153
  good_marker = False
135
154
 
136
- if each_cutoff not in cutoff_to_qualified_marker_num_dict:
137
- cutoff_to_qualified_marker_num_dict[each_cutoff] = 0
155
+ if each_cutoff not in cutoff_to_qualified_marker_dict:
156
+ cutoff_to_qualified_marker_dict[each_cutoff] = {marker_id}
138
157
 
139
158
  if good_marker is True:
140
159
  assess_list.append('1')
141
- cutoff_to_qualified_marker_num_dict[each_cutoff] += 1
160
+ cutoff_to_qualified_marker_dict[each_cutoff].add(marker_id)
142
161
  else:
143
162
  assess_list.append('0')
144
163
  assess_summary_2_txt_handle.write('%s\t%s\n' % (marker_id, '\t'.join(assess_list)))
145
164
 
146
165
  # write out total in assess_summary_2_txt
147
- total_stats_list = [str(cutoff_to_qualified_marker_num_dict[each_c]) for each_c in present_pct_cutoff_list]
166
+ total_stats_list = [str(len(cutoff_to_qualified_marker_dict[each_c])) for each_c in present_pct_cutoff_list]
148
167
  assess_summary_2_txt_handle.write('Total\t%s\n' % ('\t'.join(total_stats_list)))
149
168
  assess_summary_1_txt_handle.close()
150
169
  assess_summary_2_txt_handle.close()
151
170
 
171
+ # copy alignments of qualified marker to corresponding folders
172
+ for each_cutoff in cutoff_to_qualified_marker_dict:
173
+ qualified_marker_set = cutoff_to_qualified_marker_dict[each_cutoff]
174
+ pwd_qualified_marker_dir = '%s/qualified_marker_PA_%s' % (op_dir, each_cutoff)
175
+ os.system('mkdir %s' % pwd_qualified_marker_dir)
176
+ for each_marker in qualified_marker_set:
177
+ pwd_marker_aln = '%s/%s.%s' % (trimmed_aln_dir, each_marker, trimmed_aln_ext)
178
+ cp_cmd = 'cp %s %s/' % (pwd_marker_aln, pwd_qualified_marker_dir)
179
+ os.system(cp_cmd)
180
+
181
+ # write out iTOL file
182
+ itol_binary_txt_handle = open(itol_binary_txt, 'w')
183
+ itol_binary_txt_handle.write('DATASET_BINARY\nSEPARATOR TAB\nDATASET_LABEL\tlabel1\nCOLOR\t#85C1E9\n')
184
+ itol_binary_txt_handle.write('SHOW_LABELS\t1\nLABEL_ROTATION\t45\nLABEL_SHIFT\t5\n')
185
+ itol_binary_txt_handle.write('FIELD_LABELS\t%s\n' % '\t'.join(sorted(marker_id_list)))
186
+ itol_binary_txt_handle.write('FIELD_SHAPES\t%s\n' % '\t'.join(['1']*len(marker_id_list)))
187
+ itol_binary_txt_handle.write('\nDATA\n')
188
+ for each_g in gnm_to_identified_marker_dict:
189
+ g_identified_marker_set = gnm_to_identified_marker_dict[each_g]
190
+
191
+ pa_list = []
192
+ for each_m in sorted(marker_id_list):
193
+ if each_m in g_identified_marker_set:
194
+ pa_list.append('1')
195
+ else:
196
+ pa_list.append('-1')
197
+ itol_binary_txt_handle.write('%s\t%s\n' % (each_g, '\t'.join(pa_list)))
198
+ itol_binary_txt_handle.close()
199
+
152
200
  print('Assessment results exported to:\n%s\n%s' % (assess_summary_1_txt, assess_summary_2_txt))
153
201
  print('Done!')
154
202
 
@@ -154,8 +154,8 @@ def Marker2Tree(args):
154
154
  for gnm_id in gnm_id_list_sorted:
155
155
  for each_cog in marker_id_set:
156
156
  #blastp_cmd = 'blastp -subject /home-user/wzsong/DateArTree/02_Williams_2017_45_arCOG/%s.fa -evalue 1e-30 -outfmt 6 -query /home-user/wzsong/DateArTree/01_genome_selection_Prokka/d__Archaea_o_rs_133_gnms_plus_27_mito_faa_files/%s.faa -out %s/%s_vs_%s_blastp.txt' % (each_cog, gnm_id, blast_op, gnm_id, each_cog)
157
- pwd_blast_op = '%s/%s_vs_%s_blastp.txt' % (blast_op_dir, gnm_id, each_cog)
158
- blastp_cmd = 'blastp -subject %s/%s.fa -evalue 1e-%s -outfmt 6 -query %s/%s.faa -out %s' % (marker_seq_dir, each_cog, e_value, faa_file_dir, gnm_id, pwd_blast_op)
157
+ pwd_blast_op = '%s/%s_vs_%s_blastp.txt' % (blast_op_dir, gnm_id, each_cog)
158
+ blastp_cmd = 'blastp -subject %s/%s.fa -evalue 1e-%s -outfmt 6 -query %s/%s.faa -out %s' % (marker_seq_dir, each_cog, e_value, faa_file_dir, gnm_id, pwd_blast_op)
159
159
  blast_op_to_cmd_dict[pwd_blast_op] = blastp_cmd
160
160
  blastp_cmd_txt_handle.write(blastp_cmd + '\n')
161
161
  blast_cmd_list.append(blastp_cmd)
@@ -1,4 +1,4 @@
1
- 1.7.3
1
+ 1.7.5
2
2
  - fixed bugs
3
3
 
4
4
  1.7.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TreeSAK
3
- Version: 1.7.3
3
+ Version: 1.7.5
4
4
  Summary: BioSAK
5
5
  Home-page: https://github.com/songweizhi/TreeSAK
6
6
  Author: Weizhi Song
@@ -10,5 +10,5 @@ Keywords: Bioinformatics
10
10
  Platform: UNKNOWN
11
11
  License-File: LICENSE
12
12
 
13
- TreeSAK v1.7.3
13
+ TreeSAK v1.7.5
14
14
 
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