Source of file AbstractFragmentReverse.php
Size: 2,496 Bytes - Last Modified: 2019-05-10T12:24:09+01:00
src/Utility/Fragment/AbstractFragmentReverse.php
1234567891011121314151617181920212223242526272829303132
Covered by 5 test(s):
33
Covered by 5 test(s):
34
Covered by 5 test(s):
3536373839404142
Covered by 4 test(s):
43
Covered by 4 test(s):
4445
Covered by 4 test(s):
4647
Covered by 4 test(s):
48
Covered by 4 test(s):
4950
Covered by 4 test(s):
51
Covered by 4 test(s):
52
Covered by 4 test(s):
535455
Covered by 4 test(s):
56
Covered by 4 test(s):
57
Covered by 4 test(s):
58
Covered by 4 test(s):
59606162
Covered by 4 test(s):
6364
Covered by 1 test(s):
65
Covered by 1 test(s):
6667
Covered by 1 test(s):
68
Covered by 1 test(s):
69
Covered by 4 test(s):
7071
Covered by 4 test(s):
72
Covered by 3 test(s):
73
Covered by 3 test(s):
7475
Covered by 4 test(s):
76
Covered by 4 test(s):
77
Covered by 4 test(s):
7879
Covered by 4 test(s):
808182
| <?php /** * Copyright 2019 University of Liverpool * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace pgb_liv\php_ms\Utility\Fragment; use pgb_liv\php_ms\Core\AminoAcidMono; use pgb_liv\php_ms\Core\ModifiableSequenceInterface; /** * Abstract class containing generic filtering methods * * @author Andrew Collins */ abstract class AbstractFragmentReverse extends AbstractFragment implements FragmentInterface { public function __construct(ModifiableSequenceInterface $sequence) { $this->setIsReversed(true); parent::__construct($sequence); } /** * * {@inheritdoc} */ public function getIons($charge = 1) { $ions = array(); $sequence = $this->sequence->getSequence(); $sum = 0; $cTermMass = $this->getCTerminalMass(); $nTermMass = $this->getNTerminalMass(); for ($i = $this->getEnd(); $i > $this->getStart(); $i --) { $residue = $sequence[$i - 1]; $mass = AminoAcidMono::getMonoisotopicMass($residue); // Add mass if ($i == $this->getEnd()) { $mass += $this->getAdditiveMass(); $mass += $cTermMass; } // Add modification mass // Catch modification on position or residue foreach ($this->sequence->getModifications() as $modification) { // Check every position or residue if ($modification->getLocation() === $i || (is_null($modification->getLocation()) && in_array($residue, $modification->getResidues()))) { // Residue is modified $mass += $modification->getMonoisotopicMass(); } } if ($i == 1) { $mass += $nTermMass; } $sum += $mass; $ions[($this->getEnd() - $i) + 1] = $this->getChargedIon($sum, $charge); } return $ions; } } |