src/Core/ModifiableSequenceTrait.php
public function getMonoisotopicMass()
    {
        $acids = str_split($this->getSequence(), 1);

        $mass = ChemicalConstants::HYDROGEN_MASS + ChemicalConstants::HYDROGEN_MASS + ChemicalConstants::OXYGEN_MASS;

        foreach ($acids as $acid) {
            switch ($acid) {
                case 'X':
                case 'B':
                case 'Z':
                    continue;
                default:
                    $mass += AminoAcidMono::getMonoisotopicMass($acid);
                    break;
            }
        }

        // Add modification mass
        // Catch modification on position, residue or terminus
        foreach ($this->getModifications() as $modification) {
            if (! is_null($modification->getLocation())) {
                $mass += $modification->getMonoisotopicMass();
                continue;
            }

            switch ($modification->getPosition()) {
                case Modification::POSITION_NTERM:
                case Modification::POSITION_PROTEIN_NTERM:
                    // TODO: Handle protein level safely
                    // A peptide can be both at protein n-term and not since multiple proteins supported
                    $nTerm = $this->sequence[0];
                    if (in_array($nTerm, $modification->getResidues())) {
                        $mass += $modification->getMonoisotopicMass();
                    }

                    break;

                case Modification::POSITION_CTERM:
                case Modification::POSITION_PROTEIN_CTERM:
                    // TODO: Handle protein level safely
                    // A peptide can be both at protein n-term and not since multiple proteins supported
                    $cTerm = $this->sequence[strlen($this->sequence) - 1];
                    if (in_array($cTerm, $modification->getResidues())) {
                        $mass += $modification->getMonoisotopicMass();
                    }

                    break;

                default:
                    foreach ($acids as $acid) {
                        if (in_array($acid, $modification->getResidues())) {
                            $mass += $modification->getMonoisotopicMass();
                        }
                    }
                    break;
            }
        }

        return $mass;
    }
public function getMonoisotopicMass()
    {
        $acids = str_split($this->getSequence(), 1);

        $mass = ChemicalConstants::HYDROGEN_MASS + ChemicalConstants::HYDROGEN_MASS + ChemicalConstants::OXYGEN_MASS;

        foreach ($acids as $acid) {
            switch ($acid) {
                case 'X':
                case 'B':
                case 'Z':
                    continue;
                default:
                    $mass += AminoAcidMono::getMonoisotopicMass($acid);
                    break;
            }
        }

        // Add modification mass
        // Catch modification on position, residue or terminus
        foreach ($this->getModifications() as $modification) {
            if (! is_null($modification->getLocation())) {
                $mass += $modification->getMonoisotopicMass();
                continue;
            }

            switch ($modification->getPosition()) {
                case Modification::POSITION_NTERM:
                case Modification::POSITION_PROTEIN_NTERM:
                    // TODO: Handle protein level safely
                    // A peptide can be both at protein n-term and not since multiple proteins supported
                    $nTerm = $this->sequence[0];
                    if (in_array($nTerm, $modification->getResidues())) {
                        $mass += $modification->getMonoisotopicMass();
                    }

                    break;

                case Modification::POSITION_CTERM:
                case Modification::POSITION_PROTEIN_CTERM:
                    // TODO: Handle protein level safely
                    // A peptide can be both at protein n-term and not since multiple proteins supported
                    $cTerm = $this->sequence[strlen($this->sequence) - 1];
                    if (in_array($cTerm, $modification->getResidues())) {
                        $mass += $modification->getMonoisotopicMass();
                    }

                    break;

                default:
                    foreach ($acids as $acid) {
                        if (in_array($acid, $modification->getResidues())) {
                            $mass += $modification->getMonoisotopicMass();
                        }
                    }
                    break;
            }
        }

        return $mass;
    }
public function getMonoisotopicMass ( ) { $ acids = str_split ( $ this -> getSequence ( ) , 1 ) ; $ mass = ChemicalConstants :: HYDROGEN_MASS + ChemicalConstants :: HYDROGEN_MASS + ChemicalConstants :: OXYGEN_MASS ; foreach ( $ acids as $ acid ) { switch ( $ acid ) { case 'X' : case 'B' : case 'Z' : continue ; default : $ mass += AminoAcidMono :: getMonoisotopicMass ( $ acid ) ; break ; } } // Add modification mass // Catch modification on position, residue or terminus foreach ( $ this -> getModifications ( ) as $ modification ) { if ( ! is_null ( $ modification -> getLocation ( ) ) ) { $ mass += $ modification -> getMonoisotopicMass ( ) ; continue ; } switch ( $ modification -> getPosition ( ) ) { case Modification :: POSITION_NTERM : case Modification :: POSITION_PROTEIN_NTERM : // TODO: Handle protein level safely // A peptide can be both at protein n-term and not since multiple proteins supported $ nTerm = $ this -> sequence [ 0 ] ; if ( in_array ( $ nTerm , $ modification -> getResidues ( ) ) ) { $ mass += $ modification -> getMonoisotopicMass ( ) ; } break ; case Modification :: POSITION_CTERM : case Modification :: POSITION_PROTEIN_CTERM : // TODO: Handle protein level safely // A peptide can be both at protein n-term and not since multiple proteins supported $ cTerm = $ this -> sequence [ strlen ( $ this -> sequence ) - 1 ] ; if ( in_array ( $ cTerm , $ modification -> getResidues ( ) ) ) { $ mass += $ modification -> getMonoisotopicMass ( ) ; } break ; default : foreach ( $ acids as $ acid ) { if ( in_array ( $ acid , $ modification -> getResidues ( ) ) ) { $ mass += $ modification -> getMonoisotopicMass ( ) ; } } break ; } } return $ mass ; }
Gets the theoretical monoisotopic neutral mass for this sequence and it's modifications

@return float The neutral mass of the sequence
Gets the theoretical monoisotopic neutral mass for this sequence and it s modifications