bpp-seq
2.2.0
|
Utilitary methods dealing with sequence containers. More...
#include <Bpp/Seq/Container/SequenceContainerTools.h>
Public Member Functions | |
SequenceContainerTools () | |
virtual | ~SequenceContainerTools () |
Static Public Member Functions | |
static SequenceContainer * | createContainerOfSpecifiedSize (const Alphabet *alphabet, size_t size) |
Create a container with ![]() | |
static SequenceContainer * | createContainerWithSequenceNames (const Alphabet *alphabet, const std::vector< std::string > &seqNames) throw (Exception) |
Create a container with specified names. More... | |
template<class ContFrom , class ContTo , class Seq > | |
static void | convertContainer (const ContFrom &input, ContTo &output) |
Generic function which creates a new container from another one, by specifying the class of sequence to be stored. More... | |
static void | getSelectedSequences (const OrderedSequenceContainer &sequences, const SequenceSelection &selection, SequenceContainer &outputCont) throw (Exception) |
Add a specified set of sequences from a container to another. More... | |
static void | getSelectedSequences (const SequenceContainer &sequences, const std::vector< std::string > &selection, SequenceContainer &outputCont, bool strict=true) throw (Exception) |
Add a specified set of sequences from a container to another. More... | |
static void | keepOnlySelectedSequences (OrderedSequenceContainer &sequences, const SequenceSelection &selection) |
Remove all sequences that are not in a given selection from a given container. More... | |
static bool | sequencesHaveTheSameLength (const SequenceContainer &sequences) |
Check if all sequences in a SequenceContainer have the same length. More... | |
static void | getCounts (const SequenceContainer &sequences, std::map< int, int > &) |
Compute base counts. More... | |
static void | getFrequencies (const SequenceContainer &sequences, std::map< int, double > &f, double pseudoCount=0) |
Compute base frequencies. More... | |
static void | append (SequenceContainer &seqCont1, const SequenceContainer &seqCont2, bool checkNames=true) throw (Exception) |
Append all the sequences of a SequenceContainer to the end of another. More... | |
static void | append (SequenceContainer &seqCont1, const OrderedSequenceContainer &seqCont2, bool checkNames=true) throw (Exception) |
Append all the sequences of a SequenceContainer to the end of another, OrderedSequenceContainer implementation. More... | |
static void | merge (const SequenceContainer &seqCont1, const SequenceContainer &seqCont2, SequenceContainer &outputCont) throw (Exception) |
Concatenate the sequences from two containers. More... | |
static void | convertAlphabet (const SequenceContainer &seqCont, SequenceContainer &outputCont) throw (Exception) |
Convert a SequenceContainer with a new alphabet. More... | |
static SequenceContainer * | getCodonPosition (const SequenceContainer &sequences, size_t pos) throw (AlphabetException) |
Extract a certain position (1, 2 or 3) from a container of codon sequences and returns the resulting nucleotide container. More... | |
Utilitary methods dealing with sequence containers.
Definition at line 61 of file SequenceContainerTools.h.
|
inline |
Definition at line 65 of file SequenceContainerTools.h.
|
inlinevirtual |
Definition at line 66 of file SequenceContainerTools.h.
|
inlinestatic |
Append all the sequences of a SequenceContainer to the end of another.
seqCont1 | The SequenceContainer in which the sequences will be added. |
seqCont2 | The SequenceContainer from which the sequences are taken. |
checkNames | Tell if the sequence names should be check for unicity. |
Definition at line 214 of file SequenceContainerTools.h.
|
inlinestatic |
Append all the sequences of a SequenceContainer to the end of another, OrderedSequenceContainer implementation.
seqCont1 | The SequenceContainer in which the sequences will be added. |
seqCont2 | The SequenceContainer from which the sequences are taken. |
checkNames | Tell if the sequence names should be check for unicity. |
Definition at line 228 of file SequenceContainerTools.h.
References bpp::SequenceContainer::addSequence(), bpp::OrderedSequenceContainer::getNumberOfSequences(), and bpp::OrderedSequenceContainer::getSequence().
|
inlinestatic |
Convert a SequenceContainer with a new alphabet.
This method assume that the original container has proper sequence names. Names will be checked only if the output container is not empty.
seqCont | The container to convert. |
outputCont | A container (most likely empty) with an alphabet into which the container will be converted. |
Definition at line 272 of file SequenceContainerTools.h.
|
inlinestatic |
Generic function which creates a new container from another one, by specifying the class of sequence to be stored.
Compared to several copy constructors, this function allows to change the class of the inner sequence class used for storing sequences. The function used the addSequence method, so that it can also be used to concatenate containers.
input | The container to copy. |
output | The container where new sequences will be appended. |
Definition at line 112 of file SequenceContainerTools.h.
|
static |
Create a container with void sequences.
A new VectorSequenceContainer with the specified alphabet is created. The destruction of this new container is up to the user. Sequences have name "0", "1",... "n-1" and no content and comments.
alphabet | The alphabet to use in the container. |
size | The number of sequences in the container. |
Definition at line 56 of file SequenceContainerTools.cpp.
References bpp::VectorSequenceContainer::addSequence().
|
static |
Create a container with specified names.
A new VectorSequenceContainer with the specified alphabet is created. The destruction of this new container is up to the user. Sequences have the specified names and no content and comments.
alphabet | The alphabet to use in the container. |
seqNames | The names of the sequences. |
Exception | If two sequence names are not unique. |
Definition at line 68 of file SequenceContainerTools.cpp.
References bpp::SequenceContainer::setSequencesNames().
|
static |
Extract a certain position (1, 2 or 3) from a container of codon sequences and returns the resulting nucleotide container.
sequences | The input sequence container, with codon alphabet. |
pos | The codon position to retrieve. |
AlphabetException | If input sequences are not registered with a codon alphabet. |
Definition at line 204 of file SequenceContainerTools.cpp.
References bpp::VectorSequenceContainer::addSequence(), bpp::AbstractSequenceContainer::getContent(), bpp::WordAlphabet::getNPosition(), and bpp::CodonAlphabet::getNucleicAlphabet().
|
static |
Compute base counts.
Example of usage: getting the GC count from a sequence container. map<int, int> counts; SequenceContainerTools::getCounts(myContainer, counts); //My container is previously defined. int GCcontent = counts[1] + counts[2] ;
States are stored as their int code.
Definition at line 187 of file SequenceContainerTools.cpp.
References bpp::SequenceContainer::getContent(), and bpp::SequenceContainer::getSequencesNames().
|
static |
Compute base frequencies.
Example of usage: getting the GC content from a sequence container. map<int, double> freqs; SequenceContainerTools::getFrequencies(myContainer, freqs); //My container is previously defined. double GCcontent = (freqs[1] + freqs[2]) / (freqs[0] + freqs[1] + freqs[2] + freqs[3]);
States are stored as their int code.
Definition at line 154 of file SequenceContainerTools.cpp.
References bpp::SequenceContainer::getAlphabet(), bpp::SequenceContainer::getContent(), bpp::SequenceContainer::getSequencesNames(), and bpp::Alphabet::getSize().
|
static |
Add a specified set of sequences from a container to another.
Sequences are specified by their position, beginning at 0. Name verification will be performed, only if the output container is not empty, based on the assumption that the container passed as argument is a correct one. Redundant selection is not checked, so be careful with what you're doing!
sequences | The container from wich sequences are to be taken. |
selection | The positions of all sequences to retrieve. |
outputCont | A container where the selection should be added. |
Exception | In case of bad sequence name, alphabet mismatch, etc. |
Definition at line 80 of file SequenceContainerTools.cpp.
Referenced by bpp::SiteContainerTools::merge().
|
static |
Add a specified set of sequences from a container to another.
Sequences are specified by their names. Name verification will be performed, only if the output container is not empty, based on the assumption that the container passed as argument is a correct one. Redundant selection is not checked, so be careful with what you're doing!
sequences | The container from wich sequences are to be taken. |
selection | The names of all sequences to retrieve. |
outputCont | A container where the selection should be added. |
strict | If yes, trying to select a sequence that is not present will raise an exception. If no, only available sequence will be added. |
Exception | In case of bad sequence name, alphabet mismatch, etc. |
Definition at line 94 of file SequenceContainerTools.cpp.
|
static |
Remove all sequences that are not in a given selection from a given container.
A new VectorSequenceContainer is created with specified sequences. The destruction of the container is up to the user. Sequences are specified by their position, beginning at 0. Redundant selection is not checked, so be careful with what you're doing!
sequences | The container from wich sequences are to be taken. |
selection | The positions of all sequences to retrieve. |
Definition at line 116 of file SequenceContainerTools.cpp.
References bpp::OrderedSequenceContainer::deleteSequence(), and bpp::OrderedSequenceContainer::getSequencesNames().
|
inlinestatic |
Concatenate the sequences from two containers.
This method will not check the original sequence names for unicity. If sequences do not have a unique name, then the resulting merged container will contain the first sequence with the given duplicated name.
seqCont1 | First container. |
seqCont2 | Second container. This container must contain sequences with the same names as in seqcont1. Additional sequences will be ignored. |
outputCont | Output sequence container to which concatenated sequences will be added. |
AlphabetMismatchException | If the alphabet in the 3 containers do not match. |
Definition at line 249 of file SequenceContainerTools.h.
References bpp::BasicSequence::append().
|
static |
Check if all sequences in a SequenceContainer have the same length.
sequences | The container to check. |
Definition at line 138 of file SequenceContainerTools.cpp.
References bpp::SequenceContainer::getSequence(), bpp::SequenceContainer::getSequencesNames(), and bpp::SymbolList::size().