All files / src/colorschemes index.js

73.08% Statements 19/26
50% Branches 5/10
50% Functions 3/6
75% Lines 18/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89                                              6x                                           6x       6x 6x 6x 6x     6x     6x 12x 12x           12x     6x       6x           12x 12x 12x 120x   12x        
import {
  StaticSchemeClass,
  DynSchemeClass
} from "./schemeclass";
 
import Buried from "./buried";
import Cinema from "./cinema";
import Clustal from "./clustal";
import Clustal2 from "./clustal2";
import Helix from "./helix";
import Hydro from "./hydrophobicity";
import Lesk from "./lesk";
import Mae from "./mae";
import Nucleotide from "./nucleotide";
import Purine from "./purine";
import Strand from "./strand";
import Taylor from "./taylor";
import Turn from "./turn";
import Zappo from "./zappo";
 
import pid from "./pid_colors";
 
 
const staticSchemes = {
  buried: Buried,
  buried_index: Buried,
  cinema: Cinema,
  clustal2: Clustal2,
  clustal: Clustal,
  helix: Helix,
  helix_propensity: Helix,
  hydro: Hydro,
  lesk: Lesk,
  mae: Mae,
  nucleotide: Nucleotide,
  purine: Purine,
  purine_pyrimidine: Purine,
  strand: Strand,
  strand_propensity: Strand,
  taylor: Taylor,
  turn: Turn,
  turn_propensity: Turn,
  zappo: Zappo
};
 
const dynSchemes = {
  pid: pid
};
 
const Colors = function(opt){
  this.maps = clone(staticSchemes);
  this.dyn = clone(dynSchemes);
  this.opt = opt;
}
 
Colors.getScheme = function(scheme){
  return staticSchemes[scheme];
}
Colors.prototype.getScheme = function(scheme) {
  var color = this.maps[scheme];
  Iif (color === undefined) {
    color = {};
    if(this.dyn[scheme] !== undefined){
      return new DynSchemeClass(this.dyn[scheme],this.opt);
    }
  }
  return new StaticSchemeClass(color);
};
 
Colors.prototype.addStaticScheme = function(name,scheme) {
  this.maps[name] = scheme;
}
 
Colors.prototype.addDynScheme = function(name,scheme) {
  this.dyn[name] = scheme;
}
 
// small helper to clone an object
function clone(obj) {
  Iif (null == obj || "object" !== typeof obj) return obj;
  var copy = obj.constructor();
  for (var attr in obj) {
    Eif (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
  }
  return copy;
}
 
export default Colors;