Source of file UniprotFastaEntry.php
Size: 3,367 Bytes - Last Modified: 2018-01-02T13:40:00+00:00
src/Core/Database/Fasta/UniprotFastaEntry.php
12345678910111213141516171819202122232425262728293031323334353637383940
Covered by 1 test(s):
4142
Covered by 1 test(s):
43
Covered by 1 test(s):
4445
Covered by 1 test(s):
46
Covered by 1 test(s):
47
Covered by 1 test(s):
4849
Covered by 1 test(s):
50
Covered by 1 test(s):
515253545556575859606162
Covered by 4 test(s):
6364
Covered by 4 test(s):
65
Covered by 4 test(s):
66
Covered by 4 test(s):
6768
Covered by 4 test(s):
69
Covered by 4 test(s):
70
Covered by 4 test(s):
71
Covered by 4 test(s):
72
Covered by 4 test(s):
7374757677
Covered by 4 test(s):
787980
Covered by 4 test(s):
81
Covered by 4 test(s):
8283
Covered by 4 test(s):
84
Covered by 4 test(s):
8586
Covered by 4 test(s):
87
Covered by 4 test(s):
88
Covered by 4 test(s):
89
Covered by 4 test(s):
90
Covered by 4 test(s):
91
Covered by 4 test(s):
92
Covered by 4 test(s):
93
Covered by 4 test(s):
94
Covered by 4 test(s):
95
Covered by 4 test(s):
96
Covered by 4 test(s):
9798
Covered by 4 test(s):
99100101
| <?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\Core\Database\Fasta; use pgb_liv\php_ms\Core\Protein; /** * A sequence Database Entry object. * By default the identifier, description * and sequence are available. Additional fields will be available if the * description has been able to be parsed in the case of FASTA data. * * @author Andrew Collins */ class UniprotFastaEntry extends DefaultFastaEntry implements FastaInterface { /** * * {@inheritdoc} * * @see \pgb_liv\php_ms\Core\Database\Fasta\DefaultFastaEntry::getDescription() */ public function getDescription(Protein $protein) { $description = '>' . $protein->getUniqueIdentifier(); $description .= ' ' . $protein->getName(); $description .= ' OS=' . $protein->getOrganismName(); if (! is_null($protein->getGeneName())) { $description .= ' GN=' . $protein->getGeneName(); } $description .= ' PE=' . $protein->getProteinExistence(); return $description . ' SV=' . $protein->getSequenceVersion(); } /** * * {@inheritdoc} * * @see \pgb_liv\php_ms\Core\Database\Fasta\DefaultFastaEntry::getProtein() */ public function getProtein($identifier, $description, $sequence) { // Parse identifier $identifierParts = explode('|', $identifier, 3); $protein = new Protein(); $protein->setSequence($sequence); $protein->setUniqueIdentifier($identifier); if (count($identifierParts) == 3) { $protein->setDatabasePrefix($identifierParts[0]); $protein->setAccession($identifierParts[1]); $protein->setEntryName($identifierParts[2]); } else { $protein->setAccession($identifierParts[0]); $protein->setEntryName($identifierParts[1]); } $protein->setDescription($description); // Parse description $osPosition = strpos($description, ' OS='); $protein->setName(substr($description, 0, $osPosition)); $matches = array(); preg_match_all('/([OS|GN|PE|SV]{2})=(.+?(?=\s(GN=|PE=|SV=)|$))/', $description, $matches); foreach ($matches[1] as $key => $value) { if ($value == 'OS') { $protein->setOrganismName($matches[2][$key]); } elseif ($value == 'GN') { $protein->setGeneName($matches[2][$key]); } elseif ($value == 'PE') { $protein->setProteinExistence($matches[2][$key]); } elseif ($value == 'SV') { $protein->setSequenceVersion($matches[2][$key]); } } return $protein; } } |