Class: Microhomology::Talen

Inherits:
Object
  • Object
show all
Defined in:
lib/microhomology.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Talen

Returns a new instance of Talen.



78
79
80
81
82
# File 'lib/microhomology.rb', line 78

def initialize(key)
  @key = key
  @dna = open(get_ensembl_url).read
  @results = perform_microhomology
end

Instance Attribute Details

#dnaObject

Returns the value of attribute dna.



76
77
78
# File 'lib/microhomology.rb', line 76

def dna
  @dna
end

#keyObject

Returns the value of attribute key.



76
77
78
# File 'lib/microhomology.rb', line 76

def key
  @key
end

#resultsObject

Returns the value of attribute results.



76
77
78
# File 'lib/microhomology.rb', line 76

def results
  @results
end

Instance Method Details

#exonsObject



88
89
90
# File 'lib/microhomology.rb', line 88

def exons
  self.dna.scan /[A-Z]+/
end

#get_ensembl_urlObject



84
85
86
# File 'lib/microhomology.rb', line 84

def get_ensembl_url
  "http://rest.ensembl.org/sequence/id/#{self.key}?content-type=text/plain;mask_feature=true"
end

#intronsObject



92
93
94
# File 'lib/microhomology.rb', line 92

def introns
  self.dna.scan /[a-z]+/
end

#perform_microhomologyObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/microhomology.rb', line 96

def perform_microhomology
  targets = []
  self.dna.scan(Microhomology::TALEN) do |talen|
    targets << {
                "target" => talen,
                "first" => Regexp.last_match.offset(0).first, 
                "last" => Regexp.last_match.offset(0).last,
                "microhomology" => []
                }
  end

  if targets
    targets.each do |target|

      talen_site = Bio::Sequence::NA.new(target['target'])
      talen_site_complement = talen_site.complement.reverse

      talen1  = talen_site[0..15]
      spacer1 = talen_site[16..22]
      spacer2 = talen_site[23..30]
      talen2  = talen_site[31..47]

      talen_forward = Bio::Sequence::NA.new("#{talen1}#{spacer2}#{spacer1}#{talen2}")
      talen_reverse = talen_forward.complement.reverse

      target["microhomology"] << { 
          "forward_strand" => "#{talen_site.upcase}",
          "reverse_strand" => "#{talen_site_complement.upcase}",
          "oligo_forward" => "#{talen_forward.upcase}",
          "oligo_reverse" => "#{talen_reverse.upcase}"
        }
    end
    targets
  else
    "Sorry, no TALEN targets found."
  end
end