lib/genevalidator/hsp.rb in genevalidator-1.6.2 vs lib/genevalidator/hsp.rb in genevalidator-1.6.3
- old
+ new
@@ -1,7 +1,8 @@
require 'genevalidator/blast'
require 'genevalidator/exceptions'
+
module GeneValidator
# A class that initialises the BLAST tabular attributes
class Hsp
attr_accessor :hit_from # ref. from the unaligned hit sequence
attr_accessor :hit_to
@@ -43,16 +44,15 @@
@hit_alignment = hash['sseq'] if hash['sseq']
@align_len = hash['length'].to_i if hash['length']
@pidentity = hash['pident'].to_f if hash['pident']
@identity = hash['nident'].to_f if hash['nident']
@hsp_evalue = hash['evalue'].to_f if hash['evalue']
- if hash['qseq']
- query_seq_type = BlastUtils.guess_sequence_type(@query_alignment)
- fail SequenceTypeError if query_seq_type != :protein
- end
- if hash['sseq']
- hit_seq_type = BlastUtils.guess_sequence_type(@hit_alignment)
- fail SequenceTypeError if hit_seq_type != :protein
- end
+ assert_seq_type(@query_alignment) if hash['sseq']
+ assert_seq_type(@hit_alignment) if hash['sseq']
+ end
+
+ def assert_seq_type(query)
+ seq_type = BlastUtils.guess_sequence_type(query)
+ fail SequenceTypeError if seq_type != :protein
end
end
end