Module: Bio::Protparam::Local

Defined in:
lib/bio/util/protparam.rb

Instance Method Summary collapse

Instance Method Details

#aa_comp(aa_code = nil) ⇒ Object

Calculate the percentage composition of an AA sequence as a Hash object. It return percentage of a given amino acid if aa_code is not nil.


749
750
751
752
753
754
755
756
757
758
759
# File 'lib/bio/util/protparam.rb', line 749

def aa_comp(aa_code=nil)
  if aa_code.nil?
    aa_map = {}
    IUPAC_CODE.keys.each do |k|
      aa_map[k] = 0.0
    end
    aa_map.update(aa_comp_map){|k,_,v| round(v, 1) }
  else
    round(aa_comp_map[aa_code], 1)
  end
end

#aliphatic_indexObject

Calculate aliphatic index of an AA sequence.

_The aliphatic index of a protein is defined as the relative volume occupied by aliphatic side chains (alanine, valine, isoleucine, and leucine). It may be regarded as a positive factor for the increase of thermostability of globular proteins._


719
720
721
722
723
724
# File 'lib/bio/util/protparam.rb', line 719

def aliphatic_index
  aa_map = aa_comp_map
  @aliphatic_index ||=  round(aa_map[:A]        +
                              2.9 * aa_map[:V]  +
                              (3.9 * (aa_map[:I] + aa_map[:L])), 2)
end

#amino_acid_numberObject

Return the number of residues in an AA sequence.


535
536
537
# File 'lib/bio/util/protparam.rb', line 535

def amino_acid_number
  @seq.length
end

#gravyObject

Calculate GRAVY score of an AA sequence.

_The GRAVY(Grand Average of Hydropathy) value for a peptide or protein is calculated as the sum of hydropathy values [9] of all the amino acids, divided by the number of residues in the sequence._


734
735
736
737
738
739
740
741
742
# File 'lib/bio/util/protparam.rb', line 734

def gravy
  @gravy ||= begin
               hydropathy_sum = 0.0
               each_aa do |aa|
                 hydropathy_sum += HYDROPATHY[aa]
               end
               round(hydropathy_sum / @seq.length.to_f, 3)
             end
end

#half_life(species = nil) ⇒ Object

Return estimated half_life of an AA sequence.

_The half-life is a prediction of the time it takes for half of the amount of protein in a cell to disappear after its synthesis in the cell. ProtParam relies on the “N-end rule”, which relates the half-life of a protein to the identity of its N-terminal residue; the prediction is given for 3 model organisms (human, yeast and E.coli)._


649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/bio/util/protparam.rb', line 649

def half_life(species=nil)
  n_end = @seq[0].chr.to_sym
  if species
    HALFLIFE[species][n_end]
  else
    {
      :ecoli     => HALFLIFE[:ecoli][n_end],
      :mammalian => HALFLIFE[:mammalian][n_end],
      :yeast     => HALFLIFE[:yeast][n_end]
    }
  end
end

#instability_indexObject

Calculate instability index of an AA sequence.

_The instability index provides an estimate of the stability of your protein in a test tube. Statistical analysis of 12 unstable and 32 stable proteins has revealed [7] that there are certain dipeptides, the occurence of which is significantly different in the unstable proteins compared with those in the stable ones. The authors of this method have assigned a weight value of instability to each of the 400 different dipeptides (DIWV)._


674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/bio/util/protparam.rb', line 674

def instability_index
  @instability_index ||=
    begin
      instability_sum = 0.0
      i = 0
      while @seq[i+1] != nil
        aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym]
        if DIWV.key?(aa) && DIWV[aa].key?(next_aa)
          instability_sum += DIWV[aa][next_aa]
        end
        i += 1
      end
      round((10.0/amino_acid_number.to_f) * instability_sum, 2)
    end
end

#molecular_weightObject

Calculate molecular weight of an AA sequence.

_Protein Mw is calculated by the addition of average isotopic masses of amino acids in the protein and the average isotopic mass of one water molecule._


614
615
616
617
618
619
620
621
622
# File 'lib/bio/util/protparam.rb', line 614

def molecular_weight
  @mw ||= begin
            mass = WATER_MASS
            each_aa do |aa|
              mass += AVERAGE_MASS[aa.to_sym]
            end
            (mass * 10).floor().to_f / 10
          end
end

#num_carbonObject

Return the number of carbons.


574
575
576
# File 'lib/bio/util/protparam.rb', line 574

def num_carbon
  @num_carbon ||= total_atoms :C
end

#num_hydrogenObject


578
579
580
# File 'lib/bio/util/protparam.rb', line 578

def num_hydrogen
  @num_hydrogen ||= total_atoms :H
end

#num_negObject

Return the number of negative amino acids (D and E) in an AA sequence.


519
520
521
# File 'lib/bio/util/protparam.rb', line 519

def num_neg
  @num_neg ||= @seq.count("DE")
end

#num_nitroObject

Return the number of nitrogens.


586
587
588
# File 'lib/bio/util/protparam.rb', line 586

def num_nitro
  @num_nitro ||= total_atoms :N
end

#num_oxygenObject

Return the number of oxygens.


594
595
596
# File 'lib/bio/util/protparam.rb', line 594

def num_oxygen
  @num_oxygen ||= total_atoms :O
end

#num_posObject

Return the number of positive amino acids (R and K) in an AA sequence.


527
528
529
# File 'lib/bio/util/protparam.rb', line 527

def num_pos
  @num_neg ||= @seq.count("RK")
end

#num_sulphurObject

Return the number of sulphurs.


602
603
604
# File 'lib/bio/util/protparam.rb', line 602

def num_sulphur
  @num_sulphur ||= total_atoms :S
end

#stabilityObject

Return wheter the sequence is stable or not as String (stable/unstable).

_Protein whose instability index is smaller than 40 is predicted as stable, a value above 40 predicts that the protein may be unstable._


698
699
700
# File 'lib/bio/util/protparam.rb', line 698

def stability
  (instability_index <= 40) ? "stable" : "unstable"
end

#stable?Boolean

Return true if the sequence is stable.

Returns:

  • (Boolean)

706
707
708
# File 'lib/bio/util/protparam.rb', line 706

def stable?
  (instability_index <= 40) ? true : false
end

#theoretical_pIObject

Claculate theoretical pI for an AA sequence with bisect algorithm. pK value by Bjelqist, et al. is used to calculate pI.


629
630
631
632
633
634
635
636
637
# File 'lib/bio/util/protparam.rb', line 629

def theoretical_pI
  charges = []
  residue_count().each do |residue|
    charges << charge_proc(residue[:positive],
                           residue[:pK],
                           residue[:num])
  end
  round(solve_pI(charges), 2)
end

#total_atoms(type = nil) ⇒ Object

Return the number of atoms in a sequence. If type is given, return the number of specific atoms in a sequence.


544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/bio/util/protparam.rb', line 544

def total_atoms(type=nil)
  if !type.nil?
    type = type.to_sym
    if /^(?:C|H|O|N|S){1}$/ !~ type.to_s
      raise ArgumentError, "type must be C/H/O/N/S/nil(all)"
    end
  end
  num_atom = {:C => 0,
              :H => 0,
              :O => 0,
              :N => 0,
              :S => 0}
  each_aa do |aa|
    ATOM[aa].each do |t, num|
      num_atom[t] += num
    end
  end
  num_atom[:H] = num_atom[:H] - 2 * (amino_acid_number - 1)
  num_atom[:O] = num_atom[:O] - (amino_acid_number - 1)
  if type.nil?
    num_atom.values.inject(0){|prod, num| prod += num }
  else
    num_atom[type]
  end
end