static/js/binning.js
/**
 * Update a bin with selected contigs.
 * @function updateBinWith
 * @param {string} name - target bin name
 * @param {number[]} picked - contig selection
 * @param {string[]} binned - binning plan
 * @returns {number[], number[]} indices of added and removed contigs
 */
Update a bin with selected contigs.
Update a bin with selected contigs .
function updateBinWith(name, picked, binned) {
  const added = [], removed = [], unchanged = [];
  const n = picked.length;
  for (let i = 0; i < n; i++) {
    if (binned[i] === name) {
      if (!picked[i]) {
        binned[i] = '';
        removed.push(i);
      } else {
        unchanged.push(i);
      }
    } else if (picked[i]) {
      binned[i] = name;
      added.push(i);
    }
  }
  return [added, removed, unchanged];
}
function updateBinWith ( name , picked , binned ) { const added = [ ] , removed = [ ] , unchanged = [ ] ; const n = picked . length ; for ( let i = 0 ; i < n ; i ++ ) { if ( binned [ i ] === name ) { if ( ! picked [ i ] ) { binned [ i ] = '' ; removed . push ( i ) ; } else { unchanged . push ( i ) ; } } else if ( picked [ i ] ) { binned [ i ] = name ; added . push ( i ) ; } } return [ added , removed , unchanged ] ; }
Update a bin with selected contigs.
Update a bin with selected contigs .