MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / getFormula

Method getFormula

src/openms/source/CHEMISTRY/NASequence.cpp:135–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 EmpiricalFormula NASequence::getFormula(NASFragmentType type, Int charge) const
136 {
137 static const EmpiricalFormula H_form = EmpiricalFormula::hydrogen();
138 static const EmpiricalFormula phosphate_form = EmpiricalFormula("HPO3");
139 static const EmpiricalFormula thiophosphate_form = EmpiricalFormula("HPO2S1");
140 static const EmpiricalFormula internal_to_full = EmpiricalFormula::water();
141 // static const EmpiricalFormula five_prime_to_full = EmpiricalFormula("HPO3");
142 // static const EmpiricalFormula three_prime_to_full = EmpiricalFormula("");
143 static const EmpiricalFormula a_ion_to_full = EmpiricalFormula::water(-1);
144 static const EmpiricalFormula b_ion_to_full = EmpiricalFormula();
145 static const EmpiricalFormula c_ion_to_full = EmpiricalFormula("H-1PO2");
146 static const EmpiricalFormula d_ion_to_full = phosphate_form;
147 static const EmpiricalFormula w_ion_to_full = d_ion_to_full;
148 static const EmpiricalFormula x_ion_to_full = c_ion_to_full;
149 static const EmpiricalFormula y_ion_to_full = b_ion_to_full;
150 static const EmpiricalFormula z_ion_to_full = a_ion_to_full;
151 static const EmpiricalFormula aminusB_ion_to_full = EmpiricalFormula::water(-2);
152 // static const EmpiricalFormula abasicform_RNA = EmpiricalFormula("C5H8O4");
153 // static const EmpiricalFormula abasicform_DNA = EmpiricalFormula("C5H7O5P");
154
155 if (seq_.empty())
156 return EmpiricalFormula();
157
158 EmpiricalFormula our_form;
159 // Add all the ribonucleotide masses
160 for (const auto& i : seq_)
161 {
162 our_form += i->getFormula();
163 // Add the phosphate (of thiophosphate) per linkage
164 if (&i != &seq_.back()) // no linkage at last base
165 {
166 if (i->getCode().back() == '*')
167 {
168 our_form += (thiophosphate_form - internal_to_full);
169 }
170 else
171 {
172 our_form += (phosphate_form - internal_to_full);
173 }
174 }
175 }
176
177 EmpiricalFormula local_three_prime, local_five_prime;
178
179 // Make local copies of the formulas for the terminal mods so we don't get into trouble dereferencing null ptrs
180 if (three_prime_ != nullptr)
181 {
182 local_three_prime = three_prime_->getFormula() - H_form;
183 }
184 if (five_prime_ != nullptr)
185 {
186 local_five_prime = five_prime_->getFormula() - H_form;
187 }
188
189 switch (type)
190 {
191 case Full:
192 return our_form + (H_form * charge) + local_five_prime + local_three_prime;

Callers

nothing calls this directly

Calls 5

backMethod · 0.80
getCodeMethod · 0.80
getBaselossFormulaMethod · 0.80
EmpiricalFormulaFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected