MASSA-Algorithm 0.9.1__tar.gz → 1.0.0__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. massa_algorithm-1.0.0/MASSA_Algorithm/MASSA.py +286 -0
  2. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAargs.py +214 -0
  3. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAcluster.py +313 -0
  4. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAdescriptors.py +73 -0
  5. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAextraction.py +99 -0
  6. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAlogos.py → massa_algorithm-1.0.0/MASSA_Algorithm/MASSAlogos.py +3 -3
  7. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAmoloutput.py +70 -0
  8. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAod.py +23 -0
  9. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAopen_files.py +309 -0
  10. massa_algorithm-1.0.0/MASSA_Algorithm/MASSApreparation.py +79 -0
  11. massa_algorithm-1.0.0/MASSA_Algorithm/MASSAsplit.py +316 -0
  12. MASSA Algorithm-0.9.1/MASSA_Algorithm.egg-info/PKG-INFO → massa_algorithm-1.0.0/MASSA_Algorithm.egg-info/PKG-INFO +166 -118
  13. MASSA Algorithm-0.9.1/MASSA_Algorithm.egg-info/requires.txt → massa_algorithm-1.0.0/MASSA_Algorithm.egg-info/requires.txt +3 -3
  14. MASSA Algorithm-0.9.1/PKG-INFO → massa_algorithm-1.0.0/PKG-INFO +166 -118
  15. MASSA Algorithm-0.9.1/README.md → massa_algorithm-1.0.0/README.md +126 -95
  16. MASSA Algorithm-0.9.1/setup.cfg → massa_algorithm-1.0.0/setup.cfg +4 -4
  17. massa_algorithm-1.0.0/setup.py +31 -0
  18. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSA.py +0 -135
  19. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAargs.py +0 -68
  20. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAcluster.py +0 -216
  21. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAdescriptors.py +0 -46
  22. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAextraction.py +0 -78
  23. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAmoloutput.py +0 -40
  24. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAod.py +0 -19
  25. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAopen_files.py +0 -45
  26. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSApreparation.py +0 -65
  27. MASSA Algorithm-0.9.1/MASSA_Algorithm/MASSAsplit.py +0 -92
  28. MASSA Algorithm-0.9.1/setup.py +0 -27
  29. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/LICENSE +0 -0
  30. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MANIFEST.in +0 -0
  31. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MASSA_Algorithm/__init__.py +0 -0
  32. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MASSA_Algorithm.egg-info/SOURCES.txt +0 -0
  33. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MASSA_Algorithm.egg-info/dependency_links.txt +0 -0
  34. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MASSA_Algorithm.egg-info/entry_points.txt +0 -0
  35. {MASSA Algorithm-0.9.1 → massa_algorithm-1.0.0}/MASSA_Algorithm.egg-info/top_level.txt +0 -0
@@ -0,0 +1,286 @@
1
+ from MASSA_Algorithm import MASSAlogos
2
+ from MASSA_Algorithm import MASSAargs
3
+ from MASSA_Algorithm import MASSAod
4
+ from MASSA_Algorithm import MASSAopen_files
5
+ from MASSA_Algorithm import MASSAextraction
6
+ from MASSA_Algorithm import MASSAdescriptors
7
+ from MASSA_Algorithm import MASSApreparation
8
+ from MASSA_Algorithm import MASSAcluster
9
+ from MASSA_Algorithm import MASSAsplit
10
+ from MASSA_Algorithm import MASSAmoloutput
11
+
12
+
13
+ def returns_zero(total, test, validation):
14
+ """
15
+ Description:
16
+ It evaluates whether the distribution is inadequate. That is,
17
+ when the iterated cluster has a percentage greater than 0.5%
18
+ in the complete dataset but less than 0.5% in the test set.
19
+
20
+ Args:
21
+ total (dict):
22
+ Percentage of molecules in each cluster for the whole dataset.
23
+
24
+ test (dict):
25
+ Percentage of molecules in each cluster for the test subset.
26
+
27
+ validation (dict):
28
+ Percentage of molecules in each cluster for the validation subset.
29
+
30
+ Returns:
31
+ definer (boolean): Returns True if the distribution is
32
+ inadequate, and False if it is adequate.
33
+ """
34
+ definer = False
35
+ for i in total.keys():
36
+ if (total[i] > 0.5) and (test[i] <= 0.5):
37
+ # Definer = True (Distribution was not done properly).
38
+ definer = True
39
+ elif validation != None:
40
+ if (total[i] > 0.5) and (validation[i] <= 0.5):
41
+ definer = True
42
+ return definer
43
+
44
+
45
+ def main():
46
+ """
47
+ Description:
48
+ Main subroutine, allows the program to run directly from
49
+ the command line when installed via pip.
50
+ """
51
+ # Initializing from the command line.
52
+ # Print the program logo:
53
+ MASSAlogos.initial_print()
54
+
55
+ # It captures command line arguments.
56
+ (file_input,
57
+ file_output,
58
+ directoryfile_output,
59
+ extension_type,
60
+ dendrogram_xfont_size,
61
+ barplot_xfont_size,
62
+ training_percent,
63
+ number_bioact,
64
+ bioactivities_as_args,
65
+ npcs,
66
+ svd_parameter,
67
+ linkage_method,
68
+ flag_dendrogram,
69
+ splitting_strategy,
70
+ drop_errors) = MASSAargs.capture_args()
71
+ print('Initializing, wait...\n')
72
+
73
+ # Create log.txt file in directory:
74
+ arqlog = directoryfile_output+'/log.txt'
75
+ writelog = open(arqlog, 'w')
76
+
77
+ # Initial file management:
78
+ # It creates the output directories.
79
+ MASSAod.output_directory(directoryfile_output)
80
+ # Read molecules.
81
+ mols = MASSAopen_files.read_molecules(file_input, writelog, drop_errors)
82
+ # Extracting the property names from the ".sdf" input file.
83
+ sdf_property_names = MASSAopen_files.get_sdf_property_names(mols)
84
+ # Structure 3D management - It adds hydrogens keeping 3D coordenates.
85
+ mols_h = MASSAopen_files.hydrogen_add(mols)
86
+
87
+ # Extraction properties from ".sdf":
88
+ # It extracts the names of the molecules and creates a name:molecule dictionary and a dataframe.
89
+ names, dataframe = MASSAextraction.name_extraction(mols_h)
90
+ # It defines a list of what biological activities are being extracted.
91
+ biological_activity = MASSAextraction.the_biological_handler(
92
+ sdf_property_names, number_bioact, bioactivities_as_args)
93
+ # It adds the biological activities to the dataframe.
94
+ dataframe = MASSAextraction.list_activities(dataframe, biological_activity)
95
+
96
+ # Get fingeprint and other descriptors:
97
+ # Get physicochemical descriptors.
98
+ dataframe = MASSAdescriptors.physicochemical_descriptors(dataframe)
99
+ # Get AtomPairs fingerprint.
100
+ dataframe = MASSAdescriptors.atompairs_fingerprint(dataframe)
101
+
102
+ # Normalizes physicochemical and biological properties.
103
+ # Creates matrices for the three domains (struc, phys-chem, bio):
104
+ bio_matrix, phch_matrix, fp_matrix = MASSApreparation.normalizer_or_matrix(
105
+ dataframe, biological_activity)
106
+
107
+ # PCA:
108
+ # PCA for the biological domain.
109
+ bio_pca = MASSApreparation.pca_maker(bio_matrix, npcs, svd_parameter)
110
+ # PCA for the physicochemical domain.
111
+ phch_pca = MASSApreparation.pca_maker(phch_matrix, npcs, svd_parameter)
112
+ # PCA for the structural domain.
113
+ fp_pca = MASSApreparation.pca_maker(fp_matrix, npcs, svd_parameter)
114
+
115
+ # First clustering (HCA):
116
+ # It performs HCA clustering without generating the dendrogram for the biological domain.
117
+ leaves_cluster_bio, bio_hca, linkage_bio, cutoff_bio = MASSAcluster.hca_clusters(
118
+ bio_pca, names, 'bio', directoryfile_output, extension_type, linkage_method)
119
+ # It performs HCA clustering without generating the dendrogram for the physicochemical domain.
120
+ leaves_cluster_phch, phch_hca, linkage_phch, cutoff_phch = MASSAcluster.hca_clusters(
121
+ phch_pca, names, 'PhCh', directoryfile_output, extension_type, linkage_method)
122
+ # It performs HCA clustering without generating the dendrogram for the structural domain.
123
+ leaves_cluster_fp, fp_hca, linkage_fp, cutoff_fp = MASSAcluster.hca_clusters(
124
+ fp_pca, names, 'FP', directoryfile_output, extension_type, linkage_method)
125
+
126
+ # It adds the biological cluster identification to the spreadsheet.
127
+ dataframe = MASSApreparation.organize_df_clusterization(
128
+ dataframe, bio_hca, 'bio')
129
+ # It adds the physicochemical cluster identification to the spreadsheet.
130
+ dataframe = MASSApreparation.organize_df_clusterization(
131
+ dataframe, phch_hca, 'PhCh')
132
+ # It adds the structural cluster identification to the spreadsheet.
133
+ dataframe = MASSApreparation.organize_df_clusterization(
134
+ dataframe, fp_hca, 'FP')
135
+
136
+ # Second clustering (Kmodes):
137
+ # It creates a matrix with cluster identifications for each of the three domains for Kmodes.
138
+ matrix_for_kmodes = MASSApreparation.organize_for_kmodes(dataframe)
139
+ # It performs Kmodes clustering for the general domain.
140
+ all_hca = MASSAcluster.kmodes_clusters(matrix_for_kmodes, names)
141
+ # It adds the general cluster identification to the spreadsheet.
142
+ dataframe = MASSApreparation.organize_df_clusterization(
143
+ dataframe, all_hca, 'all')
144
+
145
+ # Split into training, test:
146
+ dataframe, test_or_val_molecules = MASSAsplit.split_train_test_sets(
147
+ dataframe, training_percent, splitting_strategy)
148
+
149
+ # Bar plot of frequencies
150
+ # (Calculates the percentages of molecules in each cluster for each
151
+ # dataset and generates a bar graph for each domain):
152
+
153
+ # Biological Bar Plot
154
+ bio_total, bio_training, bio_test, bio_val = MASSAsplit.freq_clusters(
155
+ dataframe,
156
+ directoryfile_output,
157
+ extension_type,
158
+ 'Cluster_Biological',
159
+ barplot_xfont_size,
160
+ splitting_strategy)
161
+ # Physicochemical Bar Plot
162
+ phch_total, phch_training, phch_test, phch_val = MASSAsplit.freq_clusters(
163
+ dataframe,
164
+ directoryfile_output,
165
+ extension_type,
166
+ 'Cluster_Physicochemical',
167
+ barplot_xfont_size,
168
+ splitting_strategy)
169
+ # Structural Bar Plot
170
+ fp_total, fp_training, fp_test, fp_val = MASSAsplit.freq_clusters(
171
+ dataframe,
172
+ directoryfile_output,
173
+ extension_type,
174
+ 'Cluster_Structural',
175
+ barplot_xfont_size,
176
+ splitting_strategy)
177
+ # General Bar Plot
178
+ all_total, all_training, all_test, all_val = MASSAsplit.freq_clusters(
179
+ dataframe,
180
+ directoryfile_output,
181
+ extension_type,
182
+ 'Cluster_General',
183
+ barplot_xfont_size,
184
+ splitting_strategy)
185
+
186
+ # Verifying percentages:
187
+ # For biological domain:
188
+ bio_ok = returns_zero(bio_total, bio_test, bio_val)
189
+ # For physicochemical domain:
190
+ phch_ok = returns_zero(phch_total, phch_test, phch_val)
191
+ # For structural domain:
192
+ fp_ok = returns_zero(fp_total, fp_test, fp_val)
193
+ ok = [bio_ok, phch_ok, fp_ok]
194
+ max_iters = 0
195
+
196
+ # Redo the distribution in case of errors (up to 10 times):
197
+ while (True in ok) and (max_iters < 10):
198
+ # Split into training, test:
199
+ dataframe, test_or_val_molecules = MASSAsplit.split_train_test_sets(
200
+ dataframe, training_percent, splitting_strategy)
201
+
202
+ # Bar plot of frequencies (Calculates the percentages of molecules in each
203
+ # cluster for each dataset and generates a bar graph for each domain):
204
+
205
+ # Biological Bar Plot:
206
+ bio_total, bio_training, bio_test, bio_val = MASSAsplit.freq_clusters(
207
+ dataframe, directoryfile_output, extension_type,
208
+ 'Cluster_Biological', barplot_xfont_size, splitting_strategy
209
+ )
210
+ # Physicochemical Bar Plot
211
+ phch_total, phch_training, phch_test, phch_val = MASSAsplit.freq_clusters(
212
+ dataframe, directoryfile_output, extension_type,
213
+ 'Cluster_Physicochemical', barplot_xfont_size, splitting_strategy
214
+ )
215
+ # Structural Bar Plot
216
+ fp_total, fp_training, fp_test, fp_val = MASSAsplit.freq_clusters(
217
+ dataframe, directoryfile_output, extension_type,
218
+ 'Cluster_Structural', barplot_xfont_size, splitting_strategy
219
+ )
220
+ # General Bar Plot
221
+ all_total, all_training, all_test, all_val = MASSAsplit.freq_clusters(
222
+ dataframe, directoryfile_output, extension_type,
223
+ 'Cluster_General', barplot_xfont_size, splitting_strategy
224
+ )
225
+
226
+ # Verifying percentages:
227
+
228
+ # For biological domain:
229
+ bio_ok = returns_zero(bio_total, bio_test, bio_val)
230
+ # For physicochemical domain:
231
+ phch_ok = returns_zero(phch_total, phch_test, phch_val)
232
+ # For structural domain:
233
+ fp_ok = returns_zero(fp_total, fp_test, fp_val)
234
+ ok = [bio_ok, phch_ok, fp_ok]
235
+ max_iters += 1
236
+
237
+ # Write distribution information to log file:
238
+ bio_distr = 'Biological Distribution'
239
+ MASSAsplit.log_of_distributions(
240
+ bio_distr, bio_total, bio_training,
241
+ bio_test, bio_val, splitting_strategy,
242
+ writelog
243
+ )
244
+ phch_distr = 'Physicochemical Distribution'
245
+ MASSAsplit.log_of_distributions(
246
+ phch_distr, phch_total, phch_training,
247
+ phch_test, phch_val, splitting_strategy,
248
+ writelog
249
+ )
250
+ fp_distr = 'Structural (FP) Distribution'
251
+ MASSAsplit.log_of_distributions(
252
+ fp_distr, fp_total, fp_training,
253
+ fp_test, fp_val, splitting_strategy,
254
+ writelog
255
+ )
256
+ all_distr = 'General Distribution'
257
+ MASSAsplit.log_of_distributions(
258
+ all_distr, all_total, all_training,
259
+ all_test, all_val, splitting_strategy,
260
+ writelog
261
+ )
262
+ writelog.close()
263
+
264
+ # Plot HCAs:
265
+ if flag_dendrogram == True:
266
+ print('\nGenerating dendrogram images. Please wait...')
267
+ MASSAcluster.hca_plot(
268
+ linkage_bio, names, leaves_cluster_bio,
269
+ cutoff_bio, 'bio', directoryfile_output,
270
+ extension_type, dendrogram_xfont_size, test_or_val_molecules
271
+ ) # Bio_Plot: Plot the HCA dendrogram
272
+ MASSAcluster.hca_plot(
273
+ linkage_phch, names, leaves_cluster_phch,
274
+ cutoff_phch, 'PhCh', directoryfile_output,
275
+ extension_type, dendrogram_xfont_size, test_or_val_molecules
276
+ ) # phch_Plot: Plot the HCA dendrogram
277
+ MASSAcluster.hca_plot(
278
+ linkage_fp, names, leaves_cluster_fp,
279
+ cutoff_fp, 'FP', directoryfile_output,
280
+ extension_type, dendrogram_xfont_size, test_or_val_molecules
281
+ ) # fp_Plot: Plot the HCA dendrogram
282
+
283
+ # Output management:
284
+ # It adds, for each molecule, the values of the calculated properties, the identifications of each cluster and which set the molecule belongs to.
285
+ MASSAmoloutput.output_mols(dataframe, file_output)
286
+ print('Completed')
@@ -0,0 +1,214 @@
1
+ import re
2
+ import os
3
+ import argparse
4
+ import numpy as np
5
+
6
+
7
+ def capture_args():
8
+ """Capture arguments from command-line
9
+
10
+ Returns:
11
+ args: Return the arguments to run the algorithm.
12
+ For more information read the --help|-h.
13
+ """
14
+ # Capturing arguments from command line:
15
+ parser = argparse.ArgumentParser(
16
+ prog='MASSA_Algorithm',
17
+ epilog='For more information visit: https://github.com/gcverissimo/MASSA_Algorithm',
18
+ description=(
19
+ 'Help for MASSA Algorithm: Molecular data set sampling '
20
+ '— Training-Test Separation'
21
+ ),
22
+ usage=(
23
+ '%(prog)s [-h] [-i <input_file_name>] [-o <output_file_name] '
24
+ '[-y <splitting_strategy>] [-p <percentage_of_molecules_in_training_set>] '
25
+ '[-b <number_of_biological_activities_in_input_file>] [-s <activity1>,<activity2>,<activityN>]'
26
+ '[-n <number_of_principal_components>] [-v <svd_parameter>] [-l <linkage_method] '
27
+ '[-t <extension_for_images>] [-d <dendrogram_font_size_on_Xaxis>] '
28
+ '[-x <frequency_bar_plot_font_size_on_Xaxis>] [-f <toggle_dendrogram>] '
29
+ '[-e <drop_molecules_with_errors]'
30
+ )
31
+ )
32
+ required = parser.add_argument_group('required arguments')
33
+ required.add_argument('-i', '--input', type=str, help=(
34
+ 'Input the file containing the dataset or its file path. '
35
+ 'Recommended to use an .sdf file to avoid errors.'
36
+ ), required=True)
37
+ required.add_argument('-o', '--output', type=str, help=(
38
+ 'Enter the output file name or file path. '
39
+ 'Recommended to use an .sdf file to avoid errors. '
40
+ 'Image files will be saved to a '
41
+ 'folder within the same directory as the output file.'
42
+ ), required=True)
43
+ optional = parser.add_argument_group('optional arguments')
44
+ optional.add_argument('-y', '--splitting_strategy', type=str, choices=['tt', 'tt-val'],
45
+ metavar='SPLITTING_STRATEGY', default='tt', help=(
46
+ 'Defines the splitting strategy, either into training and test '
47
+ 'sets or into training, test, and validation sets. Options = '
48
+ '\'tt\', \'tt-val\'. tt, means splitting into training and test sets. '
49
+ 'tt-val, means splitting into training, test, and validation sets. '
50
+ 'Default = \'tt\'.'
51
+ ))
52
+ optional.add_argument('-p', '--percentage_of_training', type=float,
53
+ choices=[round(i, 2) for i in list(
54
+ np.arange(0.00, 1.00, 0.01))],
55
+ metavar='PERCENTAGE_OF_TRAINING',
56
+ default=0.8, help=(
57
+ 'Percentage of molecules in training set. '
58
+ 'Must be a number from 0 to 1. Default = 0.8.'
59
+ ))
60
+ optional.add_argument('-b', '--number_of_biological', type=int, default=1,
61
+ help=(
62
+ 'Number of biological activities that will '
63
+ 'be used to separate the set into training and test. Default = 1'
64
+ ))
65
+ optional.add_argument('-s', '--the_biological_activities', type=str, default=None,
66
+ help=(
67
+ 'Enter a list with the names of biological activities '
68
+ 'separated by commas and no spaces. Example: pIC50,pMIC.')
69
+ )
70
+ optional.add_argument('-n', '--number_of_PCs', type=float,
71
+ metavar='NUMBER_OF_PRINCIPAL_COMPONENTS', default=0.85, help=(
72
+ 'Defines the number of principal components to reduce the '
73
+ 'dimensionality of variables related to biological, physicochemical '
74
+ 'and structural domains. If the value is a decimal between 0 and 1, '
75
+ 'the number of principal components is what justifies for '
76
+ '(<input number> * 100) percent of the variance. If the value '
77
+ 'is greater than 1, the number of PCs will be exactly the input '
78
+ 'integer, but PAY ATTENTION: 1st) If the number of PCs is an integer '
79
+ 'and equal to or greater than the number of physicochemical '
80
+ 'properties (7), the PCA step will be bypassed for this domain. '
81
+ '2nd) The same for the biological domain. 3rd) If the number of '
82
+ 'biological activities is less than 3, the PCA step will be '
83
+ 'bypassed for this domain. Default = 0.85.'
84
+ ))
85
+ optional.add_argument('-v', '--svd_solver_for_PCA', type=str, default='full',
86
+ metavar='SVD_SOLVER_FOR_PCA',
87
+ help=('See the sklearn.decomposition.PCA topic on '
88
+ 'https://scikit-learn.org/ '
89
+ 'for more info. Default = full.'))
90
+ optional.add_argument('-l', '--linkage_method', type=str,
91
+ choices=['complete', 'single', 'ward', 'average',
92
+ 'weighted', 'centroid', 'median'], metavar='LINKAGE_METHOD',
93
+ default='complete', help=(
94
+ 'The linkage criterion to use. The algorithm '
95
+ 'will merge the pairs of cluster that minimize '
96
+ 'this criterion. Options = complete, single, ward, '
97
+ 'average, weighted, centroid, median. Default = complete.'
98
+ ))
99
+ optional.add_argument('-t', '--image_type', type=str, default='png',
100
+ help=(
101
+ 'Extension of the image files that will be generated. '
102
+ 'Suggested = png or svg. Default = png.'
103
+ ))
104
+ optional.add_argument('-d', '--dendrogram_xfont_size', type=int, default=5,
105
+ help=(
106
+ 'Sets the font size on the x-axis '
107
+ 'of the dendrogram (molecule labels). Default = 5.'
108
+ ))
109
+ optional.add_argument('-x', '--barplot_xfont_size', type=int, default=9,
110
+ help=(
111
+ 'Sets the font size on the x-axis '
112
+ 'of the bar plot (cluster labels). Default = 9.'
113
+ ))
114
+
115
+ optional.add_argument('-f', '--dendrogram_plot', type=str, choices=['true', 'false'],
116
+ metavar='ENABLE_DENDROGRAM_PLOT', default='true',
117
+ help=('Defines whether or not dendrogram images will '
118
+ 'be generated. Options = true (dendrogram will be generated), '
119
+ 'false (dendrogram will not be generated). Default = true.'
120
+ )
121
+ )
122
+ optional.add_argument('-e', '--drop_errors', type=str, choices=['true', 'false'],
123
+ metavar='DROP_MOLECULES_WITH_ERRORS', default='false', help=(
124
+ 'Ignore chemistry errors, saving only molecules without any errors. '
125
+ 'Default = \'false\'.'
126
+ ))
127
+ args = parser.parse_args()
128
+
129
+ # Definition of arguments:
130
+ # It captures the input name and directory+name:
131
+ file_input = args.input
132
+ # It captures the output name or directory+name:
133
+ undefined_file_output = args.output
134
+ # It captures the file extension for images:
135
+ extension_type = args.image_type
136
+ # It captures the font size for the x-axis of the dendrogram:
137
+ dendrogram_xfont_size = int(args.dendrogram_xfont_size)
138
+ # It captures the font size for the x-axis of the bar plot:
139
+ barplot_xfont_size = int(args.barplot_xfont_size)
140
+ # It captures the percentage for training set:
141
+ training_percent = round(float(args.percentage_of_training), 3)
142
+ # It captures the number of biological activities:
143
+ nbio_activities = int(args.number_of_biological)
144
+ # It captures the input number of PCs:
145
+ ninput_pcs = args.number_of_PCs
146
+ # It captures the svd_solver parameter:
147
+ svd_parameter = args.svd_solver_for_PCA
148
+ # It captures the linkage method:
149
+ linkage_method = args.linkage_method
150
+ # It captures the flag for the dendrogram plot.
151
+ flag_dendrogram = str(args.dendrogram_plot).lower()
152
+ # It captures the selected splitting strategy.
153
+ flag_strategy = str(args.splitting_strategy).lower()
154
+ # It captures whether or not to ignore chemistry errors.
155
+ drop = str(args.drop_errors).lower()
156
+
157
+ if args.the_biological_activities != None:
158
+ # It creates a list with the names of the biological activities to be searched for.
159
+ bioactivities_as_args = args.the_biological_activities.split(',')
160
+ else:
161
+ bioactivities_as_args = None
162
+
163
+ # If a directory path is passed along with the filename it copies only the directory path.
164
+ if ('\\' in undefined_file_output) or ('/' in undefined_file_output):
165
+ outputsplitted = re.split('\\\\|/', undefined_file_output)
166
+ outputsplitted[-1] = ''
167
+ dir_fileoutput = '/'.join(outputsplitted)
168
+ del outputsplitted
169
+ else: # If only the filename is passed, the directory path is taken by os.getcwd().
170
+ dir_fileoutput = str(os.getcwd()) + '/'
171
+
172
+ if ninput_pcs > 1:
173
+ npcs = int(ninput_pcs)
174
+ elif (ninput_pcs > 0) and (ninput_pcs <= 1):
175
+ npcs = float(ninput_pcs)
176
+ else:
177
+ print(' ERROR: The defined number of main components is invalid.')
178
+ exit()
179
+
180
+ if flag_dendrogram == 'true':
181
+ flag_dendrogram = True
182
+ elif flag_dendrogram == 'false':
183
+ flag_dendrogram = False
184
+ else:
185
+ print(
186
+ ' ERROR: ENABLE_DENDROGRAM_PLOT parameter only accepts \'true\' or \'false\'.')
187
+ exit()
188
+
189
+ if drop == 'true':
190
+ drop = True
191
+ elif drop == 'false':
192
+ drop = False
193
+ else:
194
+ print(
195
+ ' ERROR: DROP_MOLECULES_WITH_ERRORS parameter only accepts \'true\' or \'false\'.')
196
+ exit()
197
+
198
+ return (
199
+ file_input,
200
+ undefined_file_output,
201
+ dir_fileoutput,
202
+ extension_type,
203
+ dendrogram_xfont_size,
204
+ barplot_xfont_size,
205
+ training_percent,
206
+ nbio_activities,
207
+ bioactivities_as_args,
208
+ npcs,
209
+ svd_parameter,
210
+ linkage_method,
211
+ flag_dendrogram,
212
+ flag_strategy,
213
+ drop
214
+ )