Permalink
Browse files

Added solution for subs

  • Loading branch information...
1 parent deed401 commit dafb2c259f3bfdf7b03b5cba086a9f565fa87edc @jvoorhis committed Nov 10, 2012
Showing with 11 additions and 0 deletions.
  1. +2 −0 data/rosalind_subs.txt
  2. +9 −0 src/subs.rb
View
2 data/rosalind_subs.txt
@@ -0,0 +1,2 @@
+GAGGCTGCCCAGAGGCTGGAGGCTGACAGCCAGGTATTTAGAGGCTGAGAGGCTGAGAGGCTGGAGGCTGGAGGCTGATCCCATGTGTGAGGCTGGAGGCTGAGAGGCTGTGCGCGAGGCTGGAGGCTGGGAGGCTGGGACTTATGAGGCTGAGAGGCTGAGGACGTGAGGCTGGAGGCTGGAGGCTGTAACCACACGTTAAGAGGCTGTCGAGGCTGGCGAGGCTGGATGGTTCACGAGGCTGAAGATTGAGGCTGTTCGAGGCTGGAGGCTGCCCATCCGGAGGCTGCGTGAGGCTGCGAGGCTGTGTTGAGGCTCTTCCTAGAGGCTGGAGGCTGATTAAGGAGGCTGGATAGAATGAGGCTGGTGCAGCAAGCGAGGCTGTGCCGAGGCTGGTGGTTGGAGGCTGGAGGCTGATACGAGGCTGAGACGGATGGAGGCTGGAGGCTGGTGAGGCTGCGGTAGGAGGCTGCACAGAGGCTGTGAGGCTGTGATGAGGCTGGAGGCTGCTATGAGGCTGGAGGCTGGCCAAGTGCCGAAGAGGCTGGGAGGCTGGAGGCTGAGTTCGGAGGCTGAGGAGGCTGGGAGGCTGTGTCGCTTTTGTGAGGCTGGAGGCTGGAGAGGCTGCGTGTACGAGGCTGCATCAGAGGCTGGCCTGCAGAGGCTGATGAGGCTGGCCCAGATGAGGCTGGAGGCTGAGAGGCTGTCTATGAGGCTGGAGGCTGAAGTGTGAGAGGCTGACCTTGAGGCTGTCGAGGCTGAAGAGGCTGGGGAGGCTGGAGGCTGGAGGCTGGAAGAGGCTGAGGAAGGAGGCTGCGCAGAGGCTGTCTCATGAGGCTGTGAGGCTGGAGGCTG
+GAGGCTGGA
View
9 src/subs.rb
@@ -0,0 +1,9 @@
+dna="GAGGCTGCCCAGAGGCTGGAGGCTGACAGCCAGGTATTTAGAGGCTGAGAGGCTGAGAGGCTGGAGGCTGGAGGCTGATCCCATGTGTGAGGCTGGAGGCTGAGAGGCTGTGCGCGAGGCTGGAGGCTGGGAGGCTGGGACTTATGAGGCTGAGAGGCTGAGGACGTGAGGCTGGAGGCTGGAGGCTGTAACCACACGTTAAGAGGCTGTCGAGGCTGGCGAGGCTGGATGGTTCACGAGGCTGAAGATTGAGGCTGTTCGAGGCTGGAGGCTGCCCATCCGGAGGCTGCGTGAGGCTGCGAGGCTGTGTTGAGGCTCTTCCTAGAGGCTGGAGGCTGATTAAGGAGGCTGGATAGAATGAGGCTGGTGCAGCAAGCGAGGCTGTGCCGAGGCTGGTGGTTGGAGGCTGGAGGCTGATACGAGGCTGAGACGGATGGAGGCTGGAGGCTGGTGAGGCTGCGGTAGGAGGCTGCACAGAGGCTGTGAGGCTGTGATGAGGCTGGAGGCTGCTATGAGGCTGGAGGCTGGCCAAGTGCCGAAGAGGCTGGGAGGCTGGAGGCTGAGTTCGGAGGCTGAGGAGGCTGGGAGGCTGTGTCGCTTTTGTGAGGCTGGAGGCTGGAGAGGCTGCGTGTACGAGGCTGCATCAGAGGCTGGCCTGCAGAGGCTGATGAGGCTGGCCCAGATGAGGCTGGAGGCTGAGAGGCTGTCTATGAGGCTGGAGGCTGAAGTGTGAGAGGCTGACCTTGAGGCTGTCGAGGCTGAAGAGGCTGGGGAGGCTGGAGGCTGGAGGCTGGAAGAGGCTGAGGAAGGAGGCTGCGCAGAGGCTGTCTCATGAGGCTGTGAGGCTGGAGGCTG".chars.to_a
+motif="GAGGCTGGA".chars.to_a
+i=0
+loc=[]
+dna.each_cons(motif.size) { |chars|
+ i += 1
+ loc << i if chars == motif
+}
+puts loc.join(' ')

0 comments on commit dafb2c2

Please sign in to comment.