-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoCCS.py
159 lines (122 loc) · 5.01 KB
/
autoCCS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import argparse
from multiCCS import multi
from singleCCS import single
from utils import get_config, is_valid
##########################################################################
# ArgumentParser
##########################################################################
parser = argparse.ArgumentParser()
parser.add_argument(
'--mode', type=str, required=True, choices=['single','multi'], default="single",
help='single: single-field mode, multi: multi-field mode')
parser.add_argument(
'--feature_files', required=True, type=str,
help='feature files to determine CCS values')
parser.add_argument(
'--framemeta_files', required=False, type=str, default=None,
help='frame meta info file for samples')
parser.add_argument(
'--output_dir', type=str, required=True, default='./',
help='a directory to store output files')
parser.add_argument(
'--config_file', type=str, required=True, default='config.xml',
help='Configuration file')
################################################
# args for single-field
################################################
parser.add_argument(
'--calibrant_file', type=str,
help='calibrant file contains the target m/z and CCS')
parser.add_argument(
'--tune_mix_regexp', type=str,
help='a regular expression for tune mix sample files')
parser.add_argument(
'--tune_mix_frame_regexp', type=str, default='',
help='frame feature files to calibrate CCS values')
parser.add_argument(
'--calibration_curves', type=str,
help='calibration curves obtained from Tune Mix samples')
parser.add_argument(
'--sample_meta', type=str,
help='meta info file for samples')
parser.add_argument(
'--standard_mass', type=float,
help='internal standard mass')
parser.add_argument(
'--colname_for_sample_type', type=str, default="SampleType",
help='colname for sample type in sample_meta')
parser.add_argument(
'--colname_for_filename', type=str, default="RawFileNameNew",
help='colname for filename in sample_meta')
parser.add_argument(
'--colname_for_ionization', type=str, default="IonPolarity",
help='colname for ionization in sample_meta')
parser.add_argument(
'--tunemix_sample_type', type=str, default="AgilentTuneMix",
help='sample type for tunemix in sample_meta')
parser.add_argument(
'--skip_calibrated_colname', type=str, default=None,
help='a column name for the calibrated CCS values \
when you want to skip some files already having calibrated CCS values')
parser.add_argument(
'--single_mode', type=str, choices=['fit','ccs','batch'], default="fit",
help='fit: curve fitting, ccs: CCS calibration')
parser.add_argument(
'--ppm', type=float,
help='ppm of mz tolerance. It will override mz_tolerance in config_params')
parser.add_argument(
'--degree', type=int, default=1,
help='Degree of the fitting polynomial for CCS calibration curves')
parser.add_argument(
'--calib_method', type=str, choices=['poly','power', 'linearized_power'], default="poly",
help='poly: Polynormial Function, power: Linearized Power Function')
################################################
# args for multi-field
################################################
parser.add_argument(
'--target_list_file', type=str, default='TargetList.txt',
help='Target list file (Tab-delimited text format)')
# parser.add_argument(
# '--data_folder', type=str, default='./',
# help='Data folder containing all the cef and meta data files')
parser.add_argument(
'--output', type=str, default='ccs_table.tsv',
help='Output file to save a output table')
parser.add_argument(
'--r2_threshold', type=float, default=0.99,
help='threshold value for r2')
parser.add_argument(
'--num_isotopes_threshold', type=int, default=1,
help='threshold value for num_isotopes')
parser.add_argument(
'--intensity_rank_threshold', type=int, default=3,
help='threshold value for peak intensity rank in m/z window')
parser.add_argument(
'--threshold_n_fields', type=int, default=3,
help='threshold value for the minimum number of fields for linear regression')
parser.add_argument(
'--maxint', action='store_true',
help='select max intensive peaks for ccs computation')
parser.add_argument(
'--format', type=str, choices=['cef','mzmine'], default='mzmine',
help='file format for the features, e.g., cef or mzmine')
FLAGS = {}
##########################################################################
def main(FLAGS):
print("#"*50)
print("# Parameters:", FLAGS)
print("#"*50)
# read a set of configuration parameters
config_params = get_config(FLAGS.config_file)
print(config_params)
assert is_valid(FLAGS, config_params), \
"Please check out parameters again."
if FLAGS.mode=="single":
print("Single-Field Mode")
single(FLAGS, config_params)
elif FLAGS.mode=="multi":
print("Multi-Field Mode")
multi(FLAGS, config_params)
if __name__ == '__main__':
FLAGS = parser.parse_args()
main(FLAGS)