static/js/calculate.js
/**
 * Calculate completeness and contamination of current selection given a
 * feature group.
 * @function calcComCon
 * @param {Object} mo - main object
 * @param {number} field - feature set field index
 * @param {string} group - feature group name
 * @description The metrics are analogous to CheckM's.
 * Completeness - number of features seen vs total number of features in group.
 * Contamination - number of times features are found more than once vs total
 * number of features in group.
 */
Calculate completeness and contamination of current selection given a
feature group.
Calculate completeness and contamination of current selection given a feature group .
function calcComCon(mo, field, group) {
  let feaset = new Set(mo.mems[field][group]);
  const tot = feaset.size;
  const n = mo.cache.nctg;
  const picked = mo.picked;
  const col = mo.data[field];
  const seen = new Set();
  let ndup = 0;
  let datum, j, val;
  for (let i = 0; i < n; i ++) {
    if (!picked[i]) continue;
    datum = col[i];
    for (j = 0; j < datum.length; j ++) {
      val = datum[j];
      if (feaset.has(val)) {
        if (seen.has(val)) ndup ++;
        else seen.add(val);
      }
    }
  }
  return [seen.size / tot, ndup / tot];
}
function calcComCon ( mo , field , group ) { let feaset = new Set ( mo . mems [ field ] [ group ] ) ; const tot = feaset . size ; const n = mo . cache . nctg ; const picked = mo . picked ; const col = mo . data [ field ] ; const seen = new Set ( ) ; let ndup = 0 ; let datum , j , val ; for ( let i = 0 ; i < n ; i ++ ) { if ( ! picked [ i ] ) continue ; datum = col [ i ] ; for ( j = 0 ; j < datum . length ; j ++ ) { val = datum [ j ] ; if ( feaset . has ( val ) ) { if ( seen . has ( val ) ) ndup ++ ; else seen . add ( val ) ; } } } return [ seen . size / tot , ndup / tot ] ; }
Calculate completeness and contamination of current selection given a
 feature group.
Calculate completeness and contamination of current selection given a feature group .