Class: ScanForRestrSite
- Inherits:
-
Object
- Object
- ScanForRestrSite
- Defined in:
- lib/seqtrimnext/classes/scan_for_restr_site.rb
Overview
- Author
-
Almudena Bocinos Rioboo
This class provided the methods to read the parameter’s file and to create the structure where will be storaged the param’s name and the param’s numeric-value
Instance Method Summary collapse
- #execute ⇒ Object
-
#exists?(param_name) ⇒ Boolean
Returns true if exists the parameter and nil if don’t.
-
#get_param(param) ⇒ Object
Return the parameter’s list in an array.
-
#initialize(sequence, rest) ⇒ ScanForRestrSite
constructor
Creates the structure and start the reading of parameter’s file.
-
#print_parameters ⇒ Object
Prints the pair name/numeric-value for every parameter.
-
#read_file(path_fichero) ⇒ Object
Reads param’s file.
- #set_param(param, value) ⇒ Object
Constructor Details
#initialize(sequence, rest) ⇒ ScanForRestrSite
Creates the structure and start the reading of parameter’s file
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 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 10 def initialize(sequence,rest) @seq_fasta=sequence @rest=rest puts "#{@seq_fasta} , #{@rest}" res = execute res.each do |e| puts "#{e.join(',')}" end # selects from res,the max good hit puts "--- MAX: --- " max = res.max{|e1,e2| e1[1]<=> e2[1]} puts max.join(' ; ') # checks if the max one has the size of restriction with a margen error margen = (@rest.size <= 4)? 0 : 1; # <- don't change if ((max[1] != @rest.size) && (max[1] != @rest.size-margen)) puts "-the max good hit hasn't the size minimum: #{@rest.size} or #{@rest.size-margen} " max=[] end #read_file(path) end |
Instance Method Details
#execute ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 42 def execute r=[] # # for (my $p=0; $p < $sL-$srfL; $p++){ # $os = $ns = $xs = 0; # for ( my $i=0; $i < $srfL; $i++ ) { # my $c = substr($s, $i+$p, 1); # ver si decrementar antes pos # my $cc = substr($restrSite, $i, 1); # if ($c eq $cc) { # ++$os; # } elsif ($c eq "N"){ # ++$ns; # } else { # ++$xs; # } # } # $r[$p] = [$p, $os, $ns, $xs]; # print "$p, $os, $ns, $xs\n"; # } for p in 0..@seq_fasta.size-@rest.size os = 0; ns = 0; xs = 0; puts "-------[#{p}]-#{@seq_fasta[p,@seq_fasta.size-p]} , #{@rest}" i=0 @rest.each_char do |cc| c = @seq_fasta[i+p].chr puts "(#{c}==#{cc})=>#{c==cc}" if (c == cc) os += 1 elsif (c == 'N') ns += 1 else xs += 1 end i+=1 end r[p]=[p,os,ns,xs] puts r[p].join(',') end return r end |
#exists?(param_name) ⇒ Boolean
Returns true if exists the parameter and nil if don’t
131 132 133 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 131 def exists?(param_name) return !@h[param_name].nil? end |
#get_param(param) ⇒ Object
Return the parameter’s list in an array
119 120 121 122 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 119 def get_param(param) #$LOG.debug "Get Param: #{@h[param]}" return @h[param] end |
#print_parameters ⇒ Object
Prints the pair name/numeric-value for every parameter
111 112 113 114 115 116 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 111 def print_parameters() @h.each do |clave, valor| $LOG.debug "The Parameter #{clave} have the value " +valor.to_s end end |
#read_file(path_fichero) ⇒ Object
Reads param’s file
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 88 def read_file(path_fichero) File.open(path_fichero).each_line do |line| line.chomp! # delete end of line if !line.empty? if !(line =~ /^#/) # if line is not a comment # extract the parameter's name in params[0] and the parameter's value in params[1] params = line.split(/\s*=\s*/) # storage in the hash the pair key/value, in our case will be name/numeric-value , # that are save in params[0] and params[1], respectively @h[params[0]] = params[1] $LOG.debug "read: #{params[1]}" end # end if comentario end #end if line end #end each $LOG.info "File Params have been readed" end |
#set_param(param, value) ⇒ Object
124 125 126 |
# File 'lib/seqtrimnext/classes/scan_for_restr_site.rb', line 124 def set_param(param,value) @h[param] = value end |