Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #make an array [["chrN", start, expression]]
- def profile_array(array, lines)
- lines.each do |line|
- line = line.split()
- chr = line[0]
- start = line[1].to_i
- expression = line[4].to_i
- array.push([chr, start, expression])
- end
- return array
- end
- #make an array of peaks segments[["chrN", start of segment, end of segment]]
- def array_of_peaks(arr, lines)
- lines.each do |line|
- chr = line.split(":")[0]
- start = (line.split(":")[1].split("..")[0]).to_i
- fin = (line.split(":")[1].split("..")[1].split(",")[0]).to_i
- arr.push([chr, start, fin])
- end
- return arr
- end
- #take lines that correspond to certain chr
- def choose_chr(profile, profile_chr)
- profile.each do |el|
- if el[0] == "chr1"
- profile_chr.push(el)
- end
- end
- return profile_chr
- end
- #make an array with array[index] = 0 if index doesn't lie in segment
- #start and fin - places where chr "starts" and "ends" respectively
- #for chr1 start = 564473, end = 249214301
- def make_chr_array(profile_chr, start, fin)
- indexed_profile = Array.new(start - 1) {0}
- for index in start...fin
- profile_chr.each do |el|
- if index == el[1]
- indexed_profile.push(el[2])
- else
- indexed_profile.push(0)
- end
- end
- end
- return indexed_profile
- end
- file = File.open('file', 'r')
- lines = file.readlines()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement