lib/cheripic/variants.rb in cheripic-1.1.0 vs lib/cheripic/variants.rb in cheripic-1.2.0
- old
+ new
@@ -117,19 +117,21 @@
end
@bfr_frags
end
# Applies selection procedure on assembly contigs based on the ratio_type provided.
- # If only_frag_with_vars is set to true then contigs without any variant are discarded for :hme_score
+ # If use_all_contigs is set to false then contigs without any variant are discarded for :hme_score
# while contigs without any hemisnps are discarded for :bfr_score
- # If filter_out_low_hmes is set to true then contigs are further filtered based on a cut off value of the score
+ # If include_low_hmes is set to false then contigs are further filtered based on a cut off value of the score
# @param ratio_type [Symbol] ratio_type is either :hme_score or :bfr_score
def select_contigs(ratio_type)
selected_contigs ={}
- only_frag_with_vars = Options.only_frag_with_vars
+ use_all_contigs = Options.use_all_contigs
@assembly.each_key do | frag |
- if only_frag_with_vars
+ if use_all_contigs
+ selected_contigs[frag] = @assembly[frag]
+ else
if ratio_type == :hme_score
# selecting fragments which have a variant
if @assembly[frag].hm_num + @assembly[frag].ht_num > 2 * Options.hmes_adjust
selected_contigs[frag] = @assembly[frag]
end
@@ -137,19 +139,17 @@
# in polyploidy scenario selecting fragments with at least one bfr position
if @assembly[frag].hemi_num > 0
selected_contigs[frag] = @assembly[frag]
end
end
- else
- selected_contigs[frag] = @assembly[frag]
end
end
selected_contigs = filter_contigs(selected_contigs, ratio_type)
- if only_frag_with_vars
- logger.info "Selected #{selected_contigs.length} out of #{@assembly.length} fragments with #{ratio_type} score\n"
- else
+ if use_all_contigs
logger.info "No filtering was applied to fragments\n"
+ else
+ logger.info "Selected #{selected_contigs.length} out of #{@assembly.length} fragments with #{ratio_type} score\n"
end
selected_contigs
end
# Filters out contigs below a cutoff for selected ratio_type
@@ -169,26 +169,26 @@
# Cut off value calculation used to filter out low scored contigs.
#
# @param ratio_type [Symbol] ratio_type is either :hme_score or :bfr_score
# @param selected_contigs [Hash] a hash of contigs with selected ratio_type, a subset of assembly hash
def get_cutoff(selected_contigs, ratio_type)
- filter_out_low_hmes = Options.filter_out_low_hmes
+ include_low_hmes = Options.include_low_hmes
# set minimum cut off hme_score or bfr_score to pick fragments with variants
# calculate min hme score for back or out crossed data or bfr_score for polypoidy data
# if no filtering applied set cutoff to 1.1
- if filter_out_low_hmes
+ if include_low_hmes
+ cutoff = 0.0
+ else
if ratio_type == :hme_score
adjust = Options.hmes_adjust
if Options.cross_type == 'back'
cutoff = (1.0/adjust) + 1.0
else # outcross
cutoff = (2.0/adjust) + 1.0
end
else # ratio_type is bfr_score
cutoff = bfr_cutoff(selected_contigs)
end
- else
- cutoff = 0.0
end
cutoff
end
# Cut off value calculation for bfr contigs.