File: sharedordervector.h

package info (click to toggle)
mothur 1.48.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,692 kB
  • sloc: cpp: 161,866; makefile: 122; sh: 31
file content (85 lines) | stat: -rwxr-xr-x 2,651 bytes parent folder | download | duplicates (3)
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
#ifndef SHAREDORDER_H
#define SHAREDORDER_H
/*
 *  sharedorder.h
 *  Mothur
 *
 *  Created by Sarah Westcott on 12/9/08.
 *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
 *
 */
 
 /* This class is a child to datavector.  It represents OTU information at a certain distance. 
	It is similiar to an order vector except each member of data knows which group it belongs to.
	Each member of the internal container "data" represents is an individual which knows the OTU from which it came, 
	the group it is in and the abundance is equal to the OTU number.  */


#include "datavector.hpp"
#include "sabundvector.hpp"
#include "rabundvector.hpp"
#include "sharedrabundvectors.hpp"
#include "groupmap.h"

struct individual {
		string group;
		int binNumber;
		bool operator()(const individual& i1, const individual& i2) {
		return (i1.binNumber > i2.binNumber);
		}
	individual() {  group = ""; binNumber = 0; }
};


class SharedOrderVector : public DataVector {
	
public:
	SharedOrderVector();
//	SharedOrderVector(int ns, int nb=0, int mr=0)	: DataVector(), data(ns, -1), maxRank(0), numBins(0), numSeqs(0) {};
	SharedOrderVector(const SharedOrderVector& ov)	: DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){	updateStats();}};

	SharedOrderVector(string, vector<individual>);
	SharedOrderVector(ifstream&, vector<string>&, string&);
	~SharedOrderVector(){};
	
	
	individual get(int);
	void resize(int);
	int size();
	void print(ostream&);
	vector<individual>::iterator begin();
	vector<individual>::iterator end();
	void push_back(int, string);  //abundance/OTUNUmber, group  MUST CALL UPDATE STATS AFTER PUSHBACK!!!
	void updateStats();
	void clear();

	int getNumBins();
	int getNumSeqs();
	int getMaxRank();
    
    vector<string> getGroups() { sort(allGroups.begin(), allGroups.end()); return allGroups; }
		
	RAbundVector getRAbundVector();
	SAbundVector getSAbundVector();
	OrderVector getOrderVector(map<string,int>*);
	SharedOrderVector getSharedOrderVector();
	SharedRAbundVectors* getSharedRAbundVector(string);  //get the sharedRabundvector for a sepecific group
	SharedRAbundVectors* getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
	
private:
	//GroupMap* groupmap;
    vector<string> currentLabels;
	vector<individual>  data;
    vector<string> allGroups;
	map< int, vector<individual> >::iterator it;
	int maxRank;
	int numBins;
	int numSeqs;
	bool needToUpdate;
	void set(int, int, int, string);	//index, OTU, abundance, group
    void setNamesOfGroups(string seqGroup);
	
};

#endif