Class: ViralSeq::DRMs
- Inherits:
-
Object
- Object
- ViralSeq::DRMs
- Defined in:
- lib/viral_seq/sdrm.rb
Class Method Summary collapse
-
.sdrm_hash(options) ⇒ Hash
function to retrieve sdrm positions as a hash, DRM list are stored at ‘lib/viral_seq/util/drm_list.json`.
-
.sdrm_json(options) ⇒ Array
function to export SDRM positions as json object.
Class Method Details
.sdrm_hash(options) ⇒ Hash
function to retrieve sdrm positions as a hash, DRM list are stored at ‘lib/viral_seq/util/drm_list.json`
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/viral_seq/sdrm.rb', line 8 def self.sdrm_hash() = .to_s.upcase drm_data = JSON.parse( File.read( File.join(ViralSeq.root, 'viral_seq', 'util', 'drm_list.json') ) ) if drm_data[] sdrm = {} drm_data[].each do |record| sdrm[record["position"]] = [record["wild-type"], record["mutations"]] end else abort "Input option `#{}` for ViralSeq::DRMs.sdrm_hash not supported. Program aborted.\nSupported type of mutations for '#{drm_data.keys.join(", ")}' only." end return sdrm end |
.sdrm_json(options) ⇒ Array
function to export SDRM positions as json object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/viral_seq/sdrm.rb', line 31 def self.sdrm_json() sdrm = ViralSeq::DRMs.sdrm_hash() json_array = [] sdrm.each do |pos, muts| mutation = {} mutation[:position] = pos mutation[:wildtypeCodon] = muts[0] mutation[:mutationCodons] = muts[1] json_array << mutation end return json_array end |