1 | // $Id: DataSet.cc 688 2006-10-17 11:10:03Z peter $ |
---|
2 | |
---|
3 | #include "DataSet.h" |
---|
4 | |
---|
5 | #include <set> |
---|
6 | |
---|
7 | namespace theplu { |
---|
8 | namespace yat { |
---|
9 | namespace microarray { |
---|
10 | |
---|
11 | DataSet::DataSet(const classifier::MatrixLookup& data, |
---|
12 | const classifier::Target& target, |
---|
13 | const std::vector<std::string>& probe) |
---|
14 | : data_(data), probe_(probe), target_(target) |
---|
15 | { |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | DataSet::DataSet(const DataSet& first, |
---|
20 | const std::vector<std::string>& probes) |
---|
21 | : data_(classifier::MatrixLookup(0,0)), target_(first.target()) |
---|
22 | { |
---|
23 | using std::vector; |
---|
24 | using std::string; |
---|
25 | std::set<std::string> probe_set; |
---|
26 | std::vector<size_t> index; |
---|
27 | |
---|
28 | typedef std::set<std::string>::iterator ProbeIter; |
---|
29 | |
---|
30 | // making a probe_set and checking for duplicates |
---|
31 | for (vector<string>::const_iterator i=probes.begin(); i!=probes.end();++i){ |
---|
32 | ProbeIter iter = probe_set.lower_bound((*i)); |
---|
33 | if (iter!=probe_set.end() && (*iter) == (*i)){ |
---|
34 | std::cerr << "DataSet: Error: " << (*iter) << "found twice.\n"; |
---|
35 | } |
---|
36 | probe_set.insert(iter, *i); |
---|
37 | } |
---|
38 | |
---|
39 | std::vector<size_t> new_index; |
---|
40 | std::set<std::string> probe_set2; |
---|
41 | for (size_t i = 0; i<first.probe().size(); ++i){ |
---|
42 | ProbeIter iter = probe_set.find(first.probe()[i]); |
---|
43 | if (iter!=probe_set.end()) { |
---|
44 | ProbeIter iter = probe_set2.lower_bound(first.probe()[i]); |
---|
45 | if (iter!=probe_set2.end() && (*iter) == first.probe()[i]){ |
---|
46 | std::cerr << "DataSet: Warning: " << (*iter) << "found twice.\n"; |
---|
47 | } |
---|
48 | else { |
---|
49 | probe_set2.insert(iter, first.probe()[i]); |
---|
50 | new_index.push_back(i); |
---|
51 | probe_.push_back(first.probe()[i]); |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | data_ = classifier::MatrixLookup(first.data(),new_index,true); |
---|
56 | } |
---|
57 | |
---|
58 | }}} // end of namespace microarray, yat, and theplu |
---|