55 for (map<string, Sequence*>::const_iterator it = ms.begin(); it != ms.end(); it++)
80 vector<string> keys = msc.
getKeys();
103 map<string, Sequence*>::const_iterator it =
sequences_.begin();
104 for (
unsigned int j = 0; j < i; j++)
118 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
120 if (it->second->getName() == name)
131 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
133 if (it->second->getName() == name)
145 map<string, Sequence*>::iterator it =
sequences_.begin();
146 for (
size_t j = 0; j < i; j++)
160 if (it->second->getName() == name)
170 map<string, Sequence*>::const_iterator it =
sequences_.find(key);
182 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
184 if (it->second->getName() == name)
201 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
203 if (it->second->getName() == sequence.
getName())
205 throw Exception(
"MapSequenceContainer::setSequence : Sequence's name already exists in container");
230 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
232 if (it->second->getName() == name)
233 if (it->second->getName() != name)
234 throw Exception(
"MapSequenceContainer::setSequence : Sequence's name already exists in container");
258 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
260 if (it->second->getName() == sequence.
getName())
261 if (it->first != key)
262 throw Exception(
"MapSequenceContainer::setSequenceByKey : Sequence's name already exists in container");
284 map<string, Sequence*>::iterator it =
sequences_.begin();
285 for (
size_t j = 0; j < i; j++)
300 if (it->second->getName() == name)
314 map<string, Sequence*>::iterator it =
sequences_.find(key);
329 map<string, Sequence*>::iterator it =
sequences_.begin();
330 for (
size_t j = 0; j < i; j++)
344 if (it->second->getName() == name)
358 map<string, Sequence*>::iterator it =
sequences_.find(key);
373 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
375 if (it->second->getName() == sequence.
getName())
376 throw Exception(
"MapSequenceContainer::addSequence: Sequence '" + sequence.
getName() +
", already exists in container");
381 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
383 if (key == it->first)
384 throw Exception(
"MapSequenceContainer::addSequence: key already in use. (" + key +
")");
399 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
401 keys.push_back(it->first);
412 map<string, Sequence*>::const_iterator it =
sequences_.begin();
413 for (
size_t i = 0; i < pos; i++)
440 map<string, Sequence*>::iterator it =
sequences_.begin();
441 for (
size_t i = 0; i < pos; i++)
445 it->second->setComments(comments);
452 vector<string> names;
453 for (map<string, Sequence*>::const_iterator it =
sequences_.begin(); it !=
sequences_.end(); it++)
455 names.push_back(it->second->getName());
469 for (
size_t i = 0; i < names.size(); i++)
471 for (
unsigned int j = 0; j < i; j++)
473 if (names[j] == names[i])
474 throw Exception(
"MapSequenceContainer::setSequencesNames: Sequence's name already exists in container");
478 map<string, Sequence*>::iterator it =
sequences_.begin();
479 for (
size_t i = 0; i < names.size(); i++)
481 it->second->setName(names[i]);
Partial implementation of the OrderedSequenceContainer interface.
AbstractSequenceContainer & operator=(const AbstractSequenceContainer &sc)
const Alphabet * getAlphabet() const
Get container's alphabet.
Exception thrown when two alphabets do not match.
virtual std::string getAlphabetType() const =0
Identification method.
virtual const Alphabet * getAlphabet() const =0
Get the alphabet associated to the list.
MapSequenceContainer class.
MapSequenceContainer * createEmptyContainer() const
Return a copy of this container, but with no data inside.
void deleteSequence(const std::string &name)
void clear()
Delete all data in the container.
void addSequence(const std::string &key, const Sequence &sequence, bool checkNames=true)
Add a sequence and key.
MapSequenceContainer(const std::map< std::string, Sequence * > &ms, const Alphabet *alpha)
void setSequenceByKey(const std::string &key, const Sequence &sequence, bool checkNames=true)
Set a sequence.
MapSequenceContainer & operator=(const MapSequenceContainer &msc)
Sequence * removeSequence(const std::string &name)
Extract (and remove) a sequence from the container.
size_t getSequencePosition(const std::string &name) const
Get the position of a sequence in sequence container from its name.
virtual ~MapSequenceContainer()
Sequence * removeSequenceByKey(const std::string &key)
Remove a sequence.
bool hasSequence(const std::string &name) const
Check if a sequence with a given name is present in the container.
size_t getNumberOfSequences() const
Get the number of sequences in the container.
const Sequence & getSequenceByKey(const std::string &key) const
Get a sequence.
std::vector< std::string > getKeys() const
std::map< std::string, Sequence * > sequences_
std::vector< std::string > getSequencesNames() const
Get all the names of the sequences in the container.
const Sequence & getSequence(const std::string &name) const
Retrieve a sequence object from the container.
void setSequencesNames(const std::vector< std::string > &names, bool checkNames)
Set all sequence names.
Sequence & getSequence_(size_t i)
void deleteSequenceByKey(const std::string &key)
Delete a sequence.
std::string getKey(size_t pos) const
void setSequence(const std::string &name, const Sequence &sequence, bool checkName=true)
Replace a sequence in the container.
virtual void setComments(size_t sequenceIndex, const Comments &comments)=0
Exception thrown when a sequence is not found The sequence not found exception base class.
virtual const std::string getSequenceId() const
Get the id of the sequence that was to be found.
Sequence * clone() const =0
virtual const std::string & getName() const =0
Get the name of this sequence.
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.