FEV_KEGG.Statistics.Percent module

FEV_KEGG.Statistics.Percent.floatToPercentString(x, decimalPlaces=1)[source]

Format a float as a truncated percent string.

Parameters:
  • x (float) – Must be between 0 and 1 to represent 0% to 100%.
  • decimalPlaces (int, optional) – The number of decimal places to the right to conserve.
Returns:

String of x, shortened to decimalPlaces decimal places, concatenated with the ‘%’ sign.

Return type:

str

FEV_KEGG.Statistics.Percent.getPercent(x, baseValue)[source]

Calculate percentage.

Parameters:
  • x (float or int) –
  • baseValue (float or int) –
Returns:

Percentage of x out of baseValue, normalised to 100.

Return type:

float

FEV_KEGG.Statistics.Percent.getPercentSentence(x, baseValue, decimalPlaces=1)[source]

Calculate percentage and return shortened string within a fancy sentence.

Parameters:
  • x (float or int) –
  • baseValue (float or int) –
  • decimalPlaces (int, optional) – The number of decimal places to the right to conserve.
Returns:

String of result of getPercent(), shortened to decimalPlaces decimal places, and put into a complete sentence of the form “x/baseValue -> result%””, i.e. 23/42 -> 54.76%.

Return type:

str

FEV_KEGG.Statistics.Percent.getPercentString(x, baseValue)[source]

Calculate percentage and return as string.

Parameters:
  • x (float or int) –
  • baseValue (float or int) –
Returns:

String of result of getPercent().

Return type:

str

FEV_KEGG.Statistics.Percent.getPercentStringShort(x, baseValue, decimalPlaces=1)[source]

Calculate percentage and return as shortened string.

Parameters:
  • x (float or int) –
  • baseValue (float or int) –
  • decimalPlaces (int, optional) – The number of decimal places to the right to conserve.
Returns:

String of result of getPercent(), shortened to decimalPlaces decimal places.

Return type:

str