OpenMS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Compomer Class Reference

Holds information on an edge connecting two features from a (putative) charge ladder. More...

#include <OpenMS/DATASTRUCTURES/Compomer.h>

Collaboration diagram for Compomer:
[legend]

Public Types

enum  SIDE { LEFT , RIGHT , BOTH }
 Enumeration for specifying which side of the compomer to operate on. More...
 
typedef std::map< String, AdductCompomerSide
 Type definition for one side of a compomer (maps adduct labels to Adduct objects) More...
 
typedef std::vector< CompomerSideCompomerComponents
 Container for both sides of a compomer. More...
 

Public Member Functions

 Compomer ()
 Default Constructor. More...
 
 Compomer (Int net_charge, double mass, double log_p)
 Constructor with net-charge, mass, and probability. More...
 
 Compomer (const Compomer &p)
 Copy constructor. More...
 
Compomeroperator= (const Compomer &source)
 Assignment Operator. More...
 
void add (const Adduct &a, UInt side)
 Add an adduct to a specific side of the compomer. More...
 
bool isConflicting (const Compomer &cmp, UInt side_this, UInt side_other) const
 Determines if two compomers conflict with each other. More...
 
void setID (const Size &id)
 Set a unique identifier for this compomer. More...
 
const SizegetID () const
 Get the unique identifier of this compomer. More...
 
const CompomerComponentsgetComponent () const
 Get both sides (left and right) of this compomer. More...
 
const IntgetNetCharge () const
 Get the net charge of this compomer. More...
 
const double & getMass () const
 Get the total mass difference represented by this compomer. More...
 
const IntgetPositiveCharges () const
 Get the sum of positive charges in this compomer. More...
 
const IntgetNegativeCharges () const
 Get the sum of negative charges in this compomer. More...
 
const double & getLogP () const
 Get the log probability of this adduct combination. More...
 
const double & getRTShift () const
 Get the expected retention time shift caused by this compomer. More...
 
String getAdductsAsString () const
 Get a string representation of all adducts in this compomer. More...
 
String getAdductsAsString (UInt side) const
 Get a string representation of adducts on a specific side. More...
 
bool isSingleAdduct (Adduct &a, const UInt side) const
 Check if the compomer contains only a single adduct on the specified side. More...
 
Compomer removeAdduct (const Adduct &a) const
 Remove all adducts of type a. More...
 
Compomer removeAdduct (const Adduct &a, const UInt side) const
 Remove all adducts of type a from side (LEFT or RIGHT) More...
 
StringList getLabels (const UInt side) const
 Returns the adduct labels from side (LEFT or RIGHT) More...
 
void add (const CompomerSide &add_side, UInt side)
 Add a complete set of adducts to a specific side of the compomer. More...
 

Private Attributes

CompomerComponents cmp_
 Adducts of left and right side. More...
 
Int net_charge_
 Net charge (right - left) More...
 
double mass_
 Net mass (right - left) More...
 
Int pos_charges_
 Sum of positive charges. More...
 
Int neg_charges_
 Sum of negative charges. More...
 
double log_p_
 Log probability of this adduct combination. More...
 
double rt_shift_
 Expected net RT shift (-shift_leftside + shift_rightside) More...
 
Size id_
 Unique identifier for this compomer. More...
 

Friends

bool operator< (const Compomer &c1, const Compomer &c2)
 Comparison operator for sorting compomers. More...
 
std::ostream & operator<< (std::ostream &os, const Compomer &cmp)
 Output stream operator for printing compomer contents. More...
 
bool operator== (const Compomer &a, const Compomer &b)
 Equality comparison operator. More...
 

Detailed Description

Holds information on an edge connecting two features from a (putative) charge ladder.

A Compomer represents the chemical composition difference between two mass spectrometry features. It stores information about the adducts (ions, molecules, or atoms) that explain the mass and charge differences between these features.

The Compomer has two sides:

  • LEFT side: adducts subtracted from the first feature
  • RIGHT side: adducts added to the first feature

This model allows representing the relationship between features that correspond to the same analyte but with different adduct compositions or charge states.

The Compomer maintains metadata such as:

  • Net charge (difference between right and left sides)
  • Total mass difference
  • Probability score of this adduct combination
  • Expected RT shift caused by the adducts

This class is used extensively in the feature decharging and adduct annotation processes.

Member Typedef Documentation

◆ CompomerComponents

typedef std::vector<CompomerSide> CompomerComponents

Container for both sides of a compomer.

Vector with exactly two elements:

  • [0] = left side (adducts subtracted)
  • [1] = right side (adducts added)

◆ CompomerSide

typedef std::map<String, Adduct> CompomerSide

Type definition for one side of a compomer (maps adduct labels to Adduct objects)

Member Enumeration Documentation

◆ SIDE

enum SIDE

Enumeration for specifying which side of the compomer to operate on.

  • LEFT: The left side (adducts subtracted from the first feature)
  • RIGHT: The right side (adducts added to the first feature)
  • BOTH: Both sides of the compomer
Enumerator
LEFT 
RIGHT 
BOTH 

Constructor & Destructor Documentation

◆ Compomer() [1/3]

Compomer ( )

Default Constructor.

Initializes an empty compomer with zero net charge, mass, and probability.

◆ Compomer() [2/3]

Compomer ( Int  net_charge,
double  mass,
double  log_p 
)

Constructor with net-charge, mass, and probability.

Parameters
net_chargeNet charge of the compomer (right side - left side)
massMass difference represented by the compomer
log_pLog probability of this adduct combination

◆ Compomer() [3/3]

Compomer ( const Compomer p)

Copy constructor.

Parameters
pSource compomer to copy from

Member Function Documentation

◆ add() [1/2]

void add ( const Adduct a,
UInt  side 
)

Add an adduct to a specific side of the compomer.

Adds the specified amount of the adduct to the given side and updates the compomer's properties (net charge, mass, etc.).

Parameters
aThe adduct to add
sideWhich side to add the adduct to (0=LEFT, 1=RIGHT)

◆ add() [2/2]

void add ( const CompomerSide add_side,
UInt  side 
)

Add a complete set of adducts to a specific side of the compomer.

Parameters
add_sideThe set of adducts to add
sideWhich side to add the adducts to (LEFT or RIGHT)

◆ getAdductsAsString() [1/2]

String getAdductsAsString ( ) const

Get a string representation of all adducts in this compomer.

Returns
String representation of adducts on both sides

◆ getAdductsAsString() [2/2]

String getAdductsAsString ( UInt  side) const

Get a string representation of adducts on a specific side.

Parameters
sideWhich side to get adducts for (LEFT, RIGHT, or BOTH)
Returns
String representation of adducts on the specified side

◆ getComponent()

const CompomerComponents& getComponent ( ) const

Get both sides (left and right) of this compomer.

Returns
Reference to the compomer components (left and right sides)

◆ getID()

const Size& getID ( ) const

Get the unique identifier of this compomer.

Returns
The unique ID of this compomer

◆ getLabels()

StringList getLabels ( const UInt  side) const

Returns the adduct labels from side (LEFT or RIGHT)

Get a list of labels for the side (useful for assigning channels (light, heavy etc) to features).

◆ getLogP()

const double& getLogP ( ) const

Get the log probability of this adduct combination.

Higher values indicate more likely combinations.

Returns
Log probability value

◆ getMass()

const double& getMass ( ) const

Get the total mass difference represented by this compomer.

Returns
Mass difference in Da

◆ getNegativeCharges()

const Int& getNegativeCharges ( ) const

Get the sum of negative charges in this compomer.

Returns
Total negative charges

◆ getNetCharge()

const Int& getNetCharge ( ) const

Get the net charge of this compomer.

The net charge is calculated as the difference between the right and left sides.

Returns
Net charge value

◆ getPositiveCharges()

const Int& getPositiveCharges ( ) const

Get the sum of positive charges in this compomer.

Returns
Total positive charges

◆ getRTShift()

const double& getRTShift ( ) const

Get the expected retention time shift caused by this compomer.

Returns
Expected RT shift value

◆ isConflicting()

bool isConflicting ( const Compomer cmp,
UInt  side_this,
UInt  side_other 
) const

Determines if two compomers conflict with each other.

Checks if these two compomers can coexist for one feature by examining if they have conflicting adduct compositions on the specified sides.

Parameters
cmpThe other Compomer to compare against
side_thisWhich side of this compomer to check (0=LEFT, 1=RIGHT)
side_otherWhich side of the other compomer to check (0=LEFT, 1=RIGHT)
Returns
True if the compomers conflict (cannot coexist), false otherwise

◆ isSingleAdduct()

bool isSingleAdduct ( Adduct a,
const UInt  side 
) const

Check if the compomer contains only a single adduct on the specified side.

Parameters
aOutput parameter that will contain the adduct if found
sideWhich side to check (LEFT or RIGHT)
Returns
True if only a single adduct is present on the specified side

◆ operator=()

Compomer& operator= ( const Compomer source)

Assignment Operator.

Parameters
sourceSource compomer to assign from
Returns
Reference to this object

◆ removeAdduct() [1/2]

Compomer removeAdduct ( const Adduct a) const

Remove all adducts of type a.

Remove ALL instances of the given adduct, BUT use the given adducts parameters (charge, logp, mass etc) to update the compomers members

◆ removeAdduct() [2/2]

Compomer removeAdduct ( const Adduct a,
const UInt  side 
) const

Remove all adducts of type a from side (LEFT or RIGHT)

remove ALL instances of the given adduct from the given side (LEFT or RIGHT), BUT use the given adducts parameters (charge, logp, mass etc) to update the compomers members

◆ setID()

void setID ( const Size id)

Set a unique identifier for this compomer.

Parameters
idThe unique ID to assign

Friends And Related Function Documentation

◆ operator<

bool operator< ( const Compomer c1,
const Compomer c2 
)
friend

Comparison operator for sorting compomers.

Sorts compomers by (in order of importance):

  1. Net charge
  2. Mass
  3. Probability
Parameters
c1First compomer to compare
c2Second compomer to compare
Returns
True if c1 should be ordered before c2

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Compomer cmp 
)
friend

Output stream operator for printing compomer contents.

Parameters
osOutput stream to write to
cmpCompomer to print
Returns
Reference to the output stream

◆ operator==

bool operator== ( const Compomer a,
const Compomer b 
)
friend

Equality comparison operator.

Parameters
aFirst compomer to compare
bSecond compomer to compare
Returns
True if the compomers are equal

Member Data Documentation

◆ cmp_

CompomerComponents cmp_
private

Adducts of left and right side.

◆ id_

Size id_
private

Unique identifier for this compomer.

◆ log_p_

double log_p_
private

Log probability of this adduct combination.

◆ mass_

double mass_
private

Net mass (right - left)

◆ neg_charges_

Int neg_charges_
private

Sum of negative charges.

◆ net_charge_

Int net_charge_
private

Net charge (right - left)

◆ pos_charges_

Int pos_charges_
private

Sum of positive charges.

◆ rt_shift_

double rt_shift_
private

Expected net RT shift (-shift_leftside + shift_rightside)