Source of file FragmentFactory.php

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

src/Utility/Fragment/FragmentFactory.php

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetFragmentMethods
4849505152535455565758596061
Covered by 9 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
6263
Covered by 9 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
64
Covered by 9 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
65
Covered by 9 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
66
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
67
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
68
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
69
Covered by 7 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
70
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
71
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
72
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
73
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
74
Covered by 6 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
75
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
76
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
77
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
78
Covered by 5 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
79
Covered by 5 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
80
Covered by 5 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
81
Covered by 3 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
82
Covered by 3 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
83
Covered by 3 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
84
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
85
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
86
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
87
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
88
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
89
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
90
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
91
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
92
Covered by 9 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodUnknown
9394
Covered by 8 test(s):
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCID
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodHCD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodECD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodCTD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEDD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodNETD
  • pgb_liv\php_ms\Test\Unit\FragmentTest::testObjectCanGetMethodEThcD
959697
<?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\Utility\Fragment;

use pgb_liv\php_ms\Core\ModifiableSequenceInterface;

/**
 * Helper methods to get fragmentation types by instrument type
 *
 * @author Andrew Collins
 */
class FragmentFactory
{

    /**
     * List of all methods currently supported
     *
     * @var string[]
     */
    private static $methods = array(
        'CID',
        'HCD',
        'ECD',
        'ETD',
        'CTD',
        'EDD',
        'NETD',
        'ETHCD'
    );

    public static function getFragmentMethods()
    {
        return self::$methods;
    }

    /**
     * For a specified method, returns the possible fragmentat ion types that may be produced
     *
     * @param string $method
     *            The method to get fragment types for
     * @param ModifiableSequenceInterface $sequence
     *            The peptide or protein sequence object to get fragment types for
     * @return FragmentInterface[]
     */
    public static function getMethodFragments($method, ModifiableSequenceInterface $sequence)
    {
        $fragmentTypes = array();
        
        switch (strtoupper($method)) {
            case 'CID':
            case 'HCD':
                $fragmentTypes['B'] = new BFragment($sequence);
                $fragmentTypes['Y'] = new YFragment($sequence);
                break;
            case 'ECD':
                $fragmentTypes['C'] = new CFragment($sequence);
                $fragmentTypes['Z'] = new ZFragment($sequence);
                $fragmentTypes['B'] = new BFragment($sequence);
                break;
            case 'ETD':
                $fragmentTypes['C'] = new CFragment($sequence);
                $fragmentTypes['Z'] = new ZFragment($sequence);
                break;
            case 'CTD':
            case 'EDD':
            case 'NETD':
                $fragmentTypes['A'] = new AFragment($sequence);
                $fragmentTypes['X'] = new XFragment($sequence);
                break;
            case 'ETHCD':
                $fragmentTypes['B'] = new BFragment($sequence);
                $fragmentTypes['Y'] = new YFragment($sequence);
                $fragmentTypes['C'] = new CFragment($sequence);
                $fragmentTypes['Z'] = new ZFragment($sequence);
                break;
            default:
                throw new \InvalidArgumentException('Unknown fragmentation method type "' . $method . '"');
        }
        
        return $fragmentTypes;
    }
}