Class: Protein
- Inherits:
-
Object
- Object
- Protein
- Defined in:
- lib/protk/protein.rb
Instance Attribute Summary collapse
-
#group_number ⇒ Object
Returns the value of attribute group_number.
-
#group_probability ⇒ Object
Returns the value of attribute group_probability.
-
#n_indistinguishable_proteins ⇒ Object
Returns the value of attribute n_indistinguishable_proteins.
-
#peptides ⇒ Object
Returns the value of attribute peptides.
-
#percent_coverage ⇒ Object
Returns the value of attribute percent_coverage.
-
#probability ⇒ Object
Returns the value of attribute probability.
-
#protein_name ⇒ Object
Returns the value of attribute protein_name.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
Class Method Summary collapse
-
.from_mzid(xmlnode, mzid_doc) ⇒ Object
Note: This is hacked together to work for a specific PeptideShaker output type Refactor and properly respect cvParams for real conversion.
- .from_protxml(xmlnode) ⇒ Object
Instance Method Summary collapse
- #as_protxml ⇒ Object
-
#initialize ⇒ Protein
constructor
A new instance of Protein.
-
#representative_peptides ⇒ Object
Return just one peptide for each unique sequence choosing the peptide with highest probability.
Constructor Details
#initialize ⇒ Protein
Returns a new instance of Protein.
121 122 123 |
# File 'lib/protk/protein.rb', line 121 def initialize() end |
Instance Attribute Details
#group_number ⇒ Object
Returns the value of attribute group_number.
9 10 11 |
# File 'lib/protk/protein.rb', line 9 def group_number @group_number end |
#group_probability ⇒ Object
Returns the value of attribute group_probability.
10 11 12 |
# File 'lib/protk/protein.rb', line 10 def group_probability @group_probability end |
#n_indistinguishable_proteins ⇒ Object
Returns the value of attribute n_indistinguishable_proteins.
14 15 16 |
# File 'lib/protk/protein.rb', line 14 def n_indistinguishable_proteins @n_indistinguishable_proteins end |
#peptides ⇒ Object
Returns the value of attribute peptides.
16 17 18 |
# File 'lib/protk/protein.rb', line 16 def peptides @peptides end |
#percent_coverage ⇒ Object
Returns the value of attribute percent_coverage.
15 16 17 |
# File 'lib/protk/protein.rb', line 15 def percent_coverage @percent_coverage end |
#probability ⇒ Object
Returns the value of attribute probability.
11 12 13 |
# File 'lib/protk/protein.rb', line 11 def probability @probability end |
#protein_name ⇒ Object
Returns the value of attribute protein_name.
13 14 15 |
# File 'lib/protk/protein.rb', line 13 def protein_name @protein_name end |
#sequence ⇒ Object
Returns the value of attribute sequence.
12 13 14 |
# File 'lib/protk/protein.rb', line 12 def sequence @sequence end |
Class Method Details
.from_mzid(xmlnode, mzid_doc) ⇒ Object
Note: This is hacked together to work for a specific PeptideShaker output type Refactor and properly respect cvParams for real conversion
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/protk/protein.rb', line 87 def from_mzid(xmlnode,mzid_doc) coverage_cvparam="" prot=new() groupnode = xmlnode.parent prot.group_number=groupnode.attributes['id'].split("_").last.to_i+1 prot.protein_name=mzid_doc.get_dbsequence(xmlnode,xmlnode.attributes['dBSequence_ref']).attributes['accession'] prot.n_indistinguishable_proteins=mzid_doc.get_proteins_for_group(groupnode).length prot.group_probability=mzid_doc.get_cvParam(groupnode,"MS:1002470").attributes['value'].to_f coverage_node=mzid_doc.get_cvParam(xmlnode,"MS:1001093") prot.percent_coverage=coverage_node.attributes['value'].to_f if coverage_node prot.probability = mzid_doc.get_protein_probability(xmlnode) # require 'byebug';byebug peptide_nodes=mzid_doc.get_peptides_for_protein(xmlnode) prot.peptides = peptide_nodes.collect { |e| Peptide.from_mzid(e,mzid_doc) } Constants.instance.log "Generated protein entry with probability #{prot.probability}" , :debug prot end |
.from_protxml(xmlnode) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/protk/protein.rb', line 51 def from_protxml(xmlnode) prot=new() groupnode = xmlnode.parent prot.group_probability = groupnode['probability'].to_f prot.group_number = groupnode['group_number'].to_i prot.probability = xmlnode['probability'].to_f prot.protein_name = xmlnode['protein_name'] prot.n_indistinguishable_proteins = xmlnode['n_indistinguishable_proteins'].to_i prot.percent_coverage = xmlnode['percent_coverage'].to_f peptide_nodes = xmlnode.find('protxml:peptide','protxml:http://regis-web.systemsbiology.net/protXML') prot.peptides = peptide_nodes.collect { |e| Peptide.from_protxml(e) } prot end |
Instance Method Details
#as_protxml ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/protk/protein.rb', line 18 def as_protxml node = XML::Node.new('protein') node['protein_name']=self.protein_name.to_s node['n_indistinguishable_proteins']=self.n_indistinguishable_proteins.to_s node['probability']=self.probability.to_s node['percent_coverage']=self.percent_coverage.to_s node['unique_stripped_peptides']=self.peptides.collect {|p| p.sequence }.join("+") node['total_number_peptides']=self.peptides.length.to_s self.peptides.each do |peptide| node<<peptide.as_protxml end node end |
#representative_peptides ⇒ Object
Return just one peptide for each unique sequence choosing the peptide with highest probability
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/protk/protein.rb', line 127 def representative_peptides() best_peptides={} self.peptides.each do |peptide| seq = peptide.sequence if best_peptides[seq].nil? best_peptides[seq]=peptide else best_peptides[seq]=peptide if peptide.probability > best_peptides[seq].probability end end best_peptides.values end |