Skip to content

Commit

Permalink
Merge pull request #15 from homonecloco/max_hits
Browse files Browse the repository at this point in the history
Now the hit count is preserved
  • Loading branch information
homonecloco committed Aug 7, 2018
2 parents f41f6c8 + 5e65c42 commit d0c961b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/polymarker.rb
Expand Up @@ -392,7 +392,7 @@ def do_align(aln, exo_f, found_contigs, min_identity,fasta_file,options)
end

kasp_container.add_primers_file(primer_3_output) if added_exons > 0
header = "Marker,SNP,RegionSize,chromosome,total_contigs,contig_regions,SNP_type,#{original_name},#{snp_in},common,primer_type,orientation,#{original_name}_TM,#{snp_in}_TM,common_TM,selected_from,product_size,errors,is_repetitive"
header = "Marker,SNP,RegionSize,chromosome,total_contigs,contig_regions,SNP_type,#{original_name},#{snp_in},common,primer_type,orientation,#{original_name}_TM,#{snp_in}_TM,common_TM,selected_from,product_size,errors,is_repetitive,hit_count"
File.open(output_primers, 'w') { |f| f.write("#{header}\n#{kasp_container.print_primers}") }

File.open(output_to_order, "w") { |io| io.write(kasp_container.print_primers_with_tails()) }
Expand Down
1 change: 1 addition & 0 deletions lib/bio/PolyploidTools/ExonContainer.rb
Expand Up @@ -221,6 +221,7 @@ def remove_alignments_over_max_hits
snp_array.each do |snp|
if snp.exon_list.size > max_hits
total_hits = snp.exon_list.size
snp.hit_count = total_hits
snp.exon_list = {}
snp.repetitive = true
snp.errors << "The marker is in a repetitive region (#{total_hits} hits to reference)"
Expand Down
7 changes: 5 additions & 2 deletions lib/bio/PolyploidTools/SNP.rb
Expand Up @@ -18,6 +18,7 @@ class SNP
attr_accessor :max_hits
attr_accessor :errors
attr_accessor :repetitive
attr_accessor :hit_count



Expand Down Expand Up @@ -69,6 +70,7 @@ def initialize
@exon_list = Hash.new {|hsh, key| hsh[key] = [] }
@errors = Array.new
@repetitive = false
@hit_count = 0
end

def to_polymarker_coordinates(flanking_size, total:nil)
Expand Down Expand Up @@ -340,8 +342,9 @@ def primer_3_all_strings(target_chromosome, parental)
errors << "The sequence (#{seq_original.size}) is shorter than #{primer_3_min_seq_length}"
return primer_3_propertes
end

if exon_list.size > max_hits
hit_count = exon_list.size
puts exon_list.inspect
if hit_count > max_hits
errors << "The marker maps to #{exon_list.size} positions (max_hits: #{max_hits}). "
repetitive = true
return primer_3_propertes
Expand Down
5 changes: 4 additions & 1 deletion lib/bio/db/primer3.rb
Expand Up @@ -60,6 +60,7 @@ class SNP
attr_accessor :regions
attr_accessor :primer3_errors
attr_accessor :repetitive
attr_accessor :hit_count

def line_1_name
"#{gene}:#{position}#{original}>#{snp} #{line_1}}"
Expand Down Expand Up @@ -249,6 +250,7 @@ def values
def print_primers
to_print = values.dup
to_print << @repetitive
to_print << hit_count
to_print.join(",")
end

Expand Down Expand Up @@ -765,7 +767,8 @@ def add_snp(snp_in)
snp.position = snp_in.position
snp.snp = snp_in.snp
snp.repetitive = snp_in.repetitive

#puts snp_in.inspect
snp.hit_count = snp_in.hit_count
snp.line_1 = @line_1
snp.line_2 = @line_2
snp.snp_from = snp_in
Expand Down

0 comments on commit d0c961b

Please sign in to comment.