Bifrost: UnitigColors Class Reference

Bifrost

Data Structures | Public Types | Public Member Functions
UnitigColors Class Reference

Represent the k-mer color sets of a unitig. More...

## Data Structures
class | UnitigColors_const_iterator
| See UnitigColors::const_iterator. More...

## Public Types
typedef UnitigColors_const_iterator | const_iterator
| Iterator for the colors of a unitig. More...

## Public Member Functions
| UnitigColors ()
| Constructor (set up an empty container of k-mer color sets).
| UnitigColors (const UnitigColors &o)
| Copy constructor. More...
| UnitigColors (UnitigColors &&o)
| Move constructor. More...
| ~UnitigColors ()
| Destructor.
UnitigColors & | operator= (const UnitigColors &o)
| Copy assignment operator. More...
UnitigColors & | operator= (UnitigColors &&o)
| Move assignment operator. More...
void | clear ()
| Empty a UnitigColors of its content.
bool | isEqual (const UnitigMapBase &um, const UnitigColors &o, const UnitigMapBase &um_o) const
| Check if two UnitigColors are equal. More...
bool | isEmpty () const
| Check if a UnitigColors is empty (no colors). More...
void | add (const UnitigMapBase &um, const size_t color_id)
| Add a color in the current UnitigColors to all k-mers of a unitig mapping. More...
void | remove (const UnitigMapBase &um, const size_t color_id)
| Remove a color in the current UnitigColors for all k-mers of a unitig mapping. More...
bool | contains (const UnitigMapBase &um, const size_t color_id) const
| Check if a color is present on all k-mers of a unitig mapping. More...
size_t | size (const UnitigMapBase &um) const
| Get the number of pairs (k-mer position, color) of a reference unitig. More...
size_t | size (const UnitigMapBase &um, const size_t color_id) const
| Get the number of k-mers of a reference unitig having a given color. More...
size_t | colorMax (const UnitigMapBase &um) const
| Get the largest color index of all k-mers of a reference unitig. More...
bool | write (ostream &stream_out, const bool copy_UnitigColors=true) const
| Write a UnitigColors to a stream. More...
bool | read (istream &stream_in)
| Read a UnitigColors from a stream. More...
size_t | getSizeInBytes () const
| Size of the UnitigColors in bytes. More...
const_iterator | begin (const UnitigMapBase &um) const
| Create a constant iterator on all pairs (k-mer position, color) of the UnitigColors. More...
const_iterator | end () const
| Create a constant iterator to the "past-the-last" pair (k-mer position, color) of the UnitigColors. More...
bool | optimizeFullColors (const UnitigMapBase &um)
| If possible, decrease the memory usage of the UnitigColors by optimizing the memory for "full colors" (a color is "full" when it is present on all k-mers of the reference unitig). More...

## Detailed Description

Represent the k-mer color sets of a unitig.

## Member Typedef Documentation

## ◆ const_iterator

UnitigColors::const_iterator

Iterator for the colors of a unitig.

The iterator iterates over the colors of a unitig in ascending order. For each color, it iterates over the positions of the mapped k-mers (UnitigMap parameter of UnitigColors::begin()) having this color, in ascending order.

## Constructor & Destructor Documentation

## ◆ UnitigColors() [1/2]

UnitigColors::UnitigColors | ( | const UnitigColors & | o | ) |

Copy constructor.

After the call to this constructor, the same UnitigColors object exists twice in memory.

Parameters

  o | is the color set to copy.

## ◆ UnitigColors() [2/2]

UnitigColors::UnitigColors | ( | UnitigColors && | o | ) |

Move constructor.

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

Parameters

  o | is the color set to move.

## Member Function Documentation

## ◆ add()

void UnitigColors::add | ( | const UnitigMapBase & | um,
|  | const size_t | color_id
| ) |  |

Add a color in the current UnitigColors to all k-mers of a unitig mapping.

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig for which the color must be added. The color will be added only for the given mapping, i.e, unitig[um.dist..um.dist+um.len+k-1]
  color_id | is the ID of the color to add.

## ◆ begin()

const_iterator UnitigColors::begin | ( | const UnitigMapBase & | um | ) | const

Create a constant iterator on all pairs (k-mer position, color) of the UnitigColors.

The iterator goes from the smallest to the largest color index. For each such color index, the iterator goes from the smallest to the largest k-mer position.

Returns
  a constant iterator to the smallest pair (k-mer position, color) of the UnitigColors.

## ◆ colorMax()

size_t UnitigColors::colorMax | ( | const UnitigMapBase & | um | ) | const

Get the largest color index of all k-mers of a reference unitig.

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig.

Returns
  The largest color index of all k-mers of a reference unitig.

## ◆ contains()

bool UnitigColors::contains | ( | const UnitigMapBase & | um,
|  | const size_t | color_id
| ) |  | const

Check if a color is present on all k-mers of a unitig mapping.

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig. All k-mers of this mapping will be checked for the presence of the color. If true is returned, all k-mers of the mapping have the color. If false is returned, at least one k-mer of the mapping does not have the color.
  color_id | is the ID of the color to check the presence.

Returns
  a boolean indicating if the color is present on all k-mers of the unitig mapping.

## ◆ end()

const_iterator UnitigColors::end | ( |  | ) | const

Create a constant iterator to the "past-the-last" pair (k-mer position, color) of the UnitigColors.

Returns
  a constant iterator to the "past-the-last" pair (k-mer position, color) of the UnitigColors.

## ◆ getSizeInBytes()

size_t UnitigColors::getSizeInBytes | ( |  | ) | const

Size of the UnitigColors in bytes.

Returns
  Size of the UnitigColors in bytes.

## ◆ isEmpty()

bool UnitigColors::isEmpty | ( |  | ) | const
| inline

Check if a UnitigColors is empty (no colors).

Returns
  a boolean indicating if the UnitigColors is empty.

## ◆ isEqual()

bool UnitigColors::isEqual | ( | const UnitigMapBase & | um,
|  | const UnitigColors & | o,
|  | const UnitigMapBase & | um_o
| ) |  | const

Check if two UnitigColors are equal.

Parameters

  um | is a UnitigMapBase object representing the reference unitig to which the current UnitigColors calling this function (this) is associated.
  o | is the UnitigColors to compare to the current UnitigColors calling this function (this).
  um_o | is a UnitigMapBase object representing the reference unitig to which the input UnitigColors o (parameter) is associated.

Returns
  a boolean indicating whether the two UnitigColors are equal.

## ◆ operator=() [1/2]

UnitigColors& UnitigColors::operator= | ( | const UnitigColors & | o | ) |

Copy assignment operator.

After the call to this operator, the same UnitigColors object exists twice in memory.

Parameters

  o | is the UnitigColors to copy.

Returns
  a reference to the current UnitigColors which is a copy of o.

## ◆ operator=() [2/2]

UnitigColors& UnitigColors::operator= | ( | UnitigColors && | o | ) |

Move assignment operator.

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

Parameters

  o | is the UnitigColors to move.

Returns
  a reference to the current UnitigColors having (owning) the content of o.

## ◆ optimizeFullColors()

bool UnitigColors::optimizeFullColors | ( | const UnitigMapBase & | um | ) |

If possible, decrease the memory usage of the UnitigColors by optimizing the memory for "full colors" (a color is "full" when it is present on all k-mers of the reference unitig).

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig.

Returns
  a boolean indicating if it was possible to optimize the memory usage of the UnitigColors.

## ◆ read()

bool UnitigColors::read | ( | istream & | stream_in | ) |

Read a UnitigColors from a stream.

Parameters

  stream_in | is an in stream from which the UnitigColors must be read. 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.

## ◆ remove()

void UnitigColors::remove | ( | const UnitigMapBase & | um,
|  | const size_t | color_id
| ) |  |

Remove a color in the current UnitigColors for all k-mers of a unitig mapping.

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig for which the color must be removed. The color will be removed only for the given mapping, i.e, unitig[um.dist..um.dist+um.len+k-1]
  color_id | is the ID of the color to remove.

## ◆ size() [1/2]

size_t UnitigColors::size | ( | const UnitigMapBase & | um | ) | const

Get the number of pairs (k-mer position, color) of a reference unitig.

Returns
  Number of pairs (k-mer position, color) of a reference unitig.

## ◆ size() [2/2]

size_t UnitigColors::size | ( | const UnitigMapBase & | um,
|  | const size_t | color_id
| ) |  | const

Get the number of k-mers of a reference unitig having a given color.

Parameters

  um | is a UnitigMapBase object representing a mapping to a reference unitig.
  color_id | is the color index.

Returns
  Number of k-mers of a reference unitig having a given color.

## ◆ write()

bool UnitigColors::write | ( | ostream & | stream_out,
|  | const bool | copy_UnitigColors = `true`
| ) |  | const

Write a UnitigColors to a stream.

Parameters

  stream_out | is an out stream to which the UnitigColors must 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 file:

- src/ColorSet.hpp