Class: Protein

Inherits:
Object
  • Object
show all
Defined in:
lib/protk/protein.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProtein

Returns a new instance of Protein.



114
115
116
# File 'lib/protk/protein.rb', line 114

def initialize()

end

Instance Attribute Details

#group_numberObject

Returns the value of attribute group_number.



9
10
11
# File 'lib/protk/protein.rb', line 9

def group_number
  @group_number
end

#group_probabilityObject

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_proteinsObject

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

#peptidesObject

Returns the value of attribute peptides.



16
17
18
# File 'lib/protk/protein.rb', line 16

def peptides
  @peptides
end

#percent_coverageObject

Returns the value of attribute percent_coverage.



15
16
17
# File 'lib/protk/protein.rb', line 15

def percent_coverage
  @percent_coverage
end

#probabilityObject

Returns the value of attribute probability.



11
12
13
# File 'lib/protk/protein.rb', line 11

def probability
  @probability
end

#protein_nameObject

Returns the value of attribute protein_name.



13
14
15
# File 'lib/protk/protein.rb', line 13

def protein_name
  @protein_name
end

#sequenceObject

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) ⇒ 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
# File 'lib/protk/protein.rb', line 87

def from_mzid(xmlnode)

	coverage_cvparam=""
	prot=new()
	groupnode = xmlnode.parent

	prot.group_number=groupnode.attributes['id'].split("_").last.to_i+1
	prot.protein_name=MzIdentMLDoc.get_dbsequence(xmlnode,xmlnode.attributes['dBSequence_ref']).attributes['accession']
	prot.n_indistinguishable_proteins=MzIdentMLDoc.get_proteins_for_group(groupnode).length
	prot.group_probability=MzIdentMLDoc.get_cvParam(groupnode,"MS:1002470").attributes['value'].to_f

	coverage_node=MzIdentMLDoc.get_cvParam(xmlnode,"MS:1001093")

	prot.percent_coverage=coverage_node.attributes['value'].to_f if coverage_node
	prot.probability = MzIdentMLDoc.get_protein_probability(xmlnode)
	# require 'byebug';byebug

	peptide_nodes=MzIdentMLDoc.get_peptides_for_protein(xmlnode)

	prot.peptides = peptide_nodes.collect { |e| Peptide.from_mzid(e) }
	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_protxmlObject



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_peptidesObject

Return just one peptide for each unique sequence choosing the peptide with highest probability



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/protk/protein.rb', line 120

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