-
Notifications
You must be signed in to change notification settings - Fork 2
/
CInput.cpp
executable file
·209 lines (200 loc) · 7.36 KB
/
CInput.cpp
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#include "CMainInc.h"
#include "Util/CUtilInc.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
using namespace GCTFFind;
CInput* CInput::m_pInstance = 0L;
CInput* CInput::GetInstance(void)
{
if(m_pInstance != 0L) return m_pInstance;
m_pInstance = new CInput;
return m_pInstance;
}
void CInput::DeleteInstance(void)
{
if(m_pInstance == 0L) return;
delete m_pInstance;
m_pInstance = 0L;
}
CInput::CInput(void)
{
strcpy(m_acInMrcTag, "-InMrc");
strcpy(m_acOutMrcTag, "-OutMrc");
strcpy(m_acOutCtfTag, "-OutCtf");
strcpy(m_acAngFileTag, "-AngFile");
strcpy(m_acKvTag, "-kV");
strcpy(m_acCsTag, "-Cs");
strcpy(m_acAmpContrastTag, "-AmpContrast");
strcpy(m_acPixelSizeTag, "-PixSize");
strcpy(m_acExtPhaseTag, "-ExtPhase");
strcpy(m_acTileSizeTag, "-TileSize");
strcpy(m_acTiltRangeTag, "-TiltRange");
strcpy(m_acLogSpectTag, "-LogSpect");
strcpy(m_acSerialTag, "-Serial");
strcpy(m_acInSuffixTag, "-InSuffix");
strcpy(m_acGpuIDTag, "-Gpu");
//------------------------------------
m_fKv = 300.0f;
m_fCs = 2.7f; // mm
m_fAmpContrast = 0.07f;
m_fPixelSize = 1.0f; // A
m_afExtPhase[0] = 0.0f; // degree
m_afExtPhase[1] = 0.0f; // not search when 0 or negative
m_afTiltRange[0] = 0.0f;
m_afTiltRange[1] = 0.0f;
m_iLogSpect = 0;
m_iTileSize = 512;
m_iGpuID = 0;
memset(m_acInMrcFile, 0, sizeof(m_acInMrcFile));
memset(m_acOutMrcFile, 0, sizeof(m_acOutMrcFile));
memset(m_acOutCtfFile, 0, sizeof(m_acOutCtfFile));
memset(m_acAngFile, 0, sizeof(m_acAngFile));
memset(m_acInSuffix, 0, sizeof(m_acInSuffix));
}
CInput::~CInput(void)
{
}
void CInput::ShowTags(void)
{
printf("%-15s\n"
" 1. Input MRC file that contains single image or a stack of\n"
" frames. In the latter case, CTF will be estimated for \n"
" each frame.\n\n", m_acInMrcTag);
printf("%-15s\n"
" 1. Output MRC file that contains the averaged\n"
" amplitude spectrum.\n"
" 2. If the input is a stack of frames, the output will be\n"
" a stack of spectra, one for each frame.\n\n", m_acOutMrcTag);
printf("%-15s\n"
" 1. Output text file containing the estimated ctf parameters\n"
" one line per tilt image.\n\n", m_acOutCtfTag);
printf("%-15s\n"
" 1. Input text file that contains a single column for tilt\n"
" angles. The order must match the images in the input\n"
" MRC file.\n"
" 2. Optional. When not given, the output CTF file will not\n"
" have columns for tilt angle.\n\n", m_acAngFileTag);
printf("%-15s\n"
" 1. Min and max tilt angles of the tilt series if it is\n"
" collected with a fixed tilt step.\n\n", m_acTiltRangeTag);
printf("%-15s\n"
" 1. High tension in keV.\n\n", m_acKvTag);
printf("%-15s\n"
" 1. Spherical aberration Cs in mm\n\n", m_acCsTag);
printf("%-15s\n"
" 1. Amplitude contrast, default 0.07.\n\n", m_acAmpContrastTag);
printf("%-15s\n"
" 1. Pixel size in A.\n\n", m_acPixelSizeTag);
printf("%-15s\n"
" 1. Extra phase shift and search range in degree.\n\n",
m_acExtPhaseTag);
printf("%-15s\n"
" 1. Tile size in pixels.\n\n", m_acTileSizeTag);
printf("%-15s\n"
" 1. Calculate logarithmic spectrum. It is not enabled by default.\n\n",
m_acLogSpectTag);
printf("%-15s\n"
" 1. Image or tilt series with their file names ended with the\n"
" specified suffix will be loaded for CTF estimation.\n"
" 2. In this case, -InMrc and -InSuffix are jointly used to\n"
" to screen files for CTF estimation.\n\n", m_acInSuffixTag);
printf("%-15s\n"
" 1. Enable serial CTS estimation where there are multiple files\n"
" to be processed.\n"
" 2. -Serial 1 enables serial processing.\n\n", m_acSerialTag);
printf("%-15s\n"
" 1. GPU IDs. Default 0.\n"
" 2. User can choose any other number.\n", m_acGpuIDTag);
}
void CInput::Parse(int argc, char* argv[])
{
m_argc = argc;
m_argv = argv;
//------------
int aiRange[2];
CParseArgs aParseArgs;
aParseArgs.Set(argc, argv);
aParseArgs.FindVals(m_acInMrcTag, aiRange);
aParseArgs.GetVal(aiRange[0], m_acInMrcFile);
//-------------------------------------------
aParseArgs.FindVals(m_acOutMrcTag, aiRange);
aParseArgs.GetVal(aiRange[0], m_acOutMrcFile);
//--------------------------------------------
aParseArgs.FindVals(m_acOutCtfTag, aiRange);
aParseArgs.GetVal(aiRange[0], m_acOutCtfFile);
//--------------------------------------------
aParseArgs.FindVals(m_acInSuffixTag, aiRange);
aParseArgs.GetVal(aiRange[0], m_acInSuffix);
//------------------------------------------
aParseArgs.FindVals(m_acAngFileTag, aiRange);
aParseArgs.GetVal(aiRange[0], m_acAngFile);
//-------------------------------------------
aParseArgs.FindVals(m_acKvTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_fKv);
//----------------------------------
aParseArgs.FindVals(m_acCsTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_fCs);
//----------------------------------
aParseArgs.FindVals(m_acAmpContrastTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_fAmpContrast);
//-------------------------------------------
aParseArgs.FindVals(m_acPixelSizeTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_fPixelSize);
//-----------------------------------------
aParseArgs.FindVals(m_acExtPhaseTag, aiRange);
if(aiRange[1] > 2) aiRange[1] = 2;
aParseArgs.GetVals(aiRange, m_afExtPhase);
if(m_afExtPhase[1] < 0) m_afExtPhase[1] = 0.0f;
//---------------------------------------------
aParseArgs.FindVals(m_acTiltRangeTag, aiRange);
if(aiRange[1] > 2) aiRange[1] = 2;
aParseArgs.GetVals(aiRange, m_afTiltRange);
m_afTiltRange[0] = fmax(m_afTiltRange[0], -70.1f);
m_afTiltRange[1] = fmin(m_afTiltRange[1], 70.1f);
//-----------------------------------------------
aParseArgs.FindVals(m_acTileSizeTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_iTileSize);
//----------------------------------------
aParseArgs.FindVals(m_acLogSpectTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_iLogSpect);
//----------------------------------------
aParseArgs.FindVals(m_acSerialTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_iSerial);
//--------------------------------------
aParseArgs.FindVals(m_acGpuIDTag, aiRange);
if(aiRange[1] > 1) aiRange[1] = 1;
aParseArgs.GetVals(aiRange, &m_iGpuID);
mPrint();
}
void CInput::mPrint(void)
{
printf("\n");
printf("%-15s %s\n", m_acInMrcTag, m_acInMrcFile);
printf("%-15s %s\n", m_acInSuffixTag, m_acInSuffix);
printf("%-15s %s\n", m_acOutMrcTag, m_acOutMrcFile);
printf("%-15s %s\n", m_acOutCtfTag, m_acOutCtfFile);
printf("%-15s %s\n", m_acAngFileTag, m_acAngFile);
//-------------------------------------------------
printf("%-15s %f\n", m_acKvTag, m_fKv);
printf("%-15s %f\n", m_acCsTag, m_fCs);
printf("%-15s %f\n", m_acAmpContrastTag, m_fAmpContrast);
printf("%-15s %f\n", m_acPixelSizeTag, m_fPixelSize);
printf("%-15s %f %f\n", m_acExtPhaseTag,
m_afExtPhase[0], m_afExtPhase[1]);
printf("%-15s %d\n", m_acTileSizeTag, m_iTileSize);
printf("%-15s %.2f %.2f\n", m_acTiltRangeTag,
m_afTiltRange[0], m_afTiltRange[1]);
printf("%-15s %d\n", m_acLogSpectTag, m_iLogSpect);
printf("%-15s %d\n", m_acSerialTag, m_iSerial);
printf("%-15s %d\n", m_acGpuIDTag, m_iGpuID);
//--------------------------------------------
printf("\n");
}