-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBatchUtils.cpp
130 lines (116 loc) · 3.4 KB
/
BatchUtils.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
// $Id: BatchUtils.cpp,v 1.8 2009/06/25 04:03:33 samn Exp $
#include "stdafx.h"
#include "BatchUtils.h"
#include "FileUtils.h"
#include "StringUtils.h"
using namespace std;
void ParseRatings(vector<string>& vstr,vector<double>& vrate)
{
vrate.push_back(0); //for background cluster
int i = 0, isz = vstr.size();
for(i=0;i<isz;i++)
vrate.push_back(atof(vstr[i].c_str()));
}
void ParseRatings(string& str,vector<string>& vstr)
{
string strDelim("[],");
Split(str,strDelim,vstr);
}
void ParseRatings(string& str,vector<double>& vrate)
{
vector<string> vstr;
ParseRatings(str,vstr);
ParseRatings(vstr,vrate);
}
bool ParseQBatchLines(vector<string>& vstr, vector<BatchRec>& vqb,int& iBatchMode)
{
iBatchMode = BATCH_QUAL_USER; //quality of user-made clusters
int iSz = vstr.size(), i = 0;
if(!iSz) return false;
bool bRead = false;
string strDelim("\t");
string strBaseDir(vstr[0]);//first line is base directory from which all else is relative
if(strBaseDir[strBaseDir.size()-1] != '\\')
strBaseDir += '\\';
for(i=1;i<iSz;i++)
{
vector<string> vtoks;
Split(vstr[i],strDelim,vtoks);
if(vtoks.size()>=6)
{
bRead = true;
BatchRec oB;
oB.strBPF = strBaseDir + vtoks[0];
if(!stricmp(vtoks[0].c_str(),"orig"))//quality of original cluster values
iBatchMode = BATCH_QUAL_ORIG; //(auto-clustered, or saved by user without .cl)
oB.strCL = strBaseDir + vtoks[1];
oB.iTetrode = atoi(vtoks[2].c_str());
oB.dPrct = atof(vtoks[3].c_str());
oB.outCL = strBaseDir + vtoks[4];
ParseRatings(vtoks[5],oB.vRatings);
oB.bReadyToRun = true;
vqb.push_back(oB);
}
}
return bRead;
}
bool ParseTSBatchLines(vector<string>& vstr, vector<BatchRec>& vb)
{
int iSz = vstr.size(), i = 0;
if(!iSz) return false;
bool bRead = false;
string strDelim("\t");
string strBaseDir(vstr[0]);//first line is base directory from which all else is relative
if(strBaseDir[strBaseDir.size()-1] != '\\')
strBaseDir += '\\';
for(i=1;i<iSz;i++)
{
vector<string> vtoks;
Split(vstr[i],strDelim,vtoks);
if(vtoks.size()>=2)
{
bRead = true;
BatchRec oB;
oB.strBPF = strBaseDir + vtoks[0]; //input BPF
oB.outBPF = strBaseDir + vtoks[1]; //output BPF
oB.bReadyToRun = true;
vb.push_back(oB);
}
}
return bRead;
}
bool ParseACBatchLines(vector<string>& vstr, vector<BatchRec>& vb)
{
int iSz = vstr.size(), i = 0;
if(!iSz) return false;
bool bRead = false;
string strDelim("\t");
string strBaseDir(vstr[0]);//first line is base directory from which all else is relative
if(strBaseDir[strBaseDir.size()-1] != '\\')
strBaseDir += '\\';
for(i=1;i<iSz;i++)
{ vector<string> vtoks;
Split(vstr[i],strDelim,vtoks);
if(vtoks.size()>=7)
{ BatchRec oB;
oB.strBPF = strBaseDir + vtoks[0]; //input BPF
oB.outBPF = strBaseDir + vtoks[1]; //output BPF
oB.iACType = atoi(vtoks[2].c_str());
if(oB.iACType==CLUST_KM || oB.iACType==CLUST_KK)
{
oB.iMinClust = atoi(vtoks[3].c_str());
oB.iMaxClust = atoi(vtoks[4].c_str());
oB.iIters = atoi(vtoks[5].c_str());
if(oB.iACType==CLUST_KM)
oB.iDBIters = atoi(vtoks[6].c_str());
else if(oB.iACType==CLUST_KK)
oB.iMaxKKClust = atoi(vtoks[6].c_str());
oB.bAutoC = true;
oB.bReadyToRun = true;
vb.push_back(oB);
bRead = true;
}
}
}
return bRead;
}