/** * Retrieves the index mass including all modifications * @param string $weighttype The weighttype to use for masses * @param int $index The index of the amino acid in sequence * @return float The total mass of the amino acid including all modifications */ public function getIndexMass($weighttype, $index) { $loc = basename(__FILE__) . '/' . __METHOD__; $arrModifications; $dblAddMass = 0; $dblMass = 0; $objMod = null; $strAa = ''; if (!isset($this->Sequence) || $this->Sequence === '') { $this->toLog('error', $loc, 'Sequence not set', 'Failed to get modification for index. Sequence not set yet.', ''); return; } if ($index >= strlen($this->Sequence)) { $this->toLog('error', $loc, 'Index out of bounds', 'Specified index is out of sequence bounds.', ''); return -1; } $strAa = substr($this->Sequence, $index, 1); $dblMass = parent::getIndexMass($weighttype, $index); $arrModifications = $this->getIndexModifications($index, $weighttype); for ($i = 0, $j = count($arrModifications); $i < $j; $i++) { $objMod = $arrModifications[$i]; $dblAddMass += $this->getModificationMass($objMod['accession'], $strAa, $index, $weighttype); } return $dblMass + $dblAddMass; }