Module: CommonFunctions

Defined in:
lib/full_lengther_next/classes/common_functions.rb

Instance Method Summary collapse

Instance Method Details

#contenidos_en_prot(hit, full_prot, q) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/full_lengther_next/classes/common_functions.rb', line 4

def contenidos_en_prot(hit, full_prot, q)
	
	is_ok = false
	q_index_start = 9999
	fr_index_start = 0
	min_index_start = 9999
	aas_parecidos = 0
	masked_x = 0
	suma_fragments = 0

	masked_x = hit.q_seq.count('X')
	masked_x = masked_x + hit.q_seq.count('-')
	
	full_prot = full_prot.gsub(/[\-Xx]+/,'')
	compare_prot = hit.q_seq.gsub(/[\-Xx]+/,'-')
	fragments_array = compare_prot.split(/\-+/)
	
	fragments_array.each do |seq|
		# puts "seq: #{seq}\nfull_prot: #{full_prot}"
		simliar_fragment = full_prot.lcs(seq)
		suma_fragments += simliar_fragment.length
		
		fr_index_start = full_prot.index(simliar_fragment)

		if (q_index_start == 9999)
			q_index_start = fr_index_start
		end
		full_prot = full_prot[(fr_index_start + simliar_fragment.length)..full_prot.length]
	end
	
	simliar_fragment = full_prot.lcs(compare_prot)
	
	# if ($verbose)
		# puts "#{q.query_def}-------------------------------------#{suma_fragments} de #{compare_prot.length}"
		# puts "#{q.query_def}-------------------------------------#{suma_fragments + masked_x} >= #{compare_prot.length * 0.7}"
		# puts "\nfull: #{full_prot}\ncomp: #{compare_prot}\nsimliar_fragment: #{simliar_fragment}"
	# end
	
	if (suma_fragments + masked_x >= compare_prot.length * 0.7)
		is_ok = true
		# puts "OK -- encontramos suficiente similitud entre query y subject -- OK"
	else
		is_ok = false
		# puts "\nfull: #{full_prot}\ncomp: #{compare_prot}"
		# puts "Warning!: no match comparing proteins"
	end

	min_index_start = [min_index_start, q_index_start].min
	
	if (min_index_start == 9999)
		min_index_start = 0
	end
	
	return [is_ok, min_index_start]
end

#corrige_frame(ref_frame, ref_start, ref_end) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/full_lengther_next/classes/common_functions.rb', line 78

def corrige_frame(ref_frame,ref_start,ref_end)

	if (ref_frame.abs == 2)
		ref_start = ref_start + 1
		ref_end = ref_end + 1
	elsif (ref_frame.abs == 3)
		ref_start = ref_start + 2
		ref_end = ref_end + 2
	end
	
	return [ref_start,ref_end]

end

#reverse_seq(query_fasta, h_qframe, h_qstart, h_qend) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/full_lengther_next/classes/common_functions.rb', line 63

def reverse_seq(query_fasta, h_qframe, h_qstart, h_qend)

	q_frame = -h_qframe.to_i

	q_beg = query_fasta.length - h_qend - 1
	q_end = query_fasta.length - h_qstart - 1

	query_fasta = query_fasta.complementary_dna

	# el qend y el qstart estan al reves porque cuando la seq tiene frame negativo el blast los pone al reves
	return [query_fasta, q_frame, q_beg, q_end]
end