Source of file AbstractSearchParameters.php

Size: 4,936 Bytes - Last Modified: 2019-05-10T12:24:09+01:00

src/Search/Parameters/AbstractSearchParameters.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanValidiateGetSetValidNmeEnabled
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDatabases2
49
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanValidiateGetSetValidNmeEnabled
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDatabases2
505152535455565758
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanValidiateGetSetValidNmeEnabled
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDatabases2
5960616263
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidEnzyme
64
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidEnzyme
65666768
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidEnzyme
  • pgb_liv\php_ms\Test\Unit\MsgfPlusSearchParametersTest::testCanGetSetValidEnzyme
6970717273
Covered by 3 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidMissedCleavageCount
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanSetInvalidMissedCleavageCountNegative
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanSetInvalidMissedCleavageCountString
74
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanSetInvalidMissedCleavageCountNegative
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanSetInvalidMissedCleavageCountString
757677
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidMissedCleavageCount
78
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidMissedCleavageCount
79808182
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidMissedCleavageCount
8384858687
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidPrecursorTolerance
8889909192
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidPrecursorTolerance
93
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidPrecursorTolerance
94959697
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFragmentTolerance
98
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFragmentTolerance
99100101102103104105106107
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFragmentTolerance
108109110111112113114115116117118119120121
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidSpectraPath
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetInvalidSpectraPath
122
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetInvalidSpectraPath
123124125
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidSpectraPath
126
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidSpectraPath
127128129130
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidSpectraPath
131132133134135
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDecoyEnabled
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetInvalidDecoyEnabled
136
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetInvalidDecoyEnabled
137138139
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDecoyEnabled
140
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDecoyEnabled
141142143144
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidDecoyEnabled
145146147148149
Covered by 4 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidModifications
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanClearModifications
150
Covered by 4 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidModifications
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanClearModifications
151152153154155156157158
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidModifications
159160161162163
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanClearModifications
164
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanClearModifications
165166167168
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
169
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
170
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
171172173174
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
175
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
176
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
177
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
178
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
179
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
180181
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidFixedModifications1
182183184185186
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
187
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
188
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
189190191192
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
193
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
194
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
195
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
196
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
197
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
198199
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\AbstractSearchParametersTest::testCanGetSetValidVariableModifications1
200201202
<?php
/**
 * Copyright 2016 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\Search\Parameters;

use pgb_liv\php_ms\Core\Tolerance;
use pgb_liv\php_ms\Core\Modification;

/**
 * Abstract class containing generic filtering methods
 *
 * @author Andrew Collins
 */
abstract class AbstractSearchParameters
{

    private $databases;

    private $spectraPath;

    private $precursorTolerance;

    private $fragmentTolerance;

    private $enzyme;

    private $isDecoyEnabled = false;

    private $missedCleavageCount;

    private $modifications = array();

    public function setDatabases($databases)
    {
        $this->databases = $databases;
    }

    /**
     * The sequence database(s) to be searched.
     *
     * @return string
     */
    public function getDatabases()
    {
        return $this->databases;
    }

    public function setEnzyme($enzyme)
    {
        $this->enzyme = $enzyme;
    }

    public function getEnzyme()
    {
        return $this->enzyme;
    }

    public function setMissedCleavageCount($maxCleave)
    {
        if (! is_int($maxCleave) || $maxCleave < 0) {
            throw new \InvalidArgumentException('Argument 1 must be an unsigned integer value');
        }
        
        $this->missedCleavageCount = $maxCleave;
    }

    public function getMissedCleavageCount()
    {
        return $this->missedCleavageCount;
    }

    public function getPrecursorTolerance()
    {
        return $this->precursorTolerance;
    }

    public function setPrecursorTolerance(Tolerance $tolerance)
    {
        $this->precursorTolerance = $tolerance;
    }

    public function setFragmentTolerance(Tolerance $tolerance)
    {
        $this->fragmentTolerance = $tolerance;
    }

    /**
     * Gets the Fragment Tolerance object
     *
     * @return \pgb_liv\php_ms\Core\Tolerance
     */
    public function getFragmentTolerance()
    {
        return $this->fragmentTolerance;
    }

    /**
     * Sets the spectra file location
     *
     * @param string $filePath
     *            Path to the spectra file
     * @param bool $ignoreValidation
     *            If true will disable validation that the file must exist
     * @throws \InvalidArgumentException Thrown if $ignoreValidation is false and the file does not exist
     */
    public function setSpectraPath($filePath, $ignoreValidation = false)
    {
        if (! $ignoreValidation && ! file_exists($filePath)) {
            throw new \InvalidArgumentException('Argument 1 must specify a valid file');
        }
        
        $this->spectraPath = $filePath;
    }

    public function getSpectraPath()
    {
        return $this->spectraPath;
    }

    public function setDecoyEnabled($bool)
    {
        if (! is_bool($bool)) {
            throw new \InvalidArgumentException('Argument 1 must be a boolean value');
        }
        
        $this->isDecoyEnabled = $bool;
    }

    public function isDecoyEnabled()
    {
        return $this->isDecoyEnabled;
    }

    public function addModification(Modification $modification)
    {
        $this->modifications[] = $modification;
    }

    /**
     *
     * @return Modification[]
     */
    public function getModifications()
    {
        return $this->modifications;
    }

    public function clearModifications()
    {
        $this->modifications = array();
    }

    public function addFixedModification(Modification $modification)
    {
        $modification->setType(Modification::TYPE_FIXED);
        $this->addModification($modification);
    }

    public function getFixedModifications()
    {
        $fixed = array();
        foreach ($this->getModifications() as $modification) {
            if ($modification->getType() == Modification::TYPE_FIXED) {
                $fixed[] = $modification;
            }
        }
        
        return $fixed;
    }

    public function addVariableModification(Modification $modification)
    {
        $modification->setType(Modification::TYPE_VARIABLE);
        $this->addModification($modification);
    }

    public function getVariableModifications()
    {
        $variable = array();
        foreach ($this->getModifications() as $modification) {
            if ($modification->getType() == Modification::TYPE_VARIABLE) {
                $variable[] = $modification;
            }
        }
        
        return $variable;
    }
}