42 #include "../Alphabet/CodonAlphabet.h" 45 #include <Bpp/Text/TextTools.h> 59 for (
size_t i = 0; i < size; ++i)
70 const vector<string>& seqNames)
73 SequenceContainer* sc = createContainerOfSpecifiedSize(alphabet, seqNames.size());
85 bool checkNames = outputCont.getNumberOfSequences() > 0;
86 for (
size_t i = 0; i < selection.size(); i++)
88 outputCont.addSequence(sequences.getSequence(selection[i]), checkNames);
96 const std::vector<std::string>& selection,
99 bool checkNames = outputCont.getNumberOfSequences() > 0;
100 for (
size_t i = 0; i < selection.size(); i++)
104 outputCont.addSequence(sequences.getSequence(selection[i]), checkNames);
108 if (sequences.hasSequence(selection[i]))
109 outputCont.addSequence(sequences.getSequence(selection[i]), checkNames);
121 for (
size_t i = 0; i < names.size(); i++)
126 for (
size_t j = 0; j < selection.size() && !test; j++)
128 test = (selection[j] == i);
141 if (seqNames.size() <= 1)
144 for (
size_t i = 1; i < seqNames.size(); i++)
158 for (
size_t j = 0; j < names.size(); j++)
160 vector<int> seq = sequences.
getContent(names[j]);
161 for (
size_t i = 0; i < seq.size(); i++)
165 n +=
static_cast<double>(seq.size());
168 if (pseudoCount != 0)
171 for (
int i = 0; i < static_cast<int>(pA->
getSize()); i++)
176 n += pseudoCount *
static_cast<double>(pA->
getSize());
179 for (map<int, double>::iterator i = f.begin(); i != f.end(); i++)
181 i->second = i->second / n;
191 for (
size_t j = 0; j < names.size(); j++)
193 vector<int> seq = sequences.
getContent(names[j]);
194 for (
size_t i = 0; i < seq.size(); i++)
208 throw AlphabetException(
"SequenceContainerTools::getCodonPosition. Input sequences should be of type codon.");
209 vector<string> names = sequences.getSequencesNames();
211 for (
size_t j = 0; j < names.size(); j++)
213 vector<int> seq = sequences.
getContent(names[j]);
214 vector<int> newseq(seq.size());
215 for (
size_t i = 0; i < seq.size(); i++)
virtual void setSequencesNames(const std::vector< std::string > &names, bool checkNames)=0
Set all sequence names.
virtual void deleteSequence(size_t sequenceIndex)=0
Delete a sequence of the container.
const std::vector< int > & getContent(const std::string &name) const
Get the content of a sequence.
The OrderedSequenceContainer interface.
This alphabet is used to deal NumericAlphabet.
The VectorSequenceContainer class.
virtual unsigned int getSize() const =0
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you'll need in most cases.
int getNPosition(int word, size_t n) const
Get the int code of the n-position of a word given its int description.
std::vector< size_t > SequenceSelection
virtual void addSequence(const Sequence &sequence, bool checkName=true)
Add a sequence at the end of the container.
The alphabet exception base class.
A basic implementation of the Sequence interface.
virtual const Sequence & getSequence(const std::string &name) const =0
Retrieve a sequence object from the container.
virtual size_t size() const =0
Get the number of elements in the list.
virtual std::vector< std::string > getSequencesNames() const =0
Get all the names of the sequences in the container.
virtual const NucleicAlphabet *const getNucleicAlphabet() const
virtual const std::vector< int > & getContent(const std::string &name) const =0
Get the content of a sequence.
virtual const Alphabet * getAlphabet() const =0
Get sequence container's alphabet.
virtual std::vector< std::string > getSequencesNames() const =0
Get all the names of the sequences in the container.
The SequenceContainer interface.