Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Buote Xu authored and Buote Xu committed Jun 26, 2012
1 parent 32dc356 commit 61a15ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions examples/example-bruker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ int main(int argc, char * argv[]) {
}
typedef SetA<Centroid,1,0 > SetType;
typedef SetType::ResultType ResultType;
typedef unsigned int LabelType;

ptime start = microsec_clock::universal_time();

SNSplitter<SetType> splitter(options);
SNSplitter<SetType, LabelType> splitter(options);

CentroidBoxGenerator gen(10,1);
ResultType test = std::vector<std::vector<unsigned int> >();
Expand All @@ -49,7 +50,7 @@ int main(int argc, char * argv[]) {
<< td.total_seconds()
<< std::endl;
std::cout << "finding connected components... ";
std::vector<unsigned int> labels;
std::vector<LabelType> labels;
unsigned int nComponents = findConnectedComponents(fullAdjList, labels);
std::vector<unsigned int> counter(nComponents, 0);
for (std::vector<LabelType>::size_type i = 0; i < labels.size(); ++i) {
Expand All @@ -64,14 +65,13 @@ int main(int argc, char * argv[]) {
std::sort(counter.begin(), counter.end());
std::reverse(counter.begin(), counter.end());


/*
std::ofstream ofs((options.outputfileName_ + ".counts").c_str());
ofs << "Count" << std::endl;
typedef std::map<unsigned int, unsigned int>::const_iterator It;
for (It it = counter.begin(); it != counter.end(); ++it) {
ofs << *it << std::endl;
}

std::ifstream ifs(options.inputfileName_.c_str());
std::vector<Centroid> centroids;
int sn = 0;
Expand Down Expand Up @@ -102,6 +102,6 @@ int main(int argc, char * argv[]) {
std::cout << i << ": " << labelcounts[labelcounts.size() - i] << std::endl;
}
std::ofstream ofs(options.outputfileName_.c_str());

*/

}
14 changes: 7 additions & 7 deletions examples/splitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int parseProgramOptions(int argc, char* argv[], ProgramOptions& options)
}
return 1;
}
template <ContainerType>
template <typename ContainerType>
unsigned int
parseString(const std::string & str, ContainerType & centroids, int sn, bool onlyheader = false) {
float mz=0, massrange_lo=0, massrange_hi=0, rt=0;
Expand All @@ -98,7 +98,7 @@ parseString(const std::string & str, ContainerType & centroids, int sn, bool onl
return numentries;
}

template <class SetType>
template <class SetType, class LabelType = unsigned int>
struct
SNSplitter {
private:
Expand All @@ -108,7 +108,7 @@ SNSplitter {

public:
typedef typename SetType::ResultType ResultType;
typedef unsigned int LabelType;
typedef typename std::vector<unsigned int>::size_type size_type;
SNSplitter(const ProgramOptions& options) : options_(options) {

overlap_ = std::max(options_.minClusterSize_ * options_.snWindowSize_ - 1, options_.snWindowSize_);
Expand All @@ -120,11 +120,11 @@ SNSplitter {
std::vector<LabelType> labels;
LabelType nComponents = findConnectedComponents(adjList, labels);
std::vector<unsigned int> counter(nComponents, 0);
for (std::vector<LabelType>::size_type i = 0; i < labels.size(); ++i) {
for (size_type i = 0; i < labels.size(); ++i) {
++counter[labels[i] - 1];
}
typedef typename ResultType::value_type InnerType;
for (std::vector<LabelType>::size_type i = 0; i < labels.size(); ++i) {
for (size_type i = 0; i < labels.size(); ++i) {
if (counter[labels[i]-1] < options_.minClusterSize_) {
InnerType().swap(adjList[i]);
//std::copy(adjList[i].begin(), adjList[i].end(), std::back_inserter(filteredAdjList[i]));
Expand All @@ -133,9 +133,9 @@ SNSplitter {
return adjList;
}
ResultType
joinAdjLists(const ResultType & filteredAdjList, ResultType & fullAdjList, typename ResultType::size_type offset) {
joinAdjLists(const ResultType & filteredAdjList, ResultType & fullAdjList, size_type offset) {
//fullAdjList.resize(filteredAdjList.size() + offset);
typename ResultType::size_type index;
size_type index;
typedef typename ResultType::value_type InnerType;
typename ResultType::value_type::const_iterator it1;
for (index = 0; index < filteredAdjList.size(); ++index) {
Expand Down

0 comments on commit 61a15ea

Please sign in to comment.