Bifrost
Data Structures | Public Member Functions
ColorSet Class Reference

Represent a color set for a unitig. More...

Data Structures

class  ColorSet_const_iterator
 

Public Member Functions

 ColorSet ()
 Color set constructor (set up an empty color set). More...
 
 ~ColorSet ()
 Color set destructor.
 
 ColorSet (const ColorSet &o)
 Color set copy constructor. More...
 
 ColorSet (ColorSet &&o)
 Color set move constructor. More...
 
ColorSetoperator= (const ColorSet &o)
 Color set copy assignment operator. More...
 
ColorSetoperator= (ColorSet &&o)
 Color set move assignment operator. More...
 
void empty ()
 Empty a color set.
 
void setUnoccupied ()
 Empty a color set and set it as "unoccupied": the color set is "free" to be used, it is not associated with any unitig.
 
void setOccupied ()
 Set the color set as "occupied": the color set is NOT "free" to be used, it is now associated with a unitig.
 
bool isUnoccupied () const
 Get if the color set as "unoccupied" (NOT associated with a unitig). More...
 
bool isOccupied () const
 Get if the color set as "occupied" (associated with a unitig). More...
 
void add (const UnitigMap< HashID > &um, const size_t color_id)
 Add a color in the current color set for a unitig or a sub-unitig. More...
 
bool contains (const UnitigMap< HashID > &um, const size_t color_id) const
 Check if a color is present on a unitig or a sub-unitig. More...
 
ColorSet reverse (const size_t len_unitig) const
 Reverse the order of the colors. More...
 
size_t size () const
 Get the number of colors (total number of colors associated with a unitig). More...
 
const_iterator begin () const
 Create a constant iterator to the first color of the color set. More...
 
const_iterator end () const
 Create a constant iterator to the the "past-the-last" color of the color set. More...
 
bool write (ostream &stream_out) const
 Write a color set. More...
 
void optimize ()
 Optimize the memory of a color set. More...
 

Detailed Description

Represent a color set for a unitig.

The number of colors in such a set , i.e number of k-mers in unitig * number of color per k-mer, can't exceed 2^32

Constructor & Destructor Documentation

◆ ColorSet() [1/3]

ColorSet::ColorSet ( )

Color set constructor (set up an empty color set).

The color set is initialized as "unoccupied": the color set is "free" to be used, it is not associated with any unitig.

◆ ColorSet() [2/3]

ColorSet::ColorSet ( const ColorSet o)

Color set copy constructor.

After the call to this constructor, the same color set exists twice in memory.

Parameters
ois the color set to copy.

◆ ColorSet() [3/3]

ColorSet::ColorSet ( ColorSet &&  o)

Color set move constructor.

After the call to this constructor, the color set to move is empty, its content has been transfered (moved) to the new color set.

Parameters
ois the color set to move.

Member Function Documentation

◆ add()

void ColorSet::add ( const UnitigMap< HashID > &  um,
const size_t  color_id 
)

Add a color in the current color set for a unitig or a sub-unitig.

Parameters
umis a UnitigMap representing the mapping of a unitig for which the color must be added. The color will be added only for the sub-unitig mapped, i.e, unitig[um.dist..um.dist+um.len+k-1]
color_idis the ID of the color to add.

◆ begin()

const_iterator ColorSet::begin ( ) const
inline

Create a constant iterator to the first color of the color set.

Returns
a constant iterator to the first color of the color set.

◆ contains()

bool ColorSet::contains ( const UnitigMap< HashID > &  um,
const size_t  color_id 
) const

Check if a color is present on a unitig or a sub-unitig.

Parameters
umis a UnitigMap representing the mapping of a unitig for which the color presence must be checked. The color will be checked only for the sub-unitig mapped, i.e, unitig[um.dist..um.dist+um.len+k-1]
color_idis the ID of the color to check.

◆ end()

const_iterator ColorSet::end ( ) const
inline

Create a constant iterator to the the "past-the-last" color of the color set.

Returns
a constant iterator to the first the "past-the-last" of the color set.

◆ isOccupied()

bool ColorSet::isOccupied ( ) const
inline

Get if the color set as "occupied" (associated with a unitig).

Returns
a boolean indicating if the color set is "occupied" (true) or not (false).

◆ isUnoccupied()

bool ColorSet::isUnoccupied ( ) const
inline

Get if the color set as "unoccupied" (NOT associated with a unitig).

Returns
a boolean indicating if the color set is "unoccupied" (true) or not (false).

◆ operator=() [1/2]

ColorSet & ColorSet::operator= ( const ColorSet o)

Color set copy assignment operator.

After the call to this operator, the same color set exists twice in memory.

Parameters
ois the color set to copy.
Returns
a reference to the current color set being a copy of o.

◆ operator=() [2/2]

ColorSet & ColorSet::operator= ( ColorSet &&  o)

Color set move assignment operator.

After the call to this operator, the color set to move is empty, its content has been transfered (moved) to another color set.

Parameters
ois the color set to move.
Returns
a reference to the current color set having (owning) the content of o.

◆ optimize()

void ColorSet::optimize ( )
inline

Optimize the memory of a color set.

Useful in case one or more sub-unitig share the same color.

◆ reverse()

ColorSet ColorSet::reverse ( const size_t  len_unitig) const

Reverse the order of the colors.

This function must be used if a unitig is reverse-complemented.

Parameters
len_unitigis the length of the unitig to which this color set is associated.
Returns
a new color set which is the reverse of the current one.

◆ size()

size_t ColorSet::size ( ) const

Get the number of colors (total number of colors associated with a unitig).

Returns
number of colors (total number of colors associated with a unitig) in this color set.

◆ write()

bool ColorSet::write ( ostream &  stream_out) const

Write a color set.

Parameters
stream_outis an out stream to which the color set will be written. It must be opened prior to the call of this function and it won't be closed by this function.
Returns
a boolean indicating if the write was successful.

The documentation for this class was generated from the following files: