Module: Wrnap::Global::Extensions::TwoStructureBasedMethods

Defined in:
lib/wrnap/global/rna/extensions.rb

Instance Method Summary collapse

Instance Method Details

#bp_distance(structure_1, structure_2) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/wrnap/global/rna/extensions.rb', line 88

def bp_distance(structure_1, structure_2)
  # Takes two structures and calculates the distance between them by |symmetric difference(bp_in_a, bp_in_b)|
  raise "The two structures are not the same length" unless structure_1.length == structure_2.length

  bp_set_1, bp_set_2 = base_pairs(structure_1), base_pairs(structure_2)

  ((bp_set_1 - bp_set_2) + (bp_set_2 - bp_set_1)).count
end