コード例 #1
0
def convertToRichMSSpectrum(input_):
    rs = pyopenms.RichMSSpectrum()
    for p in input_:
        rp = pyopenms.RichPeak1D()
        rp.setMZ(p.getMZ())
        rp.setIntensity(p.getIntensity())
        rs.push_back(rp)
    return rs
コード例 #2
0
    def testRichMSSpectrum(self):
        spec = pyopenms.RichMSSpectrum()
        p = pyopenms.RichPeak1D()
        p.setMZ(500.0)
        p.setIntensity(1e5)
        spec.push_back(p)

        p_back, = list(spec)
        assert isinstance(p_back, pyopenms.RichPeak1D)
        assert p_back.getMZ() == 500.0
        assert p_back.getIntensity() == 1e5
コード例 #3
0
    def testRichMSSpectrum(self):
        spec = pyopenms.RichMSSpectrum()
        p = pyopenms.RichPeak1D()
        p.setMZ(500.0)
        p.setIntensity(1e5)
        spec.push_back(p)

        p_back, = list(spec)
        assert isinstance(p_back, pyopenms.RichPeak1D)
        assert p_back.getMZ() == 500.0
        assert p_back.getIntensity() == 1e5

        spec.updateRanges()
        assert isinstance(spec.getMin()[0], float)
        assert isinstance(spec.getMax()[0], float)
        assert isinstance(spec.getMinInt(), float)
        assert isinstance(spec.getMaxInt(), float)
        assert spec.getMaxInt() == 1e5
        assert spec.getMinInt() == 1e5
コード例 #4
0
    def simplisticBinnedScoring(self, phit, spectrum):
        """Simplistic phospho-scoring of a spectrum against a peptide hit.

        This function enumerates all possible locations for the
        phosphorylation and computes a similarity score between the
        experimental spectrum and the theoretical spectrum for each
        possibility.
        """
        seq = phit.getSequence().toString()
        seq = seq.replace("(Phospho)", "")
        possibilities = []
        spectrum_b = self.binSpectrum(spectrum)
        charge = 1
        # Iterate over all possible phosphosites
        for m in re.finditer("[STY]", seq):
            new_sequence = seq[:m.start() + 1] + "(Phospho)" + seq[m.start() -
                                                                   1:]
            new_aaseq = pyopenms.AASequence(new_sequence)
            # Generate theoretical spectrum
            spectrum_generator = pyopenms.TheoreticalSpectrumGenerator()
            rs = pyopenms.RichMSSpectrum()
            try:
                spectrum_generator.addPeaks(rs, new_aaseq,
                                            pyopenms.Residue.ResidueType.YIon,
                                            charge)
                spectrum_generator.addPeaks(rs, new_aaseq,
                                            pyopenms.Residue.ResidueType.BIon,
                                            charge)
            except AttributeError:
                # 1.11
                spectrum_generator.addPeaks(rs, new_aaseq,
                                            pyopenms.ResidueType.YIon, charge)
                spectrum_generator.addPeaks(rs, new_aaseq,
                                            pyopenms.ResidueType.BIon, charge)
            theor = convertToMSSpectrum(rs)
            theor_b = self.binSpectrum(theor)
            # Compare theoretical spectrum to experimental spectrum
            comp_score = self.compare_binnedSpectra(spectrum_b, theor_b)
            possibilities.append([comp_score, new_aaseq])

        # Sort the result by score, return the best scoring result
        possibilities.sort(lambda x, y: -cmp(x[0], y[0]))
        return possibilities[0]