/usr/include/libphylo/sequenceContainer.h is in rate4site 3.0.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | // $Id: sequenceContainer.h 10178 2012-01-10 20:32:58Z cohenofi $
#ifndef ___SEQUENCE_CONTAINER
#define ___SEQUENCE_CONTAINER
#include "definitions.h"
#include "sequence.h"
#include "gainLossAlphabet.h"
class sequenceContainer {
public:
class taxaIterator;
friend class taxaIterator;
class constTaxaIterator;
friend class constTaxaIterator;
//------------------------------------------------------------
//constructors:
explicit sequenceContainer();
sequenceContainer(const sequenceContainer& other,const alphabet *inAlph);
virtual ~sequenceContainer();
//questions only:
const int seqLen() const {return _seqDataVec.empty()? 0 : _seqDataVec[0].seqLen();}
const int numberOfSeqs() const {return _seqDataVec.size();}
const int alphabetSize() const {return _seqDataVec.empty()? 0 : _seqDataVec[0].getAlphabet()->size();}
const vector<string>& getGeneralRemarks() const {return _generalRemarks;}
const int makeSureAllSeqAreSameLengthAndGetLen(bool bAugumentShorterSeqs = false); //if bAugumentShorterSeqs=true then add gap characters at the end of short seqeunces
const int getId(const string &seqName, bool issueWarninInNotFound=true) const;//return -1 if not found...
sequence& operator[](const int id) {return _seqDataVec[_id2place[id]];} // get the ID of the sequence. Return the sequence itself.
const sequence& operator[](const int id) const {return _seqDataVec[_id2place[id]];}
const bool operator==(const sequenceContainer& sq) const;
const sequence& getSeqDirectFromDataVec(int i){return _seqDataVec[i];}
const Vstring names() const; // return a vector<string> of the names of all the sequences.
const string& name(const int id) const {return _seqDataVec[_id2place[id]].name();};
const alphabet* getAlphabet() const {return _seqDataVec[0].getAlphabet();}
const vector<int> getAlphabetDistribution(bool isCountUnknown=false) const;
const vector<int> getAlphabetDistribution(int pos,bool isCountUnknown=false) const;
//returns the number of positions that are invariable (all seqs are identical
int getInvariablePosNum() const;
bool isInvariable(const int pos) const;
// computed the number of sequences without gaps at a specific position
// for example, if the multiple sequence alignment is
// AT-
// AG-
// A-M
// numberOfSequencesWithoutGaps(0) = 3
// numberOfSequencesWithoutGaps(1) = 2
// numberOfSequencesWithoutGaps(2) = 1
int numberOfSequencesWithoutGaps(const int pos) const;
int numberOfSequencesWithoutUnknowns(const int pos) const;
//make changes:
void resize(int t,const alphabet* inAlph) {
if (inAlph == NULL) {
errorMsg::reportError("cannot resize when the alphabet is unknown");
}
sequence s(inAlph);
_seqDataVec.resize(t,s);
}
void add(const sequence& inSeq);
void remove(const int idSeq);
void removeAll();
void removeIdenticalSequences();
int placeToId(const int place) const {return _seqDataVec[place].id();}; //get place in the vector and return the id of the sequence
void addGeneralRemark(const string& inRemark) {_generalRemarks.push_back(inRemark);}
void changeGaps2MissingData();
//removePositions: the positions to be removed are marked as '1' in posToRemoveVec
//all other positions are '0'
void removePositions(const Vint & posToRemoveVec);
sequenceContainer getSubSeq(const int startPos, const int endPos);
int getNumOfOccurancesPerPos(const int pos, const char charId);
void removeGapPositions();
void removeGapPositionsAllSeqs();
void removeGapPositionsAccordingToAReferenceSeq(const string & seqName);
void changeDotsToGoodCharacters();
void removeUnknownPositionsAccordingToAReferenceSeq(const string & seqName);
void concatenate(sequenceContainer& other);
void startZeroSequenceContainerGL(const sequenceContainer &sc, const gainLossAlphabet& alph, const int minNumOfOnes=1, const int minNumOfZeros=0);
public:
sequence::Iterator begin(const int id){//iterface to sequence iterator
sequence::Iterator temp;
temp.begin(_seqDataVec[id]);
return temp;
}
sequence::Iterator end(const int id){//iterface to sequence iterator
sequence::Iterator temp;
temp.end(_seqDataVec[id]);
return temp;
}
class taxaIterator {
public:
explicit taxaIterator(){};
~taxaIterator(){};
void begin(sequenceContainer & inSeqCont){
_pointer = inSeqCont._seqDataVec.begin();
}
void end(sequenceContainer & inSeqCont){
_pointer = inSeqCont._seqDataVec.end();
}
sequence& operator* () {return *_pointer;}
sequence const & operator* () const {return *_pointer;}
sequence * operator-> () {return &*_pointer;} //MATAN- CHECK!!!
sequence const * operator-> () const {return &* _pointer;} // MATAN - CHECK!!!
void operator ++() {++_pointer;}
void operator --() { --_pointer; }
bool operator != (const taxaIterator& rhs){return (_pointer != rhs._pointer);}
bool operator == (const taxaIterator& rhs){return (_pointer == rhs._pointer);}
private:
vector<sequence>::iterator _pointer;
};//end if class taxaIterator
class constTaxaIterator {
public:
explicit constTaxaIterator(){};
~constTaxaIterator(){};
void begin(const sequenceContainer & inSeqCont){
_pointer = inSeqCont._seqDataVec.begin();
}
void end(const sequenceContainer & inSeqCont){
_pointer = inSeqCont._seqDataVec.end();
}
sequence const & operator*() const {return *_pointer;}
sequence const * operator->() const {return &*_pointer;}// MATAN - CHECK!!!
void operator ++() {++_pointer;}
void operator --() { --_pointer; }
bool operator != (const constTaxaIterator& rhs) {
return (_pointer != rhs._pointer);
}
bool operator == (const constTaxaIterator& rhs) {
return (_pointer == rhs._pointer);
}
private:
vector<sequence>::const_iterator _pointer;
};
public: // interfaces to iterators
taxaIterator taxaBegin(const int id=0){// interface to taxaIterator
taxaIterator temp;
temp.begin(*this);
return temp;
}
taxaIterator taxaEnd(){// interface to taxaIterator
taxaIterator temp;
temp.end(*this);
return temp;
}
constTaxaIterator constTaxaBegin() const{ //interface to const taxaIter
constTaxaIterator temp;
temp.begin(*this);
return temp;
}
constTaxaIterator constTaxaEnd() const{
constTaxaIterator temp;
temp.end(*this);
return temp;
}
private:
vector<sequence> _seqDataVec;
vector<string> _generalRemarks;
vector<int> _id2place;
};
#endif
|