Digest the protein and produce peptides matching the enzyme rules.

@param Protein $protein
Must contain a protein sequence
@return Peptide[]
502347
public function digest(Protein $protein)
    {
        $peptides = $this->performDigestion($protein);

        if ($this->isNmeEnabled) {
            $peptides = $this->performMethionineExcision($peptides);
        }

        return $peptides;
    }
916759
public function resolve($message)
    {
        $messageName = $this->messageNameResolver->resolve(
            $message
        );

        if (isset($this->mapping[$messageName])) {
            return $this->mapping[$messageName];
        }

        return [];
    }
571696
def protein_header_split_generator(elements, headers, ns):
    """"""
    for el in elements:
        header_not_matching = False
        for protein in el.findall('{%s}protein_id' % ns['xmlns']):
            if not any((re.search(h, protein.text) for h in headers)):
                header_not_matching = True
                break
        if header_not_matching:
            formatting.clear_el(el)
        else:
            yield formatting.string_and_clear(el, ns)
397741
private function parseAttributes(Protein $protein, array $attributes)
    {
        if (isset($attributes[PsiVerb::NCBI_TAX_ID])) {
            $organism = Organism::getInstance($attributes[PsiVerb::NCBI_TAX_ID]);
            $protein->setOrganism($organism);
        }

        if (isset($attributes[PsiVerb::TAX_NAME])) {
            if (! $protein->getOrganism()) {
                $protein->setOrganism(new Organism());
            }

            $protein->getOrganism()->setName($attributes[PsiVerb::TAX_NAME]);
        }

        foreach ($attributes as $key => $value) {
            switch ($key) {
                case 'DbUniqueId':
                    $protein->setAccession($value);
                    break;
                case 'GName':
                    $gene = Gene::getInstance($value);
                    $protein->setGene($gene);
                    break;
                case 'SV':
                    $protein->getDatabaseEntry()->setSequenceVersion($value);
                    break;
                case 'EV':
                    $protein->getDatabaseEntry()->setEntryVersion($value);
                    break;
                case 'PE':
                    $protein->getDatabaseEntry()->setEvidence($value);
                    break;
                case 'PName':
                    $protein->setDescription($value);
                    break;
                case 'ModRes':
                case 'ModResPsi':
                case 'ModResUnimod':
                    $modifications = self::parseModifications($value);
                    $protein->addModifications($modifications);
                    break;
                case PsiVerb::NCBI_TAX_ID:
                case PsiVerb::TAX_NAME:
                    // Safe to ignore - already handled
                    break;
                case 'Length':
                case 'VariantSimple ':
                case 'VariantComplex':
                case 'Processed':
                    // Not supported
                    break;
                default:
                    // Not supported
                    break;
            }
        }
    }
1028639
private function getArgs(string $method) : array
    {
        if (self::request()->getMethod() == 'POST') {
            $data = file_get_contents('php://input');

            // hack for multipart form
            if (!$data) {
                $data = http_build_query($_POST);
            }
        } else {
            $data = self::request()->getUri()->getQuerystring();
        }

        if (self::request()->getMethod() == 'POST' &&
            self::request()->getHeader('Content-Encoding') == 'gzip') {
            $data = gzdecode($data);
        }

        $requestData = $data ? $this->getRequestData($data) : [];

        $return = [];

        /* @var $parametersDefinition Param[] */
        $parametersDefinition = $this->reflectionMethod[$method]->getParam(Definition::PARAM);

        /* @var $parameter \ReflectionParameter */
        foreach ($this->reflectionMethod[$method]->getParameters() as $i => $parameter) {
            $parameterName = $parameter->getName();

            $value = isset($requestData[$parameterName]) ? $requestData[$parameterName] : null;

            if (is_null($value) && !$parameter->isOptional()) {
                throw new ResponseCode("Missing required parameters '$parameterName'", 422);
            }

            if (!isset($parametersDefinition[$i])) {
                throw new \Exception(sprintf(
                    "Missing phpdoc on param '%s' for method '%s:%s'",
                    $parameterName,
                    get_class($this),
                    $method
                ));
            }

            if ($parametersDefinition[$i]->getVar() !== $parameterName) {
                throw new \Exception(sprintf(
                    "Invalid phpdoc on param '%s' with name '%s' for method '%s:%s'",
                    $parameterName,
                    $parametersDefinition[$i]->getVar(),
                    get_class($this),
                    $method
                ));
            }

            $value = $this->getFinalValue(
                $parametersDefinition[$i]->getType(),
                $parametersDefinition[$i]->getVar(),
                $value,
                $parameter->isOptional()
            );

            if ($parametersDefinition[$i]->getValidation()) {
                $value = $parametersDefinition[$i]->validateCondition($parameterName, $value);
            }

            if ($parameter->isDefaultValueAvailable() && $value === null) {
                $value = $parameter->getDefaultValue();
            }

            $return[] = $value;
        }

        return $return;
    }
1209492
public function match(string $event): array
    {
        $matches = [];

        //do the obvious match
        if (isset($this->observers[$event])) {
            $matches[$event] = array(
                'event' => $event,
                'pattern' => $event,
                'variables' => []
            );
        }

        //deal with regexp
        foreach ($this->regex as $pattern) {
            //if it matches
            if (preg_match_all($pattern, $event, $match)) {
                $variables = [];

                if (is_array($match) && !empty($match)) {
                    //flatten
                    $variables = call_user_func_array('array_merge', $match);
                    array_shift($variables);
                }

                $matches[$pattern] = array(
                    'event' => $event,
                    'pattern' => $pattern,
                    'variables' => $variables
                );
            }
        }

        return array_values($matches);
    }
1122989
private function getReturnsFromAnnotation(?Annotation $annotation): array
    {
        return $this->isFilledReturnAnnotation($annotation)
            ? explode('|', preg_split('~\\s+~', $annotation->getContent())[0])
            : [];
    }
141826
public static FastaSequence convertProteinSequencetoFasta(ProteinSequence sequence){
		StringBuffer buf = new StringBuffer();
		for (AminoAcidCompound compound : sequence) {

			String c = compound.getShortName();

			if (! SequenceUtil.NON_AA.matcher(c).find()) {
				buf.append(c);
			} else {
				buf.append("X");
			}
		}

		return new FastaSequence(sequence.getAccession().getID(),buf.toString());
	}
110782
public function getTagItems(string $tag): array
    {
        $tagName = $this->getTagKey($tag);
        $keys    = $this->handler->sMembers($tagName);

        return array_map(function ($key) {
            return $this->getCacheKey($key);
        }, $keys);
    }
344978
private function getProteinDetectionHypothesis(\SimpleXMLElement $xml)
    {
        $hypothesis = array();

        $hypothesis['id'] = $this->getAttributeId($xml);
        $hypothesis['passThreshold'] = ((string) $xml->attributes()->passThreshold) == 'true';

        if (isset($xml->attributes()->name)) {
            $hypothesis['name'] = (string) $xml->attributes()->name;
        }

        if (isset($xml->attributes()->dBSequence_ref)) {
            $ref = (string) $xml->attributes()->dBSequence_ref;
            $hypothesis['protein'] = $ref;
        }

        $hypoPeptides = array();
        foreach ($xml->PeptideHypothesis as $peptideHypothesis) {
            $hypoPeptides[] = $this->getPeptideHypothesis($peptideHypothesis);
        }

        $cvParams = array();
        foreach ($xml->cvParam as $cvParam) {
            $cvParams[] = $this->getCvParam($cvParam);
        }

        $hypothesis['peptides'] = $hypoPeptides;
        $hypothesis['cvParam'] = $cvParams;

        return $hypothesis;
    }
884414
public function toASN1(): Sequence
    {
        $elements = array(new Enumerated($this->_digestedObjectType));
        if (isset($this->_otherObjectTypeID)) {
            $elements[] = new ObjectIdentifier($this->_otherObjectTypeID);
        }
        $elements[] = $this->_digestAlgorithm->toASN1();
        $elements[] = $this->_objectDigest;
        return new Sequence(...$elements);
    }
1079215
public function unpack(string $message): array
    {
        $messageAry = json_decode($message, true);
        $type       = $messageAry['pipeType'];
        $data       = $messageAry['message'];

        return [$type, $data];
    }
302963
private static function getFeedItemIdsFromArgument($function)
    {
        $feedItemIds = [];

        if (count($function->getLhsOperand()) === 1
            && $function->getLhsOperand()[0] instanceof RequestContextOperand
            && $function->getLhsOperand()[0]->getContextType() === RequestContextOperandContextType::FEED_ITEM_ID
            && $function->getOperator() === FunctionOperator::IN) {
            foreach ($function->getRhsOperand() as $argument) {
                $feedItemIds[] = $argument->getLongValue();
            }
        }

        return $feedItemIds;
    }
450820
def get_combo_subseq_within_2_5D(protein, props, within, filter_resnums=None):
        """"""
        if not protein.representative_structure:
            log.error('{}: no representative structure, cannot search for subseq'.format(protein.id))
            return {'subseq_len': 0, 'subseq': None, 'subseq_resnums': []}

        all_resnums = []
        for prop in props:
            tmp_results = protein.get_generic_subseq_within_2_5D(prop_name=prop, within=within,
                                                         filter_resnums=filter_resnums)
            all_resnums.extend(tmp_results['subseq_resnums'])
        final_resnums = list(set(all_resnums))
        sub_id = '{}-{}->{}_within_{}_{}_extracted'.format(protein.representative_structure.id,
                                                           protein.representative_chain,
                                                           protein.representative_sequence.id,
                                                           within, props)
        new_sp = protein.representative_sequence.get_subsequence(resnums=final_resnums, new_id=sub_id,
                                                                 copy_letter_annotations=False)
        return {'subseq_len': len(final_resnums), 'subseq': new_sp, 'subseq_resnums': final_resnums}
177864
public function getAll(string $table, int $page = 0): array
    {
        try {
            $this->db->beginTransaction();

            $sql = "SELECT * FROM $table";

            if ($page > 0) {
                $sql = $sql . " LIMIT " . self::LIMIT . " OFFSET " . self::LIMIT * ($page - 1);
            }
            /** @var PDOStatement $stmt */
            $stmt = $this->db->prepare($sql);
            $stmt->execute();

            $this->db->commit();

            $result = $stmt->fetchAll();

            return $result;
        } catch (PDOException $e) {
            $this->db->rollBack();
            throw new PDOException($e);
        }
    }
579087
public function digest($string)
    {
        // protect against missing data
        $needed = array(
            'nonce' => 1,
            'nc' => 1,
            'cnonce' => 1,
            'qop' => 1,
            'username' => 1,
            'uri' => 1,
            'response' => 1);
        
        $data = array();
        $keys = implode('|', array_keys($needed));
    
        preg_match_all(
            '@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@',
            $string,
            $matches,
            PREG_SET_ORDER
        );
    
        foreach ($matches as $match) {
            $data[$match[1]] = $match[3] ? $match[3] : $match[4];
            unset($needed[$match[1]]);
        }
    
        return $needed ? false : $data;
    }
919986
def get_proteins_psms_for_map(self):
        """"""
        fields = ['p.gene_acc', 'sets.set_name',
                  'pep.sequence', 'psm.psm_id']
        firstjoin = ('protein_psm', 'pp', 'protein_acc')
        genetable = 'genes'
        return self.get_unique_gene_psms(genetable, fields, firstjoin)