lib/genevalidator/validation_duplication.rb in genevalidator-1.6.2 vs lib/genevalidator/validation_duplication.rb in genevalidator-1.6.3
- old
+ new
@@ -2,10 +2,11 @@
require 'forwardable'
require 'statsample'
require 'genevalidator/exceptions'
require 'genevalidator/ext/array'
+require 'genevalidator/get_raw_sequences'
require 'genevalidator/validation_report'
require 'genevalidator/validation_test'
module GeneValidator
##
@@ -111,39 +112,28 @@
# Check duplication in the first n hits
# Output:
# +DuplicationValidationOutput+ object
def run(n = 10)
fail NotEnoughHitsError unless hits.length >= 5
- fail Exception unless prediction.is_a?(Sequence) &&
- !prediction.raw_sequence.nil? &&
- hits[0].is_a?(Sequence)
+ fail unless prediction.is_a?(Query) && !prediction.raw_sequence.nil? &&
+ hits[0].is_a?(Query)
start = Time.new
# get the first n hits
less_hits = @hits[0..[n - 1, @hits.length].min]
useless_hits = []
-
# get raw sequences for less_hits
less_hits.map do |hit|
- # get gene by accession number
next unless hit.raw_sequence.nil?
-
- hit.get_sequence_from_index_file(@raw_seq_file, @index_file_name,
- hit.identifier, @raw_seq_file_load)
-
- if hit.raw_sequence.nil? || hit.raw_sequence.empty?
- seq_type = (hit.type == :protein) ? 'protein' : 'nucleotide'
- hit.get_sequence_by_accession_no(hit.accession_no, seq_type, @db)
- end
-
+ hit.raw_sequence = FetchRawSequences.run(hit.identifier,
+ hit.accession_no)
useless_hits.push(hit) if hit.raw_sequence.nil?
- useless_hits.push(hit) if hit.raw_sequence.empty?
end
useless_hits.each { |hit| less_hits.delete(hit) }
- fail NoInternetError if less_hits.length.nil?
+ fail NoInternetError if less_hits.length == 0
averages = []
less_hits.each do |hit|
coverage = Array.new(hit.length_protein, 0)
@@ -183,11 +173,11 @@
align = []
raw_align.each { |seq| align.push(seq.to_s) }
hit_alignment = align[0]
query_alignment = align[1]
- rescue Exception
+ rescue
raise NoMafftInstallationError
end
end
# check multiple coverage
@@ -248,10 +238,10 @@
rescue NoInternetError
@validation_report = ValidationReport.new('Internet error', :error,
@short_header, @header,
@description)
@validation_report.errors.push NoInternetError
- rescue Exception
+ rescue
@validation_report = ValidationReport.new('Unexpected error', :error,
@short_header, @header,
@description)
@validation_report.errors.push 'Unexpected Error'
end