Performs methionine excision on an array of peptides

@param Peptide $peptides
@return Peptide[]
335499
private function performMethionineExcision(array $peptides)
    {
        $nmePeptides = array();
        foreach ($peptides as $peptide) {
            $entry = $peptide->getProteins()[0];

            if ($entry->getStart() > 0) {
                continue;
            }

            $sequence = $peptide->getSequence();

            if (strlen($sequence) <= 1) {
                continue;
            }

            if ($sequence[0] != 'M') {
                continue;
            }

            $nmePeptide = new Peptide();
            $nmePeptide->setSequence(substr($sequence, 1));
            $nmePeptide->addProtein($entry->getProtein(), 1, $entry->getEnd());
            $nmePeptide->setMissedCleavageCount($peptide->getMissedCleavageCount());

            $nmePeptides[] = $nmePeptide;
        }

        return array_merge($peptides, $nmePeptides);
    }
1147065
def switch_psm_to_peptable_fields(oldheader):
    """"""
    return {old: new for old, new in zip([mzidtsvdata.HEADER_PEPTIDE,
                                          mzidtsvdata.HEADER_PROTEIN,
                                          mzidtsvdata.HEADER_PEPTIDE_Q,
                                          mzidtsvdata.HEADER_PEPTIDE_PEP],
                                         [peptabledata.HEADER_PEPTIDE,
                                          peptabledata.HEADER_PROTEINS,
                                          peptabledata.HEADER_QVAL,
                                          peptabledata.HEADER_PEP])}
495153
protected function _getPortableSequencesList($sequences)
    {
        $list = [];

        foreach ($sequences as $value) {
            $list[] = $this->_getPortableSequenceDefinition($value);
        }

        return $list;
    }
324447
def getScans(self, modifications=True, fdr=True):
        
        if fdr:
            sql = "select sp.Spectrum, p.Sequence, p.PeptideID, p.SpectrumID from spectrumheaders sh left join spectra sp on (sp.UniqueSpectrumID=sh.UniqueSpectrumID) left join peptides p on (sh.SpectrumID=p.SpectrumID) WHERE p.ConfidenceLevel >= %d and p.SearchEngineRank <= %d" % (self.clvl, self.srank)
            try:
                self.cur.execute(sql)
            except sqlite3.OperationalError:
                sql = "select sp.Spectrum, p.Sequence, p.PeptideID, p.SpectrumID from spectrumheaders sh left join spectra sp on (sp.UniqueSpectrumID=sh.UniqueSpectrumID) left join peptides p on (sh.SpectrumID=p.SpectrumID) WHERE p.ConfidenceLevel >= %d" % self.clvl
                self.cur.execute(sql)
        else:
            sql = "select sp.Spectrum, p.Sequence, p.PeptideID, p.SpectrumID from spectrumheaders sh left join spectra sp on (sp.UniqueSpectrumID=sh.UniqueSpectrumID) left join peptides p on (sh.SpectrumID=p.SpectrumID)"
            self.cur.execute(sql)
        while True:
            results = self.cur.fetchmany(1000)
            if not results:
                break
            for tup in results:
                scan = self.parseFullScan(tup, modifications=modifications)
                scan.spectrumId = tup[3]
                yield scan
        yield None
3209
private function removeOldTagLines(): array
    {
        $tags = $this->getTagTokens();
        $firstTag = array_shift($tags);

        (new LineHelper($this->file))
            ->removeLines(
                $firstTag['line'],
                $this->tokens[$this->token['comment_closer']]['line']
            );

        return $firstTag;
    }
1256438
protected function performDigestion(Protein $protein)
    {
        $peptideSequences = preg_split($this->cleavageRule, $protein->getSequence());

        $peptides = array();
        $position = 0;
        foreach ($peptideSequences as $peptideSequence) {
            if (strlen($peptideSequence) == 0) {
                continue;
            }

            $peptide = new Peptide();
            $peptide->setSequence($peptideSequence);

            $endPosition = $position + strlen($peptideSequence) - 1;
            $peptide->addProtein($protein, $position, $endPosition);
            $peptide->setMissedCleavageCount(0);

            $peptides[] = $peptide;
            $position = $endPosition + 1;
        }

        $missedCleaveges = array();

        // Factor in missed cleaves
        for ($index = 0; $index < count($peptides); $index ++) {
            // Copy peptide
            $basePeptide = $peptides[$index];

            $cumulativeSequence = $peptides[$index]->getSequence();
            for ($missedCleave = 1; $missedCleave <= $this->getMaxMissedCleavage(); $missedCleave ++) {
                if ($index + $missedCleave >= count($peptides)) {
                    continue;
                }

                $cumulativeSequence .= $peptides[$index + $missedCleave]->getSequence();

                $peptide = new Peptide($cumulativeSequence);
                $peptide->setSequence($cumulativeSequence);
                $proteinEntry = $basePeptide->getProteins()[0];
                $peptide->addProtein($proteinEntry->getProtein(), $proteinEntry->getStart(),
                    $proteinEntry->getStart() + strlen($cumulativeSequence) - 1);
                $peptide->setMissedCleavageCount($missedCleave);
                $missedCleaveges[] = $peptide;
            }
        }

        return array_merge($peptides, $missedCleaveges);
    }
128310
def sort_protein_sequences(protein_sequences):
    
    return list(
        sorted(
            protein_sequences,
            key=ProteinSequence.ascending_sort_key,
            reverse=True))
109318
public static function getPoints(array $points, $tag = null)
    {
        $set = [];

        foreach ($points as $point) {
            $collector = $point->getData();

            if ($tag && $collector['tag'] != $tag) {
                continue;
            }

            $set[$point->getName()] = $point;
        }

        return $set;
    }
1296757
protected function getTerminatingSipDomains() {
        if (!$this->_terminatingSipDomains) {
            $this->_terminatingSipDomains = new TerminatingSipDomainList(
                $this->version,
                $this->solution['sid']
            );
        }

        return $this->_terminatingSipDomains;
    }
899635
private function reduceStmts(array $namespaces): array
    {
        $stmts = [];
        foreach ($namespaces as $namespace) {
            foreach ($namespace->stmts as $stmt) {
                $stmts[] = $stmt;
            }
        }
        return $stmts;
    }
1115207
private function removeDuplicates(array $pairs, array $pair): array
    {
        if (!in_array($pair, $pairs, true)) {
            $pairs[] = $pair;
        }

        return $pairs;
    }
58685
def get_proteins_for_peptide(self, psm_id):
        """"""
        protsql = self.get_sql_select(['protein_acc'], 'protein_psm')
        protsql = '{0} WHERE psm_id=?'.format(protsql)
        cursor = self.get_cursor()
        proteins = cursor.execute(protsql, psm_id).fetchall()
        return [x[0] for x in proteins]
1315787
private function getMappedPackageList(array $packages): array
    {
        $groupedPackages = $this->groupPackagesByName($packages);

        $mappedPackages = [];
        foreach ($groupedPackages as $name => $packages) {
            $highest = $this->getHighestVersion($packages);

            $mappedPackages[$name] = [
                'highest' => $highest,
                'abandoned' => $highest instanceof CompletePackageInterface ? $highest->isAbandoned() : false,
                'replacement' => $highest instanceof CompletePackageInterface ? $highest->getReplacementPackage() : null,
                'versions' => $this->getDescSortedVersions($packages),
            ];
        }

        return $mappedPackages;
    }
561917
private function removeDuplicates(array $packages): array
    {
        /** @var bool[] $registeredPackages */
        $registeredPackages = [];

        $result = array_filter(
            $packages,
            function (PackageInterface $package) use (&$registeredPackages) {
                $packageName = $package->getName();
                if (isset($registeredPackages[$packageName])) {
                    return false;
                }

                $registeredPackages[$packageName] = true;
                return true;
            }
        );

        return $result;
    }
1010497
protected static function clearEmptySections(array $sections): array
    {
        array_walk($sections, function ($templates, $index) use (&$sections) {
            if (count($templates) == 0) {
                unset($sections[$index]);
            }
        });

        return $sections;
    }
509456
public static function getMimeTypes(array $extensions)
    {
        $mimetypes = [];
        foreach ($extensions as $extension) {
            $mimetype = static::getMimeByExtension($extension, false);
            if ($mimetype && !in_array($mimetype, $mimetypes)) {
                $mimetypes[] = $mimetype;
            }
        }
        return $mimetypes;
    }
711325
function getFromKeys(array $keys)
    {
        $result = [];
        try {
            foreach ($keys as $key)
            {
                $result[] = $this->get($key);
            }
        } catch (\Exception $e) {
            throw new exReadError($e->getMessage(), $e->getCode(), $e);
        }
    }