Class: Bio::HMMER::Report::Hsp

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/hmmer/report.rb

Overview

Container class for HMMER search hsps.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsp_data, is_hmmsearch) ⇒ Hsp

Sets hsps.



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/bio/appl/hmmer/report.rb', line 483

def initialize(hsp_data, is_hmmsearch)
  @is_hmmsearch = is_hmmsearch

  @accession, @domain, seq_f, seq_t, @seq_ft, hmm_f, hmm_t, @hmm_ft,\
  score, evalue = hsp_data.split(' ')
  @seq_f = seq_f.to_i
  @seq_t = seq_t.to_i
  @hmm_f = hmm_f.to_i
  @hmm_t = hmm_t.to_i
  @score = score.to_f
  @evalue = evalue.to_f
  @hmmseq = ''
  @flatseq = ''
  @midline = ''
  @query_frame = 1
  @target_frame = 1
  # CS and RF lines are rarely used.
  @csline = nil
  @rfline = nil
end

Instance Attribute Details

#accessionObject (readonly) Also known as: target_id

Returns the value of attribute accession.



430
431
432
# File 'lib/bio/appl/hmmer/report.rb', line 430

def accession
  @accession
end

#cslineObject (readonly)

CS Line



477
478
479
# File 'lib/bio/appl/hmmer/report.rb', line 477

def csline
  @csline
end

#domainObject (readonly)

Returns the value of attribute domain.



434
435
436
# File 'lib/bio/appl/hmmer/report.rb', line 434

def domain
  @domain
end

#evalueObject (readonly)

E-value



459
460
461
# File 'lib/bio/appl/hmmer/report.rb', line 459

def evalue
  @evalue
end

#flatseqObject (readonly)

Returns the value of attribute flatseq.



468
469
470
# File 'lib/bio/appl/hmmer/report.rb', line 468

def flatseq
  @flatseq
end

#hmm_fObject (readonly)

Returns the value of attribute hmm_f.



446
447
448
# File 'lib/bio/appl/hmmer/report.rb', line 446

def hmm_f
  @hmm_f
end

#hmm_ftObject (readonly)

Returns the value of attribute hmm_ft.



452
453
454
# File 'lib/bio/appl/hmmer/report.rb', line 452

def hmm_ft
  @hmm_ft
end

#hmm_tObject (readonly)

Returns the value of attribute hmm_t.



449
450
451
# File 'lib/bio/appl/hmmer/report.rb', line 449

def hmm_t
  @hmm_t
end

#hmmseqObject (readonly)

Returns the value of attribute hmmseq.



465
466
467
# File 'lib/bio/appl/hmmer/report.rb', line 465

def hmmseq
  @hmmseq
end

#midlineObject (readonly)

Alignment midline



462
463
464
# File 'lib/bio/appl/hmmer/report.rb', line 462

def midline
  @midline
end

#query_frameObject (readonly)

Returns the value of attribute query_frame.



471
472
473
# File 'lib/bio/appl/hmmer/report.rb', line 471

def query_frame
  @query_frame
end

#rflineObject (readonly)

RF Line



480
481
482
# File 'lib/bio/appl/hmmer/report.rb', line 480

def rfline
  @rfline
end

#scoreObject (readonly) Also known as: bit_score

Score



455
456
457
# File 'lib/bio/appl/hmmer/report.rb', line 455

def score
  @score
end

#seq_fObject (readonly)

Returns the value of attribute seq_f.



437
438
439
# File 'lib/bio/appl/hmmer/report.rb', line 437

def seq_f
  @seq_f
end

#seq_ftObject (readonly)

Returns the value of attribute seq_ft.



443
444
445
# File 'lib/bio/appl/hmmer/report.rb', line 443

def seq_ft
  @seq_ft
end

#seq_tObject (readonly)

Returns the value of attribute seq_t.



440
441
442
# File 'lib/bio/appl/hmmer/report.rb', line 440

def seq_t
  @seq_t
end

#target_frameObject (readonly)

Returns the value of attribute target_frame.



474
475
476
# File 'lib/bio/appl/hmmer/report.rb', line 474

def target_frame
  @target_frame
end

Instance Method Details

#query_fromObject



550
551
552
# File 'lib/bio/appl/hmmer/report.rb', line 550

def query_from
  @is_hmmsearch ? @hmm_f   : @seq_f
end

#query_seqObject



530
531
532
# File 'lib/bio/appl/hmmer/report.rb', line 530

def query_seq
  @is_hmmsearch ? @hmmseq  : @flatseq
end

#query_toObject



555
556
557
# File 'lib/bio/appl/hmmer/report.rb', line 555

def query_to
  @is_hmmsearch ? @hmm_t   : @seq_t
end

#set_alignment(alignment) ⇒ Object



505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/bio/appl/hmmer/report.rb', line 505

def set_alignment(alignment)
  # First, split the input alignment into an array of
  # "alignment blocks." One block usually has three lines,
  # i.e. hmmseq, midline and flatseq. 
  # However, although infrequent, it can contain CS or RF lines.
  alignment.split(/ (?:\d+|-)\s*\n\n/).each do |blk|
    lines = blk.split(/\n/)   
    cstmp = (lines[0] =~ /^ {16}CS/) ? lines.shift : nil
    rftmp = (lines[0] =~ /^ {16}RF/) ? lines.shift : nil
    aln_width = lines[0][/\S+/].length
    @csline  = @csline.to_s + cstmp[19, aln_width] if cstmp
    @rfline  = @rfline.to_s + rftmp[19, aln_width] if rftmp
    @hmmseq  += lines[0][19, aln_width]
    @midline += lines[1][19, aln_width]
    @flatseq += lines[2][19, aln_width]
  end
  @csline  = @csline[3...-3] if @csline
  @rfline  = @rfline[3...-3] if @rfline
  @hmmseq  = @hmmseq[3...-3]
  @midline = @midline[3...-3]
  @flatseq = @flatseq[3...-3]
end

#target_fromObject



540
541
542
# File 'lib/bio/appl/hmmer/report.rb', line 540

def target_from
  @is_hmmsearch ? @seq_f   : @hmm_f
end

#target_seqObject



535
536
537
# File 'lib/bio/appl/hmmer/report.rb', line 535

def target_seq
  @is_hmmsearch ? @flatseq : @hmmseq
end

#target_toObject



545
546
547
# File 'lib/bio/appl/hmmer/report.rb', line 545

def target_to
  @is_hmmsearch ? @seq_t   : @hmm_t
end