Source of file DefaultFastaEntry.php

Size: 2,047 Bytes - Last Modified: 2017-07-13T11:23:11+01:00

src/Core/Database/Fasta/DefaultFastaEntry.php

12345678910111213141516171819202122232425262728293031323334353637383940
Covered by 3 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteUniprotEntry
4142434445464748495051
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
5253
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
54
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
55
Covered by 1 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
5657
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
5859606162636465666768
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
69
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
70
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
71
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
7273
Covered by 2 test(s):
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntry
  • pgb_liv\php_ms\Test\Unit\FastaWriterTest::testCanWriteDefaultEntryNoDesc
747576
<?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 DefaultFastaEntry implements FastaInterface
{

    /**
     *
     * {@inheritdoc}
     *
     * @see \pgb_liv\php_ms\Core\Database\Fasta\FastaInterface::getHeader()
     */
    public function getHeader()
    {
        return '';
    }

    /**
     *
     * {@inheritdoc}
     *
     * @see \pgb_liv\php_ms\Core\Database\Fasta\FastaInterface::getDescription()
     */
    public function getDescription(Protein $protein)
    {
        $description = '>' . $protein->getUniqueIdentifier();
        
        if (! is_null($protein->getDescription())) {
            $description .= ' ' . $protein->getDescription();
        }
        
        return $description;
    }

    /**
     *
     * {@inheritdoc}
     *
     * @see \pgb_liv\php_ms\Core\Database\Fasta\FastaInterface::getProtein()
     */
    public function getProtein($identifier, $description, $sequence)
    {
        $protein = new Protein();
        $protein->setUniqueIdentifier($identifier);
        $protein->setDescription($description);
        $protein->setSequence($sequence);
        
        return $protein;
    }
}