src/Reader/FastaReader.php
private function parseEntry()
    {
        // Scan to first entry
        do {
            $line = trim($this->peekLine());

            if (strpos($line, '>') === 0) {
                break;
            }
        } while ($this->getLine());

        $identifier = '';
        while ($line = $this->getLine()) {
            $line = trim($line);
            $identifier .= substr($line, 1);

            $nextLine = trim($this->peekLine());
            if (strpos($nextLine, '>') !== 0) {
                break;
            }
        }

        $description = '';
        $separator = strpos($identifier, ' ');

        if ($separator !== false) {
            $description = substr($identifier, $separator + 1);
            $identifier = substr($identifier, 0, $separator);
        }

        try {
            if ($this->format == null || $this->format instanceof DefaultFastaEntry) {
                $this->format = FastaEntryFactory::getParser($identifier);
            }

            $protein = $this->format->getProtein($identifier, $description);
        } catch (Exception $e) {
            $this->format = FastaEntryFactory::getParser($identifier);
            $protein = $this->format->getProtein($identifier, $description);
        }

        $protein->setIdentifier($identifier);
        $protein->setSequence($this->parseSequence());

        $this->key ++;

        return $protein;
    }
private function parseEntry()
    {
        // Scan to first entry
        do {
            $line = trim($this->peekLine());

            if (strpos($line, '>') === 0) {
                break;
            }
        } while ($this->getLine());

        $identifier = '';
        while ($line = $this->getLine()) {
            $line = trim($line);
            $identifier .= substr($line, 1);

            $nextLine = trim($this->peekLine());
            if (strpos($nextLine, '>') !== 0) {
                break;
            }
        }

        $description = '';
        $separator = strpos($identifier, ' ');

        if ($separator !== false) {
            $description = substr($identifier, $separator + 1);
            $identifier = substr($identifier, 0, $separator);
        }

        try {
            if ($this->format == null || $this->format instanceof DefaultFastaEntry) {
                $this->format = FastaEntryFactory::getParser($identifier);
            }

            $protein = $this->format->getProtein($identifier, $description);
        } catch (Exception $e) {
            $this->format = FastaEntryFactory::getParser($identifier);
            $protein = $this->format->getProtein($identifier, $description);
        }

        $protein->setIdentifier($identifier);
        $protein->setSequence($this->parseSequence());

        $this->key ++;

        return $protein;
    }
private function parseEntry ( ) { // Scan to first entry do { $ line = trim ( $ this -> peekLine ( ) ) ; if ( strpos ( $ line , '>' ) === 0 ) { break ; } } while ( $ this -> getLine ( ) ) ; $ identifier = '' ; while ( $ line = $ this -> getLine ( ) ) { $ line = trim ( $ line ) ; $ identifier .= substr ( $ line , 1 ) ; $ nextLine = trim ( $ this -> peekLine ( ) ) ; if ( strpos ( $ nextLine , '>' ) !== 0 ) { break ; } } $ description = '' ; $ separator = strpos ( $ identifier , ' ' ) ; if ( $ separator !== false ) { $ description = substr ( $ identifier , $ separator + 1 ) ; $ identifier = substr ( $ identifier , 0 , $ separator ) ; } try { if ( $ this -> format == null || $ this -> format instanceof DefaultFastaEntry ) { $ this -> format = FastaEntryFactory :: getParser ( $ identifier ) ; } $ protein = $ this -> format -> getProtein ( $ identifier , $ description ) ; } catch ( Exception $ e ) { $ this -> format = FastaEntryFactory :: getParser ( $ identifier ) ; $ protein = $ this -> format -> getProtein ( $ identifier , $ description ) ; } $ protein -> setIdentifier ( $ identifier ) ; $ protein -> setSequence ( $ this -> parseSequence ( ) ) ; $ this -> key ++ ; return $ protein ; }
Parses the current chunk into a Protein object

@return Protein
Parses the current chunk into a Protein object